working begin routine

This commit is contained in:
Siwat Sirichai 2024-01-15 15:19:49 +07:00
parent 05236797c2
commit fdf32d8503
8 changed files with 510 additions and 415 deletions

View file

@ -679,7 +679,7 @@ bool ESPMegaDisplay::beginUpdate(size_t size)
bool ESPMegaDisplay::writeUpdate(uint8_t *data, size_t size)
{
// Check if the data size is too large
if(size>4096)
if (size > 4096)
{
ESP_LOGE("ESPMegaDisplay", "LCD Update Subroutine failed to write data, data size is too large.");
return false;
@ -689,23 +689,30 @@ bool ESPMegaDisplay::writeUpdate(uint8_t *data, size_t size)
this->displayAdapter->read();
// Write the data
for (int i = 0; i < size; i++)
this->displayAdapter->write(data[i]);
// After writing the data, the display will send a 0x05 byte
// If it does, return true, otherwise return false
unsigned long startTime = millis();
while (millis() - startTime < OTA_WAIT_TIMEOUT)
{
if (this->displayAdapter->available())
this->displayAdapter->write(data[i]);
// After every 4096 bytes, we have to wait for the display to send a 0x05 byte
// If it doesn't, return false
otaBytesWritten += size;
if (otaBytesWritten % 4096 == 0)
{
if (this->displayAdapter->read() == 0x05)
unsigned long startTime = millis();
while (millis() - startTime < OTA_WAIT_TIMEOUT)
{
ESP_LOGV("ESPMegaDisplay", "LCD Update Subroutine is ready to receive data.");
return true;
if (this->displayAdapter->available())
{
if (this->displayAdapter->read() == 0x05)
{
ESP_LOGV("ESPMegaDisplay", "LCD Update Subroutine is ready to receive data.");
return true;
}
}
}
ESP_LOGE("ESPMegaDisplay", "LCD Update Subroutine failed to write data.");
return false;
}
}
ESP_LOGE("ESPMegaDisplay", "LCD Update Subroutine failed to write data.");
return false;
return true;
}
/**