blob: 8d0cfe61d9ae8fffbc500d5934685265827b3c7b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
|
#ifndef HD44780_LCD_H_
#define HD44780_LCD_H_
#include <stdint.h>
#include <avr/pgmspace.h>
/*** Hardware pin assignments ***/
#define LCD_PORT PORTB /* LCD PORT register */
#define LCD_DDR DDRB /* LCD DDR register */
#define LCD_PIN_E (1 << 5) /* E pin */
#define LCD_PIN_RS (1 << 4) /* RS pin */
#define LCD_DATA_SHIFT 0 /* Data pins at D4-D7 */
/*** Hardware parameters ***/
#define LCD_NR_LINES 2 /* Linecount. Must be power of two. */
#define LCD_NR_COLUMNS 16 /* Columncount. Must be power of two. */
#define LCD_FONT_5x10 0 /* 5x10 or 5x8 font? */
/*** Hardware access ***/
#ifndef PROGPTR
# define PROGPTR /* */
#endif
void lcd_init(void);
void lcd_commit(void);
void lcd_cmd_cursor(uint8_t line, uint8_t column);
void lcd_cmd_dispctl(uint8_t display_on,
uint8_t cursor_on,
uint8_t cursor_blink);
void lcd_upload_char(uint8_t char_code,
const uint8_t PROGPTR *char_tab);
/*** Software buffer access ***/
void lcd_put_char(char c);
/** lcd_printf -- Formatted print to the LCD buffer. */
void _lcd_printf(const char PROGPTR *_fmt, ...);
#define lcd_printf(fmt, ...) _lcd_printf(PSTR(fmt) ,##__VA_ARGS__)
/** lcd_put_str -- Write prog-str to LCD buffer. */
void lcd_put_pstr(const char PROGPTR *str);
#define lcd_put_str(str) lcd_put_pstr(PSTR(str))
void lcd_clear_buffer(void);
/** lcd_cursor - Move the LCD software cursor. */
static inline void lcd_cursor(uint8_t line, uint8_t column)
{
extern uint8_t lcd_cursor_pos;
lcd_cursor_pos = (line * LCD_NR_COLUMNS) + column;
}
/** lcd_getline - Returns the current LCD software cursor line. */
static inline uint8_t lcd_getline(void)
{
extern uint8_t lcd_cursor_pos;
return lcd_cursor_pos / LCD_NR_COLUMNS;
}
/** lcd_getcolumn - Returns the current LCD software cursor column. */
static inline uint8_t lcd_getcolumn(void)
{
extern uint8_t lcd_cursor_pos;
return lcd_cursor_pos % LCD_NR_COLUMNS;
}
#endif /* HD44780_LCD_H_ */
|