Ultibo API
C/C++ API for Ultibo Core
Loading...
Searching...
No Matches
hd44780.h
Go to the documentation of this file.
1/*
2 * This file is part of the Ultibo project, https://ultibo.org/
3 *
4 * The MIT License (MIT)
5 *
6 * Copyright (c) 2026 Garry Wood <garry@softoz.com.au>
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a copy
9 * of this software and associated documentation files (the "Software"), to deal
10 * in the Software without restriction, including without limitation the rights
11 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 * copies of the Software, and to permit persons to whom the Software is
13 * furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included in
16 * all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 * THE SOFTWARE.
25 */
26#ifndef _ULTIBO_HD44780_H
27#define _ULTIBO_HD44780_H
28
29#ifdef __cplusplus
30extern "C" {
31#endif
32
33#include "ultibo/gpio.h"
34#include "ultibo/console.h"
35
37#define HD44780_CONSOLE_DESCRIPTION "Hitachi HD44780 LCD Controller"
38
40#define HD44780_CLEARDISPLAY 0x01
41#define HD44780_RETURNHOME 0x02
42#define HD44780_ENTRYMODESET 0x04
43#define HD44780_DISPLAYCONTROL 0x08
44#define HD44780_CURSORSHIFT 0x10
45#define HD44780_FUNCTIONSET 0x20
46#define HD44780_SETCGRAMADDR 0x40
47#define HD44780_SETDDRAMADDR 0x80
48
50#define HD44780_ENTRYMODESET_RIGHT 0x00
51#define HD44780_ENTRYMODESET_LEFT 0x02
52#define HD44780_ENTRYMODESET_SHIFTINC 0x01
53#define HD44780_ENTRYMODESET_SHIFTDEC 0x00
54
56#define HD44780_DISPLAYCONTROL_DISPLAYON 0x04
57#define HD44780_DISPLAYCONTROL_DISPLAYOFF 0x00
58#define HD44780_DISPLAYCONTROL_CURSORON 0x02
59#define HD44780_DISPLAYCONTROL_CURSOROFF 0x00
60#define HD44780_DISPLAYCONTROL_BLINKON 0x01
61#define HD44780_DISPLAYCONTROL_BLINKOFF 0x00
62
64#define HD44780_CURSORSHIFT_DISPLAY 0x08
65#define HD44780_CURSORSHIFT_CURSOR 0x00
66#define HD44780_CURSORSHIFT_RIGHT 0x04
67#define HD44780_CURSORSHIFT_LEFT 0x00
68
70#define HD44780_FUNCTIONSET_8BITMODE 0x10
71#define HD44780_FUNCTIONSET_4BITMODE 0x00
72#define HD44780_FUNCTIONSET_2LINE 0x08
73#define HD44780_FUNCTIONSET_1LINE 0x00
74#define HD44780_FUNCTIONSET_5X10DOTS 0x04
75#define HD44780_FUNCTIONSET_5X8DOTS 0x00
76
78static const uint8_t HD44780_ROW_OFFSETS[4] = {0x00, 0x40, 0x14, 0x54};
79
83{
84 // Console Properties
86 // HD44780 Properties
88 uint32_t rs;
89 uint32_t rw;
90 uint32_t en;
91 uint32_t d4;
92 uint32_t d5;
93 uint32_t d6;
94 uint32_t d7;
95 uint8_t entrymode;
96 uint8_t functionset;
98 // Cursor Properties
99 uint8_t cursorx;
100 uint8_t cursory;
101 // Buffer Properties
102 uint32_t size;
103 uint8_t *buffer;
104};
105
107CONSOLE_DEVICE * STDCALL hd44780_console_create(GPIO_DEVICE *gpio, char *name, uint32_t width, uint32_t height, uint32_t rs, uint32_t rw, uint32_t en, uint32_t d4, uint32_t d5, uint32_t d6, uint32_t d7);
109
110#ifdef __cplusplus
111}
112#endif
113
114#endif // _ULTIBO_HD44780_H
struct _CONSOLE_DEVICE CONSOLE_DEVICE
Definition console.h:186
#define STDCALL
Definition globaltypes.h:45
struct _GPIO_DEVICE GPIO_DEVICE
Forward declared for GPIOPin.
Definition gpio.h:85
struct _HD44780_CONSOLE HD44780_CONSOLE
Definition hd44780.h:81
uint32_t STDCALL hd44780_console_destroy(CONSOLE_DEVICE *console)
CONSOLE_DEVICE *STDCALL hd44780_console_create(GPIO_DEVICE *gpio, char *name, uint32_t width, uint32_t height, uint32_t rs, uint32_t rw, uint32_t en, uint32_t d4, uint32_t d5, uint32_t d6, uint32_t d7)
Definition hd44780.h:83
uint32_t d4
The GPIO pin for the D4 line.
Definition hd44780.h:91
GPIO_DEVICE * gpio
The GPIO device this Console is connected to.
Definition hd44780.h:87
uint8_t cursorx
Definition hd44780.h:99
uint32_t d5
The GPIO pin for the D5 line.
Definition hd44780.h:92
uint32_t d7
The GPIO pin for the D7 line.
Definition hd44780.h:94
uint8_t cursory
Definition hd44780.h:100
uint32_t d6
The GPIO pin for the D6 line.
Definition hd44780.h:93
uint8_t displaycontrol
Current value of the Display Control settings.
Definition hd44780.h:97
uint8_t * buffer
Definition hd44780.h:103
uint32_t rw
The GPIO pin for the RW line.
Definition hd44780.h:89
uint32_t en
The GPIO pin for the EN line.
Definition hd44780.h:90
uint32_t rs
The GPIO pin for the RS line.
Definition hd44780.h:88
uint32_t size
Definition hd44780.h:102
CONSOLE_DEVICE console
Definition hd44780.h:85
uint8_t entrymode
Current value of the Entry Mode settings.
Definition hd44780.h:95
uint8_t functionset
Current value of the Function Set settings.
Definition hd44780.h:96