HD44780  0.1.3
HD44780.h
Go to the documentation of this file.
1 
12 #ifndef __HD44780_H__
13 #define __HD44780_H__
14 
15 #include <stdbool.h>
16 #include <stdlib.h>
17 
18 #if !defined(STM32F0) && !defined(STM32F1) && !defined(STM32F2) && !defined(STM32F3) && !defined(STM32F4) && \
19  !defined(STM32F7) && !defined(STM32H7) && !defined(STM32G0) && !defined(STM32G4) && !defined(STM32L0) && \
20  !defined(STM32L1) && !defined(STM32L4) && !defined(STM32L5) && !defined(STM32WB) && !defined(STM32WL)
21 #include "HD44780_conf.h"
22 #endif
23 
24 #if defined(STM32F0)
25 #include <stm32f0xx_hal.h>
26 #elif defined(STM32F1)
27 #include <stm32f1xx_hal.h>
28 #elif defined(STM32F2)
29 #include <stm32f2xx_hal.h>
30 #elif defined(STM32F3)
31 #include <stm32f3xx_hal.h>
32 #elif defined(STM32F4)
33 #include <stm32f4xx_hal.h>
34 #elif defined(STM32F7)
35 #include <stm32f7xx_hal.h>
36 #elif defined(STM32H7)
37 #include <stm32h7xx_hal.h>
38 #elif defined(STM32G0)
39 #include <stm32g0xx_hal.h>
40 #elif defined(STM32G4)
41 #include <stm32g4xx_hal.h>
42 #elif defined(STM32L0)
43 #include <stm32l0xx_hal.h>
44 #elif defined(STM32L1)
45 #include <stm32l1xx_hal.h>
46 #elif defined(STM32L4)
47 #include <stm32l4xx_hal.h>
48 #elif defined(STM32L5)
49 #include <stm32l5xx_hal.h>
50 #elif defined(STM32WB)
51 #include <stm32wbxx_hal.h>
52 #elif defined(STM32WL)
53 #include <stm32wlxx_hal.h>
54 #else
55 #error No MPU architecture selected.
56 #endif
57 
63 typedef struct
64 {
65  GPIO_TypeDef *rs_gpio;
66  GPIO_TypeDef *rw_gpio;
67  GPIO_TypeDef *en_gpio;
68  GPIO_TypeDef *d0_gpio;
69  GPIO_TypeDef *d1_gpio;
70  GPIO_TypeDef *d2_gpio;
71  GPIO_TypeDef *d3_gpio;
72  GPIO_TypeDef *d4_gpio;
73  GPIO_TypeDef *d5_gpio;
74  GPIO_TypeDef *d6_gpio;
75  GPIO_TypeDef *d7_gpio;
77  uint16_t rs_pin;
78  uint16_t rw_pin;
79  uint16_t en_pin;
80  uint16_t d0_pin;
81  uint16_t d1_pin;
82  uint16_t d2_pin;
83  uint16_t d3_pin;
84  uint16_t d4_pin;
85  uint16_t d5_pin;
86  uint16_t d6_pin;
87  uint16_t d7_pin;
94 
99 
105  bool font_5x10;
106 } HD44780;
107 
112 typedef struct
113 {
119 
125 
131 
136 
141  bool shift_rtl;
143 
150 void HD44780_init(const HD44780 *lcd);
151 
159 void HD44780_configure(const HD44780 *lcd, const HD44780_Config *config);
160 
166 void HD44780_clear(const HD44780 *lcd);
167 
173 void HD44780_return_home(const HD44780 *lcd);
174 
186 void HD44780_cursor_to(const HD44780 *lcd, uint8_t column, uint8_t row);
187 
200 void HD44780_shift_display(const HD44780 *lcd, int8_t n);
201 
218 void HD44780_create_symbol(const HD44780 *lcd, uint8_t address, bool font_5x10, const uint8_t symbol[]);
219 
229 void HD44780_put_char(const HD44780 *lcd, uint8_t chr);
230 
241 void HD44780_put_str(const HD44780 *lcd, const char *str);
242 
243 #endif /* __HD44780_H__ */
void HD44780_cursor_to(const HD44780 *lcd, uint8_t column, uint8_t row)
Move the cursor to the desired position.
void HD44780_create_symbol(const HD44780 *lcd, uint8_t address, bool font_5x10, const uint8_t symbol[])
Create a user defined character to display in the LCD.
void HD44780_configure(const HD44780 *lcd, const HD44780_Config *config)
Update the configuration of the controller.
void HD44780_return_home(const HD44780 *lcd)
Reset display shift to the initial position and move the cursor to position 0 of the first line.
void HD44780_shift_display(const HD44780 *lcd, int8_t n)
Shift the contents of the display right or left by n positions.
void HD44780_init(const HD44780 *lcd)
Initialize the necessary hardware peripherals, then configure the controller itself.
void HD44780_put_str(const HD44780 *lcd, const char *str)
Write a string to the lcd, then advance the cursor.
void HD44780_put_char(const HD44780 *lcd, uint8_t chr)
Write a single character to the lcd, then advance the cursor.
void HD44780_clear(const HD44780 *lcd)
Clear the display and move the cursor to position 0 of the first line.
HD44780 controller configuration.
Definition: HD44780.h:113
bool shift_display
Shift the display when data is entered instead of shifting only the cursor.
Definition: HD44780.h:135
bool enable_blink
Make the character indicated by the cursor blink.
Definition: HD44780.h:130
bool shift_rtl
Shift the display (depending on the shift_display parameter) and/or cursor in right to left direction...
Definition: HD44780.h:141
bool disable_display
Disable the display.
Definition: HD44780.h:118
bool enable_cursor
Make the cursor visible.
Definition: HD44780.h:124
HD44780 controller instance.
Definition: HD44780.h:64
uint16_t d0_pin
Pin number of the mcu pin connected to the controller's D0 line.
Definition: HD44780.h:80
uint16_t rs_pin
Pin number of the mcu pin connected to the controller's RS line.
Definition: HD44780.h:77
uint16_t d3_pin
Pin number of the mcu pin connected to the controller's D3 line.
Definition: HD44780.h:83
GPIO_TypeDef * d5_gpio
GPIO port of the mcu pin connected to the controller's D5 line.
Definition: HD44780.h:73
bool single_line
Display a single taller line on the display instead of the default 2 lines.
Definition: HD44780.h:98
uint16_t d4_pin
Pin number of the mcu pin connected to the controller's D4 line.
Definition: HD44780.h:84
uint16_t d6_pin
Pin number of the mcu pin connected to the controller's D6 line.
Definition: HD44780.h:86
GPIO_TypeDef * en_gpio
GPIO port of the mcu pin connected to the controller's EN line.
Definition: HD44780.h:67
GPIO_TypeDef * rs_gpio
GPIO port of the mcu pin connected to the controller's RS line.
Definition: HD44780.h:65
uint16_t d5_pin
Pin number of the mcu pin connected to the controller's D5 line.
Definition: HD44780.h:85
bool interface_8_bit
Use 8 physical data lines (DB7-DB0) for communication with the controller instead of the default 4 li...
Definition: HD44780.h:93
GPIO_TypeDef * d6_gpio
GPIO port of the mcu pin connected to the controller's D6 line.
Definition: HD44780.h:74
GPIO_TypeDef * d7_gpio
GPIO port of the mcu pin connected to the controller's D7 line.
Definition: HD44780.h:75
uint16_t en_pin
Pin number of the mcu pin connected to the controller's EN line.
Definition: HD44780.h:79
bool font_5x10
Use the 5x10 dots character font instead of the default 5x8 dots font.
Definition: HD44780.h:105
uint16_t d1_pin
Pin number of the mcu pin connected to the controller's D1 line.
Definition: HD44780.h:81
uint16_t d2_pin
Pin number of the mcu pin connected to the controller's D2 line.
Definition: HD44780.h:82
uint16_t rw_pin
Pin number of the mcu pin connected to the controller's RW line.
Definition: HD44780.h:78
GPIO_TypeDef * rw_gpio
GPIO port of the mcu pin connected to the controller's RW line.
Definition: HD44780.h:66
GPIO_TypeDef * d4_gpio
GPIO port of the mcu pin connected to the controller's D4 line.
Definition: HD44780.h:72
GPIO_TypeDef * d2_gpio
GPIO port of the mcu pin connected to the controller's D2 line.
Definition: HD44780.h:70
GPIO_TypeDef * d1_gpio
GPIO port of the mcu pin connected to the controller's D1 line.
Definition: HD44780.h:69
GPIO_TypeDef * d0_gpio
GPIO port of the mcu pin connected to the controller's D0 line.
Definition: HD44780.h:68
GPIO_TypeDef * d3_gpio
GPIO port of the mcu pin connected to the controller's D3 line.
Definition: HD44780.h:71
uint16_t d7_pin
Pin number of the mcu pin connected to the controller's D7 line.
Definition: HD44780.h:87