void show_time ( void ) { unsigned short nowtime; unsigned short ra; unsigned short rc; unsigned short ry; unsigned char ca,cb,cc; unsigned char base[4]; nowtime =xstring[0]&0xF; nowtime<<=4; nowtime|=xstring[1]&0xF; nowtime<<=4; nowtime|=xstring[2]&0xF; nowtime<<=4; nowtime|=xstring[3]&0xF; if(nowtime==lasttime) return; lasttime=nowtime; for(ra=0;ra<4;ra++) { base[ra]=((xstring[ra]&0xF)<<2)+(xstring[ra]&0xF); } for(ry=0,ra=4;ra<44;ra++,ry++) { //P1OUT^=0x40; SPI_CS_ON; spi_delay(); spi_write_byte(0x80); spi_write_sharp_address(ra&0xFF); spi_write_byte(0xFF); rc=base[0]+(ry>>3); ca=numfont[rc]; for(cb=8;cb;cb>>=1) { if(cb&ca) cc=0x00; else cc=0xFF; spi_write_byte(cc); } spi_write_byte(0xFF); rc=base[1]+(ry>>3); ca=numfont[rc]; for(cb=8;cb;cb>>=1) { if(cb&ca) cc=0x00; else cc=0xFF; spi_write_byte(cc); } spi_write_byte(0xFF); spi_write_byte(0xFF); spi_write_byte(0x00); spi_write_byte(0x00); spi_delay(); SPI_CS_OFF; } for(ry=0,ra=44+8;ra<44+48;ra++,ry++) { SPI_CS_ON; spi_delay(); spi_write_byte(0x80); spi_write_sharp_address(ra&0xFF); spi_write_byte(0xFF); rc=base[2]+(ry>>3); ca=numfont[rc]; for(cb=8;cb;cb>>=1) { if(cb&ca) cc=0x00; else cc=0xFF; spi_write_byte(cc); } spi_write_byte(0xFF); rc=base[3]+(ry>>3); ca=numfont[rc]; for(cb=8;cb;cb>>=1) { if(cb&ca) cc=0x00; else cc=0xFF; spi_write_byte(cc); } spi_write_byte(0xFF); spi_write_byte(0xFF); spi_write_byte(0x00); spi_write_byte(0x00); spi_delay(); SPI_CS_OFF; } }
//------------------------------------------------------------------- void notmain ( void ) { unsigned short ra; unsigned short rb; unsigned char rt; unsigned char up; unsigned char xbit; unsigned char xbyte; unsigned char y; //unsigned char lasty; WDTCTL = 0x5A80; // use calibrated clock DCOCTL = 0x00; BCSCTL1 = CALBC1_16MHZ; DCOCTL = CALDCO_16MHZ; //P1.0 LCD Power Control //P1.3 LCD Enable //P1.4 SPI CS //P1.5 SPI CLK //P1.6 led2 //p1.7 SPI MOSI //76543210 //11111001 //0x00xxxx //x1xx1xx1 P1DIR|=0xF9; P1OUT&=~(0xB0); P1OUT|=0x49; TACTL = 0x02E0; clear_screen(); up=0; rt=1; y=5; xbit=0x04; xbyte=1; //lasty=y; while(1) { //for(ra=1;ra<=96;ra++) ra=y; { P1OUT^=0x40; SPI_CS_ON; spi_delay(); spi_write_byte(0x80); spi_write_sharp_address(ra&0xFF); for(rb=0;rb<xbyte;rb++) { spi_write_byte(0); } spi_write_byte(xbit); for(rb++;rb<12;rb++) { spi_write_byte(0); } spi_write_byte(0x00); spi_write_byte(0x00); spi_delay(); SPI_CS_OFF; } //ra=lasty; //{ //P1OUT^=0x40; //SPI_CS_ON; //spi_delay(); //spi_write_byte(0x80); //spi_write_sharp_address(ra&0xFF); //for(rb=0;rb<12;rb++) //{ //spi_write_byte(0); //} //spi_write_byte(0x00); //spi_write_byte(0x00); //spi_delay(); //SPI_CS_OFF; //} //lasty=y; if(up) { if(y==1) { up=0; y=2; } else y--; } else { if(y==96) { up=1; y=95; } else y++; } if(rt) { if(xbit==0x01) { if(xbyte==11) { rt=0; } else { xbit=0x80; xbyte++; } } else { xbit>>=1; } } else { if(xbit==0x80) { if(xbyte==0) { rt=1; } else { xbit=0x01; xbyte--; } } else { xbit<<=1; } } }