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 
52 #define HD44780_RW_OFF (255U)
53 
60 #define HD44780_CGRAM_SIZE (8U)
61 
65 typedef struct {
66  uint8_t cols;
67  uint8_t rows;
68  gpio_t rs;
69  gpio_t rw;
70  gpio_t enable;
71  gpio_t data[8];
73 
77 typedef struct {
79  uint8_t flag;
80  uint8_t ctrl;
81  uint8_t mode;
82  uint8_t roff[HD44780_MAX_ROWS];
83 } hd44780_t;
84 
88 typedef enum {
92 
101 int hd44780_init(hd44780_t *dev, const hd44780_params_t *params);
102 
108 void hd44780_clear(const hd44780_t *dev);
109 
115 void hd44780_home(const hd44780_t *dev);
116 
124 void hd44780_set_cursor(const hd44780_t *dev, uint8_t col, uint8_t row);
125 
132 void hd44780_display(hd44780_t *dev, hd44780_state_t state);
133 
140 void hd44780_cursor(hd44780_t *dev, hd44780_state_t state);
141 
148 void hd44780_blink(hd44780_t *dev, hd44780_state_t state);
149 
155 void hd44780_scroll_left(const hd44780_t *dev);
156 
162 void hd44780_scroll_right(const hd44780_t *dev);
163 
169 void hd44780_left2right(hd44780_t *dev);
170 
176 void hd44780_right2left(hd44780_t *dev);
177 
184 void hd44780_autoscroll(hd44780_t *dev, hd44780_state_t state);
185 
195 void hd44780_create_char(const hd44780_t *dev, uint8_t location, uint8_t charmap[]);
196 
203 void hd44780_write(const hd44780_t *dev, uint8_t value);
204 
211 void hd44780_print(const hd44780_t *dev, const char *data);
212 
213 #ifdef __cplusplus
214 }
215 #endif
216 
217 #endif /* HD44780_H */
218 
disable feature
Definition: hd44780.h:89
void hd44780_print(const hd44780_t *dev, const char *data)
Write a string on the LCD.
void hd44780_set_cursor(const hd44780_t *dev, uint8_t col, uint8_t row)
Set cursor to specific position in column and row.
gpio_t rw
rw gpio pin
Definition: hd44780.h:69
Low-level GPIO peripheral driver interface definitions.
void hd44780_clear(const hd44780_t *dev)
Clear display, delete all chars.
#define HD44780_MAX_ROWS
Maximal number of rows supported by the driver.
Definition: hd44780.h:42
void hd44780_scroll_left(const hd44780_t *dev)
Enable left scrolling.
void hd44780_right2left(hd44780_t *dev)
set display direction right to left
enable feature
Definition: hd44780.h:90
void hd44780_left2right(hd44780_t *dev)
set display direction left to right
void hd44780_display(hd44780_t *dev, hd44780_state_t state)
Turn display on or off.
hd44780_state_t
Simple state values.
Definition: hd44780.h:88
void hd44780_autoscroll(hd44780_t *dev, hd44780_state_t state)
display autoscroll on or off
void hd44780_blink(hd44780_t *dev, hd44780_state_t state)
Blink cursor, on or off.
void hd44780_scroll_right(const hd44780_t *dev)
Enable right scrolling.
gpio_t enable
enable gpio pin
Definition: hd44780.h:70
uint8_t rows
number of LCD rows
Definition: hd44780.h:67
void hd44780_write(const hd44780_t *dev, uint8_t value)
Write a single character on the LCD.
hd44780_params_t p
LCD config parameters.
Definition: hd44780.h:78
uint8_t flag
LCD functional flags.
Definition: hd44780.h:79
Parameters needed for device initialization.
Definition: hd44780.h:65
Device descriptor for HD44780 LCD.
Definition: hd44780.h:77
uint8_t ctrl
LCD control flags.
Definition: hd44780.h:80
int hd44780_init(hd44780_t *dev, const hd44780_params_t *params)
Initialize the given driver.
void hd44780_home(const hd44780_t *dev)
Reset cursor to row 0 and column 0.
void hd44780_cursor(hd44780_t *dev, hd44780_state_t state)
Show cursor, on or off.
gpio_t rs
rs gpio pin
Definition: hd44780.h:68
void hd44780_create_char(const hd44780_t *dev, uint8_t location, uint8_t charmap[])
Create and store a custom character on display memory.
uint8_t cols
number of LCD cols
Definition: hd44780.h:66
uint8_t mode
LCD mode flags.
Definition: hd44780.h:81