blob: 4e08fb1646d196d02bab6ecf639116392342d106 (
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
73
74
75
76
77
78
|
#ifndef HD44780_LCD_H_
#define HD44780_LCD_H_
#include <stdint.h>
#include <avr/pgmspace.h>
/*** Hardware pin assignments ***/
#define LCD_PORT PORTD /* LCD PORT register */
#define LCD_DDR DDRD /* LCD DDR register */
#define LCD_PIN_E (1 << 3) /* E pin */
#define LCD_PIN_RS (1 << 2) /* RS pin */
#define LCD_DATA_SHIFT 4 /* 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))
/** lcd_put_mstr -- Write memory-str to LCD buffer. */
void lcd_put_mstr(const char *str);
/** lcd_shift -- Shift display contents. */
void lcd_shift(int8_t count);
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_ */
|