hd44780.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
23 #ifndef HD44780_H
24 #define HD44780_H
25 
26 #include <stdint.h>
27 
28 #include "periph/gpio.h"
29 
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33 
37 #define HD44780_MAX_COLS (40U)
38 
42 #define HD44780_MAX_ROWS (4U)
43 
47 #define HD44780_MAX_PINS (8U)
48 
55 #define HD44780_CGRAM_SIZE (8U)
56 
60 typedef struct {
61  uint8_t cols;
62  uint8_t rows;
63  gpio_t rs;
64  gpio_t rw;
65  gpio_t enable;
66  gpio_t data[HD44780_MAX_PINS];
68 
72 typedef struct {
74  uint8_t flag;
75  uint8_t ctrl;
76  uint8_t mode;
77  uint8_t roff[HD44780_MAX_ROWS];
78 } hd44780_t;
79 
83 typedef enum {
87 
96 int hd44780_init(hd44780_t *dev, const hd44780_params_t *params);
97 
103 void hd44780_clear(const hd44780_t *dev);
104 
110 void hd44780_home(const hd44780_t *dev);
111 
119 void hd44780_set_cursor(const hd44780_t *dev, uint8_t col, uint8_t row);
120 
127 void hd44780_display(hd44780_t *dev, hd44780_state_t state);
128 
135 void hd44780_cursor(hd44780_t *dev, hd44780_state_t state);
136 
143 void hd44780_blink(hd44780_t *dev, hd44780_state_t state);
144 
150 void hd44780_scroll_left(const hd44780_t *dev);
151 
157 void hd44780_scroll_right(const hd44780_t *dev);
158 
164 void hd44780_left2right(hd44780_t *dev);
165 
171 void hd44780_right2left(hd44780_t *dev);
172 
180 
190 void hd44780_create_char(const hd44780_t *dev, uint8_t location, uint8_t charmap[]);
191 
198 void hd44780_write(const hd44780_t *dev, uint8_t value);
199 
206 void hd44780_print(const hd44780_t *dev, const char *data);
207 
208 #ifdef __cplusplus
209 }
210 #endif
211 
212 #endif /* HD44780_H */
213 
hd44780_clear
void hd44780_clear(const hd44780_t *dev)
Clear display, delete all chars.
hd44780_init
int hd44780_init(hd44780_t *dev, const hd44780_params_t *params)
Initialize the given driver.
hd44780_state_t
hd44780_state_t
Simple state values.
Definition: hd44780.h:83
hd44780_print
void hd44780_print(const hd44780_t *dev, const char *data)
Write a string on the LCD.
hd44780_params_t::cols
uint8_t cols
number of LCD cols
Definition: hd44780.h:61
hd44780_autoscroll
void hd44780_autoscroll(hd44780_t *dev, hd44780_state_t state)
Display autoscroll on or off.
HD44780_ON
@ HD44780_ON
enable feature
Definition: hd44780.h:85
hd44780_params_t
Parameters needed for device initialization.
Definition: hd44780.h:60
hd44780_home
void hd44780_home(const hd44780_t *dev)
Reset cursor to row 0 and column 0.
hd44780_scroll_left
void hd44780_scroll_left(const hd44780_t *dev)
Enable left scrolling.
HD44780_MAX_ROWS
#define HD44780_MAX_ROWS
Maximal number of rows supported by the driver.
Definition: hd44780.h:42
hd44780_set_cursor
void hd44780_set_cursor(const hd44780_t *dev, uint8_t col, uint8_t row)
Set cursor to specific position in column and row.
hd44780_blink
void hd44780_blink(hd44780_t *dev, hd44780_state_t state)
Blink cursor, on or off.
hd44780_scroll_right
void hd44780_scroll_right(const hd44780_t *dev)
Enable right scrolling.
hd44780_params_t::rs
gpio_t rs
rs gpio pin
Definition: hd44780.h:63
hd44780_write
void hd44780_write(const hd44780_t *dev, uint8_t value)
Write a single character on the LCD.
hd44780_params_t::rows
uint8_t rows
number of LCD rows
Definition: hd44780.h:62
hd44780_t
Device descriptor for HD44780 LCD.
Definition: hd44780.h:72
hd44780_left2right
void hd44780_left2right(hd44780_t *dev)
Set display direction left to right.
hd44780_right2left
void hd44780_right2left(hd44780_t *dev)
Set display direction right to left.
hd44780_create_char
void hd44780_create_char(const hd44780_t *dev, uint8_t location, uint8_t charmap[])
Create and store a custom character on display memory.
hd44780_display
void hd44780_display(hd44780_t *dev, hd44780_state_t state)
Turn display on or off.
hd44780_t::p
hd44780_params_t p
LCD config parameters.
Definition: hd44780.h:73
hd44780_params_t::rw
gpio_t rw
rw gpio pin
Definition: hd44780.h:64
gpio.h
Low-level GPIO peripheral driver interface definitions.
hd44780_t::ctrl
uint8_t ctrl
LCD control flags.
Definition: hd44780.h:75
hd44780_t::flag
uint8_t flag
LCD functional flags.
Definition: hd44780.h:74
hd44780_cursor
void hd44780_cursor(hd44780_t *dev, hd44780_state_t state)
Show cursor, on or off.
HD44780_OFF
@ HD44780_OFF
disable feature
Definition: hd44780.h:84
HD44780_MAX_PINS
#define HD44780_MAX_PINS
Number of data pins for communication 4 or 8.
Definition: hd44780.h:47
hd44780_params_t::enable
gpio_t enable
enable gpio pin
Definition: hd44780.h:65
hd44780_t::mode
uint8_t mode
LCD mode flags.
Definition: hd44780.h:76