add set position function for lcd
This commit is contained in:
18
lcd.c
18
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() {
|
||||||
@@ -184,4 +200,4 @@ void lcd_write_P (const char *Buffer,...)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|||||||
60
lcd.h
60
lcd.h
@@ -6,41 +6,43 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef __LCD_H__
|
#ifndef __LCD_H__
|
||||||
#define __LCD_H__
|
#define __LCD_H__
|
||||||
|
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <util/delay.h>
|
#include <util/delay.h>
|
||||||
#include "i2c.h"
|
#include "i2c.h"
|
||||||
|
|
||||||
#define LCD_I2C_ADDR 0x4E
|
#define LCD_I2C_ADDR 0x4E
|
||||||
|
|
||||||
//Port Belegung am PCF8574 (1<<PORT)
|
//Port Belegung am PCF8574 (1<<PORT)
|
||||||
#define LCD_RS (1<<0)
|
#define LCD_RS (1<<0)
|
||||||
#define LCD_RW (1<<1)
|
#define LCD_RW (1<<1)
|
||||||
#define LCD_E (1<<2)
|
#define LCD_E (1<<2)
|
||||||
#define LCD_BACKLIGHT (1<<3)
|
#define LCD_BACKLIGHT (1<<3)
|
||||||
|
|
||||||
#define LCD_D4 (1<<4)
|
#define LCD_D4 (1<<4)
|
||||||
#define LCD_D5 (1<<5)
|
#define LCD_D5 (1<<5)
|
||||||
#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)
|
||||||
|
|
||||||
void lcd_init(void);
|
void lcd_init(void);
|
||||||
void lcd_clear(void);
|
void lcd_clear(void);
|
||||||
void lcd_home(void);
|
void lcd_home(void);
|
||||||
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,...);
|
||||||
|
|
||||||
#define lcd_write(format, args...) lcd_write_P(PSTR(format) , ## args)
|
void lcd_set_position(uint8_t row, uint8_t col);
|
||||||
|
|
||||||
|
#define lcd_write(format, args...) lcd_write_P(PSTR(format) , ## args)
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user