talon/User/lcd.h

55 lines
1.6 KiB
C
Raw Normal View History

2024-02-10 16:16:29 -05:00
#ifndef USER_LCD_H_
#define USER_LCD_H_
#include "ch32v20x.h"
static const uint8_t LCD_RS = 0x01;
static const uint8_t LCD_RW = 0x02;
static const uint8_t LCD_EN = 0x04;
static const uint8_t LCD_BACKLIGHT = 0x08;
static const uint8_t LCD_NOBACKLIGHT = 0x00;
static const uint8_t LCD_4BITMODE = 0x00;
static const uint8_t LCD_2LINE = 0x08;
static const uint8_t LCD_CLEARDISPLAY = 0x01;
static const uint8_t LCD_RETURNHOME = 0x02;
static const uint8_t LCD_ENTRYMODESET = 0x04;
static const uint8_t LCD_DISPLAYCONTROL = 0x08;
static const uint8_t LCD_CURSORSHIFT = 0x10;
static const uint8_t LCD_FUNCTIONSET = 0x20;
static const uint8_t LCD_SETCGRAMADDR = 0x40;
static const uint8_t LCD_SETDDRAMADDR = 0x80;
static const uint8_t LCD_BLINKOFF = 0x00;
static const uint8_t LCD_BLINKON = 0x01;
static const uint8_t LCD_CURSOROFF = 0x00;
static const uint8_t LCD_CURSORON = 0x02;
static const uint8_t LCD_DISPLAYON = 0x04;
static const uint8_t LCD_DISPLAYOFF = 0x00;
static const uint8_t LCD_ENTRYSHIFTDEC = 0x00;
static const uint8_t LCD_ENTRYSHIFTINC = 0x01;
static const uint8_t LCD_ENTRYRIGHT = 0x00;
static const uint8_t LCD_ENTRYLEFT = 0x02;
typedef struct {
uint8_t address;
uint8_t backlight;
uint8_t function;
uint8_t dispctrl;
uint8_t entrymode;
} lcd_t;
void lcd_init(lcd_t *lcd, uint8_t address);
void lcd_backlight(lcd_t *lcd);
void lcd_no_backlight(lcd_t *lcd);
void lcd_clear(lcd_t *lcd);
void lcd_home(lcd_t *lcd);
void lcd_write(lcd_t *lcd, char c);
void lcd_puts(lcd_t *lcd, char *str);
void lcd_cursor(lcd_t *lcd, uint8_t row, uint8_t col);
#endif /* USER_LCD_H_ */