Esempio n. 1
0
void lcd_print_picxy(unsigned int dat, unsigned char x, unsigned char y)
{/*    	定终点打印图像
参数:
	dat:	显示的点阵,十六位,数据为该行要显示的点阵
	x、y:x从0~7,T=y从0~63
调用:
	lcd_expand_switch()、lcd_write(1,)、lcd_position()
*/
	//参数检查
	ASSERT(x>7 || y>63);
	lcd_expand_switch(1);
	lcd_write_cmd(LCD_PIC_ENABLE);
	
	//将行-列坐标转换为LCD的垂直-水平坐标
	if(y>31){
		x+=8;
		y-=32;    
	}
	
	//先后写入垂直、水平地址:0x80+addr
	lcd_write_cmd(0x80+y);
	lcd_write_cmd(0x80+x);
	
	//先后写入两个字节的数据:0x80+addr;
	lcd_write_data(dat);
	lcd_write_data(dat>>8);
	
	lcd_write_cmd(LCD_PIC_DISABLE);
	lcd_expand_switch(0);
}
//-------------------------------------------------------------------------
void show_name(char *name)
{
  UINT16 i,j,length_temp,length_n;
  
  LCD_Init(); 
  length_temp=strlen(name);
  if(length_temp<=32)
  {
      length_n=1;
  }
  else
        length_n=(length_temp-32)/16+1;
  for(i=0;i<length_n;i++)
  {
         lcd_write_cmd(LCD_BASE,0x80);
         usleep(100);
         for(j=0;j<16;j++)
         {
          lcd_write_data(LCD_BASE,name[j+i*16]);
          usleep(100);
         }           
         lcd_write_cmd(LCD_BASE,0xC0);
         usleep(100);
         for(j=0;j<16;j++)
         {
          lcd_write_data(LCD_BASE,name[j+i*16+16]);
          usleep(100);
         }  
         if(length_n>1)
         usleep(1000000);  
         else
         usleep(300000);     
  }  
}
Esempio n. 3
0
/**
 * [lcd_init LCD��ʼ��]
 */
void lcd_init()
{
	lcd_write_cmd(0x3f);		 //LCD����ʾ
	lcd_write_cmd(0xc0);		 //LCD�г�ʼ��ַ����64��
	lcd_write_cmd(0xb8);		 //LCDҳ��ʼ��ַ����8ҳ
	lcd_write_cmd(0x40);		 //LCD�г�ʼ��ַ����64��
}
Esempio n. 4
0
void Startup()
{
    unsigned char msgindex, outchar;
	char Startup[ ] = "System Check        ";

	lcd_write_cmd(0x80);

	for (msgindex = 0; msgindex < 20; msgindex++)
	{
		outchar = Startup[msgindex];
		lcd_write_data(outchar);
	}
    
    PORTA = 0b00001111;
    delay_ms(1000);
    PORTA = 0b00000000;
    
    char StartupDone[ ] = "System Check Done   ";

	lcd_write_cmd(0x80);

	for (msgindex = 0; msgindex < 20; msgindex++)
	{
		outchar = StartupDone[msgindex];
		lcd_write_data(outchar);
	}
    
    AlarmAOff = 0;
    AlarmBOff = 0;
    AlarmC2Off = 0;
    AlarmCOff = 0;
}
Esempio n. 5
0
void LCDSetPos(uint8_t row, uint8_t col)
{
	switch (row) {
	case 0: lcd_write_cmd(0x80 | (col & 0x0f)); break;
    case 1: lcd_write_cmd(0xC0 | (col & 0x0f)); break;
    case 2: lcd_write_cmd(0x90 | (col & 0x0f)); break;
	case 3: lcd_write_cmd(0xD0 | (col & 0x0f)); break;
	}

}
Esempio n. 6
0
void lcd_roll(unsigned char y)
{/*        液晶卷动

参数: 卷动行编号(1~4)
调用: lcd_expand_switch()、lcd_write_cmd()
*/
	lcd_expand_switch(1);
	lcd_write_cmd(LCD_CMD_ROLL_ON);
	lcd_write_cmd(0x40 | y);
	lcd_expand_switch(0);
}
Esempio n. 7
0
/**
 * [lcd_cls LCD��������]
 * @param screen [ѡ������]
 */
void lcd_cls(SCREEN screen){
	int x,y;
	select_screen(screen);		   //screen:0-ѡ��ȫ����1-ѡ���������2-ѡ���Ұ���
	for(x=0xb8;x<0xc0;x++){			//��0xb8-0xbf,��8ҳ
		lcd_write_cmd(x);
		lcd_write_cmd(0x40);			//�еij�ʼ��ַ��0x40
		for(y=0;y<64;y++){
			lcd_write_byte(0x00);
		}
  }	   
}
Esempio n. 8
0
//-------------------------------------------------------------------------
void LCD_Init() {
	lcd_write_cmd(LCD_DISPLAY_BASE,0x38);
	usleep(2000);
	lcd_write_cmd(LCD_DISPLAY_BASE,0x0C);
	usleep(2000);
	lcd_write_cmd(LCD_DISPLAY_BASE,0x01);
	usleep(2000);
	lcd_write_cmd(LCD_DISPLAY_BASE,0x06);
	usleep(2000);
	lcd_write_cmd(LCD_DISPLAY_BASE,0x80);
	usleep(2000);
}
Esempio n. 9
0
static void dis_print_arrow(uint8 line)
{
	lcd_write_cmd(line);
	lcd_write_data(6);
	lcd_write_data(7);
	if(line == LCD_LINE_1){
		lcd_write_cmd(LCD_LINE_2);
		lcd_write_data(' ');
	  lcd_write_data(' ');
	}else{
		lcd_write_cmd(LCD_LINE_1);
		lcd_write_data(' ');
	  lcd_write_data(' ');
	}
}
Esempio n. 10
0
void dis_print_scroll(uint8 line)
{
	char buf[LCD_LINE_LEN + 1] = {0};
  size_t size = 0;	
  uint8 len = 0;
  uint8 j;

	OSAL_ASSERT(gSrollBuf != NULL);

  size = strlen(gSrollBuf);

  //SYS_TRACE("dis_print_scroll:[%d]->%s\r\n", size, gSrollBuf);

  len = size > LCD_LINE_LEN ? LCD_LINE_LEN: size;
	
	strncpy(buf, gSrollBuf, len);
	
	if(len > 1){
		gSrollBuf++;
	}else{
		gSrollBuf = gSystem_t->sroll_buf;
	}
	
	lcd_write_cmd(line);
	for(j = 0; j < LCD_LINE_LEN; j++){
		 if(buf[j] == 0){
			 lcd_write_data(' ');
		 }else{
			 lcd_write_data(buf[j]);
		 }
	 }
	
}
Esempio n. 11
0
void SetupTime() //Program to get current Time
{
	unsigned char msgindex, outchar, ctemp;
	unsigned char hour10, hour1, minute10, minute1, second10, second1;
	char Message[ ] = "Set time hhmmss:    ";

	lcd_write_cmd(0x80);

	for (msgindex = 0; msgindex < 20; msgindex++)
	{
		outchar = Message[msgindex];
		lcd_write_data(outchar);
	}

	lcd_write_cmd(0xC0); // Move cursor to line 2 position 1

	ctemp=getkey(); // waits and get an ascii key number when pressed
	lcd_write_data(ctemp); //display on LCD
	hour10 = char_2_int (ctemp);

	ctemp=getkey();
	lcd_write_data(ctemp);
	hour1 = char_2_int (ctemp);

	ctemp=getkey();
	lcd_write_data(ctemp);
	minute10 = char_2_int (ctemp);

	ctemp=getkey();
	lcd_write_data(ctemp);
	minute1 = char_2_int (ctemp);

	ctemp=getkey();
	lcd_write_data(ctemp);
	second10 = char_2_int (ctemp);

	ctemp=getkey();
	lcd_write_data(ctemp);
	second1 = char_2_int (ctemp);

	hour = hour10 * 10 + hour1;
	minute = minute10 * 10 + minute1;
	second = second10 * 10 + second1;

	delay_ms(500);
	lcd_write_cmd(0x01);
}
Esempio n. 12
0
//----------------------------------------------------------------------------------------
//
//		 ******* INICJALIZACJA WY�WIETLACZA LCD ********
//
//----------------------------------------------------------------------------------------
void lcd_init(void)
{
	// inicjowanie pin�w port�w ustalonych do pod��czenia z wy�wietlaczem LCD
	// ustawienie wszystkich jako wyj�cia
	data_dir_out();
	DDR(LCD_RSPORT) |= (1<<LCD_RS);
	DDR(LCD_EPORT) |= (1<<LCD_E);
	DDR(LCD_BACKGROUNDPORT) |= (1<<LCD_BL);
	#if USE_RW == 1
		DDR(LCD_RWPORT) |= (1<<LCD_RW);
	#endif

	// wyzerowanie wszystkich linii steruj�cych
	PORT(LCD_RSPORT) &= ~(1<<LCD_RS);
	PORT(LCD_EPORT) &= ~(1<<LCD_E);
	#if USE_RW == 1
		PORT(LCD_RWPORT) &= ~(1<<LCD_RW);
	#endif

	_delay_ms(15);
	PORT(LCD_RSPORT) &= ~(1<<LCD_RS);
	PORT(LCD_RWPORT) &= ~(1<<LCD_RW);

	// jeszcze nie mo�na u�ywa� Busy Flag
	lcd_sendHalf(LCDC_FUNC|LCDC_FUNC8B);
	_delay_ms(4.1);
	lcd_sendHalf(LCDC_FUNC|LCDC_FUNC8B);
	_delay_us(100);
	lcd_sendHalf(LCDC_FUNC|LCDC_FUNC4B);
	_delay_us(100);

	// ju� mo�na u�ywa� Busy Flag
	// tryb 4-bitowy, 2 wiersze, znak 5x7
	lcd_write_cmd( LCDC_FUNC|LCDC_FUNC4B|LCDC_FUNC2L|LCDC_FUNC5x7 );
	// wy��czenie kursora
	lcd_write_cmd( LCDC_ONOFF|LCDC_CURSOROFF );
	// w��czenie wy�wietlacza
	lcd_write_cmd( LCDC_ONOFF|LCDC_DISPLAYON );
	// przesuwanie kursora w prawo bez przesuwania zawarto�ci ekranu
	lcd_write_cmd( LCDC_ENTRY|LCDC_ENTRYR );

	// kasowanie ekranu
	lcd_cls();

	lcd_backgroundLedOn();

}
Esempio n. 13
0
/**
 * [lcd_rol LCD������ʾ]
 */
void lcd_rol(){
	int x;
	for(x=0;x<64;x++){
		select_screen(0);
		lcd_write_cmd(0xc0+x);
		delay_ms(500);
	}
}
Esempio n. 14
0
//----------------------------------------------------------------------------------------
//
//		Kasowanie ekranu wy�wietlacza
//
//----------------------------------------------------------------------------------------
void lcd_cls(void)
{
	lcd_write_cmd( LCDC_CLS );

	#if USE_RW == 0
		_delay_ms(4.9);
	#endif
}
Esempio n. 15
0
//----------------------------------------------------------------------------------------
//
//		Powr�t kursora na pocz�tek
//
//----------------------------------------------------------------------------------------
void lcd_home(void)
{
	lcd_write_cmd( LCDC_CLS|LCDC_HOME );

	#if USE_RW == 0
		_delay_ms(4.9);
	#endif
}
Esempio n. 16
0
void lcd_expand_switch(unsigned char action)
{/*        液晶开关扩展指令

调用:lcd_write_cmd()
*/
	action=action?0x34:0x30;
	lcd_write_cmd(action);
}
Esempio n. 17
0
bool dis_print(uint8 line, dis_align_t align, char *fmt, ...)
{
	 uint8 j;
	 uint8 offset;
	 char buf[6*LCD_LINE_LEN] = {0};
   char temp[LCD_LINE_LEN + 1] = {0};
   va_list ap;
   size_t len;
   bool is_need_scroll = false;

   va_start(ap, fmt);
   vsprintf(buf, fmt, ap);
   va_end(ap);

   len = strlen(buf);

   if(len > LCD_LINE_LEN){
		 is_need_scroll = true;
		 if(false == IS_Flag_Valid(DISPLAY_SCROLL_LOCK)){
			 return is_need_scroll;
		 }
	 }

   if(align == ALIGN_CENTER){
		 offset =  LCD_LINE_LEN > len? (LCD_LINE_LEN - len):(0);
		 if(offset){
			 for(j = 0; j < offset/2; j++){
				 temp[j] = ' ';
			 }
			 
			 strcat(temp, buf);
		 }else{
			 strncpy(temp, buf, LCD_LINE_LEN);
		 }
		 
	 }else{
		 strncpy(temp, buf, LCD_LINE_LEN);
	 }

   lcd_write_cmd(line);
   for(j = 0; j < LCD_LINE_LEN; j++){
		 if(temp[j] == '<'){
			 lcd_write_data(0);
		 }else if(temp[j] == '>'){
			 lcd_write_data(5);
		 }else if(temp[j] == '~'){
			 lcd_write_data(6);
		 }else if(temp[j] == 0){
			 lcd_write_data(' ');
		 }else if(temp[j] == '^'){
			 lcd_write_data(4);
		 }else{
			 lcd_write_data(temp[j]);
		 }
	 }
   
	 return is_need_scroll;
}
Esempio n. 18
0
void lcd_roll_disable(void)
{/*        液晶关卷动

调用:lcd_expand_switch()、lcd_write_cmd()
*/
	lcd_expand_switch(1);
	lcd_write_cmd(LCD_CMD_ROLL_OFF);
	lcd_expand_switch(0);
}
Esempio n. 19
0
void lcd_disp_map(unsigned char *map)
{
    unsigned char page, seg;

    
    for(page = 0xb0; page < 0xb8; page++)
    {
        lcd_write_cmd(page); //page
       
        lcd_write_cmd(0x10); //column
        
        lcd_write_cmd(0x00); //column

        for(seg = 0; seg < 128; seg++) //写128列
        {
            lcd_write_data(*map++);	
        }	
    }
}
Esempio n. 20
0
//----------------------------------------------------------------------------------------
//
//		Definicja w�asnego znaku na LCD z pami�ci FLASH
//
//		argumenty:
//		nr: 		- kod znaku w pami�ci CGRAM od 0x80 do 0x87
//		*def_znak:	- wska�nik do tablicy 7 bajt�w definiuj�cych znak
//
//----------------------------------------------------------------------------------------
void lcd_defchar_P(uint8_t nr, uint8_t *def_znak)
{
	register uint8_t i,c;
	lcd_write_cmd( 64+((nr&0x07)*8) );
	for(i=0;i<8;i++)
	{
		c = pgm_read_byte(def_znak++);
		lcd_write_data(c);
	}
}
Esempio n. 21
0
void lcd_clr_scr(void)
{
    unsigned char page, seg;

    
    for(page = 0xb0; page < 0xb8; page++)
    {
        lcd_write_cmd(page); //page
       
        lcd_write_cmd(0x10); //column
        
        lcd_write_cmd(0x00); //column

        for(seg = 0; seg < 128; seg++) //写128列
        {
            lcd_write_data(0x00);	
        }	
    }
}
Esempio n. 22
0
void dis_simple_print(uint8 line, char *fmt, ...)
{
	 uint8 j;
	 uint8 offset;
	 char buf[6*LCD_LINE_LEN] = {0};
   char temp[LCD_LINE_LEN + 1] = {0};
   va_list ap;
   size_t len;

   va_start(ap, fmt);
   vsprintf(buf, fmt, ap);
   va_end(ap);

   len = strlen(buf);

   if(len > LCD_LINE_LEN){
		 
	 }

   if(0){
		 offset =  LCD_LINE_LEN > len? (LCD_LINE_LEN - len):(0);
		 if(offset){
			 for(j = 0; j < offset/2; j++){
				 temp[j] = ' ';
			 }
			 
			 strcat(temp, buf);
		 }else{
			 strncpy(temp, buf, LCD_LINE_LEN);
		 }
		 
	 }else{
		 strncpy(temp, buf, LCD_LINE_LEN);
	 }

   lcd_write_cmd(line);
   for(j = 0; j < LCD_LINE_LEN; j++){
		 if(temp[j] == '<'){
			 lcd_write_data(0);
		 }else if(temp[j] == '>'){
			 lcd_write_data(5);
		 }else if(temp[j] == '~'){
			 lcd_write_data(6);
		 }else if(temp[j] == 0){
			 lcd_write_data(' ');
		 }else if(temp[j] == '^'){
			 lcd_write_data(4);
		 }else{
			 lcd_write_data(temp[j]);
		 }
	 }
   

}
Esempio n. 23
0
void lcd_set_location(int x0, int y0)
{
    if (LCD_TYPE == LCD_TYPE_ILI9327)
    {
        lcd_write_cmd(ILI9327_SET_COLUMN_ADDR);
        uint16_t buffer[4] = {
            0, (uint16_t)(y0 & 0xFF), // Start row
            0, 0xEF // End row = 239
        };
        lcd_write_dma(buffer, 4);
        
        lcd_write_cmd(ILI9327_SET_PAGE_ADDR);
        uint16_t buffer2[4] = {
            (uint16_t)(x0 >> 8), (uint16_t)(x0 & 0xFF), // Start column
            0x01, 0x8F // End column = 399
        };
        lcd_write_dma(buffer2, 4);
        lcd_write_cmd(ILI9327_WRITE_MEMORY);
    }
    else
    {
Esempio n. 24
0
void lcd_clr(void)
{/*        液晶清屏

参数: 空
返回: 空
调用: lcd_write_cmd()

说明:
        写指令0x01
*/
	lcd_write_cmd(LCD_CMD_CLR);
}
Esempio n. 25
0
uint32_t lcd_get_type()
{
    uint16_t buffer[5] = {0};
    lcd_write_cmd(ILI9327_DEVICE_CODE_READ);
    lcd_read_dma(buffer, 5);
    lcd_dma_ready();
    
    uint32_t result = 0;
    for (int i = 1; i < 5; i++)
        result = (result << 8) | (buffer[i] & 0xFF);
    return result;
}
Esempio n. 26
0
void SetupAlarmTimeC() //Program to get Alarm Time for Subject C
{
	unsigned char msgindex, outchar, ctemp;
	unsigned char hour10, hour1, minute10, minute1;    
	char Message[ ] = "Subject C Time hhmm:";
    
    PORTA = 0b00001000; //On LED RA3

	lcd_write_cmd(0x80);

	for (msgindex = 0; msgindex < 20; msgindex++)
	{
		outchar = Message[msgindex];
		lcd_write_data(outchar);
	}

	lcd_write_cmd(0xC0); // Move cursor to line 2 position 1

	ctemp=getkey(); // waits and get an ascii key number when pressed
	lcd_write_data(ctemp); //display on LCD
	hour10 = char_2_int (ctemp);

	ctemp=getkey();
	lcd_write_data(ctemp);
	hour1 = char_2_int (ctemp);

	ctemp=getkey();
	lcd_write_data(ctemp);
	minute10 = char_2_int (ctemp);

	ctemp=getkey();
	lcd_write_data(ctemp);
	minute1 = char_2_int (ctemp);

	hourC = hour10 * 10 + hour1;
	minuteC = minute10 * 10 + minute1;

	delay_ms(500);
	lcd_write_cmd(0x01);
}
Esempio n. 27
0
void lcd_init() {
    /* Function Set: Set the interface data length to 8 bits
     * and select 2-line display and 5x7-dot character font.
     */
    lcd_write_cmd(0x38);  /* 00111000 */
    /* Display ON/OFF Control: Set display ON, cursor ON
     * and blink OFF.
     */
    lcd_write_cmd(0x0E);  /* 00001110 */
    /* Clear Display */
    lcd_write_cmd(0x01);  /* 00000001 */
    /* Entry Mode Set: Set mode to increment the address by
     * one and to shift cursor to the right when writing
     * characters to the internal RAM.
     */
    lcd_write_cmd(0x06);  /* 00000110 */
    /* Cursor Home: Returns both cursor and display to
     * original position.
     */
    lcd_write_cmd(0x02);  /* 00000010 */
    lcd_cursor_pos = 0;
}
Esempio n. 28
0
void interrupt ISR_Timer0_Int()
{
	unsigned char hour10, hour1, minute10, minute1, second10, second1;
	if (INTCONbits.TMR0IF == 1)
	{
		//TMR0H = 0x48;
		//TMR0L = 0xE5;

		second = second + 1;
		if ( second > 59 )
		{
			second = 0;
			minute = minute + 1;
			if ( minute > 59 )
			{
				minute = 0;
				hour = hour + 1;
				if ( hour > 23 )
					hour = 0;
			}
		}

		hour10 = hour / 10;
		hour1 = hour - hour10 * 10;

		minute10 = minute / 10;
		minute1 = minute - minute10 * 10;

		second10 = second / 10;
		second1 = second - second10 * 10;

		lcd_write_cmd(0x80);
		lcd_write_data('T');
		lcd_write_data('i');
		lcd_write_data('m');
		lcd_write_data('e');
		lcd_write_data(' ');
		lcd_write_data('=');
		lcd_write_data(' ');
		lcd_write_data(int_2_char (hour10));
		lcd_write_data(int_2_char (hour1));
		lcd_write_data(':');
		lcd_write_data(int_2_char (minute10));
		lcd_write_data(int_2_char (minute1));
		lcd_write_data(':');
		lcd_write_data(int_2_char (second10));
		lcd_write_data(int_2_char (second1));
					 
		INTCONbits.TMR0IF = 0;
	}
}
Esempio n. 29
0
void lcd_init(void)
{
/*
        液晶初始化函数

参数: 空
返回: 空
调用: delay100us()、lcd_write_cmd()

说明:
        重启ST7920、复位,设置功能,清屏
*/

        //功能设置
        lcd_expand_switch(0); //8BIT控制界面,基本指令集
		delay_10us(1);
		lcd_write_cmd(0x0c);	//开显示、关光标,不闪烁
		delay_10us(1);
        lcd_write_cmd(LCD_CMD_CLR); //清除屏幕显示,将DDRAM的地址计数器清零
        delay_10us(1);
		lcd_write_cmd(0x06); //DDRAM的地址计数器(AC)加1
		lcd_clr_pic();
		delay_10us(1);
}
Esempio n. 30
0
//----------------------------------------------------------------------------------------
//
//		Ustawienie kursora w pozycji Y-wiersz, X-kolumna
//
// 		Y = od 0 do 3
// 		X = od 0 do n
//
//		funkcja dostosowuje automatycznie adresy DDRAM
//		w zale�no�ci od rodzaju wy�wietlacza (ile posiada wierszy)
//
//----------------------------------------------------------------------------------------
void lcd_locate(uint8_t y, uint8_t x)
{
	switch(y)
	{
		case 0: y = LCD_LINE1; break;

#if (LCD_Y>1)
	    case 1: y = LCD_LINE2; break; // adres 1 znaku 2 wiersza
#endif
#if (LCD_Y>2)
    	case 2: y = LCD_LINE3; break; // adres 1 znaku 3 wiersza
#endif
#if (LCD_Y>3)
    	case 3: y = LCD_LINE4; break; // adres 1 znaku 4 wiersza
#endif
	}

	lcd_write_cmd( (0x80 + y + x) );
}