Dev commit, probably not working

This commit is contained in:
CommanderRedYT
2022-06-25 21:58:28 +02:00
parent c39033399b
commit e23418dbb0
15 changed files with 209 additions and 183 deletions

View File

@ -44,7 +44,8 @@ struct BleFenceEnabledAccessor : public NewSettingsAccessor<bool> { ConfigWrappe
// Cloud
struct CloudEnabledAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.cloudSettings.cloudEnabled; } };
struct CloudTransmitTimeoutAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.cloudSettings.cloudTransmitTimeout; } };
struct CloudModeAccessor : public NewSettingsAccessor<CloudMode> { ConfigWrapper<CloudMode> &getConfig() const override { return configs.cloudSettings.cloudMode; } };
struct CloudSendStatisticsAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.cloudSettings.sendStatistic; } };
struct CloudSendScreenAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.cloudSettings.sendScreen; } };
// Time
//struct TimezoneOffsetAccessor : public NewSettingsAccessor<int32_t> { ConfigWrapper<int32_t> &getConfig() const override { return configs.timezoneOffset; } };

View File

@ -40,6 +40,7 @@ std::optional<espchrono::millis_clock::time_point> lastHeartbeat;
std::optional<espchrono::millis_clock::time_point> 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<T, OtaAnimationModes> &&
!std::is_same_v<T, LedstripAnimation> &&
!std::is_same_v<T, HandbremseMode> &&
!std::is_same_v<T, CloudMode> &&
!std::is_same_v<T, BobbyQuickActions> &&
!std::is_same_v<T, BatteryCellType>
, void>::type
@ -151,7 +151,6 @@ typename std::enable_if<
std::is_same_v<T, LedstripAnimation> ||
std::is_same_v<T, HandbremseMode> ||
std::is_same_v<T, BobbyQuickActions> ||
std::is_same_v<T, CloudMode> ||
std::is_same_v<T, BatteryCellType>
, 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<T, OtaAnimationModes> &&
!std::is_same_v<T, LedstripAnimation> &&
!std::is_same_v<T, HandbremseMode> &&
!std::is_same_v<T, CloudMode> &&
!std::is_same_v<T, BobbyQuickActions> &&
!std::is_same_v<T, BatteryCellType>
, tl::expected<void, std::string>>::type
@ -285,7 +283,6 @@ typename std::enable_if<
std::is_same_v<T, LedstripAnimation> ||
std::is_same_v<T, HandbremseMode> ||
std::is_same_v<T, BobbyQuickActions> ||
std::is_same_v<T, CloudMode> ||
std::is_same_v<T, BatteryCellType>
, tl::expected<void, std::string>>::type
set_config(ConfigWrapper<T> &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<espcpputils::ticks>(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<espcpputils::ticks>(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<espcpputils::ticks>(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<espcpputils::ticks>(
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<uint32_t>();
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());

View File

@ -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();

View File

@ -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)

View File

@ -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)

View File

@ -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<makeComponent<MenuItem, StaticText<TEXT_CLOUDENABLED>, BobbyCheckbox, CloudEnabledAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDTRANSMITTIMEOUT>, PushScreenAction<CloudTransmitTimeoutChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SENDSTATISTICS>, BobbyCheckbox, CloudSendStatisticsAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SENDSCREEN>, BobbyCheckbox, CloudSendScreenAccessor>>();
constructMenuItem<makeComponent<MenuItem, CloudCreatedText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, CloudStartedText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, CloudConnectedText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, CloudBufferLengthText, DisabledColor, DummyAction>>();
constructMenuItem<SwitchScreenTypeSafeChangeMenuItem<CloudMode, TEXT_CLOUDMODE>>(&configs.cloudSettings.cloudMode);
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDCOLLECTRATE>, PushScreenAction<CloudCollectRateChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDSENDRATE>, PushScreenAction<CloudSendRateChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PushScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();

View File

@ -41,6 +41,7 @@ SettingsPersister settingsPersister;
std::atomic<int8_t> rawButtonRequest;
std::atomic<int8_t> buttonRequest;
bool initScreenRequest{false};
Controllers controllers;

View File

@ -69,6 +69,7 @@ extern SettingsPersister settingsPersister;
extern std::atomic<int8_t> rawButtonRequest;
extern std::atomic<int8_t> buttonRequest;
extern bool initScreenRequest;
class Controllers : public std::array<Controller, 2>
{

View File

@ -370,8 +370,9 @@ public:
struct {
ConfigWrapperLegacy<bool> cloudEnabled {false, DoReset, {}, "cloudEnabled" };
ConfigWrapperLegacy<int16_t> cloudTransmitTimeout{10, DoReset, {}, "clodTransmTmout" };
ConfigWrapperLegacy<CloudMode> cloudMode {CloudMode::INACTIVE, DoReset, {}, "cloudMode" };
ConfigWrapperLegacy<std::string> cloudKey {std::string{}, DoReset, {}, "cloudKey" };
ConfigWrapperLegacy<bool> sendStatistic {false, DoReset, {}, "cloudSendStats" };
ConfigWrapperLegacy<bool> 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) \

View File

@ -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));
}
*/

View File

@ -1,39 +1,115 @@
#pragma once
// system includes
#include <cstdint>
#include <string>
// 3rdparty lib includes
#include <fmt/core.h>
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

View File

@ -56,6 +56,12 @@ void updateDisplay()
currentDisplay->buttonReleased(btn);
buttonRequest = -1;
}
if (initScreenRequest && currentDisplay)
{
currentDisplay->initScreen();
initScreenRequest = false;
}
}
void redrawDisplay()

View File

@ -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)

View File

@ -52,7 +52,6 @@ typename std::enable_if<
!std::is_same_v<T, OtaAnimationModes> &&
!std::is_same_v<T, LedstripAnimation> &&
!std::is_same_v<T, HandbremseMode> &&
!std::is_same_v<T, CloudMode> &&
!std::is_same_v<T, BatteryCellType>
, void>::type
showInputForSetting(std::string_view key, T value, std::string &body)
@ -206,7 +205,6 @@ typename std::enable_if<
std::is_same_v<T, OtaAnimationModes> ||
std::is_same_v<T, LedstripAnimation> ||
std::is_same_v<T, BatteryCellType> ||
std::is_same_v<T, CloudMode> ||
std::is_same_v<T, HandbremseMode>
, void>::type
showInputForSetting(std::string_view key, T value, std::string &body)
@ -355,7 +353,6 @@ typename std::enable_if<
!std::is_same_v<T, OtaAnimationModes> &&
!std::is_same_v<T, LedstripAnimation> &&
!std::is_same_v<T, HandbremseMode> &&
!std::is_same_v<T, CloudMode> &&
!std::is_same_v<T, BobbyQuickActions>
, tl::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
@ -443,8 +440,7 @@ typename std::enable_if<
std::is_same_v<T, OtaAnimationModes> ||
std::is_same_v<T, LedstripAnimation> ||
std::is_same_v<T, HandbremseMode> ||
std::is_same_v<T, BobbyQuickActions> ||
std::is_same_v<T, CloudMode>
std::is_same_v<T, BobbyQuickActions>
, tl::expected<void, std::string>>::type
saveSetting(ConfigWrapper<T> &config, std::string_view newValue)
{