30#ifndef SLS_AVR_LCD_HD44780_PIN_H_
31#define SLS_AVR_LCD_HD44780_PIN_H_
39#ifndef LCD_HD44780_PIN_SINGLE_SOME_CODE
40# define LCD_HD44780_PIN_SINGLE_SOME_CODE 0
43#if LCD_HD44780_PIN_MULTI_MODE
45typedef uint8_t lcd_addr_t;
69 lcd_addr_t row_1_addr;
70 lcd_addr_t row_2_addr;
71 lcd_addr_t row_3_addr;
72 lcd_addr_t row_4_addr;
77# define __LCD_MULTIMODE_ONLY_INFO_ARG(_n) const lcd_info_t *const _ ## _n
78# define __LCD_MULTIMODE_ONLY_INFO_ARG_WITH_COMMA(_n) __LCD_MULTIMODE_ONLY_INFO_ARG(_n),
81# define LCD_HD44780_PIN_MULTI_MODE 0
83# ifndef LCD_HD44780_PIN_DISPLAY_TYPE
84# define LCD_HD44780_PIN_DISPLAY_TYPE
85# error "LCD_HD44780_PIN_DISPLAY_TYPE should be specified"
88# ifndef LCD_HD44780_PIN_DATA_PORT
89# error "LCD_HD44780_PIN_DATA_PORT should be specified"
92# if !LCD_HD44780_PIN_IDL_8BIT
93# ifndef LCD_HD44780_PIN_DATA_FIRST_PIN
94# error "For 4-bit IDL the LCD_HD44780_PIN_DATA_FIRST_PIN should be specified!"
98# if (!defined(LCD_HD44780_PIN_RS_PORT)) || (!defined(LCD_HD44780_PIN_RS_PIN))
99# error "LCD_HD44780_PIN_RS_PORT and LCD_HD44780_PIN_RS_PIN should be specified!"
102# if (!defined(LCD_HD44780_PIN_E_PORT)) || (!defined(LCD_HD44780_PIN_E_PIN))
103# error "LCD_HD44780_PIN_E_PORT and LCD_HD44780_PIN_E_PIN should be specified!"
106# if defined(LCD_HD44780_PIN_RW_PORT) && defined(LCD_HD44780_PIN_RW_PIN)
107# define LCD_HD44780_PIN_ALLOW_RW 1
110# if LCD_HD44780_PIN_SINGLE_SOME_CODE
111# define lcd_info_t byte_t
113# define lcd_info_t void
115# define __LCD_MULTIMODE_ONLY_INFO_ARG(_n) void
116# define __LCD_MULTIMODE_ONLY_INFO_ARG_WITH_COMMA(_n)
129 #if LCD_HD44780_PIN_MULTI_MODE || __DOXYGEN__
155#define __HD44780_INIT_IDL_BIT 0
156#define __HD44780_INIT_READ_BIT 1
157#define __HD44780_INIT_MOV_DIR_BIT 2
158#define __HD44780_INIT_SHIFT_BIT 3
159#define __HD44780_INIT_BLINKING_BIT 4
160#define __HD44780_INIT_CURSOR_BIT 5
161#define __HD44780_INIT_FONT_BIT 6
162#define __HD44780_INIT_DISP_BIT 7
165#define HD44780_INIT_IDL_4BIT 0x00
166#define HD44780_INIT_IDL_8BIT (_BV(__HD44780_INIT_IDL_BIT))
168#define HD44780_INIT_READ_OFF 0x00
169#define HD44780_INIT_READ_ON (_BV(__HD44780_INIT_READ_BIT))
171#define HD44780_INIT_MOV_DIR_DEC 0x00
172#define HD44780_INIT_MOV_DIR_INC (_BV(__HD44780_INIT_MOV_DIR_BIT))
174#define HD44780_INIT_SHIFT_OFF 0x00
175#define HD44780_INIT_SHIFT_ON (_BV(__HD44780_INIT_SHIFT_BIT))
177#define HD44780_INIT_BLINKING_OFF 0x00
178#define HD44780_INIT_BLINKING_ON (_BV(__HD44780_INIT_BLINKING_BIT))
180#define HD44780_INIT_CURSOR_OFF 0x00
181#define HD44780_INIT_CURSOR_ON (_BV(__HD44780_INIT_CURSOR_BIT))
183#define HD44780_INIT_FONT_NORMAL 0x00
184#define HD44780_INIT_FONT_BIG (_BV(__HD44780_INIT_FONT_BIT))
186#define HD44780_INIT_DISP_OFF 0x00
187#define HD44780_INIT_DISP_ON (_BV(__HD44780_INIT_DISP_BIT))
190#define __HD44780_CONF_IDL_BIT 0
191#define __HD44780_CONF_READ_BIT 1
193#define _HD44780_CONF_IDL_4BIT 0x00
194#define _HD44780_CONF_IDL_8BIT (_BV(__HD44780_CONF_IDL_BIT))
196#define _HD44780_CONF_READ_OFF 0x00
197#define _HD44780_CONF_READ_ON (_BV(__HD44780_CONF_READ_BIT))
199#define _HD44780_HALF_DATA_MASK 0x0F
202#if LCD_HD44780_PIN_MULTI_MODE || __DOXYGEN__
363#if !LCD_HD44780_PIN_MULTI_MODE
364# if !LCD_HD44780_PIN_SINGLE_SOME_CODE
375# if LCD_HD44780_PIN_SINGLE_SOME_CODE
376 #error "TODO: implement"
377 void _sc_lcd_clear(
void);
378 void _sc_lcd_home(
const uint8_t flags);
379 void _sc_lcd_entry_mode(
const uint8_t flags);
380 void _sc_lcd_display_ctrl(
const uint8_t flags);
381 void _sc_lcd_cursor(
const uint8_t flags);
382 void _sc_lcd_func_set(
const uint8_t flags);
383 void _sc_lcd_cgr_adr(
const uint8_t flags);
384 void _sc_lcd_ddr_adr(
const uint8_t flags);
385 void _sc_lcd_set_pos(
const lcd_line_t line,
const uint8_t pos);
386 void _sc_lcd_byte(
const byte_t ch);
387 void _sc_lcd_line(
const char str[],
const lcd_line_t line,
const uint8_t start_pos);
388 void _sc_lcd_print(
const char str[]);
389 void _sc_lcd_refresh_ml(
const char str[]);
390 void _sc_lcd_custom_char(
const byte_t char_pos,
const byte_t custom_char[8]);
391 byte_t _sc_lcd_read_busy_and_addr();
392 byte_t _sc_lcd_read_data();
393# define lcd_clear(_i) _sc_lcd_clear()
394# define lcd_home(_i, flags) _sc_lcd_home((flags))
395# define lcd_entry_mode(_i, flags) _sc_lcd_entry_mode((flags))
396# define lcd_display_ctrl(_i, flags) _sc_lcd_entry_mode((flags))
397# define lcd_cursor(_i, flags) _sc_lcd_entry_mode((flags))
398# define lcd_func_set(_i, flags) _sc_lcd_entry_mode((flags))
399# define lcd_cgr_adr(_i, flags) _sc_lcd_entry_mode((flags))
400# define lcd_ddr_adr(_i, flags) _sc_lcd_entry_mode((flags))
401# define lcd_set_pos(_i, line, pos) _sc_lcd_set_pos((line), (pos))
402# define lcd_byte(_i, ch) _sc_lcd_byte((ch))
403# define lcd_line(_i, str, line, sp) _sc_lcd_line((str), (line), (sp))
404# define lcd_print(_i, str) _sc_lcd_print((str))
405# define lcd_refresh_ml(_i, str) _sc_lcd_refresh_ml((str))
406# define lcd_custom_char(_i, pos, s) _sc_lcd_custom_char((pos), (s))
407# define lcd_read_busy_and_addr(_i) _sc_lcd_read_busy_and_addr()
408# define lcd_read_data(_i) _sc_lcd_read_data()
491# if LCD_HD44780_PIN_ALLOW_RW || __DOXYGEN__
uint8_t byte_t
8-bit type
Definition defs.h:64
byte_t pin_bit_t
The type for specifying the pin bit.
Definition defs.h:91
volatile byte_t *const ddr_t
Type for passing a reference to a direct register.
Definition defs.h:93
volatile byte_t *const port_t
Type for passing a reference to a port register.
Definition defs.h:94
volatile byte_t *const pin_t
Type for passing a reference to a pin register.
Definition defs.h:95
The HD44780 compatible dot-matrix liquid crystal display lib.
lcd_line_t
LCD row.
Definition dm_hd44780.h:277
lcd_display_t
LCD display type.
Definition dm_hd44780.h:297
void lcd_byte(const lcd_info_t *const info, const byte_t ch)
Outputs a symbol.
void lcd_func_set(const lcd_info_t *const info, const uint8_t flags)
Sets options.
void lcd_entry_mode(const lcd_info_t *const info, const uint8_t flags)
Sets cursor move direction and specifies display shift.
void lcd_ddr_adr(const lcd_info_t *const info, const uint8_t flags)
Sets DDRAM address.
void lcd_custom_char(const lcd_info_t *const info, const byte_t char_pos, const byte_t custom_char[8])
Creates a custom symbol.
volatile lcd_info_struct lcd_info_t
Information to distinguish a specific display from several connected ones.
Definition lcd_hd44780_pin.h:122
void lcd_cursor(const lcd_info_t *const info, const uint8_t flags)
Moves the cursor or shifts the display.
void lcd_line(const lcd_info_t *const info, const char str[], const lcd_line_t line, const uint8_t start_pos)
Outputs a string on entry line.
void lcd_cgr_adr(const lcd_info_t *const info, const uint8_t flags)
Sets CGRAM address.
byte_t lcd_read_data()
Reads data from CGRAM or from DDRAM.
void lcd_display_ctrl(const lcd_info_t *const info, const uint8_t flags)
Sets diplay options.
void lcd_print(const lcd_info_t *const info, const char str[])
Outputs a string to buffer.
void lcd_clear(void)
Clears the display.
void lcd_set_pos(const lcd_info_t *const info, const lcd_line_t line, const uint8_t pos)
Sets DDRAM address to a given position.
byte_t lcd_read_busy_and_addr()
Waits until display is buisy and returns address counter contents.
lcd_info_t lcd_init(const lcd_init_t *const config)
Initializes the display.
void lcd_home(const lcd_info_t *const info, const uint8_t flags)
Sets DDRAM address 0 in a ddress counter.
void lcd_refresh_ml(const lcd_info_t *const info, const char str[])
Outputs a string on all lines.
Initialization information.
Definition lcd_hd44780_pin.h:127
ddr_t rs_ddr
RS DDRx register.
Definition lcd_hd44780_pin.h:137
pin_bit_t e_pin
E(enable) pin bit.
Definition lcd_hd44780_pin.h:143
port_t rw_port
RW PORTx register. This is only necessary if reading is enabled.
Definition lcd_hd44780_pin.h:146
port_t e_port
E(enable) PORTx register.
Definition lcd_hd44780_pin.h:142
pin_t data_pin
This is only necessary if reading is enabled.
Definition lcd_hd44780_pin.h:134
pin_bit_t rs_pin
RS pin bit.
Definition lcd_hd44780_pin.h:139
ddr_t e_ddr
E(enable) DDRx register.
Definition lcd_hd44780_pin.h:141
ddr_t rw_ddr
RW DDRx register. This is only necessary if reading is enabled.
Definition lcd_hd44780_pin.h:145
uint8_t data_shift
It is only necessary for 4-bit IDL.
Definition lcd_hd44780_pin.h:135
port_t data_port
Data PORTx register.
Definition lcd_hd44780_pin.h:133
uint8_t flags
Config flags.
Definition lcd_hd44780_pin.h:128
lcd_display_t display_type
Display type, see lcd_display_t.
Definition lcd_hd44780_pin.h:130
ddr_t data_ddr
Data DDRx register.
Definition lcd_hd44780_pin.h:132
pin_bit_t rw_pin
RW pin bit. This is only necessary if reading is enabled.
Definition lcd_hd44780_pin.h:147
port_t rs_port
RS PORTx register.
Definition lcd_hd44780_pin.h:138