allow payload callback, allow boot status
This commit is contained in:
parent
ffe55fd978
commit
810c2794f1
|
@ -8,8 +8,8 @@
|
|||
"args": [],
|
||||
"stopAtEntry": false,
|
||||
"externalConsole": true,
|
||||
"cwd": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/src",
|
||||
"program": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/src/build/Debug/outDebug",
|
||||
"cwd": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO",
|
||||
"program": "d:/Git/ESPMegaPRO-v3-SDK/ESPMegaPRO-OS-SDK/lib/ESPMegaPRO/build/Debug/outDebug",
|
||||
"MIMode": "gdb",
|
||||
"miDebuggerPath": "gdb",
|
||||
"setupCommands": [
|
||||
|
|
|
@ -58,6 +58,15 @@ void ESPMegaDisplay::processSerialCommand()
|
|||
{
|
||||
processPageReportPayload();
|
||||
}
|
||||
else {
|
||||
// The payload does not match any of the expected payload types
|
||||
// Pass the payload to the payload callbacks
|
||||
// type, payload, length
|
||||
for (auto const &callback : payload_callbacks)
|
||||
{
|
||||
callback.second(rx_buffer[0], reinterpret_cast<unsigned char*>(&rx_buffer[1]), rx_buffer_index - 4);;
|
||||
}
|
||||
}
|
||||
this->rx_buffer_index = 0;
|
||||
}
|
||||
|
||||
|
@ -495,3 +504,24 @@ void ESPMegaDisplay::unregisterPageChangeCallback(uint16_t handle)
|
|||
{
|
||||
page_change_callbacks.erase(handle);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Registers a callback function for payloads.
|
||||
* @param callback The callback function.
|
||||
* @return The handle of the callback function.
|
||||
*/
|
||||
uint16_t ESPMegaDisplay::registerPayloadCallback(std::function<void(uint8_t, uint8_t*, uint8_t)> callback)
|
||||
{
|
||||
uint16_t handle = payload_callbacks.size();
|
||||
payload_callbacks[handle] = callback;
|
||||
return handle;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Unregisters a callback function for payloads.
|
||||
* @param handle The handle of the callback function.
|
||||
*/
|
||||
void ESPMegaDisplay::unregisterPayloadCallback(uint16_t handle)
|
||||
{
|
||||
payload_callbacks.erase(handle);
|
||||
}
|
|
@ -30,6 +30,8 @@ class ESPMegaDisplay
|
|||
void unregisterTouchCallback(uint16_t handle);
|
||||
uint16_t registerPageChangeCallback(std::function<void(uint8_t)> callback);
|
||||
void unregisterPageChangeCallback(uint16_t handle);
|
||||
uint16_t registerPayloadCallback(std::function<void(uint8_t, uint8_t*, uint8_t)> callback);
|
||||
void unregisterPayloadCallback(uint16_t handle);
|
||||
|
||||
protected:
|
||||
uint8_t currentPage;
|
||||
|
@ -48,4 +50,5 @@ class ESPMegaDisplay
|
|||
HardwareSerial *displayAdapter;
|
||||
std::map<uint16_t, std::function<void(uint8_t, uint8_t, uint8_t)>> touch_callbacks;
|
||||
std::map<uint16_t, std::function<void(uint8_t)>> page_change_callbacks;
|
||||
std::map<uint16_t, std::function<void(uint8_t, uint8_t*, uint8_t)>> payload_callbacks;
|
||||
};
|
|
@ -872,3 +872,15 @@ void InternalDisplay::handleACStateChange(uint8_t mode, uint8_t fan_speed, uint8
|
|||
// Update the AC state
|
||||
this->refreshAC();
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Set the boot status text
|
||||
*
|
||||
* @param text The text to set
|
||||
*/
|
||||
void InternalDisplay::setBootStatus(const char *text) {
|
||||
this->displayAdapter->print("boot_state.txt=\"");
|
||||
this->displayAdapter->print(text);
|
||||
this->displayAdapter->print("\"");
|
||||
this->sendStopBytes();
|
||||
}
|
|
@ -121,6 +121,7 @@ class InternalDisplay : public ESPMegaDisplay {
|
|||
void refreshPWMAdjustmentId();
|
||||
void refreshNetworkConfig();
|
||||
void refreshMQTTConfig();
|
||||
void setBootStatus(const char* status);
|
||||
void sendIpToDisplay(IPAddress ip);
|
||||
uint8_t pmwAdjustmentPin;
|
||||
// Touch handlers
|
||||
|
|
Loading…
Reference in New Issue