From c0854fd6dfcded99280d137fa29bb97a9ade1239 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 13 Nov 2023 14:36:32 +0700 Subject: [PATCH 1/2] change lcd name --- src/espmega_iot_core.hpp | 2 +- src/{lcd.cpp => espmega_iot_lcd.cpp} | 2 +- src/{lcd.hpp => espmega_iot_lcd.hpp} | 8 +++----- 3 files changed, 5 insertions(+), 7 deletions(-) rename src/{lcd.cpp => espmega_iot_lcd.cpp} (94%) rename src/{lcd.hpp => espmega_iot_lcd.hpp} (55%) diff --git a/src/espmega_iot_core.hpp b/src/espmega_iot_core.hpp index 42582ed..959a19c 100644 --- a/src/espmega_iot_core.hpp +++ b/src/espmega_iot_core.hpp @@ -24,7 +24,7 @@ #include #include #endif -#include "lcd.hpp" +#include "espmega_iot_lcd.hpp" #ifdef ENABLE_CLIMATE_MODULE #include "ir_codes.hpp" diff --git a/src/lcd.cpp b/src/espmega_iot_lcd.cpp similarity index 94% rename from src/lcd.cpp rename to src/espmega_iot_lcd.cpp index bf089c5..6006f45 100644 --- a/src/lcd.cpp +++ b/src/espmega_iot_lcd.cpp @@ -1,5 +1,5 @@ #include -#include +#include void lcd_send_stop_bit() { diff --git a/src/lcd.hpp b/src/espmega_iot_lcd.hpp similarity index 55% rename from src/lcd.hpp rename to src/espmega_iot_lcd.hpp index 321410c..5960241 100644 --- a/src/lcd.hpp +++ b/src/espmega_iot_lcd.hpp @@ -1,11 +1,9 @@ -#ifndef EMG_LCD_ENABLED -#include +#pragma once -#define EMG_LCD_ENABLED +#include void lcd_send_stop_bit(); void lcd_send_command(String command); String lcd_wait_response(); void lcd_reset(); -void lcd_init(); -#endif \ No newline at end of file +void lcd_init(); \ No newline at end of file From 91fb96f5966ad7b999c2a262a0cc01a4d4758acd Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Mon, 13 Nov 2023 15:11:10 +0700 Subject: [PATCH 2/2] lcd upload function --- src/espmega_iot_lcd.cpp | 36 ++++++++++++++++++++++++++++++++++++ src/espmega_iot_lcd.hpp | 7 ++++++- 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/src/espmega_iot_lcd.cpp b/src/espmega_iot_lcd.cpp index 6006f45..d4c89b9 100644 --- a/src/espmega_iot_lcd.cpp +++ b/src/espmega_iot_lcd.cpp @@ -34,4 +34,40 @@ void lcd_init() lcd_reset(); delay(750); #endif +} + +bool lcd_upload_start(size_t size) +{ + Serial.begin(115200); + lcd_send_stop_bit(); + Serial.print("rest"); + lcd_send_stop_bit(); + Serial.print("connect"); + lcd_send_stop_bit(); + delay(1000); + Serial.print("whmi-wri 1024,115200,res0"); + lcd_send_stop_bit(); + lcd_wait_ack(); +} +bool lcd_upload_write(uint8_t *data, size_t size) +{ + for (int i = 0; i < size; i++) + { + Serial.write(data[i]); + } +} + +bool lcd_wait_ack() +{ + bool data_ok = false; + for (int i; i < 50; i++) + { + if (Serial.read() == 0x05) + { + data_ok = true; + break; + } + delay(100); + } + return data_ok; } \ No newline at end of file diff --git a/src/espmega_iot_lcd.hpp b/src/espmega_iot_lcd.hpp index 5960241..0e70e3c 100644 --- a/src/espmega_iot_lcd.hpp +++ b/src/espmega_iot_lcd.hpp @@ -2,8 +2,13 @@ #include + void lcd_send_stop_bit(); void lcd_send_command(String command); String lcd_wait_response(); void lcd_reset(); -void lcd_init(); \ No newline at end of file +void lcd_init(); + +bool lcd_upload_start(size_t size); +bool lcd_upload_write(uint8_t* data, size_t size); +bool lcd_wait_ack(); \ No newline at end of file