Пример #1
0
/**
@brief Write a char.
@param[in]	c	character to write
*/
void lcd_putc(const char c)
{
#ifdef LCD_USE_FB
	if( (lcd_fbc & 0x3f) >= LCD_WIDTH )
		return;

	uint8_t i = (lcd_fbc & 0x3f) + (lcd_fbc & 0x40 ? LCD_WIDTH+1 : 0);

	if( c != lcd_fb[i] ) {

		if( lcd_fbc != lcd_cur ) {
			lcd_command(0x80 + lcd_fbc);
			lcd_cur = lcd_fbc;
		}

		lcd_data(c);
		++lcd_cur;
		lcd_fb[i] = c;
	}
	++lcd_fbc;
#else
	if( (lcd_cur & 0x3f) >= LCD_WIDTH )
		return;

	lcd_data(c);
	++lcd_cur;
#endif
}
Пример #2
0
int8_t Fan_State_Dur(uint8_t fan, int8_t input){
	// Wert bearbeiten?
	if (input == MENU_INPUT_PUSH) {
		Fan_edit ^= 1;
		eeprom_write_byte((void*) &Fan_fansE[fan].dur, Fan_fans[fan].dur);
	}
	if (Fan_edit && (input == MENU_INPUT_DOWN)) {
		Fan_fans[fan].dur = (Fan_fans[fan].dur < FAN_DUR_MAX) ? (Fan_fans[fan].dur+1) : (FAN_DUR_MAX);
	}
	if (Fan_edit && (input == MENU_INPUT_UP)) {
		Fan_fans[fan].dur = (Fan_fans[fan].dur > FAN_DUR_MIN) ? (Fan_fans[fan].dur-1) : (FAN_DUR_MIN);
	}
	// Ausgabe
	lcd_clear();
	lcd_home();
	if (Fan_edit)
		lcd_data('*');
	else
		lcd_data('>');
	lcd_string_P(MENU_STR_DURATION);
	lcd_number(Fan_fans[fan].dur, 2, ' ');
	lcd_string_P(MENU_STR_MIN);
	lcd_setcursor(0, 2);
	lcd_data(' ');
	lcd_string_P(MENU_STR_BACK);
	return Fan_edit;
}
Пример #3
0
int8_t Fan_State_Humi(uint8_t fan, int8_t input) {
	// Wert bearbeiten?
	if (input == MENU_INPUT_PUSH) {
		Fan_edit ^= 1;
		eeprom_write_byte((void*) &Fan_fansE[fan].humi, Fan_fans[fan].humi);
	}
	if (Fan_edit && (input == MENU_INPUT_DOWN)) {
		Fan_fans[fan].humi = (Fan_fans[fan].humi < FAN_HUMI_MAX) ? (Fan_fans[fan].humi+1) : (FAN_HUMI_MAX);
	}
	if (Fan_edit && (input == MENU_INPUT_UP)) {
		Fan_fans[fan].humi = (Fan_fans[fan].humi > FAN_HUMI_MIN) ? (Fan_fans[fan].humi-1) : (FAN_HUMI_MIN);
	}
	// Ausgabe
	lcd_clear();
	lcd_home();
	if (Fan_edit)
		lcd_data('*');
	else
		lcd_data('>');
	lcd_string_P(MENU_STR_HUMIDITY);
	lcd_number(Fan_fans[fan].humi, 2, ' ');
	lcd_data('%');
	lcd_setcursor(0, 2);
	lcd_data(' ');
	lcd_string_P(MENU_STR_ONTIME);
	lcd_number(Fan_fans[fan].timeH, 2, ' ');
	lcd_data(':');
	lcd_number(Fan_fans[fan].timeM, 2, '0');
	return Fan_edit;
}
Пример #4
0
void print_arrows(uint8_t row)
{
	lcd_gotoxy(0, row);
	lcd_data(0x7F);         // <--
	lcd_gotoxy(15, row);
	lcd_data(0x7E);         // -->
}
Пример #5
0
/******************************************************************************
 * This function draws a bitmap at any xy-position on the screen. 
 * Be aware that some pixels are deleted due to memory organization!
 * Parameters:
 * progmem_image - prog_uint8_t array of columns aka the bitmap image
 * x             - x start coordinate on the screen (in pixel)
 * y             - y start coordinate on the screen (in pixel)
 * pages         - height of image in pages
 * columns       - width of image in pixels
 * style         - Bit2: sets inverse mode
 */
void lcd_draw_image_xy_P(PGM_VOID_P progmem_image, uint8_t x, uint8_t y, uint8_t pages, uint8_t columns, uint8_t style) {
	uint16_t i,j;
  uint8_t data   = 0;
  uint8_t inv    = style & INVERT_BIT;
	uint8_t offset = y & 0x7; //Optimized modulo 8
	//If there is an offset, we must use an additional page
	if(offset)  
    pages++;
  //If there is not enough vertical space -> cut image
  if(pages > LCD_RAM_PAGES - lcd_get_position_page())   
    pages = LCD_RAM_PAGES - lcd_get_position_page();
  //Goto starting point and draw
	lcd_moveto_xy((y>>3), x);
	for (j=0; j<pages; j++) {
		for (i=0; i<columns && (lcd_get_position_column() < LCD_WIDTH); i++){
      data = 0;
      if (!offset || j+1 != pages)
        data = pgm_read_byte(progmem_image+j*columns + i) << offset;
			if(j > 0 && offset)
				data |= pgm_read_byte(progmem_image+(j-1)*columns + i) >> (8-offset);
			if(inv)	lcd_data(~data);
      else 		lcd_data(data);
		  }
		if(j+1 != pages)
			lcd_move_xy(1,-columns);
	  }
  }
Пример #6
0
void disp_show_buf(char *buf) {
    uint8_t i;
    lcd_clear();
    lcd_home();
    for(i=0;i<16;i++)lcd_data(buf[i]);
    lcd_setcursor(0,2);
    for(;i<32;i++)lcd_data(buf[i]);
}
Пример #7
0
void lcd_contrast(uint8_t data){
    lcd_command(0x25);          //Write contrast
    if((data > 85)&&(data < 115)){
        lcd_data(data);
    }
    else{
        lcd_data(100);
    }
}
Пример #8
0
main()
{
lcd_init();
lcd_cmd(0x80);
lcd_data('A');
lcd_cmd(0xc0);
lcd_data('B');
while(1);
}
Пример #9
0
/* Send a string to the display, padding to 'len' characters with spaces */
static void fixed_str(const char *str, uint8_t len)
{
  char c;
  while ((c=*str++) && len--) {
    lcd_data(c);
  }
  if (len==0xff) return;
  while (len--) {
    lcd_data(' ');
  }
}
Пример #10
0
int8_t Fan_State_Back(uint8_t fan, int8_t input) {
	lcd_clear();
	lcd_home();
	lcd_data(' ');
	lcd_string_P(MENU_STR_DURATION);
	lcd_number(Fan_fans[fan].dur, 2, ' ');
	lcd_string_P(MENU_STR_MIN);
	lcd_setcursor(0, 2);
	lcd_data('>');
	lcd_string_P(MENU_STR_BACK);
	return 0;
}
Пример #11
0
void lcd_gotoxy(uint8_t x0, uint8_t y0,  uint8_t x1, uint8_t  y1){
    //x-координата
    lcd_command(0x2A);          //задаем область по X (x0 - начальный, x1 - конечный)
    lcd_data(x0);               //X
    lcd_data(x1);

    //Y-координата
    lcd_command(0x2B);          //задаем область по Y (y0 - начальный, y1 - конечный)
    lcd_data(y0 +1);            //у этого контроллера Y отсчитывается от 1, а не 0
    lcd_data(y1 +1);

    lcd_command(0x2C);          //WR_MEM
}
Пример #12
0
static void lcd_print_WithPosition(char * msg, unsigned int lineNumber, unsigned int nthCharacter)
{
    unsigned int counter = nthCharacter;
    unsigned int lineNum = lineNumber;
    unsigned int nthChar = nthCharacter;

    if( msg == NULL ) {
        printk( KERN_DEBUG "ERR: Empty data for lcd_print_WithPosition \n");
        return;
    }

    if( (lineNum != 1) && (lineNum != 2)  ) {
        printk( KERN_DEBUG "ERR: Invalid line number input readjusted to 1 \n");
        lineNum = 1;
    }

    if( lineNum == 1 )
    {
        lcd_setPosition( LCD_FIRST_LINE, nthChar );

        while( *(msg) != '\0' )
        {
            if( counter >= NUM_CHARS_PER_LINE )
            {
                lineNum = 2;  // continue writing on the next line if the string is too long
                counter = 0;
                nthChar = 0;
                break;
            }
            lcd_data(*msg);
            msg++;
            counter++;
        }
    }

    if( lineNum == 2)
    {
        lcd_setPosition( LCD_SECOND_LINE, nthChar );

        while( *(msg) != '\0' )
        {
            if( counter >= NUM_CHARS_PER_LINE )
            {
                break;
            }
            lcd_data(*msg);
            msg++;
            counter++;
        }
    }
}
Пример #13
0
static void lcd_task(void *params)
{
    LcdMessage msg;
    const char *string;
    const char **bitmaps;

    // Initialise the hardware.  This uses delays so must not be called prior
    // to the scheduler being started.
    lcd_setup();

    while (TRUE) {
        // Wait for a message to arrive that requires displaying
        while (queue_receive(lcd_queue, &msg, PORT_MAX_DELAY) != TRUE);

        switch (msg.type) {
        case LCD_MESSAGE_CLEAR:
            lcd_command(LCD_CLEAR_DISPLAY_CMD);
            break;

        case LCD_MESSAGE_PUT_STRING:
            lcd_goto(msg.row, msg.offset);
            string = msg.data;
            if (msg.length < 0) {
                while (*string) {
                    lcd_data(*string++);
                }
            } else {
                while (msg.length--) {
                    lcd_data(*string++);
                }
            }
            break;

        case LCD_MESSAGE_SET_CUSTOM_CHARS:
            lcd_command(LCD_CUSTOM_CHARS_CMD + msg.offset);
            bitmaps = (const char **) msg.data;
            while (msg.length--) {
                lcd_data(*bitmaps[0]);
                lcd_data(*bitmaps[1]);
                lcd_data(*bitmaps[2]);
                lcd_data(*bitmaps[3]);
                lcd_data(*bitmaps[4]);
                lcd_data(*bitmaps[5]);
                lcd_data(*bitmaps[6]);
                lcd_data(*bitmaps[7]);
                bitmaps++;
            }
            break;
        }
    }
}
Пример #14
0
/*=================================================================================
вывод широкого символа 2x8x12 на дисплей
*/
void lcd_PutChar2x8x12(uint8_t x, uint8_t y, char c){
    uint8_t     ch, mask;
    uint8_t     i, j;

    c = c - 0x20;

    //X-координата
    lcd_command(0x2A);
    lcd_data(x);  //X
    lcd_data(x +16 -1);
    //Y-координата
    lcd_command(0x2B);
    lcd_data(y +1); //Y
    lcd_data(y + 12 +1);

    lcd_command(0x2C);              // WR_MEM

    for(i = 0; i < 12; i++){        // every column of the character
        ch = fonts8x12[c*12 +i];
        mask=0x80;
        for (j = 0; j < 8; j++){    // write the pixels
            if (ch&mask){
                lcd_data(uiTextColor);
                lcd_data(uiTextColor);
            }else{
                lcd_data(uiGraphicsColor);
                lcd_data(uiGraphicsColor);
            }
            mask = mask >> 1;
        }
    }
}
Пример #15
0
// check some EEprom values for correct values 
void EE_check_init(void) {
#if (!defined(SamplingADC)  || (PROCESSOR_TYP != 328)) && !defined(USE_EEPROM)
  uint8_t tt;		// read test value
  tt = (uint8_t)eeprom_read_byte(&EE_ESR_ZEROtab[0]);
  // this value will never be changed by calibration
  if (tt != ESR_ZERO) goto init_ee;
 #ifdef AUTO_CAL
  uint8_t tt0;		// value of first c_zero_tab
  uint8_t ww;		// loop counter
  tt0 = tt;			// init tt0 value
  for (ww=0;ww<7;ww++) {		//checking loop
      tt = (uint8_t)eeprom_read_byte(&c_zero_tab[ww]);
      if (ww == 0) tt0 = tt;		// save first value
      // for forth element, tt must be tt0 or tt0+1
      if ((ww == 3) && ((tt != tt0) && (tt != (tt0+1)) && (tt != (tt0+2)) )) goto init_ee;
      if ((tt > 190) || (tt < 10)) goto init_ee;	// value too low or too big
  }
 #endif
 return;

init_ee:
 // init all EEprom values
 lcd_line1();
 lcd_data('E');
 lcd_data('E');
 #ifdef AUTO_CAL
 // write the correction value for ADC internal 1.1V reference 
 (void) eeprom_write_byte((uint8_t *)(&RefDiff), (uint8_t)REF_R_KORR);	// offset for true reference Voltage
 // write the correction value for comparator 1.1V reference
 (void) eeprom_write_word((uint16_t *)(&ref_offset), REF_C_KORR);	// hold zero offset + slew rate dependend offset
 // write all 7 c_zero_tab values
 (void) eeprom_write_word((uint16_t *)(&c_zero_tab[0]),((C_NULL)*256) + (C_NULL));
 (void) eeprom_write_byte((uint8_t *)(&c_zero_tab[2]),(C_NULL+TP2_CAP_OFFSET));
 (void) eeprom_write_byte((uint8_t *)(&c_zero_tab[3]),(C_NULL+2));
 (void) eeprom_write_byte((uint8_t *)(&c_zero_tab[4]),(C_NULL+TP2_CAP_OFFSET));
 (void) eeprom_write_word((uint16_t *)(&c_zero_tab[5]),((C_NULL)*256) + (C_NULL));
 #endif
 // write 4 EE_ESR_ZEROtab values
 (void) eeprom_write_word((uint16_t *)(&EE_ESR_ZEROtab[0]),(ESR_ZERO*256)+ESR_ZERO);
 (void) eeprom_write_word((uint16_t *)(&EE_ESR_ZEROtab[2]),(ESR_ZERO*256)+ESR_ZERO);
 #if ((LCD_ST_TYPE == 7565) || (LCD_ST_TYPE == 1306))
 (void) eeprom_write_byte((uint8_t *)(&EE_Volume_Value), VOLUME_VALUE);
 #endif
 #ifdef WITH_ROTARY_SWITCH
// (void) eeprom_write_byte(&EE_RotarySwitch,0); 		// no switch is detected
 #endif
 wait_about1s();	// time to read the "EE" message, initialization of EEprom finished
#endif
}
Пример #16
0
/******************************************************************************
 * This function draws a bitmap from the current position on the screen.
 * Parameters:
 * progmem_image - prog_uint8_t array of columns aka the bitmap image
 * pages         - height of image in pages
 * columns       - width of image in pixels (or columns)
 * style         - Bit2: sets inverse mode
 */  
void lcd_draw_image_P(PGM_VOID_P progmem_image, uint8_t pages, uint8_t columns, uint8_t style) {
	uint8_t i,j = 0;
  uint8_t inv = (style & INVERT_BIT);
	while(j<pages && (lcd_get_position_page() < LCD_RAM_PAGES)) {
		for (i=0; i<columns && (lcd_get_position_column() < LCD_WIDTH); i++) {
      uint8_t tmp = pgm_read_byte(progmem_image++);
			if(!inv)
				lcd_data(tmp);
			else
				lcd_data(~tmp);
      }
    if(++j != pages && lcd_get_position_column() != 0)
      lcd_move_xy(1,-columns);
    }
  }
/**
 * Add a custom character
 */
void lcd_add_character(unsigned char addr, unsigned char * pattern) {
    unsigned char i;

    lcd_command(SET_CGRAM_ADDR | addr << 3);
    for (i = 0; i < 8; i++)
        lcd_data(pattern[i]);
}
Пример #18
0
void lcd_fill2(int *spih, uint16_t sx, uint16_t sy, uint16_t x, uint16_t y, uint16_t color565) {
	uint16_t tmp=0;
	int cnt;
	if (sx>479) sx=0;
	if (sy>319) sy=0;
	if (x>479)  x=479;
	if (y>319)  y=319;
	
	if (sx>x) {
		tmp=sx;
		sx=x;
		x=tmp;
	}
	
	if (sy>y) {
		tmp=sy;
		sy=y;
		y=tmp;
	}
	
	cnt = (y-sy) * (x-sx);
	lcd_setarea2(spih, sx,sy,x,y);
	for(int t=0;t<cnt;t++) {
		lcd_data(spih, color565);
	}	
}
Пример #19
0
/*
=========================================================================================================

Function: lcd_write
Description: writes a string to the lcd using lcd_data ()

==============================================================================================================
*/
void lcd_write (char * ptr) {
	
		while (*ptr !='\0')
		{
			lcd_data(*ptr);
			ptr++;
}}
Пример #20
0
void lcd_string(char *data)
{
    while(*data) {
        lcd_data(*data);
        data++;
    }
}
Пример #21
0
void lcd_fill(void) {
  const uint8_t offset = 0;
  for (uint8_t page = 0; page < UC1701_NUM_PAGES; page++) {
    //Each bank is a single row 8 bits tall
    /* No longer need to manually set page and reset column cursor - handled by lcd */
    lcd_command(UC1701_SET_PAGE_ADDR | ((page) & 0b00001111));
    lcd_command(UC1701_SET_COL_ADDR_MSB | ((offset >> 4) & UC1701_SET_COL_MASK) );
    lcd_command(UC1701_SET_COL_ADDR_LSB | (offset & UC1701_SET_COL_MASK));
#ifdef GRAPHICS_USE_FRAM
    fram_read_n_bytes(FRAM_FB_START + (DISPLAY_WIDTH * page), DISPLAY_WIDTH, (uint8_t*)buffer.pagebuffer);
    LCD_DC_DATA();
    LCD_CE_ACTIVATE();
#endif
    for (uint8_t column = 0; column < DISPLAY_WIDTH; column++) {
      //lcd_data(buffer.fb[(page * DISPLAY_WIDTH) + column]);
#ifdef GRAPHICS_USE_FRAM
      spi_send(buffer.pagebuffer[column]);
#else
      lcd_data(BUFFER_GET_BYTE((page * DISPLAY_WIDTH) + column));
#endif
    }
#ifdef GRAPHICS_USE_FRAM
    LCD_CE_DEACTIVATE();
#endif
  }
}
Пример #22
0
main()
{
unsigned char temp;
unsigned char a[10];
	unsigned char i=0;

	uart_init();
lcd_init();

	do
	{		
		temp=uart_rx();
		uart_tx(temp);
		a[i++]=temp;
		lcd_cmd(0x01);
		lcd_data(temp);
		lcd_cmd(0x85);
		lcd_int(temp);
		lcd_cmd(0x89);
		lcd_string("0x");
		lcd_hex(temp);
		delay_ms(1000);
	}while(temp!=13);
	a[--i]='\0';
	lcd_cmd(0xc0);
	lcd_string(a);
	delay_ms(5000);
}
Пример #23
0
void lcd_display(unsigned int val)
{  
unsigned char flg=0;
lcd_command(0xC7);
if(val==0)
lcd_data('0');
while(val>0)
{   
lcd=val%10;
val=val/10;
lcd_command(0xC7-flg);
lcd_data(lcd+'0');
flg++;  
}
  
}
Пример #24
0
static void lcd_v2_display_init(void)
{
    unsigned int x, y;

    lcd_write_reg(0xD0, 0x0003);
    lcd_write_reg(0xEB, 0x0B00);
    lcd_write_reg(0xEC, 0x00CF);
    lcd_write_reg(0xC7, 0x030F);

    lcd_write_reg(0x01, 0x001C);
    lcd_write_reg(0x02, 0x0100);
    lcd_write_reg(0x03, 0x1038);
    lcd_write_reg(0x07, 0x0000);
    lcd_write_reg(0x08, 0x0808);
    lcd_write_reg(0x0F, 0x0901);
    lcd_write_reg(0x10, 0x0000);
    lcd_write_reg(0x11, 0x1B41);
    lcd_write_reg(0x12, 0x2010);
    lcd_write_reg(0x13, 0x0009);
    lcd_write_reg(0x14, 0x4C65);

    lcd_write_reg(0x30, 0x0000);
    lcd_write_reg(0x31, 0x00DB);
    lcd_write_reg(0x32, 0x0000);
    lcd_write_reg(0x33, 0x0000);
    lcd_write_reg(0x34, 0x00DB);
    lcd_write_reg(0x35, 0x0000);
    lcd_write_reg(0x36, 0x00AF);
    lcd_write_reg(0x37, 0x0000);
    lcd_write_reg(0x38, 0x00DB);
    lcd_write_reg(0x39, 0x0000);

    lcd_write_reg(0x50, 0x0000);
    lcd_write_reg(0x51, 0x0705);
    lcd_write_reg(0x52, 0x0C0A);
    lcd_write_reg(0x53, 0x0401);
    lcd_write_reg(0x54, 0x040C);
    lcd_write_reg(0x55, 0x0608);
    lcd_write_reg(0x56, 0x0000);
    lcd_write_reg(0x57, 0x0104);
    lcd_write_reg(0x58, 0x0E06);
    lcd_write_reg(0x59, 0x060E);

    lcd_write_reg(0x20, 0x0000);
    lcd_write_reg(0x21, 0x0000);

    lcd_write_reg(0x07, 0x1017);

    lcd_write_reg(0x20, 0x00AF);
    lcd_write_reg(0x21, 0x0000);

    lcd_cmd(0x22);

    for (x=0; x<LCD_WIDTH; x++)
        for(y=0; y<LCD_HEIGHT; y++)
            lcd_data(0x00);

    display_on = true;
}
Пример #25
0
/*=================================================================================
//Заливка отдним цветом
*/
void lcd_FillScreen(uint8_t color){
    uint16_t i;
    
    lcd_gotoxy(0,0,100,79); //очистка LCD
    for(i=0;i<8080;i++){    //заливка LCD
        lcd_data(color);
    }
}
Пример #26
0
/*=================================================================================
//Заливка черным
*/
void lcd_Clear(void){
    uint16_t i;
    
    lcd_gotoxy(0, 0, DISP_W - 1, DISP_H - 1);
    for(i=0; i < DISP_W * DISP_H; i++){    //заливка LCD
        lcd_data(0x00);
    }
}
void puts_lcd( unsigned char *data, unsigned char count )
{
  	while ( count )
	{
		lcd_data( *data++ );
		count --;
	}
}
Пример #28
0
lcd_dataa(unsigned char *disp)
{
unsigned char x;
for(x=0;disp[x]!=0;x++)
{
lcd_data(disp[x]); 
}
}
void LCD_Diplay(unsigned char * string)
{
    int i;                             //variable to represent index of string
    for (i=0; string[i] !='\0'; i++)
    {
        lcd_data(string[i]);           //to print sting on LCD
    }

}
Пример #30
0
int8_t Menu_Version(int8_t input) {
	lcd_clear();
	lcd_home();
	lcd_string_P(MENU_STR_VER);
	lcd_data(':');
	lcd_setcursor(0, 2);
	lcd_string_P(GITVERSION);
	return 0;
}