qmk_firmware/internals/hd44780.md

241 lines
12 KiB
Markdown
Raw Normal View History

# group `hd44780`
HD44780 Character LCD Driver
## Summary
Members | Descriptions
--------------------------------|---------------------------------------------
`define `[`HD44780_CMD_CLEAR_DISPLAY`](#group__hd44780_1ga317a0fa779dcbd40d04095e1c3b16447) |
`define `[`HD44780_CMD_RETURN_HOME`](#group__hd44780_1ga64cd4e167d1a9cd65b32d5dcd7ac1bb8) |
`define `[`HD44780_CMD_ENTRY_MODE`](#group__hd44780_1ga6a4bd39ff528e4b7c7cc556095466158) |
`define `[`HD44780_ENTRY_MODE_INC`](#group__hd44780_1ga8def8b2eb6120f932fc5831e3fbb3377) |
`define `[`HD44780_ENTRY_MODE_SHIFT`](#group__hd44780_1gac58c05aa3eae28e88272bfb7ee7f5c40) |
`define `[`HD44780_CMD_DISPLAY`](#group__hd44780_1gafb9f17134eb0765671ea8f43b188ae1e) |
`define `[`HD44780_DISPLAY_ON`](#group__hd44780_1gaefd6f75e3454ecbe00950c818e9e9420) |
`define `[`HD44780_DISPLAY_CURSOR`](#group__hd44780_1gad125b60be30b2cd0e0bfb23f949238ec) |
`define `[`HD44780_DISPLAY_BLINK`](#group__hd44780_1gadb288f3996fafc6537c5e413eff39df8) |
`define `[`HD44780_CMD_MOVE`](#group__hd44780_1gac1f843079f60718d770b34b1d9e080a1) |
`define `[`HD44780_MOVE_DISPLAY`](#group__hd44780_1ga7f5aead3ce92c0bb8eef4afb6ec03fdc) |
`define `[`HD44780_MOVE_RIGHT`](#group__hd44780_1ga5b8911c499925d126afd681d19e16985) |
`define `[`HD44780_CMD_FUNCTION`](#group__hd44780_1ga66e53be765239225f30b35689edcc7f1) |
`define `[`HD44780_FUNCTION_8_BIT`](#group__hd44780_1gab4760a025661db140bd7df635bbd67e7) |
`define `[`HD44780_FUNCTION_2_LINES`](#group__hd44780_1ga88dbd8646d5fad0456e4685239404da3) |
`define `[`HD44780_FUNCTION_5X10_DOTS`](#group__hd44780_1ga66002af4238dd0830e3dbe7780143492) |
`define `[`HD44780_CMD_SET_CGRAM_ADDRESS`](#group__hd44780_1ga73397fed8f690a6508fb5967a76bcd3f) |
`define `[`HD44780_CMD_SET_DDRAM_ADDRESS`](#group__hd44780_1ga32d29769e79b9843c284f98a9bc6ad2a) |
`define `[`HD44780_BUSY_FLAG`](#group__hd44780_1gae22e5ab2bb9069fb265a6ff8ca5d0254) |
`public void `[`hd44780_write`](#group__hd44780_1ga3a41d7df58b5856c629f8181e93b7c00)`(uint8_t data,bool isData)` | Write a byte to the display.
`public uint8_t `[`hd44780_read`](#group__hd44780_1ga855e31aeb778f32efbd75be995797d1b)`(bool isData)` | Read a byte from the display.
`public bool `[`hd44780_busy`](#group__hd44780_1gadcb1634221c116247735e3312637edc1)`(void)` | Indicates whether the display is currently processing, and cannot accept instructions.
`public void `[`hd44780_command`](#group__hd44780_1gacd6ba5f8ecc8e6776e6617312b60d28e)`(uint8_t command)` | Send a command to the display. Refer to the datasheet for the valid commands.
`public void `[`hd44780_data`](#group__hd44780_1ga8bc010c20fd8026b0d98bce13066b049)`(uint8_t data)` | Send a byte of data to the display.
`public void `[`hd44780_clear`](#group__hd44780_1gaa358b83b37987e488b8f47d48a896ef8)`(void)` | Clear the display.
`public void `[`hd44780_home`](#group__hd44780_1gac59e0708629529fee41ae215abd1e954)`(void)` | Move the cursor to the home position.
`public void `[`hd44780_on`](#group__hd44780_1ga86f7413fd10963734e7d00cc475a8aba)`(bool cursor,bool blink)` | Turn the display on, and/or set the cursor position.
`public void `[`hd44780_off`](#group__hd44780_1gaa236bcd35da58b8d3a9c5347358d3560)`(void)` | Turn the display off.
`public void `[`hd44780_set_cgram_address`](#group__hd44780_1gacd561522fddf2ec8833325fd10e3a924)`(uint8_t address)` | Set the CGRAM address.
`public void `[`hd44780_set_ddram_address`](#group__hd44780_1ga8de3a1df53c6481652683d1a6df31948)`(uint8_t address)` | Set the DDRAM address.
`public void `[`hd44780_init`](#group__hd44780_1ga16611b90107639921a68efd503949db8)`(bool cursor,bool blink)` | Initialize the display.
`public void `[`hd44780_set_cursor`](#group__hd44780_1ga0144f1c7e1de7745862f991451efa614)`(uint8_t col,uint8_t line)` | Move the cursor to the specified position on the display.
`public void `[`hd44780_define_char`](#group__hd44780_1gaa167a2e4398a665658597f328ea08736)`(uint8_t index,uint8_t * data)` | Define a custom character.
`public void `[`hd44780_putc`](#group__hd44780_1gaf9578702c16938a2abbb8c6becc9915f)`(char c)` | Print a character to the display. The newline character will move the cursor to the start of the next line.
`public void `[`hd44780_puts`](#group__hd44780_1gaefe6076f55a4619cd8279765e125e513)`(const char * s)` | Print a string of characters to the display.
`public void `[`hd44780_define_char_P`](#group__hd44780_1ga8d31109c8c7ef295511145c490cdba7d)`(uint8_t index,const uint8_t * data)` | Define a custom character from PROGMEM.
`public void `[`hd44780_puts_P`](#group__hd44780_1gad999de4c8c443783542aece3c5ffaefc)`(const char * s)` | Print a string of characters from PROGMEM to the display.
## Members
#### `define `[`HD44780_CMD_CLEAR_DISPLAY`](#group__hd44780_1ga317a0fa779dcbd40d04095e1c3b16447)
#### `define `[`HD44780_CMD_RETURN_HOME`](#group__hd44780_1ga64cd4e167d1a9cd65b32d5dcd7ac1bb8)
#### `define `[`HD44780_CMD_ENTRY_MODE`](#group__hd44780_1ga6a4bd39ff528e4b7c7cc556095466158)
#### `define `[`HD44780_ENTRY_MODE_INC`](#group__hd44780_1ga8def8b2eb6120f932fc5831e3fbb3377)
#### `define `[`HD44780_ENTRY_MODE_SHIFT`](#group__hd44780_1gac58c05aa3eae28e88272bfb7ee7f5c40)
#### `define `[`HD44780_CMD_DISPLAY`](#group__hd44780_1gafb9f17134eb0765671ea8f43b188ae1e)
#### `define `[`HD44780_DISPLAY_ON`](#group__hd44780_1gaefd6f75e3454ecbe00950c818e9e9420)
#### `define `[`HD44780_DISPLAY_CURSOR`](#group__hd44780_1gad125b60be30b2cd0e0bfb23f949238ec)
#### `define `[`HD44780_DISPLAY_BLINK`](#group__hd44780_1gadb288f3996fafc6537c5e413eff39df8)
#### `define `[`HD44780_CMD_MOVE`](#group__hd44780_1gac1f843079f60718d770b34b1d9e080a1)
#### `define `[`HD44780_MOVE_DISPLAY`](#group__hd44780_1ga7f5aead3ce92c0bb8eef4afb6ec03fdc)
#### `define `[`HD44780_MOVE_RIGHT`](#group__hd44780_1ga5b8911c499925d126afd681d19e16985)
#### `define `[`HD44780_CMD_FUNCTION`](#group__hd44780_1ga66e53be765239225f30b35689edcc7f1)
#### `define `[`HD44780_FUNCTION_8_BIT`](#group__hd44780_1gab4760a025661db140bd7df635bbd67e7)
#### `define `[`HD44780_FUNCTION_2_LINES`](#group__hd44780_1ga88dbd8646d5fad0456e4685239404da3)
#### `define `[`HD44780_FUNCTION_5X10_DOTS`](#group__hd44780_1ga66002af4238dd0830e3dbe7780143492)
#### `define `[`HD44780_CMD_SET_CGRAM_ADDRESS`](#group__hd44780_1ga73397fed8f690a6508fb5967a76bcd3f)
#### `define `[`HD44780_CMD_SET_DDRAM_ADDRESS`](#group__hd44780_1ga32d29769e79b9843c284f98a9bc6ad2a)
#### `define `[`HD44780_BUSY_FLAG`](#group__hd44780_1gae22e5ab2bb9069fb265a6ff8ca5d0254)
#### `public void `[`hd44780_write`](#group__hd44780_1ga3a41d7df58b5856c629f8181e93b7c00)`(uint8_t data,bool isData)`
Write a byte to the display.
#### Parameters
* `data` The byte to send to the display.
* `isData` Whether the byte is an instruction or character data.
#### `public uint8_t `[`hd44780_read`](#group__hd44780_1ga855e31aeb778f32efbd75be995797d1b)`(bool isData)`
Read a byte from the display.
#### Parameters
* `isData` Whether to read the current cursor position, or the character at the cursor.
#### Returns
If `isData` is `true`, the returned byte will be the character at the current DDRAM address. Otherwise, it will be the current DDRAM address and the busy flag.
#### `public bool `[`hd44780_busy`](#group__hd44780_1gadcb1634221c116247735e3312637edc1)`(void)`
Indicates whether the display is currently processing, and cannot accept instructions.
#### Returns
`true` if the display is busy.
#### `public void `[`hd44780_command`](#group__hd44780_1gacd6ba5f8ecc8e6776e6617312b60d28e)`(uint8_t command)`
Send a command to the display. Refer to the datasheet for the valid commands.
This function waits for the display to clear the busy flag before sending the command.
#### Parameters
* `command` The command to send.
#### `public void `[`hd44780_data`](#group__hd44780_1ga8bc010c20fd8026b0d98bce13066b049)`(uint8_t data)`
Send a byte of data to the display.
This function waits for the display to clear the busy flag before sending the data.
#### Parameters
* `data` The byte of data to send.
#### `public void `[`hd44780_clear`](#group__hd44780_1gaa358b83b37987e488b8f47d48a896ef8)`(void)`
Clear the display.
This function is called on init.
#### `public void `[`hd44780_home`](#group__hd44780_1gac59e0708629529fee41ae215abd1e954)`(void)`
Move the cursor to the home position.
This function is called on init.
#### `public void `[`hd44780_on`](#group__hd44780_1ga86f7413fd10963734e7d00cc475a8aba)`(bool cursor,bool blink)`
Turn the display on, and/or set the cursor position.
This function is called on init.
#### Parameters
* `cursor` Whether to show the cursor.
* `blink` Whether to blink the cursor, if shown.
#### `public void `[`hd44780_off`](#group__hd44780_1gaa236bcd35da58b8d3a9c5347358d3560)`(void)`
Turn the display off.
#### `public void `[`hd44780_set_cgram_address`](#group__hd44780_1gacd561522fddf2ec8833325fd10e3a924)`(uint8_t address)`
Set the CGRAM address.
This function is used when defining custom characters.
#### Parameters
* `address` The CGRAM address to move to, from `0x00` to `0x3F`.
#### `public void `[`hd44780_set_ddram_address`](#group__hd44780_1ga8de3a1df53c6481652683d1a6df31948)`(uint8_t address)`
Set the DDRAM address.
This function is used when printing characters to the display, and setting the cursor.
#### Parameters
* `address` The DDRAM address to move to, from `0x00` to `0x7F`.
#### `public void `[`hd44780_init`](#group__hd44780_1ga16611b90107639921a68efd503949db8)`(bool cursor,bool blink)`
Initialize the display.
This function should be called only once, before any of the other functions can be called.
#### Parameters
* `cursor` Whether to show the cursor.
* `blink` Whether to blink the cursor, if shown.
#### `public void `[`hd44780_set_cursor`](#group__hd44780_1ga0144f1c7e1de7745862f991451efa614)`(uint8_t col,uint8_t line)`
Move the cursor to the specified position on the display.
#### Parameters
* `col` The column number to move to, from 0 to 15 on 16x2 displays.
* `line` The line number to move to, either 0 or 1 on 16x2 displays.
#### `public void `[`hd44780_define_char`](#group__hd44780_1gaa167a2e4398a665658597f328ea08736)`(uint8_t index,uint8_t * data)`
Define a custom character.
#### Parameters
* `index` The index of the custom character to define, from 0 to 7.
* `data` An array of 8 bytes containing the 5-bit row data of the character, where the first byte is the topmost row, and the least significant bit of each byte is the rightmost column.
#### `public void `[`hd44780_putc`](#group__hd44780_1gaf9578702c16938a2abbb8c6becc9915f)`(char c)`
Print a character to the display. The newline character will move the cursor to the start of the next line.
The exact character shown may depend on the ROM code of your particular display - refer to the datasheet for the full character set.
#### Parameters
* `c` The character to print.
#### `public void `[`hd44780_puts`](#group__hd44780_1gaefe6076f55a4619cd8279765e125e513)`(const char * s)`
Print a string of characters to the display.
#### Parameters
* `s` The string to print.
#### `public void `[`hd44780_define_char_P`](#group__hd44780_1ga8d31109c8c7ef295511145c490cdba7d)`(uint8_t index,const uint8_t * data)`
Define a custom character from PROGMEM.
On ARM devices, this function is simply an alias of [hd44780_define_char()](.build/docs/internals/undefined.md#group__hd44780_1gaa167a2e4398a665658597f328ea08736).
#### Parameters
* `index` The index of the custom character to define, from 0 to 7.
* `data` A PROGMEM array of 8 bytes containing the 5-bit row data of the character, where the first byte is the topmost row, and the least significant bit of each byte is the rightmost column.
#### `public void `[`hd44780_puts_P`](#group__hd44780_1gad999de4c8c443783542aece3c5ffaefc)`(const char * s)`
Print a string of characters from PROGMEM to the display.
On ARM devices, this function is simply an alias of [hd44780_puts()](.build/docs/internals/undefined.md#group__hd44780_1gaefe6076f55a4619cd8279765e125e513).
#### Parameters
* `s` The PROGMEM string to print.