add set position function for lcd
This commit is contained in:
16
lcd.c
16
lcd.c
@@ -44,6 +44,22 @@ void lcd_nibble_out(unsigned char c, unsigned char cd) {
|
|||||||
lcd_out(out | rs );
|
lcd_out(out | rs );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void lcd_set_position(uint8_t row, uint8_t col){
|
||||||
|
if(col >= LCD_WIDTH)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if(row==0)
|
||||||
|
lcd_nibble_out(0x80|col, 0);
|
||||||
|
if(row==1)
|
||||||
|
lcd_nibble_out(0xC0|col, 0);
|
||||||
|
if(row==2)
|
||||||
|
lcd_nibble_out(0x80|(col+LCD_WIDTH), 0);
|
||||||
|
if(row==3)
|
||||||
|
lcd_nibble_out(0xC0|(col+LCD_WIDTH), 0);
|
||||||
|
|
||||||
|
char_counter = (row * LCD_WIDTH) + col;
|
||||||
|
}
|
||||||
|
|
||||||
//***************************************************************************************
|
//***************************************************************************************
|
||||||
// clear LCD
|
// clear LCD
|
||||||
void lcd_clear() {
|
void lcd_clear() {
|
||||||
|
|||||||
4
lcd.h
4
lcd.h
@@ -31,7 +31,7 @@
|
|||||||
#define LCD_D6 (1<<6)
|
#define LCD_D6 (1<<6)
|
||||||
#define LCD_D7 (1<<7)
|
#define LCD_D7 (1<<7)
|
||||||
|
|
||||||
#define LCD_WIDTH 16
|
#define LCD_WIDTH 20
|
||||||
#define LCD_ADDR_LINE1 (0x80)
|
#define LCD_ADDR_LINE1 (0x80)
|
||||||
#define LCD_ADDR_LINE2 (0xC0)
|
#define LCD_ADDR_LINE2 (0xC0)
|
||||||
|
|
||||||
@@ -41,6 +41,8 @@
|
|||||||
void lcd_print_str (char *str);
|
void lcd_print_str (char *str);
|
||||||
void lcd_write_P (const char *Buffer,...);
|
void lcd_write_P (const char *Buffer,...);
|
||||||
|
|
||||||
|
void lcd_set_position(uint8_t row, uint8_t col);
|
||||||
|
|
||||||
#define lcd_write(format, args...) lcd_write_P(PSTR(format) , ## args)
|
#define lcd_write(format, args...) lcd_write_P(PSTR(format) , ## args)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user