void Tick() {
	unsigned char key;
	static unsigned char cursor = 0;
	// transitions'
	switch(state) {
		case start:
			LCD_Cursor(0);
			state = display; break;
		case display:
			state = display; break;
		default:
			state = start;
	}
	// state actions
	switch(state) {
		case start:
		break;
		case display:
		key = GetKeypadKey();
		if(key!='\0'){
			cursor = (cursor==16 ? 0 : cursor);
			LCD_Cursor(++cursor);
			LCD_WriteData(key);
			LCD_Cursor(0);
		}
		break;
	}
}
Example #2
0
int lcdDisplayTick(task* t){

	//actions	
	switch(t->state){
		case lcd_init:
			LCD_init();							//initialize LCD
			LCD_ClearScreen();					//clear screen of any artifacts
			break;
		case s1:
			//LCD_ClearScreen();					//clear screen of any artifacts
			//LCD_DisplayString(1,motionSensorMsg);	//display motion sensor message
			
				LCD_Cursor(14);
				
				if(fanMode)
				{
				    LCD_WriteData(1);
			    }
			    else if(led_fan && !kill && enable && temp)
			    {
			        LCD_WriteData(2);
			    }
			    else
			    {
			        LCD_WriteData(' ');
			    }
			    
				LCD_Cursor(12);
			    
			    if(enable)
			    {
			        LCD_WriteData(3);
			    }
			    else
			    {
			        LCD_WriteData(4);
			    }
			
			break;
		default:
			break;
	}

	//transitions
	switch(t->state){
		case lcd_init:
			t->state = s1;
			break;
		case s1:
			t->state = s1;
			break;
		default:
			break;
	}
	
	return 0;
}
Example #3
0
void LCD_DisplayString( unsigned char column, const unsigned char* string) {
   LCD_ClearScreen();
   unsigned char c = column;
   while(*string) {
      LCD_Cursor(c++);
      LCD_WriteData(*string++);
   }
	LCD_Cursor(0); 
}
void LCD_DisplayDrawLongString(char *string){
	char i = 0;
	LCD_Cursor(1,1);
	while (*string)
	{
		if(i == NUM_OF_CHARS_PER_STR) LCD_Cursor(2,1);
		LCD_DisplayCharacterRus (*string++);
		i++;
	}
}
Example #5
0
/**
 ******************************************************************************
 **
 **	Function Name		: LCD_WipeOffRL
 **
 **	Description			: "Wipe" screen lright-to-left.
 **
 **	Passed Parameters	: None
 **
 **	Modified Data		: None
 **
 **	Return Value		: None
 **
 ******************************************************************************
 */
void LCD_WipeOffRL( void )
{
	uint8 i;
	for( i=40; i>0; i-- ) {
		#define BLOCK 0xff
		LCD_Cursor( 1,i );		LCD_DisplayCharacter( 1, BLOCK );
		LCD_Cursor( 2,i );		LCD_DisplayCharacter( 1, BLOCK );
		LCD_Cursor( 3,i );		LCD_DisplayCharacter( 2, BLOCK );
		LCD_Cursor( 4,i );		LCD_DisplayCharacter( 2, BLOCK );
	}
}
Example #6
0
/**
 ******************************************************************************
 **
 **	Function Name		: LCD_WipeOnLR
 **
 **	Description			: Display an entire screen by
 **			              wiping it on( right to left ).
 **
 **	Passed Parameters	: ptr = pointer to a string containing the entire screen
 **
 **	Modified Data		: None
 **
 **	Return Value		: None
 **
 ******************************************************************************
 */
void LCD_WipeOnRL( uint8 *ptr )
{
	// "wipe" on new screen
	uint8 i;
	for( i=20; i>0; i-- ) {
		LCD_Cursor( 1,i );		LCD_DisplayCharacter( 1, *( ptr+ 0+i-1 ) );
		LCD_Cursor( 2,i );		LCD_DisplayCharacter( 1, *( ptr+40+i-1 ) );
		LCD_Cursor( 3,i );		LCD_DisplayCharacter( 2, *( ptr+80+i-1 ) );
		LCD_Cursor( 4,i );		LCD_DisplayCharacter( 2, *( ptr+120+i-1 ) );
	}
}
Example #7
0
/**
 ******************************************************************************
 **
 **	Function Name		: LCD_WipeOnLR
 **
 **	Description			: Display an entire screen by
 **			              wiping it on( left to right ).
 **
 **	Passed Parameters	: ptr = pointer to a string containing the entire screen
 **
 **	Modified Data		: None
 **
 **	Return Value		: None
 **
 ******************************************************************************
 */
void LCD_WipeOnLR( uint8 *ptr )
{
	// "wipe" on new screen
	uint8 i;
	for( i=0; i<40; i++ ) {
		LCD_Cursor( 1,i+1 );		LCD_DisplayCharacter( 1, *( ptr+ 0+i ) );
		LCD_Cursor( 2,i+1 );		LCD_DisplayCharacter( 1, *( ptr+40+i ) );
		LCD_Cursor( 3,i+1 );		LCD_DisplayCharacter( 2, *( ptr+80+i ) );
		LCD_Cursor( 4,i+1 );		LCD_DisplayCharacter( 2, *( ptr+120+i ) );
	}
}
void restart_game() {
    LCD_DisplayString(1,(unsigned char*)"");
    player = PLAYER_TOP;
    LCD_Cursor(player);
    LCD_WriteData('@');
    LCD_Cursor(0);
    obs1=LCD_TOP_RIGHT;
    obs2=(LCD_BOT_RIGHT - 8);
    gameover = OFF;
    pause = OFF;
}
void Display_Update_Ingame ()
{
	LCD_Cursor(8); // score tens
	LCD_WriteData(points/10 + '0');
	LCD_Cursor(9); // score one
	LCD_WriteData(points%10 + '0');
		
	LCD_Cursor(26); //enemy ones
	LCD_WriteData(enemy_count + '0');
	LCD_Cursor(0);
	return;
}
Example #10
0
/**
 ******************************************************************************
 **
 **	Function Name		: LCD_WipeOffLR
 **
 **	Description			: "Wipe" screen left-to-right.
 **
 **	Passed Parameters	: None
 **
 **	Modified Data		: None
 **
 **	Return Value		: None
 **
 ******************************************************************************
 */
void LCD_WipeOffLR( void )
{
	// "wipe" off old screen( left to right )
	uint8 i;
	for( i=1; i<41; i++ ) {
		#define BLOCK 0xff
		LCD_Cursor( 1,i );		LCD_DisplayCharacter( 1, BLOCK );
		LCD_Cursor( 2,i );		LCD_DisplayCharacter( 1, BLOCK );
		LCD_Cursor( 3,i );		LCD_DisplayCharacter( 2, BLOCK );
		LCD_Cursor( 4,i );		LCD_DisplayCharacter( 2, BLOCK );
	}
}
void Display_Gameover() {
	LCD_DisplayString(5, "GAME OVER        Score: ");
	LCD_Cursor(3);
	LCD_WriteData(0b00001000);
	LCD_Cursor(15);
	LCD_WriteData(0b00001000);
	LCD_Cursor(28);
	LCD_WriteData(points/10 + '0');
	LCD_Cursor(29);
	LCD_WriteData(points%10 + '0');
	LCD_Cursor(0);
	return;
}
Example #12
0
//Function Definitions
void toggle_pause() {
    pause = pause ? 0 : 1;
    if(pause) {
        for(int i=0; i<8; i++) {
            LCD_Cursor(i+5);
            LCD_WriteData(pause_message[i]);
        }
    } else {
        LCD_DisplayString(1,(unsigned char*)" ");
        LCD_Cursor(player);
        LCD_WriteData('@');
        move_obstacles();
    }
}
void Display_Initiate_Ingame ()
{
	LCD_ClearScreen();
	LCD_DisplayString(1, "Score:          Enemies:");
	LCD_Cursor(8); // score tens
	LCD_WriteData(points/10 + '0');
	LCD_Cursor(9); // score one
	LCD_WriteData(points%10 + '0');
	
	LCD_Cursor(26); //enemy ones
	LCD_WriteData(enemy_count + '0');
	Display_Star(12);
	LCD_Cursor(0);
	return;
}
// ************************************ //
// ***Вывод строки длиннее 20 символов* //
// ***из памяти программ*************** //
// ***строка выводится как две строки * //
// ************************************ //
void LCD_DisplayFlashLongString(char *str){
	
	char i = 0;
	LCD_Cursor(1,1);
	char string = pgm_read_byte(str);
	while (string)
	{
		if(i == NUM_OF_CHARS_PER_STR) LCD_Cursor(2,1);
		
		LCD_DisplayCharacterRus (string);
		str++;
		string = pgm_read_byte(str);
		i++;
	}
	
}
void LCD_DisplayStringRus (char row, char column , char *string)
{
	LCD_Cursor (row, column);
	while (*string)
	LCD_DisplayCharacterRus (*string++);
	
}
Example #16
0
void move_player(int pos) {
    if(pos == PLAYER_TOP) {
        player = PLAYER_TOP;
        LCD_Cursor(PLAYER_BOT);
        LCD_WriteData(' ');
        LCD_Cursor(PLAYER_TOP);
        LCD_WriteData('@');
    } else if(pos==PLAYER_BOT) {
        player = PLAYER_BOT;
        LCD_Cursor(PLAYER_TOP);
        LCD_WriteData(' ');
        LCD_Cursor(PLAYER_BOT);
        LCD_WriteData('@');
    }
    LCD_Cursor(0);
}
Example #17
0
/**
 ******************************************************************************
 **
 **	Function Name		: LCD_DisplayRow
 **
 **	Description			: Display a string at the specified row.
 **
 **	Passed Parameters	: None
 **
 **	Modified Data		: None
 **
 **	Return Value		: None
 **
 ******************************************************************************
 */
void LCD_DisplayRow( uint8 row, uint8 *string )
{
	uint8 i;
	LCD_Cursor( row, 1 );
	for( i=0; i<40; i++ )		
		if( *string != '\0')
			LCD_DisplayCharacter( row, *string++ );
}
Example #18
0
void LCD_Clear(u16 Color)
{
  	u32 index=0;
 
  	LCD_Cursor(0x00, 319); 
  	LCD_REG=0x22;//WriteRAM_Prepare 
  	for(index=0;index<76800;index++)LCD_RAM=Color;
}
Example #19
0
//Main
int main(void) {
    DDRB = 0xFF;
    PORTB = 0x00;
    DDRA = 0xFF;
    PORTA = 0x00;
    DDRD = 0xFF;
    PORTD = 0x00;
    DDRC = 0xF0;
    PORTC = 0x0F;

    //Task initializing
    unsigned char i=0;

    //Keypad Task
    tasks[i].state = keypad_start;
    tasks[i].period = keypadGCD;
    tasks[i].elapsedTime = 0;
    tasks[i].TickFct = &tickFct_Keypad;
    i++;

    //Obstacle Movement
    tasks[i].state = obs_start;
    tasks[i].period = obstacleGCD;
    tasks[i].elapsedTime = 0;
    tasks[i].TickFct = &tickFct_Obstacles;
    i++;

    //Collision Detection
    tasks[i].state = col_start;
    tasks[i].period = collisionGCD;
    tasks[i].elapsedTime = 0;
    tasks[i].TickFct = &tickFct_Collision;

    //Setup
    TimerSet(tasksPeriodGCD);
    TimerOn();
    LCD_init();
    LCD_DisplayString(1,(unsigned char*)" ");
    LCD_Cursor(1);
    LCD_WriteData('@');
    LCD_Cursor(0);
    while (1) {

    }
}
Example #20
0
void lcdTick(){
	LCD_ClearScreen();
	switch(gameStatus){
		case intro:
			LCD_DisplayString(4," WHACKAMOLE!");
			displayIntro();
			break;
		case highscore:
			LCD_DisplayString(3, " HIGHSCORE: " );
			LCD_Cursor(24);
			if(currHighScore > 9){
				unsigned char temp = currHighScore/10;
				LCD_WriteData(temp+'0');
				temp = currHighScore % 10;
				LCD_WriteData(temp+'0');
			}
			else
				LCD_WriteData(currHighScore + '0');
			break;
		case resetHighScore:
			LCD_DisplayString(3, " RESETTING    ...HIGHSCORE... " );
			break;
		case play:
			LCD_DisplayString(3, " HIT MOLES!");
			LCD_DisplayString(17, " Score: ");
			LCD_Cursor(30);
			LCD_WriteData(0 +'0');
			break;
		case gameOver:
			LCD_DisplayString(3, " GAME OVER!");
			LCD_DisplayString(17, " YOUR SCORE: ");
			LCD_Cursor(30);
			if(currScore > 9){
				unsigned char temp = currScore/10;
				LCD_WriteData(temp+'0');
				temp = currScore % 10;
				LCD_WriteData(temp+'0');
			}
			else
			LCD_WriteData(currScore + '0');
			break;
	}
	LCD_Cursor(40);
}
Example #21
0
//X,Y为窗口左下角座标,注意设置窗口后座标不要超出该范围
void LCD_Window(u16 Xpos, u16 Ypos, u16 Height, u16 Width)
{
  	if(Xpos>=Height)LCD_WriteReg(0x50,(Xpos-Height+1));
  	else LCD_WriteReg(0x50,0);
  	LCD_WriteReg(0x51,Xpos);
  	if(Ypos>=Width)LCD_WriteReg(0x52,(Ypos-Width+1)); 
  	else LCD_WriteReg(0x52,0);
  	LCD_WriteReg(0x53,Ypos);
  	LCD_Cursor(Xpos,Ypos);
}
Example #22
0
/**
 ******************************************************************************
 **
 **	Function Name		: LCD_DisplayString
 **
 **	Description			:  Display a string at the specified row and column.
 **
 **	Passed Parameters	: None
 **
 **	Modified Data		: None
 **
 **	Return Value		: None
 **
 ******************************************************************************
 */
void LCD_DisplayString( uint8 row, uint8 column, uint8 *string )
{
	uint8 Count = 0;
	LCD_Cursor( row, column );
	while( *string && Count<40 )
	{
		LCD_DisplayCharacter( row, *string++ );
		Count++;
	}
}
Example #23
0
void updateScore(unsigned char newScore){
	if(newScore == currScore+1)
		soundStatus = normal;
	else if(newScore == currScore+2)
		soundStatus = special;
	else if(newScore == currScore-2)
		soundStatus = bad;
	currScore = newScore;
	LCD_Cursor(30);
	if(currScore > 9){
		unsigned char temp = currScore/10;
		LCD_WriteData(temp+'0');
		temp = currScore % 10;
		LCD_WriteData(temp+'0');
	}
	else
	LCD_WriteData(currScore + '0');
	
	LCD_Cursor(40);
}
Example #24
0
void LCD_Char(u16 Xpos, u16 Ypos, u8 Ascii, u16 color)
{
	const u16 *c;
  	u16 Xaddr=0; 
  	u32 index=0,i=0;
					 
  	Xaddr=Xpos;
	c=&Efont->table[(Ascii-32)*Efont->Height]; 
  	LCD_Cursor(Xaddr, Ypos);  
  	for(index=0;index<Efont->Height;index++)
  	{
    	LCD_REG=0x22;//WriteRAM_Prepare
    	for(i=0;i<Efont->Width;i++)
    	{  
			if((((c[index]&((0x80<<((Efont->Width/12)*8))>>i))==0x00)&&(Efont->Width<=12))
			||(((c[index]&(0x1<<i))==0x00)&&(Efont->Width>12)))LCD_WriteRAM(BLUE);
      		else LCD_WriteRAM(color); 
    	}
    	Xaddr++;
    	LCD_Cursor(Xaddr, Ypos);
  	}
Example #25
0
void LCD_Fill(u16 x1, u16 y1, u16 x2, u16 y2, u16 color)
{          
	u16 i,j;
	u16 xlen=0;

	xlen=y2-y1+1;	   
	for(i=x1;i<=x2;i++)
	{
	 	LCD_Cursor(i,y2);
		LCD_REG=0x22;      	  
		for(j=0;j<xlen;j++)LCD_WriteRAM(color); 	  
	}						  	    
}  
Example #26
0
//This function displays any data upto 5 digits. It also requires row and column address
void LCD_Print(unsigned char Row, char Col,unsigned int Val, unsigned int Digits)
{
 unsigned char Flag=0;
 unsigned int Temp,Mi,Th,Hu,Te,Un=0;

 if(Row==0 || Col==0)
 {
  LCD_Home();
 }
 else
 {
  LCD_Cursor(Row,Col);
 }
 if(Digits==5 || Flag==1)
 {
  Mi=Val/10000+48;
  LCD_Data(Mi);
  Flag=1;
 }
 if(Digits==4 || Flag==1)
 {
  Temp = Val/1000;
  Th = (Temp % 10) + 48;
  LCD_Data(Th);
  Flag=1;
 }
 if(Digits==3 || Flag==1)
 {
  Temp = Val/100;
  Hu = (Temp%10) + 48;
  LCD_Data(Hu);
  Flag=1;
 }
 if(Digits==2 || Flag==1)
 {
  Temp = Val/10;
  Te = (Temp%10) + 48;
  LCD_Data(Te);
  Flag=1;
 }
 if(Digits==1 || Flag==1)
 {
  Un = (Val%10) + 48;
  LCD_Data(Un);
 }
 if(Digits>5)
 {
  LCD_Data('E');
 }
	
}
Example #27
0
/**
 * @param	pcWriteBuffer
 * @param	xWriteBufferLen
 * @param	pcCommandString
 * @return
 */
static BaseType_t LCD_CursorCommand(char *pcWriteBuffer, size_t xWriteBufferLen, const char *pcCommandString)
{
	const char *parameterPtr;
	int32_t paramterLen;
	uint32_t mode;

	parameterPtr = FreeRTOS_CLIGetParameter(pcCommandString, 1, &paramterLen);
	mode = DecToInt((char *) parameterPtr, paramterLen);

	LCD_Cursor(mode & BIT0);
	LCD_Blink(mode & BIT1);

	sprintf(pcWriteBuffer, "Cursor set to mode: %d\n", (uint16_t)(mode & 0x03));

	return pdFALSE;

}
void Display_Star(unsigned char i) { //i is position ranging from 1 - 13
	//LCD_Cursor(i);
	//LCD_WriteData(0b00001000);
	LCD_Cursor(i+1);
	LCD_WriteData(0b00001001);
	LCD_Cursor(i+2);
	LCD_WriteData(0b00001010);
	LCD_Cursor(i+3);
	LCD_WriteData(0b00001011);
	LCD_Cursor(i+16);
	LCD_WriteData(0b00001100);
	LCD_Cursor(i+17);
	LCD_WriteData(0b00001101);
	LCD_Cursor(i+18);
	LCD_WriteData(0b00001110);
	LCD_Cursor(i+19);
	LCD_WriteData(0b00001111);
	LCD_Cursor(0);
	return;
}
Example #29
0
void JPEG_encode(void)//编码主函数
{

	u8 res;
	u16 i,j,color;

	res=f_mount(0, &fatfs);
	while(res)LCD_String(20,20,"SD mount failed!",RED);
	res=f_open(&fileW,"0:/DCMI/ph1.jpg",FA_WRITE|FA_CREATE_ALWAYS);//创建并打开
	while(res)LCD_String(20,20,"file create failed!",RED);

	cinfo=jpeg_create_compress();//创建JPEG压缩文件
	cinfo->image_width=240;
  	cinfo->image_height=320;
  	cinfo->output=0;//数据输出到NULL;
  	jpeg_set_default(cinfo);//设置默认参数
	jpeg_start_compress(cinfo);//开始压缩,写压缩文件头信息
	j=0;
	while(cinfo->next_line<cinfo->image_height)
	{
		for(i=0;i<240;i++)//读取一行
		{
			LCD_Cursor(i,cinfo->next_line);			
			if((lcdid&0xff00)==0x9300)color=BGR565toRGB565(LCD_ReadRAM());
			else color=LCD_ReadRAM();
			cinfo->inbuf[j++]=(u8)((color&0xf800)>>8);
			cinfo->inbuf[j++]=(u8)((color&0x07e0)>>3);
			cinfo->inbuf[j++]=(u8)((color&0x001f)<<3);
		}
		cinfo->next_line++; 
	  	//当数据填满时压缩并输出数据(填满16行)
	  	if(cinfo->next_line%cinfo->inbuf_height==0)
		{
			j=0;
	    	jint_process_rows(cinfo);//在这里压缩
	    	memset((void*)(cinfo->inbuf),0,cinfo->inbuf_size);//清空输入缓冲区
	  	}
	}	
	jpeg_finish_compress(cinfo);
	f_close(&fileW);
	LEDOn(LED4);
	while(1);
}
Example #30
0
/**
 ******************************************************************************
 **
 **	Function Name		: LCD_DisplayStringCentered
 **
 **	Description			: Display a string centered on the specified row.
 **
 **	Passed Parameters	: None
 **
 **	Modified Data		: None
 **
 **	Return Value		: None
 **
 ******************************************************************************
 */
void LCD_DisplayStringCentered( uint8 row, uint8 *string )
{
	uint8 len = strlen( (char *)string );

	if( len <= 40 ) {
		// if the string is less than one line, center it ...
		uint8 i;
		LCD_Cursor( row, 1 );
		for( i=0; i<40; i++ )
			LCD_DisplayCharacter( row, ' ' );
		
		LCD_DisplayString( row,( ( 40 - len ) / 2 )+1,string );
	}
	else {
		// if the string is more than one line, display first 20 characters
		uint8 temp[41];
		strncpy((char *)temp, (char *)string, 40 );
		temp[40] = 0;
		LCD_DisplayString( row,1,temp );
	}
}