Пример #1
0
/******************************************************************************
* This function writes a string to the display
*
* Interface assumptions:
* The pstr must be zero-terminated.
*
* Return value:
* None
*
*
******************************************************************************/
void LCD_WriteString
  (
  uint8_t line,  /* IN: Line in display */
  uint8_t *pstr	 /* Pointer to text string */
  )
{
  uint8_t len;
  uint8_t x;
  uint8_t *error = "Wrong line 1 & 2";

  if( line == 2 ) {
    LCDLine(LineTwo);
  }
  else if ( line == 1 ) {
    LCDLine(LineOne);
    }
    else {
	  LCD_ClearDisplay();
	  LCDLine(LineOne);
      pstr = error;
    }

  len = GetStrlen(pstr);
  for ( x = 0; x < len; x++ ) {
    LCD_WriteChar( pstr[x] );
  }

  /* Clear the rest of the line */
  for ( ; x < gMAX_LCD_CHARS_c; x++ ) {
    LCD_WriteChar( ' ' );
  }
}
Пример #2
0
void LCD_WriteNum(double data)//写double型数,小数点后保留6位,从高位向低位写
{
	char str[5];
	int flag=0,i;
	if(data<0)
	{
		LCD_WriteChar('-');//写负号
		data=-data;
	}
	LCD_WriteInt((int)data);//写整数部分
	data=data-(int)data;
	for(i=0;i<5;i++)//将小数部分保留在一个字符串内
	{
		data=data*10;
		str[i]=(int)data+'0';
		if(str[i]!='0')
		{
			flag=i+1;
		}
		data=data-(int)data;
		
	}
	if(flag!=0)
		LCD_WriteChar('.');//写小数点
	for(i=0;i<flag;i++)
	{
		LCD_WriteChar(str[i]);//写小数部分
	}	
	for(i=flag;i<6;i++)
	{
		LCD_WriteChar(' ');//小数点后不够6位则补空格
	}
}
Пример #3
0
void Record_data()
{
	keyscan();
	
	if(flag_new)
	{
		
		switch(key)
		{
			case 1:	if(flag_d==1) Height++;
					if(flag_d==2) Weight++;
					break;
			case 2:	if(flag_d==1) Height--;
					if(flag_d==2) Weight--;
					break;
			case 3:	flag_d++;break;
			default:  break;
		}
		if(flag_d==1)	{	LCD_WriteChar(78,2,'*');LCD_WriteChar(78,3,' ');}
		if(flag_d==2)   {	LCD_WriteChar(78,3,'*');LCD_WriteChar(78,2,' ');}
		if(flag_d==3)	flag_data=1; 
	   	LCD_WriteNum(45,2,Height);
		LCD_WriteNum(51,3,Weight);

	   flag_new=0;
	}		
}
Пример #4
0
void run_end()
{
	uint Ener,bup,shijian; 	
	shijian=time_m*10+time_s/6;
	if(shijian==0)  bup=0;
	else bup=run_bu*10/shijian;
	Ener=(43*Height/10+57*Weight/10+92*shijian/10+26*bup/10)/10;
	LCD_WriteString(0,0,"Height:    cm");
	LCD_WriteString(0,1,"Weight:    kg");
	LCD_WriteNum(45,0,Height);
	LCD_WriteNum(51,1,Weight);
	LCD_WriteString(0,2,"Time:");
	
	LCD_WriteNum(35,2,time_m);
	LCD_WriteNum(60,2,time_s);
	LCD_WriteChar(49,2,':');

	LCD_WriteString(0,3,"Step:");
	LCD_WriteNum(35,3,run_bu);

/*	LCD_WriteNum(0,0,43*Height/10);
	LCD_WriteNum(0,1,57*Weight/10);
	LCD_WriteNum(0,2,92*shijian/10);
	LCD_WriteNum(0,3,26*bup/10);*/


	LCD_WriteString(0,4,"Ener:     kcal");
	LCD_WriteNum(35,4,Ener);

	LCD_WriteString(0,5,"YOU ARM GREAT!");
	
			 
}
Пример #5
0
void LCD_WriteString(char *str)
{   
    while(*str)
    {              
        LCD_WriteChar(*str);
        str++;
    }
}
Пример #6
0
/*
********************************************************** 
*函数名:LCD_WriteString
*功能: LCD写6X8的字符串 
*参数:X , Y , S    
*返回值:无
备 注: 
**********************************************************
*/
void LCD_WriteString(unsigned char X,unsigned char Y,char *s)
{
  while(*s) 
  {
     LCD_WriteChar(X,Y,*s);
     s++;
     X += 6;
  }
}
Пример #7
0
void LCD_WriteString(String s, int x, int y, int col) {
    int i = 0;
    while(1) {
        char c = s[i];
        if(c==0)
            break;
        LCD_WriteChar(c,x+8*i,y, col);
        i++;
    }
}
Пример #8
0
void LCD_WriteDouble(double data,int m)//写double型数,m为小数点后位数,从高位向低位写
{
	if(data<0&&data>-1)
		LCD_WriteChar('-');//写负号
	LCD_WriteInt((int)data);//写整数部分
	if(m>0)
	{
		int i;
		LCD_WriteChar('.');//写小数点
		if(data<0)
			data=-data;
		data=data-(int)data;
		for(i=0;i<m;i++)//写小数部分
		{
			data=data*10;
			LCD_WriteChar((int)data+'0');
			data=data-(int)data;
		}
		
	}
	
}
Пример #9
0
void LCD_Refresh(void)
{

#ifdef CONFIG_VIRTUAL_CONSOLE

    int loopx, loopy;

    for (loopy = 0; loopy < HEIGHT; loopy++) {
	LCD_Position(0, loopy);

	for (loopx = 0; loopx < WIDTH; loopx++)
	    LCD_WriteChar(Visible->screen[loopy][loopx]);
    }

    LCD_Position(Visible->xpos, Visible->ypos);

#else

    WriteChar(Visible, '\f');

#endif
}
Пример #10
0
void printPart_lcd() {
    LCD_Clear();
    LCD_CursorPosition(0);

    LCD_WriteString(type_descs[PartSS]);
    if(PartSS == ERROR || PartSS >= NOID) return;

    LCD_WriteINT(part_val);
    LCD_WriteChar(part_unit);
    LCD_CursorPosition(21);

    LCD_WriteString("1:");
    LCD_WriteChar(pins[0]);
    LCD_WriteChar(' ');

    LCD_WriteString("2:");
    LCD_WriteChar(pins[1]);
    LCD_WriteChar(' ');

    LCD_WriteString("3:");
    LCD_WriteChar(pins[2]);
    LCD_WriteChar(' ');
}
void main(void){  
	unsigned char i,cmd, param[9], tmp; 
	unsigned long lhfe;
	//unsigned char t[]={"Hello World"};

    init();			//setup the crystal, pins

	Delay_MS(10);	

	HD44780_Reset();//setup the LCD
	HD44780_Init();
	//LCD_Backlight(1);//turn it on, we ignore the parameter

LCD_CursorPosition(0);
LCD_WriteString("Part Ninja v0.0a");
LCD_CursorPosition(21);
LCD_WriteString("      testing...");

	while(1){
		PartType=0;
		PartMode=0;
		RepeatDetect=0;
		checkpins(0, 1, 2); //CBE npn --
		checkpins(0, 2, 1); //CBE npn
		checkpins(1, 0, 2); //CBE npn --
		checkpins(1, 2, 0); //CBE npn
		checkpins(2, 0, 1); //CBE npn
		checkpins(2, 1, 0); //CBE npn

		if(PartType==PART_TRANSISTOR){
			if(RepeatDetect==0){
				hfe[1] = hfe[0];
				vBE[1] = vBE[0];
			}

			if(hfe[0]>hfe[1]){
				hfe[1] = hfe[0];
				vBE[1] = vBE[0];
				tmp = c;
				c = e;
				e = tmp;
			}

			lhfe = hfe[1];

			lhfe *= (((unsigned long)4700 * 100) / (unsigned long)680);	//Verhältnis von High- zu Low-Widerstand

			if(vBE[1]<11) vBE[1] = 11;
			lhfe /= vBE[1];
			hfe[1] = (unsigned int) lhfe;

			LCD_Clear();
			LCD_CursorPosition(0);
			if(PartMode == PART_MODE_NPN) {
				LCD_WriteString("NPN ");
			} else if (PartMode==PART_MODE_PNP) {
				LCD_WriteString("PNP ");
			}
			LCD_WriteString("  hFE:");	
			LCD_WriteByteVal(hfe[1]);

			LCD_CursorPosition(21);
			LCD_WriteString("C=");
			LCD_WriteChar(c+0x31);
			LCD_WriteString(" B=");
			LCD_WriteChar(b+0x31);
			LCD_WriteString(" E=");			
			LCD_WriteChar(e+0x31);

		}else if(PartType==PART_FET){

			LCD_Clear();
			LCD_CursorPosition(0);
			if(PartMode == PART_MODE_NPN) {
				LCD_WriteString("N-");
			} else if (PartMode==PART_MODE_PNP) {
				LCD_WriteString("P-");
			}
			LCD_WriteString("FET ");

			f=gthvoltage;
			f=((f)/1024)*5;
			gthvoltage=f;
			LCD_WriteString("  Vth:");
			LCD_WriteByteVal(gthvoltage);
			//lcd_data('m');
			LCD_WriteString("v");

			LCD_CursorPosition(21);
			LCD_WriteString("G=");
			LCD_WriteChar(b+0x31);
			LCD_WriteString(" D=");
			LCD_WriteChar(c+0x31);
			LCD_WriteString(" S=");			
			LCD_WriteChar(e+0x31);



		}

	}


}//end main
void HD66773R_Driver::WriteFormattedChar( unsigned char c )
{
    NATIVE_PROFILE_HAL_DRIVERS_DISPLAY();
    
           
    if(c < 32)
    {        
        switch(c)
        {        
        case '\b':                      /* backspace, clear previous char and move cursor back */
            if((g_HD66773R_Driver.m_cursor % TextColumns()) > 0)
            {
                g_HD66773R_Driver.m_cursor--;
                LCD_WriteChar( ' ', g_HD66773R_Driver.m_cursor / TextColumns(), g_HD66773R_Driver.m_cursor % TextColumns() );
            }
            break;

        case '\f':                      /* formfeed, clear screen and home cursor */
            //LCD_Clear();
            g_HD66773R_Driver.m_cursor = 0;
            break;

        case '\n':                      /* newline */
            g_HD66773R_Driver.m_cursor += TextColumns();
            g_HD66773R_Driver.m_cursor -= (g_HD66773R_Driver.m_cursor % TextColumns());
            break;

        case '\r':                      /* carriage return */
            g_HD66773R_Driver.m_cursor -= (g_HD66773R_Driver.m_cursor % TextColumns());
            break;

        case '\t':                      /* horizontal tab */
            g_HD66773R_Driver.m_cursor += (Font_TabWidth() - ((g_HD66773R_Driver.m_cursor % TextColumns()) % Font_TabWidth()));
            // deal with line wrap scenario
            if((g_HD66773R_Driver.m_cursor % TextColumns()) < Font_TabWidth())
            {
                // bring the cursor to start of line
                g_HD66773R_Driver.m_cursor -= (g_HD66773R_Driver.m_cursor % TextColumns());
            }
            break;

        case '\v':                      /* vertical tab */
            g_HD66773R_Driver.m_cursor += TextColumns();
            break;

        default:
            DEBUG_TRACE2(TRACE_ALWAYS, "Unrecognized control character in LCD_WriteChar: %2u (0x%02x)\r\n", (unsigned int) c, (unsigned int) c);
            break;
        }
    }
    else
    {        
        LCD_WriteChar( c, g_HD66773R_Driver.m_cursor / TextColumns(), g_HD66773R_Driver.m_cursor % TextColumns() );
        g_HD66773R_Driver.m_cursor++;
    }

    if(g_HD66773R_Driver.m_cursor >= (TextColumns() * TextRows()))
    {
        g_HD66773R_Driver.m_cursor = 0;
    }
}
int main()
{
	int				_row, _col;
	char			c;
	U32				status;
	
	AT91PS_PIO    	pPioA  	= AT91C_BASE_PIOA;
	AT91PS_PMC    	pPMC   	= AT91C_BASE_PMC;
	AT91PS_USART 	pUART0 	= AT91C_BASE_US0;

	
	/* Initialize the Atmel AT91SAM7X256 (watchdog, PLL clock, default interrupts, etc.) */
	AT91F_LowLevel_Init();
	
	/* Init the LCD */
	InitLCD();

	/* Init the UART */
	AT91F_US_Configure(pUART0, MCK, AT91C_US_ASYNC_MODE, 9600L, 0 );
	AT91F_PMC_EnablePeripheralClock(pPMC, 1 << AT91C_ID_US0 );
    AT91F_US_EnableRx(pUART0);
    AT91F_US_EnableTx(pUART0);
	AT91F_PIO_Disable( pPioA, RXD0 | TXD0 | RTS0 | CTS0  );
	AT91F_PIO_A_RegisterSelection( pPioA, RXD0 | TXD0 | RTS0 | CTS0  );

	
	/* enable interrupts */
	AT91F_Finalize_Init();

	
	/* add your program here ... */
	LCD_ClearScreen( LCD_COLOR_RED );
	LCD_WriteString("UART Demo:", &Fixedsys_descriptor, 2, Fixedsys_descriptor.font_height, 
			                                               LCD_COLOR_WHITE, LCD_COLOR_RED);
	_row = 2*(Fixedsys_descriptor.font_height+2);
	_col = 2;
	
	/* ... and here */
	while ( true )
	{
		status = AT91F_US_RxReady(pUART0);
		if(status) {
			c = AT91F_US_GetChar(pUART0);
			AT91F_US_PutChar(pUART0, c);
			LCD_WriteChar(c, &Fixedsys_descriptor, _col, _row, LCD_COLOR_WHITE, LCD_COLOR_RED);
			if (_col<(128-Fixedsys_descriptor.font_width))
				_col += Fixedsys_descriptor.font_width;
			else {
				_col = 2;
				_row += (Fixedsys_descriptor.font_height+2);
				if (_row>(128-Fixedsys_descriptor.font_height)) {
					LCD_ClearScreen( LCD_COLOR_RED );
					_row = 2; //Fixedsys_descriptor.font_height;
					_col = 2;
				}
			}
		}
		else
			status = AT91F_US_TxReady(pUART0);
			if(status) {
				//AT91F_US_PutChar(pUART0, '.');
			}
	}
	
	/* Actually, the execution never gets here */
	return 0;
}
Пример #14
0
void WriteChar(register Console * C, char c)
{
    int loopx, loopy;

    if (c == '\f') {
	C->xpos = 0;
	C->ypos = 0;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	if (Visible == &Con[Current_VCminor])
#endif

	    LCD_Position(C->xpos, C->ypos);

	for (loopy = 0; loopy < HEIGHT; loopy++) {

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	    for (loopx = 0; loopx < WIDTH; loopx++)
		C->screen[loopy][loopx] = ' ';

	    if (Visible == &Con[Current_VCminor])
#endif

		LCD_ClearLine(loopy);
	}
	return;
    }

    switch (c) {

    case '\b':
	if (C->xpos > 0) {
	    C->xpos--;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	    if (Visible == &Con[Current_VCminor])
#endif

		LCD_Position(C->xpos, C->ypos);

	    /* clear the character */
	    WriteChar(C, ' ');

	    /* and move back again */
	    C->xpos--;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	    if (Visible == &Con[Current_VCminor])
#endif

		LCD_Position(C->xpos, C->ypos);
	}
	return;

    case '\r':

#ifdef CONFIG_SIBO_CONSOLE_ECHO

	send_byte('\n');

#endif

	C->xpos = 0;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	if (Visible == &Con[Current_VCminor])
#endif

	    LCD_Position(C->xpos, C->ypos);

	return;

    case '\n':

#ifdef CONFIG_SIBO_CONSOLE_ECHO

	send_byte('\n');

#endif

	C->ypos++;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	if (Visible == &Con[Current_VCminor])
#endif
	    LCD_Position(C->xpos, C->ypos);

	if (C->ypos == HEIGHT) {
	    C->ypos--;

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

	    for (loopy = 0; loopy < HEIGHT - 1; loopy++)
		for (loopx = 0; loopx < WIDTH; loopx++)
		    C->screen[loopy][loopx] = C->screen[loopy + 1][loopx];

	    for (loopx = 0; loopx < WIDTH; loopx++)
		C->screen[C->ypos][loopx] = ' ';

	    if (Visible == &Con[Current_VCminor])
#endif

	    {
		LCD_ScrollUp();
		LCD_ClearLine(C->ypos);
		LCD_Position(C->xpos, C->ypos);
	    }
	}
	return;
    }

#ifdef CONFIG_SIBO_VIRTUAL_CONSOLE

    C->screen[C->ypos][C->xpos] = c;

    if (Visible == &Con[Current_VCminor])
#endif

	LCD_WriteChar(c);

#ifdef CONFIG_SIBO_CONSOLE_ECHO

    send_byte(c);

#endif

    C->xpos++;

    if (C->xpos == WIDTH) {
	WriteChar(C, '\r');
	WriteChar(C, '\n');
    }
}
Пример #15
0
void WriteChar(register Console * C, char c)
{
#ifdef CONFIG_VIRTUAL_CONSOLE
    int loopx
#endif
    int loopy;

    switch (c) {
    case '\f':
	C->xpos = C->ypos = 0;

	if (Visible == &Con[Current_VCminor])
	    LCD_Position(C->xpos, C->ypos);

	for (loopy = 0; loopy < HEIGHT; loopy++) {

#ifdef CONFIG_VIRTUAL_CONSOLE

	    for (loopx = 0; loopx < WIDTH; loopx++)
		C->screen[loopy][loopx] = ' ';

#endif

	    if (Visible == &Con[Current_VCminor])
		LCD_ClearLine(loopy);
	}
	return;

    case '\b':
	if (C->xpos > 0) {
	    C->xpos--;

	    if (Visible == &Con[Current_VCminor])
		LCD_Position(C->xpos, C->ypos);
	}
	return;

    case '\r':
	C->xpos = 0;

	if (Visible == &Con[Current_VCminor])
	    LCD_Position(C->xpos, C->ypos);

	return;

    case '\n':
	C->ypos++;

	if (Visible == &Con[Current_VCminor])
	    LCD_Position(C->xpos, C->ypos);

	if (C->ypos == HEIGHT) {
	    C->ypos--;

#ifdef CONFIG_VIRTUAL_CONSOLE

	    for (loopy = 0; loopy < HEIGHT - 1; loopy++)
		for (loopx = 0; loopx < WIDTH; loopx++)
		    C->screen[loopy][loopx] = C->screen[loopy + 1][loopx];

	    for (loopx = 0; loopx < WIDTH; loopx++)
		C->screen[C->ypos][loopx] = ' ';

#endif

	    if (Visible == &Con[Current_VCminor]) {
		LCD_ScrollUp();
		LCD_ClearLine(C->ypos);
		LCD_Position(C->xpos, C->ypos);
	    }
	}
	return;

    default:
	break;
    }

    if (Visible == &Con[Current_VCminor])
	LCD_WriteChar(c);

#ifdef CONFIG_VIRTUAL_CONSOLE

    C->screen[C->ypos][C->xpos] = c;

#endif

    C->xpos++;

    if (C->xpos == WIDTH) {
	WriteChar(C, '\r');
	WriteChar(C, '\n');
    }
}
Пример #16
0
void LCD_WriteChar(char c, int x, int y) {
    LCD_WriteChar(c,x,y,0xFFFF);
}
void main(void){  
	unsigned char i,cmd, param[9]; 
	//unsigned char t[]={"Hello World"};

    init();			//setup the crystal, pins
	usbbufflush();	//setup the USB byte buffer

delayMS(10);	

	HD44780_Reset();//setup the LCD
	HD44780_Init();

    USBDeviceInit();//setup usb

    while(1){

        USBDeviceTasks(); 

    	if((USBDeviceState < CONFIGURED_STATE)||(USBSuspendControl==1)) continue;
		usbbufservice();//load any USB data into byte buffer
		
		cmd=waitforbyte();//wait for a byte from USB

		if(cmd!=MATRIX_ORBITAL_COMMAND){//assume text, if 254 then enter command mode

			LCD_WriteChar(cmd); //not a command, just write it to the display

		}else{//previous byte was 254, now get actual command

			switch(waitforbyte()){//switch on the command
				case BACKLIGHT_ON: //1 parameter (minutes 00=forever)
					param[0]=waitforbyte();
					LCD_Backlight(1);//turn it on, we ignore the parameter
					break;
				case BACKLIGHT_OFF:
					LCD_Backlight(0);//backlight off
					break;
				case CLEAR:
					LCD_Clear();
					break;
				case HOME:
					LCD_Home();
					break;
				case POSITION: //2 parameters (col, row)
					param[0]=waitforbyte();
					param[1]=waitforbyte();
					cmd=( ((param[1]-1)*20) + param[0] ); //convert to 20x4 layout (used defined lines, add rows...)
					LCD_CursorPosition(cmd);
					break;
				case UNDERLINE_CURSER_ON:
					LCD_UnderlineCursor(1);
					break;
				case UNDERLINE_CURSER_OFF:
					LCD_UnderlineCursor(0);
					break;
				case BLOCK_CURSER_ON:
					LCD_BlinkCursor(1);
					break;
				case BLOCK_CURSER_OFF:
					LCD_BlinkCursor(0);
					break;
				case BACKLIGHT_BRIGHTNESS://1 parameter (brightness)
					param[0]=waitforbyte();					
					break;
				case CUSTOM_CHARACTER: //9 parameters (character #, 8 byte bitmap)
					LCD_WriteCGRAM(waitforbyte());//write character address
					for(i=1; i<9; i++){
						LCD_WriteRAM(waitforbyte()); //send 8 bitmap bytes
					}
					break;
				default: //error
					break;
			}
		}
	    CDCTxService();
	}

}//end main
//this function redraws the LCD, takes care of scrolling
void LCD_refresh(void){
	static unsigned char searchTerm=0;
	unsigned char i,j,k;
	
	if(trendParser.success==0) return; //don't clear the IP address until we successfully connect to terms feed

	switch(displayMode){
		case IDLE: break;//do nothing
		case UPDATE: //this section draws the basic frame with updating... in the scroll area
			//
			//	Basic screen layout (all lines)
			//
			//clear screen
			LCD_Clear();
			//Write line 1: Trending now:
			LCD_CursorPosition(1);
			LCD_WriteString("Trending now:");
			//write line 3: 
			LCD_CursorPosition(41);
			LCD_WriteString(">Recent tweets");
			//write line 2/4: updating...
			LCD_CursorPosition(21);
			LCD_WriteString("   updating...");
			LCD_CursorPosition(61);
			LCD_WriteString("   updating...");
			searchTerm=0;//reset the local searchTerm index variable that tracks which trend term is presently highlighted
			scrollOffset=0;//clear both scroll offsets
			scrollOffset2=0;
			displayMode=IDLE; //next time, the dislay does nothing
			break;
		case NEWSCROLL: //this draws the highlighted trend term on line three and continues to the scroll function
			//
			//	Update current trend (line 3)
			//
			LCD_CursorPosition(41); //line 3, position 1
			LCD_WriteString("                    ");//clear old term
			LCD_CursorPosition(41);

			//get the start position of the currently highlighted term
			//if it's 0, start at 0, else start at the end of the last term+1
			i=0;
			if(searchTerm!=0) i=trendParser.bufValueEndPosition[(searchTerm-1)];//get start postion (already +1 because of auto increment)
			j=0;
			k=(trendParser.bufValueEndPosition[searchTerm]-1); //save a few operations if we're not optimizing well
			while(i<k){ //repeat untill the end positon //<=
				if(j==20 || i==TREND_PARSER_BUFFER )break; //prevent overruns and line over-writes
				LCD_WriteChar(trendParser.buf[i]); //write the character fromt he buffer to the LCD
				i++;
				j++;
			}
			displayMode=SCROLL; //next time just scroll
		case SCROLL:

			//
			//	Trend scroll	(line 2)
			//
			LCD_CursorPosition(21);//line 2
			scrollPointer=scrollOffset; //adjust the scroll position based on the previous position

			for(i=0; i<20; i++){ //draw 20 characters, offset one from the previous time, loop 0 is we hit the end
				scrollPointer++;
				if(scrollPointer>=trendParser.bufWritePointer || scrollPointer>=TREND_PARSER_BUFFER ) scrollPointer=0;
				LCD_WriteChar(trendParser.buf[scrollPointer]); //write the character to the LCD
			}

			scrollOffset++; //next time start one positon further in the text buffer
				if(scrollOffset>=trendParser.bufWritePointer || scrollOffset>= TREND_PARSER_BUFFER){ //reset at the end, prevent overruns
				scrollOffset=0;
			}

			//
			//	Tweet scroll (line 4)
			//
			if(searchParser.term!=0){//if at least one trend term is populated, scroll the stored tweets (search results)

				LCD_CursorPosition(61);//line 4
				scrollPointer2=scrollOffset2; //get the offset from last time
				//j=searchParser.bufValueEndPosition[searchTerm];//store this so it's easier to get each time

				for(i=0; i<20; i++){ //write 20 characters from the tweet search parser buffer
					scrollPointer2++;
					if((scrollPointer2>searchParser.bufValueEndPosition[searchTerm]) || (scrollPointer2>= SEARCH_PARSER_BUFFER)){
						if(scrollPointer2<searchParser.bufWritePointer)
							LCD_WriteChar(searchParser.buf[scrollPointer2]); //display the next character 	HD44780_WriteByte(DATA, c);
						else
							LCD_WriteChar(' ');//lead out the end of the line end with blanks, don't do a partial repeat
					}else{
						LCD_WriteChar(searchParser.buf[scrollPointer2]); //display the next character
					}

				}

				scrollOffset2++;//increment the scroll offset
				//if we're at the end (10 from the end) or overrun, reset the scroll offset and change the highlighted trend term
				if((scrollOffset2+10)>=searchParser.bufValueEndPosition[searchTerm] || scrollOffset2>= SEARCH_PARSER_BUFFER){
					while(1){
						searchTerm++;//next term
						if(searchTerm==searchParser.term || searchTerm>=MAX_TREND_TERMS){
							searchTerm=0; //if more terms than we have fetched, or more than max, go back to 0
							scrollOffset2=0;//start at beginning next time
							break;//get out of this loop if we're starting over!
						}else{
							if(searchParser.bufValueEndPosition[searchTerm]!=0){
								scrollOffset2=(searchParser.bufValueEndPosition[(searchTerm-1)]);//get the end postion of the next tweet section
								scrollOffset2=scrollOffset2-10;//adjust for continous scroll
								break; //if there's no data for this term, skip it
							}
						}
					}
					displayMode=NEWSCROLL; //update the currently highlighted term next time before scrolling
				}
				
			}//scroll line 4

			break;
	}

}
Пример #19
0
void main()
{
	LCD_Init();
	Timer_Init();
	delay(50);
	while(1)
	{
//		key_scan();
//		duoji_saomiao();	
/*		LCD_WriteNum(0,4,duoji1);
		LCD_WriteNum(0,5,duoji2);*/

/*		Read_light();
		Read_light1();
		Read_light2();
		duoji_genzong();
		DHT11_Receive();

		LCD_WriteNum(0,4,RH);
		LCD_WriteNum(50,4,TH);*/



		while(1)
		{			
			LCD_WriteString(0,1,"T warning:");
			LCD_WriteString(0,3,"Now T:");	
		   while(!flag_T)
		   {
		   		read_Twarn(1,3);
		   }
		   		Read_light();
				Read_light1();
				Read_light2();
				LCD_Clear();
				LCD_WriteString(0,2,"T warning:");
				LCD_WriteString(0,3,"Now T:");
		   while(1)
		   {
		   		LCD_WriteChar(48,3,' ');
		   		read_Twarn(2,3);
				run_T_warn();
				if(duoji1==900)
				{ 
					while((duoji2!=1600)||(duoji1!=2250))
					{
						if(duoji1!=2250)	duoji1=duoji1+10;
						if(duoji2!=1600)	
						{
							if(duoji2>1600) duoji2=duoji2-10;
							else duoji2=duoji2+10;
						}
						delay(30);
			
					}
				}
				if(T_warn>TH)
				{
					if(temp>500||temp1>500||temp2>500)	{LCD_WriteString(0,0,"   Working    ");	duoji_genzong();}
					else   {LCD_WriteString(0,0," Bad weather  ");Read_light();	Read_light1();Read_light2();}
				}
						
		   }
		}
 		
	}
}