From 8988b59103604e7b5128345997e2438f1f529787 Mon Sep 17 00:00:00 2001 From: Siwat Sirichai Date: Fri, 16 Feb 2024 01:23:59 +0700 Subject: [PATCH] fix internal display pwm adjustment bug --- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaDisplay.cpp | 4 ++-- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaDisplay.hpp | 8 ++++---- ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/InternalDisplay.cpp | 1 + 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaDisplay.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaDisplay.cpp index e80c924..21a4303 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaDisplay.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaDisplay.cpp @@ -507,7 +507,7 @@ void ESPMegaDisplay::reset() * @brief Constructor for the ESPMegaDisplay class. * @param displayAdapter The serial adapter connected to the display. */ -ESPMegaDisplay::ESPMegaDisplay(HardwareSerial *displayAdapter, uint16_t baudRate, uint16_t uploadBaudRate, uint8_t txPin, uint8_t rxPin) +ESPMegaDisplay::ESPMegaDisplay(HardwareSerial *displayAdapter, uint32_t baudRate, uint32_t uploadBaudRate, uint8_t txPin, uint8_t rxPin) { this->baudRate = baudRate; this->uploadBaudRate = uploadBaudRate; @@ -657,7 +657,7 @@ bool ESPMegaDisplay::beginUpdate(size_t size) * @note The baud rate that is used to transfer the data is defined by the uploadBaudRate parameter in the constructor. * @return True if the OTA update is started, false otherwise. */ -bool ESPMegaDisplay::beginUpdate(size_t size, uint16_t baudRate) +bool ESPMegaDisplay::beginUpdate(size_t size, uint32_t baudRate) { if (xSemaphoreTake(this->serialMutex, DISPLAY_MUTEX_TAKE_TIMEOUT) == pdFALSE) { diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaDisplay.hpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaDisplay.hpp index 2337942..3a24707 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaDisplay.hpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/ESPMegaDisplay.hpp @@ -17,7 +17,7 @@ class ESPMegaDisplay { public: - ESPMegaDisplay(HardwareSerial *displayAdapter, uint16_t baudRate, uint16_t uploadBaudRate, uint8_t txPin, uint8_t rxPin); + ESPMegaDisplay(HardwareSerial *displayAdapter, uint32_t baudRate, uint32_t uploadBaudRate, uint8_t txPin, uint8_t rxPin); void begin(); void loop(); void reset(); @@ -39,13 +39,13 @@ class ESPMegaDisplay void giveSerialMutex(); SemaphoreHandle_t serialMutex; bool beginUpdate(size_t size); - bool beginUpdate(size_t size, uint16_t baudRate); + bool beginUpdate(size_t size, uint32_t baudRate); bool writeUpdate(uint8_t* data, size_t size); void endUpdate(); size_t getUpdateBytesWritten(); protected: - uint16_t baudRate; - uint16_t uploadBaudRate; + uint32_t baudRate; + uint32_t uploadBaudRate; uint8_t txPin; uint8_t rxPin; size_t otaBytesWritten; diff --git a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/InternalDisplay.cpp b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/InternalDisplay.cpp index a847b63..2fc8efa 100644 --- a/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/InternalDisplay.cpp +++ b/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/InternalDisplay.cpp @@ -608,6 +608,7 @@ void InternalDisplay::refreshPWMAdjustmentId() this->displayAdapter->print(pmwAdjustmentPin); this->displayAdapter->print("\""); this->sendStopBytes(); + this->giveSerialMutex(); } /**