diff --git a/components/TFT_eSPI b/components/TFT_eSPI index 5ca80d8..62c4a15 160000 --- a/components/TFT_eSPI +++ b/components/TFT_eSPI @@ -1 +1 @@ -Subproject commit 5ca80d8cf80623282e10a0506ffbee8426d59bfb +Subproject commit 62c4a15b6b2b67f924a9004c511adaada2c943dc diff --git a/main/accessors/settingsaccessors.h b/main/accessors/settingsaccessors.h index 7b9c7a5..e51e760 100644 --- a/main/accessors/settingsaccessors.h +++ b/main/accessors/settingsaccessors.h @@ -44,7 +44,8 @@ struct BleFenceEnabledAccessor : public NewSettingsAccessor { ConfigWrappe // Cloud struct CloudEnabledAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.cloudSettings.cloudEnabled; } }; struct CloudTransmitTimeoutAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.cloudSettings.cloudTransmitTimeout; } }; -struct CloudModeAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.cloudSettings.cloudMode; } }; +struct CloudSendStatisticsAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.cloudSettings.sendStatistic; } }; +struct CloudSendScreenAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.cloudSettings.sendScreen; } }; // Time //struct TimezoneOffsetAccessor : public NewSettingsAccessor { ConfigWrapper &getConfig() const override { return configs.timezoneOffset; } }; diff --git a/main/cloud.cpp b/main/cloud.cpp index afda88c..405ff59 100644 --- a/main/cloud.cpp +++ b/main/cloud.cpp @@ -40,6 +40,7 @@ std::optional lastHeartbeat; std::optional lastOtaStatus; bool hasAnnouncedItself{}; +espchrono::millis_clock::time_point isSendingNvs{}; constexpr const char * const TAG = "BOBBYCLOUD"; constexpr const auto json_document_size = 1024; @@ -69,7 +70,6 @@ typename std::enable_if< !std::is_same_v && !std::is_same_v && !std::is_same_v && - !std::is_same_v && !std::is_same_v && !std::is_same_v , void>::type @@ -151,7 +151,6 @@ typename std::enable_if< std::is_same_v || std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v , void>::type toArduinoJson(std::string_view key, T value, T defaultValue, JsonObject &object) @@ -195,7 +194,6 @@ typename std::enable_if< !std::is_same_v && !std::is_same_v && !std::is_same_v && - !std::is_same_v && !std::is_same_v && !std::is_same_v , tl::expected>::type @@ -285,7 +283,6 @@ typename std::enable_if< std::is_same_v || std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v , tl::expected>::type set_config(ConfigWrapper &config, std::string_view newValue) @@ -559,7 +556,7 @@ void cloudHeartbeat() void initCloud() { if (configs.cloudSettings.cloudEnabled.value() && - !configs.cloudUrl.value().empty() && configs.cloudSettings.cloudMode.value() != CloudMode::INACTIVE && wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED) + !configs.cloudUrl.value().empty() && wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED) { createCloud(); if (!cloudClient) @@ -576,7 +573,7 @@ void updateCloud() const auto now = espchrono::millis_clock::now(); - if (configs.cloudSettings.cloudMode.value() == CloudMode::STATISTICS || configs.cloudSettings.cloudMode.value() == CloudMode::STATISTICS_AND_REMOTE_DISPLAY) + if (configs.cloudSettings.sendStatistic.value()) { if (!lastCloudCollect || now - *lastCloudCollect >= std::chrono::milliseconds{ configs.boardcomputerHardware.timersSettings.cloudCollectRate.value()}) { @@ -629,7 +626,7 @@ void cloudCollect() return; } - if (configs.cloudSettings.cloudMode.value() == CloudMode::STATISTICS || configs.cloudSettings.cloudMode.value() == CloudMode::STATISTICS_AND_REMOTE_DISPLAY) + if (configs.cloudSettings.sendStatistic.value()) { if (cloudBuffer.empty()) cloudBuffer = '['; @@ -708,71 +705,68 @@ void cloudCollect() void cloudSend() { - if (configs.cloudSettings.cloudEnabled.value() && - !configs.cloudUrl.value().empty() && (configs.cloudSettings.cloudMode.value() == CloudMode::STATISTICS || configs.cloudSettings.cloudMode.value() == CloudMode::STATISTICS_AND_REMOTE_DISPLAY) || ((configs.cloudSettings.cloudMode.value() == CloudMode::REMOTE_DISPLAY || configs.cloudSettings.cloudMode.value() == CloudMode::STATISTICS_AND_REMOTE_DISPLAY) && !hasAnnouncedItself)) + if (!configs.cloudSettings.cloudEnabled.value()) { - if (!cloudClient) - { - if (espchrono::ago(lastCreateTry) < 10s) - return; - createCloud(); - return; - } - - if (!cloudStarted) - { - if (espchrono::ago(lastStartTry) < 10s) - return; - - if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED) - return; - - startCloud(); - } - - if (!cloudStarted) - return; - - if (!cloudClient.is_connected()) - return; - - if (cloudBuffer.empty() && hasAnnouncedItself) - return; - - cloudBuffer += ']'; - - const auto timeout = std::chrono::ceil(espchrono::milliseconds32{configs.cloudSettings.cloudTransmitTimeout.value()}).count(); - - if (!hasAnnouncedItself && configs.cloudSettings.cloudEnabled.value()) - { - std::string helloWorld = getLoginMessage(); - ESP_LOGW(TAG, "=====> %s", helloWorld.c_str()); - const auto written_helloWorld = cloudClient.send_text(helloWorld, timeout); - if (written_helloWorld == helloWorld.size()) - hasAnnouncedItself = true; - } - - const auto written = cloudClient.send_text(cloudBuffer, timeout); - - if (written < 0) - { - ESP_LOGE("BOBBY", "cloudClient.send_text() failed with %i", written); - } - else if (written != cloudBuffer.size()) - { - ESP_LOGE("BOBBY", "websocket sent size mismatch, sent=%i, expected=%i", written, cloudBuffer.size()); - } - - cloudBuffer.clear(); + if (cloudClient) + destroyCloud(); + return; } - else if (cloudClient && !configs.cloudSettings.cloudEnabled.value()) - { - destroyCloud(); - } - else if(!cloudClient || !cloudStarted) + + if (!cloudClient) { initCloud(); + return; } + + if (configs.cloudUrl.value().empty()) + return; + + if (!configs.cloudSettings.sendStatistic.value() && !configs.cloudSettings.sendScreen.value()) + return; + + if (!cloudStarted) + { + if (espchrono::ago(lastStartTry) < 10s) + return; + + if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED) + return; + + startCloud(); + return; + } + + if (!cloudClient.is_connected()) + return; + + if (cloudBuffer.empty() && hasAnnouncedItself) + return; + + cloudBuffer += ']'; + + const auto timeout = std::chrono::ceil(espchrono::milliseconds32{configs.cloudSettings.cloudTransmitTimeout.value()}).count(); + + if (!hasAnnouncedItself && configs.cloudSettings.cloudEnabled.value()) + { + std::string helloWorld = getLoginMessage(); + ESP_LOGW(TAG, "=====> %s", helloWorld.c_str()); + const auto written_helloWorld = cloudClient.send_text(helloWorld, timeout); + if (written_helloWorld == helloWorld.size()) + hasAnnouncedItself = true; + } + + const auto written = cloudClient.send_text(cloudBuffer, timeout); + + if (written < 0) + { + ESP_LOGE("BOBBY", "cloudClient.send_text() failed with %i", written); + } + else if (written != cloudBuffer.size()) + { + ESP_LOGE("BOBBY", "websocket sent size mismatch, sent=%i, expected=%i", written, cloudBuffer.size()); + } + + cloudBuffer.clear(); } std::string getLoginMessage() @@ -785,56 +779,37 @@ std::string getLoginMessage() void cloudSendDisplay(std::string_view data) { - if (configs.cloudSettings.cloudEnabled.value() && - !configs.cloudUrl.value().empty() && configs.cloudSettings.cloudMode.value() != CloudMode::INACTIVE) + static std::string screenBuffer; + static uint64_t msg_id{0}; + + if (!cloudStarted || !cloudClient || !cloudClient.is_connected() || espchrono::ago(isSendingNvs) < 4s) + return; + + /* custom menu display handling + if (!espgui::currentDisplay) + return; + + if (const auto &menuDisplay = espgui::currentDisplay->asMenuDisplay(); menuDisplay) { - if (!cloudClient) - { - if (espchrono::ago(lastCreateTry) < 10s) - return; - createCloud(); - } - if (!cloudClient) - return; - - if (!cloudStarted) - { - if (espchrono::ago(lastStartTry) < 10s) - return; - - if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED) - return; - - startCloud(); - } - if (!cloudStarted) - return; - - if (!cloudClient.is_connected()) - return; - - auto timeout = std::chrono::ceil(espchrono::milliseconds32{configs.cloudSettings.cloudTransmitTimeout.value()}).count(); - int written; - - if (hasAnnouncedItself) - written = cloudClient.send_text(data, timeout); - else - return; - ESP_LOGW(TAG, "%s", fmt::format("{}", data).c_str()); - - if (written < 0) - { - ESP_LOGE("BOBBY", "cloudClient.send_text() failed with %i", written); - hasAnnouncedItself = false; - } - else if (written != data.size()) - { - ESP_LOGE("BOBBY", "websocket sent size mismatch, sent=%i, expected=%i", written, data.size()); - } + // custom handle menu display + return; } - else if (cloudClient && !configs.cloudSettings.cloudEnabled.value()) + */ + + // fill 1024 bytes with the data + screenBuffer += std::string{data} + '\u0000'; + + if (screenBuffer.length() > 1024) { - destroyCloud(); + // send data + const auto timeout = std::chrono::ceil( + espchrono::milliseconds32{configs.cloudSettings.cloudTransmitTimeout.value()}).count(); + cloudClient.send_text(screenBuffer, timeout); + + // clear buffer + screenBuffer.clear(); + ESP_LOGI(TAG, "sent screen data %lu", msg_id); + msg_id++; } } @@ -896,6 +871,7 @@ void cloudEventHandler(void *event_handler_arg, esp_event_base_t event_base, int } const auto id = _id.as(); doc.clear(); + isSendingNvs = espchrono::millis_clock::now(); send_config(id); return; } @@ -1038,6 +1014,10 @@ void cloudEventHandler(void *event_handler_arg, esp_event_base_t event_base, int buttonRequest = button; } + else if (type == "initScreen") + { + initScreenRequest = true; + } else { ESP_LOGE(TAG, "unknown type: %s", type.c_str()); diff --git a/main/cloud.h b/main/cloud.h index bd2412e..a8fc3d5 100644 --- a/main/cloud.h +++ b/main/cloud.h @@ -16,13 +16,6 @@ extern espchrono::millis_clock::time_point lastCreateTry; extern espchrono::millis_clock::time_point lastStartTry; extern std::string cloudBuffer; -#define CloudModeValues(x) \ - x(INACTIVE) \ - x(STATISTICS) \ - x(REMOTE_DISPLAY) \ - x(STATISTICS_AND_REMOTE_DISPLAY) -DECLARE_BOBBYTYPESAFE_ENUM(CloudMode, : uint8_t, CloudModeValues) - void createCloud(); void destroyCloud(); void startCloud(); diff --git a/main/configutils_bobby.h b/main/configutils_bobby.h index 48faa3c..0b3006b 100644 --- a/main/configutils_bobby.h +++ b/main/configutils_bobby.h @@ -13,7 +13,6 @@ IMPLEMENT_NVS_GET_SET_ENUM(BatteryCellType) IMPLEMENT_NVS_GET_SET_ENUM(BobbyQuickActions) -IMPLEMENT_NVS_GET_SET_ENUM(CloudMode) IMPLEMENT_NVS_GET_SET_ENUM(HandbremseMode) IMPLEMENT_NVS_GET_SET_ENUM(LedstripAnimation) IMPLEMENT_NVS_GET_SET_ENUM(OtaAnimationModes) diff --git a/main/configwrapper_bobby.cpp b/main/configwrapper_bobby.cpp index 7214090..b58f53e 100644 --- a/main/configwrapper_bobby.cpp +++ b/main/configwrapper_bobby.cpp @@ -6,7 +6,6 @@ INSTANTIATE_CONFIGWRAPPER_TEMPLATES(BatteryCellType) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(BobbyQuickActions) -INSTANTIATE_CONFIGWRAPPER_TEMPLATES(CloudMode) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(HandbremseMode) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(LedstripAnimation) INSTANTIATE_CONFIGWRAPPER_TEMPLATES(OtaAnimationModes) diff --git a/main/displays/menus/cloudsettingsmenu.cpp b/main/displays/menus/cloudsettingsmenu.cpp index 8f50037..8b2415c 100644 --- a/main/displays/menus/cloudsettingsmenu.cpp +++ b/main/displays/menus/cloudsettingsmenu.cpp @@ -22,7 +22,8 @@ namespace { constexpr char TEXT_CLOUDSETTINGS[] = "Cloud settings"; constexpr char TEXT_CLOUDENABLED[] = "Cloud enabled"; constexpr char TEXT_CLOUDTRANSMITTIMEOUT[] = "Transmit timeout"; -constexpr char TEXT_CLOUDMODE[] = "Cloud mode"; +constexpr char TEXT_SENDSTATISTICS[] = "Send Statistics"; +constexpr char TEXT_SENDSCREEN[] = "Send Screen"; constexpr char TEXT_CLOUDCOLLECTRATE[] = "Cloud collect rate"; constexpr char TEXT_CLOUDSENDRATE[] = "Cloud send rate"; constexpr char TEXT_BACK[] = "Back"; @@ -67,11 +68,12 @@ CloudSettingsMenu::CloudSettingsMenu() { constructMenuItem, BobbyCheckbox, CloudEnabledAccessor>>(); constructMenuItem, PushScreenAction>>(); + constructMenuItem, BobbyCheckbox, CloudSendStatisticsAccessor>>(); + constructMenuItem, BobbyCheckbox, CloudSendScreenAccessor>>(); constructMenuItem>(); constructMenuItem>(); constructMenuItem>(); constructMenuItem>(); - constructMenuItem>(&configs.cloudSettings.cloudMode); constructMenuItem, PushScreenAction>>(); constructMenuItem, PushScreenAction>>(); constructMenuItem, PushScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); diff --git a/main/globals.cpp b/main/globals.cpp index 5f00590..30ec1b1 100644 --- a/main/globals.cpp +++ b/main/globals.cpp @@ -41,6 +41,7 @@ SettingsPersister settingsPersister; std::atomic rawButtonRequest; std::atomic buttonRequest; +bool initScreenRequest{false}; Controllers controllers; diff --git a/main/globals.h b/main/globals.h index f5e2460..1a92e71 100644 --- a/main/globals.h +++ b/main/globals.h @@ -69,6 +69,7 @@ extern SettingsPersister settingsPersister; extern std::atomic rawButtonRequest; extern std::atomic buttonRequest; +extern bool initScreenRequest; class Controllers : public std::array { diff --git a/main/newsettings.h b/main/newsettings.h index 074547b..cb6db84 100644 --- a/main/newsettings.h +++ b/main/newsettings.h @@ -370,8 +370,9 @@ public: struct { ConfigWrapperLegacy cloudEnabled {false, DoReset, {}, "cloudEnabled" }; ConfigWrapperLegacy cloudTransmitTimeout{10, DoReset, {}, "clodTransmTmout" }; - ConfigWrapperLegacy cloudMode {CloudMode::INACTIVE, DoReset, {}, "cloudMode" }; ConfigWrapperLegacy cloudKey {std::string{}, DoReset, {}, "cloudKey" }; + ConfigWrapperLegacy sendStatistic {false, DoReset, {}, "cloudSendStats" }; + ConfigWrapperLegacy sendScreen {false, DoReset, {}, "cloudSendScreen" }; } cloudSettings; struct { @@ -713,8 +714,9 @@ public: \ x(cloudSettings.cloudEnabled) \ x(cloudSettings.cloudTransmitTimeout) \ - x(cloudSettings.cloudMode) \ x(cloudSettings.cloudKey) \ + x(cloudSettings.sendStatistic) \ + x(cloudSettings.sendScreen) \ \ x(udpCloudSettings.udpUid) \ x(udpCloudSettings.udpCloudEnabled) \ diff --git a/main/remotedisplaywebsocket.cpp b/main/remotedisplaywebsocket.cpp index 892afda..e69de29 100644 --- a/main/remotedisplaywebsocket.cpp +++ b/main/remotedisplaywebsocket.cpp @@ -1,29 +0,0 @@ -#include "remotedisplaywebsocket.h" -/* -// local includes -#include "cloud.h" - -void handleDrawPixel(uint16_t x, uint16_t y, uint16_t color) -{ -} - -void handleDrawRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) -{ - cloudSendDisplay(fmt::format("{\"type\":\"drawRect\",\"x\":{},\"y\":{},\"w\":{},\"h\":{},\"C\":\"{}\"}", x, y, width, height, color)); -} - -void handleFillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) -{ - cloudSendDisplay(fmt::format("{\"type\":\"fillRect\",\"x\":{},\"y\":{},\"w\":{},\"h\":{},\"C\":\"{}\"}", x, y, width, height, color)); -} - -void handleDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) -{ - cloudSendDisplay(fmt::format("{\"type\":\"drawLine\",\"x1\":{},\"y1\":{},\"x2\":{},\"y2\":{},\"C\":\"{}\"}", x1, y1, x2, y2, color)); -} - -void handleFillScreen(uint16_t color) -{ - cloudSendDisplay(fmt::format("{\"type\":\"fillScreen\",\"C\":\"{}\"}", color)); -} -*/ diff --git a/main/remotedisplaywebsocket.h b/main/remotedisplaywebsocket.h index b3c8e96..2cbd74d 100644 --- a/main/remotedisplaywebsocket.h +++ b/main/remotedisplaywebsocket.h @@ -1,39 +1,115 @@ #pragma once -// system includes -#include -#include +// 3rdparty lib includes #include -void cloudSendDisplay(std::string_view data); +// local includes +#include "cloud.h" -void handleDrawPixel(uint16_t x, uint16_t y, uint16_t color); -void handleDrawRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color); -void handleFillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color); -void handleDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color); -void handleFillScreen(uint16_t color); +#include "esp_log.h" -void handleDrawPixel(uint16_t x, uint16_t y, uint16_t color) +namespace remotedisplay { +void drawCentreString(std::string_view string, int32_t x, int32_t y, uint8_t font) { - cloudSendDisplay(fmt::format("{{\"type\":\"drawPixel\",\"x\":{},\"y\":{},\"C\":\"{}\"}}", x, y, color)); + cloudSendDisplay(fmt::format("_dcstr {} {} {} {}", x, y, string, font)); } -void handleDrawRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) +void drawChar(int32_t x, int32_t y, uint16_t c, uint16_t color, uint16_t bg, uint8_t size) { - cloudSendDisplay(fmt::format("{{\"type\":\"drawRect\",\"x\":{},\"y\":{},\"w\":{},\"h\":{},\"C\":\"{}\"}}", x, y, width, height, color)); + cloudSendDisplay(fmt::format("_dc {} {} {} {} {}", x, y, c, color, bg, size)); } -void handleFillRect(uint16_t x, uint16_t y, uint16_t width, uint16_t height, uint16_t color) +void drawCircle(int32_t x, int32_t y, int32_t r, uint32_t color) { - cloudSendDisplay(fmt::format("{{\"type\":\"fillRect\",\"x\":{},\"y\":{},\"w\":{},\"h\":{},\"C\":\"{}\"}}", x, y, width, height, color)); + cloudSendDisplay(fmt::format("_dcirc {} {} {} {}", x, y, r, color)); } -void handleDrawLine(uint16_t x1, uint16_t y1, uint16_t x2, uint16_t y2, uint16_t color) +void drawEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color) { - cloudSendDisplay(fmt::format("{{\"type\":\"drawLine\",\"x1\":{},\"y1\":{},\"x2\":{},\"y2\":{},\"C\":\"{}\"}}", x1, y1, x2, y2, color)); + cloudSendDisplay(fmt::format("_dellip {} {} {} {} {}", x, y, rx, ry, color)); } -void handleFillScreen(uint16_t color) +void drawFastHLine(int32_t x, int32_t y, int32_t w, uint16_t color) { - cloudSendDisplay(fmt::format("{{\"type\":\"fillScreen\",\"C\":\"{}\"}}", color)); + cloudSendDisplay(fmt::format("_dhl {} {} {} {}", x, y, w, color)); } + +void drawFastVLine(int32_t x, int32_t y, int32_t h, uint16_t color) +{ + cloudSendDisplay(fmt::format("_dvl {} {} {} {}", x, y, h, color)); +} + +void drawLine(int32_t xs, int32_t ys, int32_t xe, int32_t ye, uint16_t color) +{ + cloudSendDisplay(fmt::format("_dl {} {} {} {} {}", xs, ys, xe, ye, color)); +} + +void drawPixel(int32_t x, int32_t y, uint16_t color) +{ + return; // wont support + cloudSendDisplay(fmt::format("_dp {} {} {}", x, y, color)); +} + +void drawRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color) +{ + ESP_LOGI("remotedisplay", "drawRect"); + cloudSendDisplay(fmt::format("_dr {} {} {} {} {}", x, y, w, h, color)); +} + +void drawRightString(std::string_view string, int32_t x, int32_t y, uint8_t font) +{ + cloudSendDisplay(fmt::format("_drs {} {} {} {}", x, y, string, font)); +} + +void drawRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color) +{ + cloudSendDisplay(fmt::format("_drr {} {} {} {} {} {}", x, y, w, h, radius, color)); +} + +void drawString(std::string_view string, int32_t poX, int32_t poY, uint8_t font) +{ + cloudSendDisplay(fmt::format("_ds {} {} {} {}", poX, poY, string, font)); +} + +void drawSunkenRect(int32_t x, int32_t y, int32_t w, int32_t h, uint32_t color0, uint32_t color1, uint32_t color2) +{ + cloudSendDisplay(fmt::format("_dsr {} {} {} {} {} {} {}", x, y, w, h, color0, color1, color2)); +} + +void drawTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color) +{ + cloudSendDisplay(fmt::format("_dt {} {} {} {} {} {} {}", x1, y1, x2, y2, x3, y3, color)); +} + + +void fillCircle(int32_t x, int32_t y, int32_t r, uint32_t color) +{ + cloudSendDisplay(fmt::format("_fcirc {} {} {} {}", x, y, r, color)); +} + +void fillEllipse(int16_t x, int16_t y, int32_t rx, int32_t ry, uint16_t color) +{ + cloudSendDisplay(fmt::format("_fellip {} {} {} {} {}", x, y, rx, ry, color)); +} + +void fillRect(int32_t x, int32_t y, int32_t w, int32_t h, uint16_t color) +{ + cloudSendDisplay(fmt::format("_fr {} {} {} {} {}", x, y, w, h, color)); +} + +void fillRoundRect(int32_t x, int32_t y, int32_t w, int32_t h, int32_t radius, uint32_t color) +{ + cloudSendDisplay(fmt::format("_frr {} {} {} {} {} {}", x, y, w, h, radius, color)); +} + +void fillScreen(uint32_t color) +{ + cloudSendDisplay(fmt::format("_fs {}", color)); +} + +void fillTriangle(int32_t x1,int32_t y1, int32_t x2,int32_t y2, int32_t x3,int32_t y3, uint32_t color) +{ + cloudSendDisplay(fmt::format("_ft {} {} {} {} {} {} {}", x1, y1, x2, y2, x3, y3, color)); +} + +} // namespace remotedisplay diff --git a/main/screens.cpp b/main/screens.cpp index 6ab6bbf..e1b4330 100644 --- a/main/screens.cpp +++ b/main/screens.cpp @@ -56,6 +56,12 @@ void updateDisplay() currentDisplay->buttonReleased(btn); buttonRequest = -1; } + + if (initScreenRequest && currentDisplay) + { + currentDisplay->initScreen(); + initScreenRequest = false; + } } void redrawDisplay() diff --git a/main/typeutils.h b/main/typeutils.h index aa0fe4b..5e331fe 100644 --- a/main/typeutils.h +++ b/main/typeutils.h @@ -43,7 +43,6 @@ DEFINE_FOR_TYPE(OtaAnimationModes) DEFINE_FOR_TYPE(LedstripAnimation) DEFINE_FOR_TYPE(HandbremseMode) DEFINE_FOR_TYPE(BobbyQuickActions) -DEFINE_FOR_TYPE(CloudMode) DEFINE_FOR_TYPE(BatteryCellType) DEFINE_FOR_TYPE(wifi_auth_mode_t) DEFINE_FOR_TYPE(wifi_stack::mac_t) diff --git a/main/webserver_newsettings.cpp b/main/webserver_newsettings.cpp index 0d38182..8ae9d91 100644 --- a/main/webserver_newsettings.cpp +++ b/main/webserver_newsettings.cpp @@ -52,7 +52,6 @@ typename std::enable_if< !std::is_same_v && !std::is_same_v && !std::is_same_v && - !std::is_same_v && !std::is_same_v , void>::type showInputForSetting(std::string_view key, T value, std::string &body) @@ -206,7 +205,6 @@ typename std::enable_if< std::is_same_v || std::is_same_v || std::is_same_v || - std::is_same_v || std::is_same_v , void>::type showInputForSetting(std::string_view key, T value, std::string &body) @@ -355,7 +353,6 @@ typename std::enable_if< !std::is_same_v && !std::is_same_v && !std::is_same_v && - !std::is_same_v && !std::is_same_v , tl::expected>::type saveSetting(ConfigWrapper &config, std::string_view newValue) @@ -443,8 +440,7 @@ typename std::enable_if< std::is_same_v || std::is_same_v || std::is_same_v || - std::is_same_v || - std::is_same_v + std::is_same_v , tl::expected>::type saveSetting(ConfigWrapper &config, std::string_view newValue) {