Skip to content

File syn_charlcd.h

FileList > display > syn_charlcd.h

Go to the source code of this file

Generic Character LCD Driver (HD44780, ST7066, KS0066 over I2C PCF8574 or 4-Bit Parallel GPIO).

  • #include "../common/syn_defs.h"
  • #include "../drivers/syn_soft_i2c.h"
  • #include "../port/syn_port_gpio.h"
  • #include <stdbool.h>
  • #include <stddef.h>
  • #include <stdint.h>

Classes

Type Name
struct SYN_CharLCD
Generic Character LCD Context.

Public Types

Type Name
enum SYN_CharLCDMode
Character LCD Interface Mode.

Public Functions

Type Name
void syn_charlcd_clear (SYN_CharLCD * lcd)
Clear LCD screen and reset cursor to home (0,0).
void syn_charlcd_create_char (SYN_CharLCD * lcd, uint8_t slot, const uint8_t charmap)
Load a custom 5x8 pixel character into CGRAM.
SYN_Status syn_charlcd_init_gpio (SYN_CharLCD * lcd, SYN_GPIO_Pin rs, SYN_GPIO_Pin en, SYN_GPIO_Pin d4, SYN_GPIO_Pin d5, SYN_GPIO_Pin d6, SYN_GPIO_Pin d7, uint8_t cols, uint8_t rows)
Initialize Character LCD in Direct 4-Bit Parallel GPIO mode.
SYN_Status syn_charlcd_init_i2c (SYN_CharLCD * lcd, SYN_GPIO_Pin scl, SYN_GPIO_Pin sda, uint8_t i2c_addr, uint8_t cols, uint8_t rows)
Initialize Character LCD in I2C PCF8574 Backpack mode.
void syn_charlcd_print (SYN_CharLCD * lcd, const char * str)
Print an ASCII string at current cursor position.
void syn_charlcd_set_backlight (SYN_CharLCD * lcd, bool enable)
Turn display backlight ON or OFF (I2C backpack mode).
void syn_charlcd_set_cursor (SYN_CharLCD * lcd, uint8_t col, uint8_t row)
Set cursor position.

Public Types Documentation

enum SYN_CharLCDMode

Character LCD Interface Mode.

enum SYN_CharLCDMode {
    SYN_CHARLCD_MODE_I2C = 0,
    SYN_CHARLCD_MODE_GPIO_4BIT
};


Public Functions Documentation

function syn_charlcd_clear

Clear LCD screen and reset cursor to home (0,0).

void syn_charlcd_clear (
    SYN_CharLCD * lcd
) 

Parameters:

  • lcd LCD context.

function syn_charlcd_create_char

Load a custom 5x8 pixel character into CGRAM.

void syn_charlcd_create_char (
    SYN_CharLCD * lcd,
    uint8_t slot,
    const uint8_t charmap
) 

Parameters:

  • lcd LCD context.
  • slot CGRAM slot (0 to 7).
  • charmap Array of 8 bytes (each byte represents a 5-bit pixel row).

function syn_charlcd_init_gpio

Initialize Character LCD in Direct 4-Bit Parallel GPIO mode.

SYN_Status syn_charlcd_init_gpio (
    SYN_CharLCD * lcd,
    SYN_GPIO_Pin rs,
    SYN_GPIO_Pin en,
    SYN_GPIO_Pin d4,
    SYN_GPIO_Pin d5,
    SYN_GPIO_Pin d6,
    SYN_GPIO_Pin d7,
    uint8_t cols,
    uint8_t rows
) 

Parameters:

  • lcd LCD context.
  • rs Register Select GPIO pin.
  • en Enable GPIO pin.
  • d4 Data Bit 4 GPIO pin.
  • d5 Data Bit 5 GPIO pin.
  • d6 Data Bit 6 GPIO pin.
  • d7 Data Bit 7 GPIO pin.
  • cols Columns (e.g. 16 or 20).
  • rows Rows (e.g. 2 or 4).

Returns:

SYN_OK on success.


function syn_charlcd_init_i2c

Initialize Character LCD in I2C PCF8574 Backpack mode.

SYN_Status syn_charlcd_init_i2c (
    SYN_CharLCD * lcd,
    SYN_GPIO_Pin scl,
    SYN_GPIO_Pin sda,
    uint8_t i2c_addr,
    uint8_t cols,
    uint8_t rows
) 

Parameters:

  • lcd LCD context.
  • scl I2C SCL GPIO pin.
  • sda I2C SDA GPIO pin.
  • i2c_addr PCF8574 I2C address (e.g. 0x27 or 0x3F).
  • cols Columns (e.g. 16 or 20).
  • rows Rows (e.g. 2 or 4).

Returns:

SYN_OK on success.


function syn_charlcd_print

Print an ASCII string at current cursor position.

void syn_charlcd_print (
    SYN_CharLCD * lcd,
    const char * str
) 

Parameters:

  • lcd LCD context.
  • str Null-terminated string.

function syn_charlcd_set_backlight

Turn display backlight ON or OFF (I2C backpack mode).

void syn_charlcd_set_backlight (
    SYN_CharLCD * lcd,
    bool enable
) 

Parameters:

  • lcd LCD context.
  • enable True for backlight ON.

function syn_charlcd_set_cursor

Set cursor position.

void syn_charlcd_set_cursor (
    SYN_CharLCD * lcd,
    uint8_t col,
    uint8_t row
) 

Parameters:

  • lcd LCD context.
  • col Column (0 to cols-1).
  • row Row (0 to rows-1).


The documentation for this class was generated from the following file src/syntropic/display/syn_charlcd.h