From 75e645eebf47dead41f4258a5eac3412d2aefbc7 Mon Sep 17 00:00:00 2001 From: Christian Lind Vie Madsen Date: Thu, 1 Aug 2024 16:42:56 +0200 Subject: [PATCH] commands needs double check.. --- lcd_hd44780.c | 30 ++++++++++++++++++++++++++---- lcd_hd44780.h | 9 +++++---- 2 files changed, 31 insertions(+), 8 deletions(-) diff --git a/lcd_hd44780.c b/lcd_hd44780.c index cf608a7..8183196 100644 --- a/lcd_hd44780.c +++ b/lcd_hd44780.c @@ -1,5 +1,8 @@ #include "lcd_hd44780.h" #include + + + void lcd_hd44780_writeToDisp(lcd_hd44780_t *inst){ inst->setGetGpio_event(&(inst->gpio_data),LCD_HD44780_SET); @@ -43,6 +46,25 @@ static void lcd_writeCmd_disp(lcd_hd44780_t *inst, hd44780_cmd_t cmd, hd44780_se inst->setGetGpio_event(&(inst->gpio_data),getSet); +} + +void lcd_hd44780_initDisp(lcd_hd44780_t *inst){ + + // Wait for more than 15ms after VCC rise.. + // Delay(15) + lcd_writeCmd_disp(inst, LCD_HD44780_FUNCTION_SET,LCD_HD44780_SET); + + // Wait for 4.1ms.. + // Delay(4) + + lcd_writeCmd_disp(inst, LCD_HD44780_DISP_ONOFF_CTL,LCD_HD44780_SET); + + // delay 100us + + lcd_writeCmd_disp(inst, LCD_HD44780_ENTRY_MODE,LCD_HD44780_SET); + + + } void lcd_hd44780_regGpioEvt(lcd_hd44780_t *inst, setGet_Gpio_Event_fpt getGpioEvt_fpt){ @@ -64,16 +86,16 @@ void lcd_hd44780_init(lcd_hd44780_t *inst, lcd_hd44780_bitmode bit_mode){ //inst->gpio_data = 0x00; inst->bit_mode = bit_mode; - +/* inst->gpio_data.data_bus = 0x0; inst->gpio_data.e_pin = 0x0; inst->gpio_data.rs_pin = 0x1; inst->gpio_data.rw_pin = 0x0; - inst->setGetGpio_event(&(inst->gpio_data), 1); + inst->setGetGpio_event(&(inst->gpio_data), 1);*/ - - lcd_writeCmd_disp(inst,LCD_HD44780_CLEAR_DISP,LCD_HD44780_SET); + lcd_hd44780_initDisp(inst); + //lcd_writeCmd_disp(inst,LCD_HD44780_CLEAR_DISP,LCD_HD44780_SET); //lcd_writeCmd_disp(inst,LCD_HD44780_DISP_ONOFF_CTL,LCD_HD44780_SET); return; diff --git a/lcd_hd44780.h b/lcd_hd44780.h index 2093536..a1c8ab1 100644 --- a/lcd_hd44780.h +++ b/lcd_hd44780.h @@ -21,15 +21,16 @@ typedef enum { LCD_HD44780_CLEAR_DISP = 0x1, LCD_HD44780_RETURN_HOME = 0x2, - LCD_HD44780_ENTRY_MODE = 0x3, - LCD_HD44780_DISP_ONOFF_CTL = 0x4, + LCD_HD44780_ENTRY_MODE = 0x6, + LCD_HD44780_DISP_ONOFF_CTL = 0xE, LCD_HD44780_CURSOR_SHIFT = 0x6, + LCD_HD44780_FUNCTION_SET = 0x30, }hd44780_cmd_t; typedef enum{ - LCD_HD44780_GET = 0, - LCD_HD44780_SET = 1, + LCD_HD44780_SET = 0, + LCD_HD44780_GET = 1, }hd44780_setGet_t;