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 
9 #pragma once
10 
27 #include <stdint.h>
28 
29 #include "periph/gpio.h"
30 
31 #ifdef __cplusplus
32 extern "C" {
33 #endif
34 
38 #define HD44780_MAX_COLS (40U)
39 
43 #define HD44780_MAX_ROWS (4U)
44 
48 #define HD44780_MAX_PINS (8U)
49 
56 #define HD44780_CGRAM_SIZE (8U)
57 
61 typedef struct {
62  uint8_t cols;
63  uint8_t rows;
64  gpio_t rs;
65  gpio_t rw;
66  gpio_t enable;
67  gpio_t data[HD44780_MAX_PINS];
69 
73 typedef struct {
75  uint8_t flag;
76  uint8_t ctrl;
77  uint8_t mode;
78  uint8_t roff[HD44780_MAX_ROWS];
79 } hd44780_t;
80 
84 typedef enum {
86  HD44780_ON
88 
97 int hd44780_init(hd44780_t *dev, const hd44780_params_t *params);
98 
104 void hd44780_clear(const hd44780_t *dev);
105 
111 void hd44780_home(const hd44780_t *dev);
112 
120 void hd44780_set_cursor(const hd44780_t *dev, uint8_t col, uint8_t row);
121 
129 
137 
145 
152 
159 
166 
173 
181 
191 void hd44780_create_char(const hd44780_t *dev, uint8_t location, uint8_t charmap[]);
192 
199 void hd44780_write(const hd44780_t *dev, uint8_t value);
200 
207 void hd44780_print(const hd44780_t *dev, const char *data);
208 
209 #ifdef __cplusplus
210 }
211 #endif
212 
Low-level GPIO peripheral driver interface definitions.
void hd44780_right2left(hd44780_t *dev)
Set display direction right to left.
void hd44780_scroll_left(const hd44780_t *dev)
Enable left scrolling.
hd44780_state_t
Simple state values.
Definition: hd44780.h:84
void hd44780_autoscroll(hd44780_t *dev, hd44780_state_t state)
Display autoscroll on or off.
void hd44780_cursor(hd44780_t *dev, hd44780_state_t state)
Show cursor, on or off.
void hd44780_scroll_right(const hd44780_t *dev)
Enable right scrolling.
#define HD44780_MAX_ROWS
Maximal number of rows supported by the driver.
Definition: hd44780.h:43
void hd44780_left2right(hd44780_t *dev)
Set display direction left to right.
#define HD44780_MAX_PINS
Number of data pins for communication 4 or 8.
Definition: hd44780.h:48
void hd44780_set_cursor(const hd44780_t *dev, uint8_t col, uint8_t row)
Set cursor to specific position in column and row.
void hd44780_write(const hd44780_t *dev, uint8_t value)
Write a single character on the LCD.
void hd44780_clear(const hd44780_t *dev)
Clear display, delete all chars.
void hd44780_print(const hd44780_t *dev, const char *data)
Write a string on the LCD.
void hd44780_home(const hd44780_t *dev)
Reset cursor to row 0 and column 0.
int hd44780_init(hd44780_t *dev, const hd44780_params_t *params)
Initialize the given driver.
void hd44780_create_char(const hd44780_t *dev, uint8_t location, uint8_t charmap[])
Create and store a custom character on display memory.
void hd44780_blink(hd44780_t *dev, hd44780_state_t state)
Blink cursor, on or off.
void hd44780_display(hd44780_t *dev, hd44780_state_t state)
Turn display on or off.
@ HD44780_ON
enable feature
Definition: hd44780.h:86
@ HD44780_OFF
disable feature
Definition: hd44780.h:85
Parameters needed for device initialization.
Definition: hd44780.h:61
gpio_t rw
rw gpio pin
Definition: hd44780.h:65
gpio_t rs
rs gpio pin
Definition: hd44780.h:64
uint8_t cols
number of LCD cols
Definition: hd44780.h:62
gpio_t enable
enable gpio pin
Definition: hd44780.h:66
uint8_t rows
number of LCD rows
Definition: hd44780.h:63
Device descriptor for HD44780 LCD.
Definition: hd44780.h:73
hd44780_params_t p
LCD config parameters.
Definition: hd44780.h:74
uint8_t flag
LCD functional flags.
Definition: hd44780.h:75
uint8_t mode
LCD mode flags.
Definition: hd44780.h:77
uint8_t ctrl
LCD control flags.
Definition: hd44780.h:76