Ejemplo n.º 1
0
/*********************************************************************
* Function:  LCD_SetArea(start_x,start_y,end_x,end_y)
*
* PreCondition: SetActivePage(page)
*
* Input: start_x, end_x	- start column and end column
*		 start_y,end_y 	- start row and end row position (i.e. page address)
*
* Output: none
*
* Side Effects: none
*
* Overview: defines start/end columns and start/end rows for memory access
*			from host to SSD1963
* Note: none
********************************************************************/
void LCD_SetArea(u16 start_x, u16 start_y, u16 end_x, u16 end_y)
{
	long offset;

	offset = (u16)_activePage*(GetMaxY()+1);

	start_y = offset + start_y;
	end_y   = offset + end_y;



	LCD_WriteCommand(CMD_SET_COLUMN);
	Clr_Cs;
	LCD_WriteData(start_x>>8);
	LCD_WriteData(start_x);
	LCD_WriteData(end_x>>8);
	LCD_WriteData(end_x);
	Set_Cs;
	LCD_WriteCommand(CMD_SET_PAGE);
	Clr_Cs;
	LCD_WriteData(start_y>>8);
	LCD_WriteData(start_y);
	LCD_WriteData(end_y>>8);
	LCD_WriteData(end_y);
	Set_Cs;
}
Ejemplo n.º 2
0
void LCD_Update(void)
{
    uint8_t i;

    LCD_WriteCmd(LCDCMD_SET_DDRAM_ADDRESS | LCD_FIRSTLINE_ADDRESS);
    
    for(i = 0; i < 16; i++)
    {
        if( LCDText[i] == 0 )
        {
            LCD_WriteData(' ');
        }
        else
        {
            LCD_WriteData(LCDText[i]);
        }
    }
    
    LCD_WriteCmd(LCDCMD_SET_DDRAM_ADDRESS | LCD_SECONDLINE_ADDRESS);
    
    for(i = 16; i < 32; i++)
    {
        if( LCDText[i] == 0 )
        {
            LCD_WriteData(' ');
        }
        else
        {
            LCD_WriteData(LCDText[i]);
        }
    }
}
Ejemplo n.º 3
0
/********************************************************************************************************
*  Function: LCD_OpenWin				                                                           
*  Object: lcd open window for display
*  Input: x0,y0, x1, y1
*  Output: none                                  
*  brief: none
********************************************************************************************************/
void LCD_OpenWin(uint16_t x0, uint16_t y0, uint16_t x1, uint16_t y1)
{
		/*
		#if (LCD_DIRECT == 1)
			LCD_WriteReg(0x0044);
			LCD_WriteData((x1<<8)+x0);
			LCD_WriteReg(0x0045);
			LCD_WriteData((y1<<8)+y0);	
			LCD_WriteReg(0x0021);
			LCD_WriteData((y0<<8)+x0); 
		#else
			LCD_WriteReg(0x0045);
			LCD_WriteData((x1<<8)+x0);
			LCD_WriteReg(0x0044);
			LCD_WriteData((y1<<8)+y0);
			LCD_WriteReg(0x0021);
			LCD_WriteData((x0<<8)+y0); 
		#endif
			LCD_WriteReg(0x0022);
		//S_DogFeed();
		*/
		LCD_WriteReg(0x2A);	
		LCD_WriteData(y0>>8);
		LCD_WriteData(0x00FF&y0);		
		LCD_WriteData(y1>>8);
		LCD_WriteData(0x00FF&y1);
		LCD_WriteReg(0x2B);	
		LCD_WriteData(x0>>8);
		LCD_WriteData(0x00FF&x0);		
		LCD_WriteData(x1>>8);
		LCD_WriteData(0x00FF&x1);
		LCD_WriteReg(0x2C);
}
Ejemplo n.º 4
0
/********************************************************************************************************
*  Function: LCD_DisGB2312String16x16				                                                           
*  Object: display a chinese string
*  Input: site, char, fColor, bColor
*  Output: none                                  
*  brief: none
********************************************************************************************************/
void LCD_DisGB2312String16x16(uint16_t x0, uint16_t y0, u8 *s, uint16_t fColor, uint16_t bColor)
{
		uint16_t Num;
		u8 i,j,m,l = 1;
		while(*s)
		{
				LCD_OpenWin(x0, y0+(16-1)*(l-1), x0+16-1, y0+(16-1)*l);
				for(Num = 0; Num < sizeof(GB2312Code16x16)/35; Num++)
				{
						if((GB2312Code16x16[Num].Head[0] == *s) && (GB2312Code16x16[Num].Head[1] == *(s+1)))
						{ 
								for(i = 0; i < 32; i++) 
								{
										m = GB2312Code16x16[Num].Infor[i];
										for(j = 0; j<8; j++) 
										{
												if(m&CHSBIT7)
													LCD_WriteData(fColor);
												else 
													LCD_WriteData(bColor);
												m<<=1;
										}
								}
						}
				}
				s+=2;
				l++;
		}
}
Ejemplo n.º 5
0
/**************************************************************************
*   Function name :   Bcd3IntLcd
*   Returns :         нет       
*   Parameters :      значение числа от 0 до 999    
*   Purpose :         переводит число в символ и выводит на жкд        
****************************************************************************/
void Bcd3IntLcd(unsigned int value)
{
    unsigned char high = 0;
    unsigned char flag = 0;
   
    if (value >= 100) flag = 48;   
    else flag = 32;
    while (value >= 100)                
    {
        high++;
        value -= 100;
    }
    if (high) high += 48;
    else high = 32;
    LCD_WriteData(high );
    
    high = 0;
    while (value >= 10)                 
    {
        high++;
        value -= 10;
    }
    if (high) high += 48;
    else high = flag;
    LCD_WriteData(high );
    
    value += 48;
    LCD_WriteData(value);  
}
Ejemplo n.º 6
0
void Lcd_SetCursor(unsigned int x,unsigned int y)
{
    LCD_WriteRegIndex(0x20);
    LCD_WriteData(x);//水平坐标
    LCD_WriteRegIndex(0x21);
    LCD_WriteData(y);//垂直坐标
}
Ejemplo n.º 7
0
/**************************************************************************
*   Function name :   Bcd5IntLcd
*   Returns :         нет       
*   Parameters :      значение числа от 0 до 65535    
*   Purpose :         переводит число в символ и выводит на жкд        
****************************************************************************/
void Bcd5IntLcd(unsigned int value)
{
    unsigned char high = 0;
    unsigned char flag = 0;
    unsigned char flag2 = 0;
	unsigned char flag3 = 0;  
    
    if (value >= 10000) {flag = 48; flag2 = 48; flag3 = 48;}  
    else
    {
      if (value >= 1000) {flag = 32; flag2 = 48; flag3 = 48;}
      else {flag = 32; flag2 = 32; flag3 = 48;}
    }
    
    while (value >= 10000)               
    {
        high++;
        value -= 10000;
    }
    if (high) high += 48;
    else high = 32;
    LCD_WriteData(high);
    
    high = 0;	


    while (value >= 1000)                // Count thousand
    {
        high++;
        value -= 1000;
    }
    if (high) high += 48;
    else high = flag;
    LCD_WriteData(high);
    
    high = 0;
    while (value >= 100)                
    {
        high++;
        value -= 100;
    }
    if (high) high += 48;
    else high = flag2;
    LCD_WriteData(high );
    
    
    high = 0;
    while (value >= 10)                 
    {
        high++;
        value -= 10;
    }
    if (high) high += 48;
    else high = flag3;
    LCD_WriteData(high );
    
    value += 48;
    LCD_WriteData(value);  
}
Ejemplo n.º 8
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;
}
/*=====================================================================================================*/
void LCD_SetCursor( u16 CoordiX, u16 CoordiY )
{
	LCD_WriteCmd(0x2A);
  LCD_WriteData(Byte8H(CoordiX));
	LCD_WriteData(Byte8L(CoordiX));
	LCD_WriteCmd(0x2B);
  LCD_WriteData(Byte8H(CoordiY));
	LCD_WriteData(Byte8L(CoordiY));
	LCD_WriteCmd(0x2C);
}
Ejemplo n.º 10
0
/*====================================================================================================*/
void LCD_SetCursor( uint16_t coordiX, uint16_t coordiY )
{
  LCD_WriteCmd(0x2A);
  LCD_WriteData(Byte8H(coordiX));
  LCD_WriteData(Byte8L(coordiX));
  LCD_WriteCmd(0x2B);
  LCD_WriteData(Byte8H(coordiY));
  LCD_WriteData(Byte8L(coordiY));
  LCD_WriteCmd(0x2C);
}
Ejemplo n.º 11
0
/**
 ******************************************************************************
 **
 **	Function Name		: LCD_DefineCharacter
 **
 **	Description			: Define dot pattern for user-defined character.
 **
 **	Passed Parameters	: address = address of character( 0x00-0x07 )
 **						  pattern = pointer to 8-byte array containing 
 **                                 the dot pattern
 **	Modified Data		: None
 **
 **	Return Value		: None
 **
 ******************************************************************************
 */
void LCD_DefineChar( uint8 address, const uint8 *pattern )
{
	uint8 i;

	LCD_WriteControl( 1, 0x40 +( address << 3 ) );
	LCD_WriteControl( 2, 0x40 +( address << 3 ) );
	for( i=0; i<8; i++ ) {
		LCD_WriteData( 1, *pattern++ );
		LCD_WriteData( 2, *pattern++ );
	}
}
Ejemplo n.º 12
0
/*********************************************************************
* Function:  SetScrollArea(SHORT top, SHORT scroll, SHORT bottom)
*
* PreCondition: none
*
* Input: top - Top Fixed Area in number of lines from the top
*				of the frame buffer
*		 scroll - Vertical scrolling area in number of lines
*		 bottom - Bottom Fixed Area in number of lines
*
* Output: none
*
* Side Effects: none
*
* Overview:
*
* Note: Reference: section 9.22 Set Scroll Area, SSD1963 datasheet Rev0.20
********************************************************************/
void LCD_SetScrollArea(u16 top, u16 scroll, u16 bottom)
{
	LCD_WriteCommand(CMD_SET_SCROLL_AREA);
	Clr_Cs;
	LCD_WriteData(top>>8);
	LCD_WriteData(top);
	LCD_WriteData(scroll>>8);
	LCD_WriteData(scroll);
	LCD_WriteData(bottom>>8);
	LCD_WriteData(bottom);
	Set_Cs;	
}
Ejemplo n.º 13
0
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;
}
Ejemplo n.º 14
0
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;
}
Ejemplo n.º 15
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();
    }
}
Ejemplo n.º 16
0
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;
}
Ejemplo n.º 17
0
/**
 ******************************************************************************
 **
 **	Function Name		: LCD_DisplayCharacter
 **
 **	Description			: Display a single character, 
 **						  at the current cursor location.
 **
 **	Passed Parameters	: None
 **
 **	Modified Data		: None
 **
 **	Return Value		: None
 **
 ******************************************************************************
 */
void LCD_DisplayCharacter( uint8 line, uint8 a_char )
{
	switch( line )
	{
		case 1:
		case 2:
			LCD_WriteData( 1, a_char );
		break;

		case 3:
		case 4:
			LCD_WriteData( 2, a_char );
		break;
	}
}
Ejemplo n.º 18
0
/*******************************************************************************
* Function Name  : PCLK_inversion (Pixel Clock Setting Register)
* Description    : PDAT is fetched at PCLK falling edge.
* Input          : None
* Output         : None
* Return         : None
* Attention		 : None
*******************************************************************************/
void PCLK_inversion(void)
{
    uint8_t temp;
    temp = LCD_ReadReg(0x04); //PCRS
    temp |= 0x80;
    LCD_WriteData(temp);
}
Ejemplo n.º 19
0
/*******************************************************************************
* Function Name  : PCLK_non_inversion (Pixel Clock Setting Register)
* Description    : PDAT is fetched at PCLK rising edge.
* Input          : None
* Output         : None
* Return         : None
* Attention		 : None
*******************************************************************************/
void PCLK_non_inversion(void)
{
    uint8_t temp;
    temp = LCD_ReadReg(0x04); //PCRS
    temp &= 0x7f;
    LCD_WriteData(temp);
}
Ejemplo n.º 20
0
/**************************************************************************
*   Function name :   Bcd2Lcd
*   Returns :         нет       
*   Parameters :      значение числа от 0 до 99   
*   Purpose :         переводит число в символ и выводит на жкд        
****************************************************************************/
void Bcd2Lcd(unsigned char value)
{
    unsigned char high = 0;
    
    while (value >= 10)                 
    {
        high++;
        value -= 10;
    }
    if (high) high += 48;
    else high = 32;
    LCD_WriteData(high);

    value += 48;
    LCD_WriteData(value);  
}
Ejemplo n.º 21
0
/*******************************************************************************
* Function Name  : Serial_ROM_select1
* Description    : Serial Flash/ROM 0 or 1 I/F is selected.
* Input          : None
* Output         : None
* Return         : None
* Attention	     : None
*******************************************************************************/
void Serial_ROM_select1(void)
{
    uint8_t temp;
    temp = LCD_ReadReg(0x05); //SROC
    temp |=0x80;
    LCD_WriteData(temp);
}
Ejemplo n.º 22
0
Archivo: power.c Proyecto: kono123/iam
void Power_Init(void)
{
//  P4DIR |= 0x03;
//  P5DIR |= 0x0F;
//  P4SEL = 0x0;
//  P5SEL = 0x0;

//  PORT_HI(5,4);
//  PORT_HI(5,5);
//  LCD_CS_Diactivate();
//  LCD_A0_LO();

  printf("Hello LCD !!\n");
  LCD_WriteData(0xa5);
  LCD_WriteData(0x0F);
}
Ejemplo n.º 23
0
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
void LCD_DefineCharacter(char index, char * pattern)
{
    char i ;
    LCD_WriteCommand(HD44780_CGRAM_SET + (8 * index));
    for(i = 0; i < 8; i++)
        LCD_WriteData(*(pattern + i));
}
Ejemplo n.º 24
0
void LCD_PutPixel(unsigned char X,unsigned char Y, unsigned char color)
  {
    unsigned char data;     
    unsigned char adress=X_OFFSET;       

    if( (X>=XMAX) || (Y>=YMAX) )return;

    adress += X;                                                 
 
    LCD_WriteCommand(0xB0 + (Y/8));
    LCD_WriteCommand((unsigned char)adress & 0x0F);   
    LCD_WriteCommand((unsigned char)((adress & 0xF0) >> 4) + 0x10);       

    LCD_WriteCommand(0xE0); // вход в режим записи
    data = LCD_read_data(1);              //dummy read
    data = LCD_read_data(0);              //realy read
    LCD_WriteCommand(0xEE);  // выход из режимазаписи       

 
    if(color == 1) 
      data |= 0x01 << (Y%8);     
    else 
      data &= ~(0x01 << (Y%8));  
	
    LCD_WriteData(data);
  }
Ejemplo n.º 25
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);
}
Ejemplo n.º 26
0
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;
	}
}
Ejemplo n.º 27
0
void showTime(uint8_t x,uint8_t y ,uint16_t value){
		
		uint8_t sec=value%60;
		uint8_t minute=(value%3600)/60;
		uint8_t hour=value/3600;
		if(sec==0){
			LCD_ClearField(x,y,8);
		}
		LCD_Goto(x,y);
		LCD_SendNumber(hour,' ');
		LCD_WriteData(':');
		LCD_SendNumber(minute,' ');
		LCD_WriteData(':');
		LCD_SendNumber(sec,' ');
			
}
Ejemplo n.º 28
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++);
   }
}
Ejemplo n.º 29
0
void LCD_WriteText(uint8_t * text) {	

	while(*text) {
	  LCD_WriteData(*text);
	  text++;
}

}
Ejemplo n.º 30
0
/**
  *  函数名称:LCD_ShowString
  *  函数参数:坐标值 、字符串
  *  函数功能:lcd1602 设置坐标
  *  日期:2016-1-20
  */
void LCD_ShowString(uint8 x, uint8 y, uint8 *str)
{
   LCD_WriteCmd((((y & 1) << 6) + x) | 0x80);   /* 设置光标的位置 */
	while(*str)
	{
	    LCD_WriteData(*str++);
	}
}