Exemple #1
0
/*!
 * \brief Rewrite all LCD content
 *
 * \param *dta  Pointer to the memory
 *
 */
void LCD_write_all(uint8_t *dta)
{
	uint8_t i,j;
	for (i = 0; i < 4; i++) {
		/* Set line */
		switch (i) {
			case 0:	LCD_sendcmd(LCD_EN1 | 0x80); break;
			case 1: LCD_sendcmd(LCD_EN1 | 0xc0); break;
			case 2: LCD_sendcmd(LCD_EN2 | 0x80); break;
			case 3: LCD_sendcmd(LCD_EN2 | 0xc0); break;
				
		}
		for (j = 0; j < 40; j++) {
			/* ** Do you have some other data ? */
			if (!*dta) {
				j = 40;
				i = 5;
			}
			else {
				/* <N> ** Is it <ENTER> ? */
				if (*dta == '\n') {
					j = 40;
				}
				else {
					/* ** Is it first or second line ? */
					if (i <3)
						LCD_senddata(LCD_EN1 | *dta);           /* Send data to first or second line */
					else
						LCD_senddata(LCD_EN2 | *dta);           /* Send data to fird or fourht line */
				}
			}
			dta++;			
		}
	}
}		
Exemple #2
0
/*!
 * \brief Putchar for fprintf
 * Send character c to the LCD display.  After a '\1' set cursor to first line, '\2' set cursor to secound line,
 * '\3' set cursor to third line, '\4' set cursor to fourth line, '\5' clear display.
 * the next character will first clear the display.
 * 
 * \param c input char
 * \param FILE * output FILE
 *
 * \return status output status
 *
 */
uint16_t lcd_putchar(uint8_t c, FILE *unused)
{
        static uint8_t line = 1;
        if (c == 1) {
                LCD_cursor_yx(1,1);                             /* Set cursor to first line */
                line = 1;
        }
        else if (c == 2) {
                LCD_cursor_yx(2,1);                             /* Set cursor to second line */
                line = 2;
        }
        else if (c == 3) {                                      
                LCD_cursor_yx(3,1);                             /* Set cursor to third line */
                line = 3;
        }
        else if (c == 4) {
                LCD_cursor_yx(4,1);                             /* Set cursor to fourth line */
                line = 4;
        }
        else if (c == 5) {
                LCD_sendcmd(LCD_EN1 | LCD_EN2 | 0x1);           /* Clear both displays */
                line = 1;
        }
        else if (c == '\n') {                                   /* Set cursor to next line */ 
                LCD_cursor_yx(((++line < 5) ? line : (line = 1)),1);   
        }
        else    LCD_senddata(((line <3) ? LCD_EN1 : LCD_EN2) | c); /* Send data to LCD */
        return 0;
}
Exemple #3
0
/*!
 *      M       A       I       N
 *
 */
int main(void) {
    uint16_t poc = 0;
    uint8_t i,j;
    uint8_t dir;
    uint8_t tmp;

        LCD_init();                                     /* Initialize display */

        LCD_wr_cgram(0,&cgrom_p[0]);                    /* Program first char in CG-RAM */
        LCD_sendcmd(LCD_EN1 | LCD_EN2 | 0xc);           /* Disable cursors */

        for (i = 1; i < 5; i++)                         /* Fill display with pattern */
                for (j = 1; j < 41; j++) {
                        LCD_cursor_yx(i,j);
                        LCD_senddata(((i <3) ? LCD_EN1 : LCD_EN2)| 0);
                        _delay_ms(100);                 
                }
        LCD_sendcmd(LCD_EN1 | LCD_EN2 | 0x1);           /* Clear display */
                 
        i = 1; j = 1;
        dir = 0;
        do{
                LCD_cursor_yx(i,j);                                     /* Display figure */
                LCD_senddata(((i <3) ? LCD_EN1 : LCD_EN2)| 0);
                for (tmp = 0; tmp < 20; tmp++)
                        _delay_ms(10);                                  /* Wait for while */

                LCD_cursor_yx(i,j);
                LCD_senddata(((i <3) ? LCD_EN1 : LCD_EN2)| ' ');        /* Clear figure */
                switch(dir) {                                           /* State machine - direction control */
                        case 0: j++;                                    
                                if (j == 40) dir = 1;                   /* Right */
                                break;

                        case 1: i++;                                            
                                if (i == 4) dir = 2;                    /* Down */
                                break;
                        case 2: j--;
                                if (j == 1) dir = 3;                    /* Left */
                                break;
                        case 3: i--;
                                if (i == 1) dir =0;                     /* Up */
                                break;  
                }
        } while(1);
}
Exemple #4
0
/*!
 * \brief Send one digit to LCD
 *
 * \param pos   start position
 * \param val   value (only number)
 * 
 */
void LCD_write_big_num(uint8_t pos, uint8_t val)
{
	uint8_t i,j;
	for (i = 0; i <4; i++) {
		switch (i) {
			case 0:	LCD_sendcmd(LCD_EN1 | (0x80 + pos)); break;
			case 1: LCD_sendcmd(LCD_EN1 | (0xc0 + pos)); break;
			case 2: LCD_sendcmd(LCD_EN2 | (0x80 + pos)); break;
			case 3: LCD_sendcmd(LCD_EN2 | (0xc0 + pos)); break;
		}
		for (j = 0; j < 4; j++) {
			if (i <2)
				LCD_senddata(LCD_EN1 | big_number[val][4*i+j]);
			else
				LCD_senddata(LCD_EN2 | big_number[val][4*i+j]);
		}		
	}
}
Exemple #5
0
/*!
 * \brief Pre-set one CGRAM character
 *
 * \param char_val      Number of char. Only 0 - 7 are permitted.
 * \param *char_buf     Pointer to the memory on the first microline
 *
 */
void LCD_wr_cgram(uint8_t char_val, const uint8_t *char_buf )
{ uint8_t i = 8;

  char_val <<= 3;
  LCD_sendcmd(LCD_EN1 | LCD_EN2 | cmd_set_cgram_addr | char_val );

  while(i--) LCD_senddata( LCD_EN1 | LCD_EN2 | *char_buf++ );

  LCD_sendcmd(LCD_EN1 | LCD_EN2 | cmd_set_ddram_addr);
}
Exemple #6
0
/**
 * @brief Puts czech cp-1250 encoded character into display
 */
void lcd_cz_putc(char c, display_t *dis)
{
	uint8_t id = lcd_czech_get_cz_id(c);

	// Czech character
	if (id != 0xFF)
	{
		print_czech_character(id, &coord);
	} else {
		LCD_senddata( ((coord.y < 2) ? LCD_EN1 : LCD_EN2) | c);
	}	
}
Exemple #7
0
/**
 * @brief Loads czech character into LCD slot.
 * @param czech_char_id - identification of czech character
 * @param lcd_slot_id - identification of lcd slot
 */
static void lcd_load_cz_char(uint8_t cz_char_id, uint8_t lcd_slot_id)
{

	LCD_sendcmd(LCD_EN1| cmd_set_cgram_addr | (lcd_slot_id << 3) );

	uint8_t i = 0;
	for (i=0; i < 8; i++)
	{
		LCD_senddata(LCD_EN1 | cz_char_cgrom[cz_char_id][i]);
	}
	LCD_sendcmd(LCD_EN1 | cmd_set_ddram_addr);
	LCD_cursor_yx(coord.y+1,coord.x);

}
Exemple #8
0
/*!
 * \brief Function display string on LCD 
 *
 * \param *str  Pointer to string (0x00 is expected on the end of the text)
 */
void LCD_puts(uint8_t *str, uint8_t row)
{
	while (*str)
		LCD_senddata( ((row < 3) ? LCD_EN1 : LCD_EN2) | *str++); /* Send one char to LCD */
}
Exemple #9
0
/**
 * Prints character from slot
 * @param slot_id - slot to print
 */
static void lcd_print_slot(uint8_t slot_id, display_t *dis)
{
	LCD_senddata( ((dis->y < 2) ? LCD_EN1 : LCD_EN2)  | slot_id);
}