Merge pull request #119 from bobbycar-graz/rewrite

Move lots of implementations into separate .cpp files
This commit is contained in:
2021-11-02 23:35:22 +01:00
committed by GitHub
145 changed files with 5786 additions and 5548 deletions

View File

@ -14,7 +14,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node: [feedc0de, comred, peter]
node: [feedc0de, comred, peter, mick]
steps:
- name: Checkout (without submodules)
uses: actions/checkout@v2

View File

@ -93,7 +93,6 @@ set(headers
displays/gameoflifedisplay.h
displays/gametrakcalibratedisplay.h
displays/garagedisplay.h
displays/graphdisplay.h
displays/ledstripcolorsdisplay.h
displays/lockscreen.h
displays/menus/aboutmenu.h
@ -148,7 +147,6 @@ set(headers
displays/poweroffdisplay.h
displays/powersupplydisplay.h
displays/spirodisplay.h
displays/splitgraphdisplay.h
displays/starfielddisplay.h
displays/statusdisplay.h
displays/updatedisplay.h
@ -278,7 +276,6 @@ set(sources
displays/gameoflifedisplay.cpp
displays/gametrakcalibratedisplay.cpp
displays/garagedisplay.cpp
displays/graphdisplay.cpp
displays/ledstripcolorsdisplay.cpp
displays/lockscreen.cpp
displays/menus/aboutmenu.cpp
@ -314,9 +311,12 @@ set(sources
displays/menus/mosfetsmenu.cpp
displays/menus/motorfeedbackdebugmenu.cpp
displays/menus/motorstatedebugmenu.cpp
displays/menus/otamenu.cpp
displays/menus/selectotabuildmenu.cpp
displays/menus/presetsmenu.cpp
displays/menus/profilesmenu.cpp
displays/menus/selectbatterytypemenu.cpp
displays/menus/selectbuildservermenu.cpp
displays/menus/selectmodemenu.cpp
displays/menus/settingsmenu.cpp
displays/menus/stationwifisettingsmenu.cpp
@ -330,7 +330,6 @@ set(sources
displays/poweroffdisplay.cpp
displays/powersupplydisplay.cpp
displays/spirodisplay.cpp
displays/splitgraphdisplay.cpp
displays/starfielddisplay.cpp
displays/statusdisplay.cpp
displays/updatedisplay.cpp

View File

@ -0,0 +1,15 @@
#include "bluetoothbeginaction.h"
// local includes
#include "globals.h"
#ifdef FEATURE_BLUETOOTH
void BluetoothBeginAction::triggered()
{
if (!bluetoothSerial.begin(deviceName))
{
//Serial.println("Could not begin bluetooth");
// TODO: better error handling
}
}
#endif

View File

@ -1,23 +1,12 @@
#pragma once
#include "actioninterface.h"
#include "globals.h"
// 3rdparty lib includes
#include <actioninterface.h>
using namespace espgui;
namespace {
#ifdef FEATURE_BLUETOOTH
class BluetoothBeginAction : public virtual ActionInterface
class BluetoothBeginAction : public virtual espgui::ActionInterface
{
public:
void triggered() override
{
if (!bluetoothSerial.begin(deviceName))
{
//Serial.println("Could not begin bluetooth");
// TODO: better error handling
}
}
void triggered() override;
};
#endif
}

View File

@ -9,6 +9,7 @@
using namespace espgui;
namespace {
#ifdef FEATURE_LEDSTRIP
template<int16_t type>
class LedStripSetAnimationAction : public virtual ActionInterface
{
@ -35,4 +36,5 @@ public:
void triggered() override { animation_type = LEDSTRIP_ANIMATION_TYPE_SPEEDSYNCANIMATION; }
};
*/
#endif
}

View File

@ -8,6 +8,7 @@
using namespace espgui;
#ifdef FEATURE_LEDSTRIP
namespace {
class LedstripAnimationBlinkNoneAction : public virtual ActionInterface
{
@ -49,3 +50,4 @@ public:
void triggered() override { blinkAnimation = LEDSTRIP_OVERWRITE_BLINKBOTH; }
};
}
#endif

View File

@ -0,0 +1,26 @@
#include "rebootaction.h"
// esp-idf includes
#include <esp_system.h>
// 3rdparty lib includes
#include <tftinstance.h>
// local includes
#include "globals.h"
#include "texts.h"
void RebootAction::triggered()
{
espgui::tft.fillScreen(TFT_BLACK);
espgui::tft.setTextColor(TFT_YELLOW);
espgui::tft.drawString(TEXT_REBOOT, 5, 5, 4);
espgui::tft.fillRect(0, 34, espgui::tft.width(), 3, TFT_WHITE);
espgui::tft.setTextColor(TFT_WHITE);
espgui::tft.drawString("Rebooting now...", 0, 50, 4);
esp_restart();
}

View File

@ -1,30 +1,12 @@
#pragma once
#include <esp_system.h>
// 3rdparty lib includes
#include "actioninterface.h"
#include "globals.h"
#include "texts.h"
using namespace espgui;
namespace {
class RebootAction : public virtual ActionInterface
class RebootAction : public virtual espgui::ActionInterface
{
public:
void triggered() override
{
tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_YELLOW);
tft.drawString(TEXT_REBOOT, 5, 5, 4);
tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE);
tft.setTextColor(TFT_WHITE);
tft.drawString("Rebooting now...", 0, 50, 4);
esp_restart();
}
void triggered() override;
};
}

View File

@ -0,0 +1 @@
#include "battery.h"

View File

@ -3,10 +3,10 @@
// 3rdparty lib includes
#include <fmt/core.h>
#include <cpptypesafeenum.h>
#include <cpputils.h>
// local includes
#include "globals.h"
#include "cpputils.h"
#define BatteryCellTypeValues(x) \
x(_22P) \
@ -16,91 +16,94 @@
DECLARE_TYPESAFE_ENUM(BatteryCellType, : uint8_t, BatteryCellTypeValues)
namespace {
float mapFloat(float x, float in_min, float in_max, float out_min, float out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}
#define CURVE(higherVoltage,lowerVoltage,fromAh,toAh) if(cellVoltage >= lowerVoltage && cellVoltage <= higherVoltage) return 100 * (expected_ah - mapFloat(cellVoltage, higherVoltage, lowerVoltage, fromAh, toAh)) / expected_ah;
#define CURVE(higherVoltage,lowerVoltage,fromAh,toAh) \
if (cellVoltage >= lowerVoltage && cellVoltage <= higherVoltage) \
return 100 * (expected_ah - cpputils::mapValue<float>(cellVoltage, higherVoltage, lowerVoltage, fromAh, toAh)) / expected_ah;
float getBatteryPercentage(float batVoltage, BatteryCellType cellType)
{
const float cellVoltage = batVoltage / settings.battery.cellsSeries;
switch (cellType) {
case BatteryCellType::_22P: {
const float expected_ah = 2.2;
if(cellVoltage > 4.15){
return 100;
}
CURVE(4.15, 4.04, 0, 0.25)
CURVE(4.04, 3.95, 0.25, 0.5)
CURVE(3.95, 3.86, 0.5, 0.75)
CURVE(3.86, 3.74, 0.75, 1.0)
CURVE(3.74, 3.64, 1.0, 1.25)
CURVE(3.64, 3.59, 1.25, 1.5)
CURVE(3.59, 3.54, 1.5, 1.75)
CURVE(3.54, 3.43, 1.75, 2.0)
CURVE(3.43, 3.35, 2.0, 2.1)
CURVE(3.35, 2.50, 2.1, 2.2)
break;
}
case BatteryCellType::MH1: {
const float expected_ah = 3.2;
if(cellVoltage > 4.15){
return 100;
}
CURVE(4.15, 4.09, 0, 0.25)
CURVE(4.09, 4.04, 0.25, 0.5)
CURVE(4.04, 3.95, 0.5, 0.75)
CURVE(3.95, 3.88, 0.75, 1.0)
CURVE(3.88, 3.79, 1.0, 1.25)
CURVE(3.79, 3.70, 1.25, 1.5)
CURVE(3.70, 3.65, 1.5, 1.75)
CURVE(3.65, 3.60, 1.75, 2.0)
CURVE(3.60, 3.56, 2.0, 2.25)
CURVE(3.56, 3.50, 2.25, 2.5)
CURVE(3.50, 3.40, 2.5, 2.75)
CURVE(3.40, 3.30, 2.75, 3.0)
CURVE(3.30, 2.5, 3.0, 3.2)
break;
}
case BatteryCellType::HG2: {
const float expected_ah = 3.0;
if(cellVoltage > 4.15){
return 100;
}
CURVE(4.15, 4.08, 0, 0.25)
CURVE(4.08, 4.01, 0.25, 0.5)
CURVE(4.01, 3.92, 0.5, 0.75)
CURVE(3.92, 3.84, 0.75, 1.0)
CURVE(3.84, 3.75, 1.0, 1.25)
CURVE(3.75, 3.67, 1.25, 1.5)
CURVE(3.67, 3.62, 1.5, 1.75)
CURVE(3.62, 3.55, 1.75, 2.0)
CURVE(3.55, 3.44, 2.0, 2.25)
CURVE(3.44, 3.30, 2.25, 2.5)
CURVE(3.30, 3.05, 2.5, 2.75)
CURVE(3.05, 2.50, 2.75, 3.0)
break;
}
case BatteryCellType::VTC5: {
const float expected_ah = 2.6;
if(cellVoltage > 4.15){
return 100;
}
CURVE(4.15, 4.08, 0, 0.25)
CURVE(4.08, 3.98, 0.25, 0.5)
CURVE(3.98, 3.89, 0.5, 0.75)
CURVE(3.89, 3.79, 0.75, 1.0)
CURVE(3.79, 3.71, 1.0, 1.25)
CURVE(3.71, 3.64, 1.25, 1.5)
CURVE(3.64, 3.53, 1.5, 1.75)
CURVE(3.53, 3.44, 1.75, 2.0)
CURVE(3.44, 3.20, 2.0, 2.25)
CURVE(3.20, 2.80, 2.25, 2.5)
CURVE(2.80, 2.50, 2.5, 2.60)
break;
}
switch (cellType)
{
case BatteryCellType::_22P:
{
const float expected_ah = 2.2;
if (cellVoltage > 4.15)
return 100;
CURVE(4.15, 4.04, 0, 0.25)
CURVE(4.04, 3.95, 0.25, 0.5)
CURVE(3.95, 3.86, 0.5, 0.75)
CURVE(3.86, 3.74, 0.75, 1.0)
CURVE(3.74, 3.64, 1.0, 1.25)
CURVE(3.64, 3.59, 1.25, 1.5)
CURVE(3.59, 3.54, 1.5, 1.75)
CURVE(3.54, 3.43, 1.75, 2.0)
CURVE(3.43, 3.35, 2.0, 2.1)
CURVE(3.35, 2.50, 2.1, 2.2)
break;
}
case BatteryCellType::MH1:
{
const float expected_ah = 3.2;
if (cellVoltage > 4.15)
return 100;
CURVE(4.15, 4.09, 0, 0.25)
CURVE(4.09, 4.04, 0.25, 0.5)
CURVE(4.04, 3.95, 0.5, 0.75)
CURVE(3.95, 3.88, 0.75, 1.0)
CURVE(3.88, 3.79, 1.0, 1.25)
CURVE(3.79, 3.70, 1.25, 1.5)
CURVE(3.70, 3.65, 1.5, 1.75)
CURVE(3.65, 3.60, 1.75, 2.0)
CURVE(3.60, 3.56, 2.0, 2.25)
CURVE(3.56, 3.50, 2.25, 2.5)
CURVE(3.50, 3.40, 2.5, 2.75)
CURVE(3.40, 3.30, 2.75, 3.0)
CURVE(3.30, 2.5, 3.0, 3.2)
break;
}
case BatteryCellType::HG2:
{
const float expected_ah = 3.0;
if (cellVoltage > 4.15)
return 100;
CURVE(4.15, 4.08, 0, 0.25)
CURVE(4.08, 4.01, 0.25, 0.5)
CURVE(4.01, 3.92, 0.5, 0.75)
CURVE(3.92, 3.84, 0.75, 1.0)
CURVE(3.84, 3.75, 1.0, 1.25)
CURVE(3.75, 3.67, 1.25, 1.5)
CURVE(3.67, 3.62, 1.5, 1.75)
CURVE(3.62, 3.55, 1.75, 2.0)
CURVE(3.55, 3.44, 2.0, 2.25)
CURVE(3.44, 3.30, 2.25, 2.5)
CURVE(3.30, 3.05, 2.5, 2.75)
CURVE(3.05, 2.50, 2.75, 3.0)
break;
}
case BatteryCellType::VTC5:
{
const float expected_ah = 2.6;
if (cellVoltage > 4.15)
return 100;
CURVE(4.15, 4.08, 0, 0.25)
CURVE(4.08, 3.98, 0.25, 0.5)
CURVE(3.98, 3.89, 0.5, 0.75)
CURVE(3.89, 3.79, 0.75, 1.0)
CURVE(3.79, 3.71, 1.0, 1.25)
CURVE(3.71, 3.64, 1.25, 1.5)
CURVE(3.64, 3.53, 1.5, 1.75)
CURVE(3.53, 3.44, 1.75, 2.0)
CURVE(3.44, 3.20, 2.0, 2.25)
CURVE(3.20, 2.80, 2.25, 2.5)
CURVE(2.80, 2.50, 2.5, 2.60)
break;
}
}
return 0.f;
}
@ -116,7 +119,7 @@ float getRemainingWattHours()
float avgVoltage = 0;
for (auto &controller : controllers)
{
avgVoltage += controller.getCalibratedVoltage(settings.battery.applyCalibration);
avgVoltage += controller.getCalibratedVoltage();
}
avgVoltage = avgVoltage / controllers.size();
@ -128,7 +131,7 @@ std::string getBatteryPercentageString()
float avgVoltage = 0;
for (auto &controller : controllers)
{
avgVoltage += controller.getCalibratedVoltage(settings.battery.applyCalibration);
avgVoltage += controller.getCalibratedVoltage();
}
avgVoltage = avgVoltage / controllers.size();

View File

@ -0,0 +1,267 @@
#include "ble_bobby.h"
// esp-idf includes
#include <esp_log.h>
namespace {
constexpr const char * const TAG = "BOBBYBLE";
} // namespace
#ifdef FEATURE_BLE
BLEServer *pServer{};
BLEService *pService{};
BLECharacteristic *livestatsCharacteristic{};
BLECharacteristic *remotecontrolCharacteristic{};
#ifdef FEATURE_WIRELESS_CONFIG
BLECharacteristic *wirelessConfig{};
BLECharacteristic *getwifilist{};
#endif
RemoteControlCallbacks bleRemoteCallbacks;
#ifdef FEATURE_WIRELESS_CONFIG
WirelessSettingsCallbacks bleWirelessSettingsCallbacks;
WiFiListCallbacks bleWiFiListCallbacks;
#endif
void createBle()
{
ESP_LOGI("BOBBY", "called");
BLEDevice::init(deviceName);
const auto serviceUuid{"0335e46c-f355-4ce6-8076-017de08cee98"};
pServer = BLEDevice::createServer();
pService = pServer->createService(serviceUuid);
livestatsCharacteristic = pService->createCharacteristic("a48321ea-329f-4eab-a401-30e247211524", NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY);
remotecontrolCharacteristic = pService->createCharacteristic("4201def0-a264-43e6-946b-6b2d9612dfed", NIMBLE_PROPERTY::WRITE);
remotecontrolCharacteristic->setCallbacks(&bleRemoteCallbacks);
#ifdef FEATURE_WIRELESS_CONFIG
wirelessConfig = pService->createCharacteristic("4201def1-a264-43e6-946b-6b2d9612dfed", NIMBLE_PROPERTY::WRITE);
wirelessConfig->setCallbacks(&bleWirelessSettingsCallbacks);
getwifilist = pService->createCharacteristic("4201def2-a264-43e6-946b-6b2d9612dfed", NIMBLE_PROPERTY::READ);
getwifilist->setCallbacks(&bleWiFiListCallbacks);
#endif
pService->start();
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(serviceUuid);
pAdvertising->setScanResponse(true);
BLEDevice::startAdvertising();
}
void destroyBle()
{
ESP_LOGI("BOBBY", "called");
BLEDevice::deinit(true);
pServer = {};
pService = {};
livestatsCharacteristic = {};
remotecontrolCharacteristic = {};
#ifdef FEATURE_WIRELESS_CONFIG
wirelessConfig = {};
getwifilist = {};
#endif
}
void initBle()
{
if (settings.bleSettings.bleEnabled)
createBle();
}
void handleBle()
{
if (settings.bleSettings.bleEnabled)
{
if (!pServer)
createBle();
if (livestatsCharacteristic->getSubscribedCount())
{
StaticJsonDocument<1024> doc;
{
auto arr = doc.createNestedArray("v");
if (controllers.front.feedbackValid)
arr.add(controllers.front.getCalibratedVoltage());
else
arr.add(nullptr);
if (controllers.back.feedbackValid)
arr.add(controllers.back.getCalibratedVoltage());
else
arr.add(nullptr);
}
{
auto arr = doc.createNestedArray("t");
if (controllers.front.feedbackValid)
arr.add(fixBoardTemp(controllers.front.feedback.boardTemp));
else
arr.add(nullptr);
if (controllers.back.feedbackValid)
arr.add(fixBoardTemp(controllers.back.feedback.boardTemp));
else
arr.add(nullptr);
}
{
auto arr = doc.createNestedArray("e");
if (controllers.front.feedbackValid)
{
arr.add(controllers.front.feedback.left.error);
arr.add(controllers.front.feedback.right.error);
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
if (controllers.back.feedbackValid)
{
arr.add(controllers.back.feedback.left.error);
arr.add(controllers.back.feedback.right.error);
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
}
{
auto arr = doc.createNestedArray("s");
if (controllers.front.feedbackValid)
{
arr.add(convertToKmh(controllers.front.feedback.left.speed * (settings.controllerHardware.invertFrontLeft ? -1 : 1)));
arr.add(convertToKmh(controllers.front.feedback.right.speed * (settings.controllerHardware.invertFrontRight ? -1 : 1)));
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
if (controllers.back.feedbackValid)
{
arr.add(convertToKmh(controllers.back.feedback.left.speed * (settings.controllerHardware.invertBackLeft ? -1 : 1)));
arr.add(convertToKmh(controllers.back.feedback.right.speed * (settings.controllerHardware.invertBackRight ? -1 : 1)));
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
}
{
auto arr = doc.createNestedArray("a");
if (controllers.front.feedbackValid)
{
arr.add(fixCurrent(controllers.front.feedback.left.dcLink) * 2);
arr.add(fixCurrent(controllers.front.feedback.right.dcLink) * 2);
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
if (controllers.back.feedbackValid)
{
arr.add(fixCurrent(controllers.back.feedback.left.dcLink) * 2);
arr.add(fixCurrent(controllers.back.feedback.right.dcLink) * 2);
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
}
std::string json;
serializeJson(doc, json);
livestatsCharacteristic->setValue(json);
livestatsCharacteristic->notify();
}
}
else if (pServer)
{
destroyBle();
}
}
void RemoteControlCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
{
const auto &val = pCharacteristic->getValue();
StaticJsonDocument<256> doc;
if (const auto error = deserializeJson(doc, val))
{
ESP_LOGW(TAG, "ignoring cmd with invalid json: %.*s %s", val.size(), val.data(), error.c_str());
return;
}
#ifdef FEATURE_LEDSTRIP
auto newBlinkAnimation = doc["anim"].as<int16_t>();
if (blinkAnimation != newBlinkAnimation) blinkAnimation = newBlinkAnimation;
#endif
if (!simplified)
{
modes::remoteControlMode.setCommand(RemoteCommand{
.frontLeft = doc["fl"].as<int16_t>(),
.frontRight = doc["fr"].as<int16_t>(),
.backLeft = doc["bl"].as<int16_t>(),
.backRight = doc["br"].as<int16_t>()
});
}
}
#ifdef FEATURE_WIRELESS_CONFIG
void WirelessSettingsCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
{
const auto &val = pCharacteristic->getValue();
StaticJsonDocument<256> doc;
if (const auto error = deserializeJson(doc, val))
{
ESP_LOGW(TAG, "ignoring cmd with invalid json: %.*s %s", val.size(), val.data(), error.c_str());
return;
}
auto write_type = doc["type"].as<std::string>();
if (write_type == "wifi") {
const int index = doc["wifi_index"].as<int>();
ESP_LOGI(TAG, "[ble_config]: Set wifi%i: WiFi-SSID: %s, WiFi-Password: ***", doc["wifi_index"].as<int>(), doc["wifi_ssid"].as<const char*>());
stringSettings.wifis[index].ssid = doc["wifi_ssid"].as<std::string>();
stringSettings.wifis[index].key = doc["wifi_pass"].as<std::string>();
saveSettings();
} else {
const auto deserialized = deserializeJson(doc, val);
ESP_LOGW(TAG, "Unkown type %s -> json: %.*s %s", doc["type"].as<const char*>(), val.size(), val.data(), deserialized.c_str());
}
}
void WiFiListCallbacks::onRead(NimBLECharacteristic *pCharacteristic) {
StaticJsonDocument<768> responseDoc;
auto wifis = stringSettings.wifis;
auto wifiArray = responseDoc.createNestedArray("wifis");
ESP_LOGI(TAG, "[ble_wifilist] Got request for listing wifi ssids.");
for (unsigned int index = 0; index < wifis.size(); index++) {
wifiArray.add(wifis[index].ssid);
}
responseDoc["wifi_count"] = wifis.size();
std::string json;
serializeJson(responseDoc, json);
pCharacteristic->setValue(json);
}
#endif
#endif

View File

@ -1,8 +1,5 @@
#pragma once
// esp-idf includes
#include <esp_log.h>
// 3rdparty lib includes
#include <ArduinoJson.h>
#ifdef FEATURE_BLE
@ -21,15 +18,14 @@
//wifistack
#include "wifi_bobbycar.h"
namespace {
#ifdef FEATURE_BLE
BLEServer *pServer{};
BLEService *pService{};
BLECharacteristic *livestatsCharacteristic{};
BLECharacteristic *remotecontrolCharacteristic{};
extern BLEServer *pServer;
extern BLEService *pService;
extern BLECharacteristic *livestatsCharacteristic;
extern BLECharacteristic *remotecontrolCharacteristic;
#ifdef FEATURE_WIRELESS_CONFIG
BLECharacteristic *wirelessConfig{};
BLECharacteristic *getwifilist{};
extern BLECharacteristic *wirelessConfig;
extern BLECharacteristic *getwifilist;
#endif
void createBle();
@ -55,250 +51,15 @@ public:
};
#endif
RemoteControlCallbacks bleRemoteCallbacks;
extern RemoteControlCallbacks bleRemoteCallbacks;
#ifdef FEATURE_WIRELESS_CONFIG
WirelessSettingsCallbacks bleWirelessSettingsCallbacks;
WiFiListCallbacks bleWiFiListCallbacks;
extern WirelessSettingsCallbacks bleWirelessSettingsCallbacks;
extern WiFiListCallbacks bleWiFiListCallbacks;
#endif
void initBle()
{
if (settings.bleSettings.bleEnabled)
createBle();
}
void initBle();
void handleBle()
{
if (settings.bleSettings.bleEnabled)
{
if (!pServer)
createBle();
void handleBle();
if (livestatsCharacteristic->getSubscribedCount())
{
StaticJsonDocument<1024> doc;
{
auto arr = doc.createNestedArray("v");
if (controllers.front.feedbackValid)
arr.add(controllers.front.getCalibratedVoltage(settings.battery.applyCalibration));
else
arr.add(nullptr);
if (controllers.back.feedbackValid)
arr.add(controllers.back.getCalibratedVoltage(settings.battery.applyCalibration));
else
arr.add(nullptr);
}
{
auto arr = doc.createNestedArray("t");
if (controllers.front.feedbackValid)
arr.add(fixBoardTemp(controllers.front.feedback.boardTemp));
else
arr.add(nullptr);
if (controllers.back.feedbackValid)
arr.add(fixBoardTemp(controllers.back.feedback.boardTemp));
else
arr.add(nullptr);
}
{
auto arr = doc.createNestedArray("e");
if (controllers.front.feedbackValid)
{
arr.add(controllers.front.feedback.left.error);
arr.add(controllers.front.feedback.right.error);
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
if (controllers.back.feedbackValid)
{
arr.add(controllers.back.feedback.left.error);
arr.add(controllers.back.feedback.right.error);
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
}
{
auto arr = doc.createNestedArray("s");
if (controllers.front.feedbackValid)
{
arr.add(convertToKmh(controllers.front.feedback.left.speed * (settings.controllerHardware.invertFrontLeft ? -1 : 1)));
arr.add(convertToKmh(controllers.front.feedback.right.speed * (settings.controllerHardware.invertFrontRight ? -1 : 1)));
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
if (controllers.back.feedbackValid)
{
arr.add(convertToKmh(controllers.back.feedback.left.speed * (settings.controllerHardware.invertBackLeft ? -1 : 1)));
arr.add(convertToKmh(controllers.back.feedback.right.speed * (settings.controllerHardware.invertBackRight ? -1 : 1)));
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
}
{
auto arr = doc.createNestedArray("a");
if (controllers.front.feedbackValid)
{
arr.add(fixCurrent(controllers.front.feedback.left.dcLink) * 2);
arr.add(fixCurrent(controllers.front.feedback.right.dcLink) * 2);
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
if (controllers.back.feedbackValid)
{
arr.add(fixCurrent(controllers.back.feedback.left.dcLink) * 2);
arr.add(fixCurrent(controllers.back.feedback.right.dcLink) * 2);
}
else
{
arr.add(nullptr);
arr.add(nullptr);
}
}
std::string json;
serializeJson(doc, json);
livestatsCharacteristic->setValue(json);
livestatsCharacteristic->notify();
}
}
else if (pServer)
{
destroyBle();
}
}
void createBle()
{
ESP_LOGI("BOBBY", "called");
BLEDevice::init(deviceName);
const auto serviceUuid{"0335e46c-f355-4ce6-8076-017de08cee98"};
pServer = BLEDevice::createServer();
pService = pServer->createService(serviceUuid);
livestatsCharacteristic = pService->createCharacteristic("a48321ea-329f-4eab-a401-30e247211524", NIMBLE_PROPERTY::READ | NIMBLE_PROPERTY::NOTIFY);
remotecontrolCharacteristic = pService->createCharacteristic("4201def0-a264-43e6-946b-6b2d9612dfed", NIMBLE_PROPERTY::WRITE);
remotecontrolCharacteristic->setCallbacks(&bleRemoteCallbacks);
#ifdef FEATURE_WIRELESS_CONFIG
wirelessConfig = pService->createCharacteristic("4201def1-a264-43e6-946b-6b2d9612dfed", NIMBLE_PROPERTY::WRITE);
wirelessConfig->setCallbacks(&bleWirelessSettingsCallbacks);
getwifilist = pService->createCharacteristic("4201def2-a264-43e6-946b-6b2d9612dfed", NIMBLE_PROPERTY::READ);
getwifilist->setCallbacks(&bleWiFiListCallbacks);
#endif
pService->start();
BLEAdvertising *pAdvertising = BLEDevice::getAdvertising();
pAdvertising->addServiceUUID(serviceUuid);
pAdvertising->setScanResponse(true);
BLEDevice::startAdvertising();
}
void destroyBle()
{
ESP_LOGI("BOBBY", "called");
BLEDevice::deinit(true);
pServer = {};
pService = {};
livestatsCharacteristic = {};
remotecontrolCharacteristic = {};
#ifdef FEATURE_WIRELESS_CONFIG
wirelessConfig = {};
getwifilist = {};
#endif
}
void RemoteControlCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
{
const auto &val = pCharacteristic->getValue();
StaticJsonDocument<256> doc;
if (const auto error = deserializeJson(doc, val))
{
ESP_LOGW(TAG, "ignoring cmd with invalid json: %.*s %s", val.size(), val.data(), error.c_str());
return;
}
#ifdef FEATURE_LEDSTRIP
auto newBlinkAnimation = doc["anim"].as<int16_t>();
if (blinkAnimation != newBlinkAnimation) blinkAnimation = newBlinkAnimation;
#endif
if (!simplified)
{
modes::remoteControlMode.setCommand(RemoteCommand{
.frontLeft = doc["fl"].as<int16_t>(),
.frontRight = doc["fr"].as<int16_t>(),
.backLeft = doc["bl"].as<int16_t>(),
.backRight = doc["br"].as<int16_t>()
});
}
}
#ifdef FEATURE_WIRELESS_CONFIG
void WirelessSettingsCallbacks::onWrite(NimBLECharacteristic* pCharacteristic)
{
const auto &val = pCharacteristic->getValue();
StaticJsonDocument<256> doc;
if (const auto error = deserializeJson(doc, val))
{
ESP_LOGW(TAG, "ignoring cmd with invalid json: %.*s %s", val.size(), val.data(), error.c_str());
return;
}
auto write_type = doc["type"].as<std::string>();
if (write_type == "wifi") {
const int index = doc["wifi_index"].as<int>();
ESP_LOGI(TAG, "[ble_config]: Set wifi%i: WiFi-SSID: %s, WiFi-Password: ***", doc["wifi_index"].as<int>(), doc["wifi_ssid"].as<const char*>());
stringSettings.wifis[index].ssid = doc["wifi_ssid"].as<std::string>();
stringSettings.wifis[index].key = doc["wifi_pass"].as<std::string>();
saveSettings();
} else {
const auto deserialized = deserializeJson(doc, val);
ESP_LOGW(TAG, "Unkown type %s -> json: %.*s %s", doc["type"].as<const char*>(), val.size(), val.data(), deserialized.c_str());
}
}
void WiFiListCallbacks::onRead(NimBLECharacteristic *pCharacteristic) {
StaticJsonDocument<768> responseDoc;
auto wifis = stringSettings.wifis;
auto wifiArray = responseDoc.createNestedArray("wifis");
ESP_LOGI(TAG, "[ble_wifilist] Got request for listing wifi ssids.");
for (unsigned int index = 0; index < wifis.size(); index++) {
wifiArray.add(wifis[index].ssid);
}
responseDoc["wifi_count"] = wifis.size();
std::string json;
serializeJson(responseDoc, json);
pCharacteristic->setValue(json);
}
#endif
#endif
}

View File

@ -16,6 +16,7 @@
// esp-idf
#include "esp_http_client.h"
#ifdef FEATURE_OTA
namespace {
void buildMenuFromJson(std::string json);
void buildMenuRequestError(std::string error);
@ -191,3 +192,4 @@ namespace {
return request_running;
}
}
#endif

View File

@ -0,0 +1,37 @@
#include "changevaluedisplay_unifiedmodelmode.h"
// esp-idf includes
#include <esp_log.h>
// local includes
#include "utils.h"
#include "texts.h"
namespace espgui {
ChangeValueDisplay<UnifiedModelMode>::ChangeValueDisplay()
{
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<UnifiedModelMode>, StaticText<TEXT_COMMUTATION>>>(UnifiedModelMode::Commutation, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<UnifiedModelMode>, StaticText<TEXT_SINUSOIDAL>>>(UnifiedModelMode::Sinusoidal, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<UnifiedModelMode>, StaticText<TEXT_FOCVOLTAGE>>>(UnifiedModelMode::FocVoltage, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<UnifiedModelMode>, StaticText<TEXT_FOCSPEED>>>(UnifiedModelMode::FocSpeed, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<UnifiedModelMode>, StaticText<TEXT_FOCTORQUE>>>(UnifiedModelMode::FocTorque, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, BackProxyAction, StaticText<TEXT_BACK>, StaticMenuItemIcon<&espgui::icons::back>>>(*this);
}
void ChangeValueDisplay<UnifiedModelMode>::start()
{
Base::start();
switch (const auto value = getValue())
{
case UnifiedModelMode::Commutation: setSelectedIndex(0); break;
case UnifiedModelMode::Sinusoidal: setSelectedIndex(1); break;
case UnifiedModelMode::FocVoltage: setSelectedIndex(2); break;
case UnifiedModelMode::FocSpeed: setSelectedIndex(3); break;
case UnifiedModelMode::FocTorque: setSelectedIndex(4); break;
default:
ESP_LOGW("BOBBY", "Unknown UnifiedModelMode: %i", int(value));
setSelectedIndex(5);
}
}
} // namespace espgui

View File

@ -1,14 +1,13 @@
#pragma once
#include <esp_log.h>
// 3rdparty lib includes
#include "changevaluedisplay.h"
#include "menudisplay.h"
#include "utils.h"
#include "actions/setvalueaction.h"
#include "actions/backproxyaction.h"
#include "icons/back.h"
#include "texts.h"
// local includes
#include "unifiedmodelmode.h"
namespace espgui {
@ -25,31 +24,4 @@ public:
void start() override;
};
ChangeValueDisplay<UnifiedModelMode>::ChangeValueDisplay()
{
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<UnifiedModelMode>, StaticText<TEXT_COMMUTATION>>>(UnifiedModelMode::Commutation, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<UnifiedModelMode>, StaticText<TEXT_SINUSOIDAL>>>(UnifiedModelMode::Sinusoidal, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<UnifiedModelMode>, StaticText<TEXT_FOCVOLTAGE>>>(UnifiedModelMode::FocVoltage, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<UnifiedModelMode>, StaticText<TEXT_FOCSPEED>>>(UnifiedModelMode::FocSpeed, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, SetValueAction<UnifiedModelMode>, StaticText<TEXT_FOCTORQUE>>>(UnifiedModelMode::FocTorque, *this, *this);
constructMenuItem<makeComponentArgs<MenuItem, BackProxyAction, StaticText<TEXT_BACK>, StaticMenuItemIcon<&espgui::icons::back>>>(*this);
}
void ChangeValueDisplay<UnifiedModelMode>::start()
{
Base::start();
switch (const auto value = getValue())
{
case UnifiedModelMode::Commutation: setSelectedIndex(0); break;
case UnifiedModelMode::Sinusoidal: setSelectedIndex(1); break;
case UnifiedModelMode::FocVoltage: setSelectedIndex(2); break;
case UnifiedModelMode::FocSpeed: setSelectedIndex(3); break;
case UnifiedModelMode::FocTorque: setSelectedIndex(4); break;
default:
ESP_LOGW("BOBBY", "Unknown UnifiedModelMode: %i", int(value));
setSelectedIndex(5);
}
}
} // namespace espgui

View File

@ -0,0 +1,251 @@
#include "cloud.h"
// esp-idf includes
#include <esp_log.h>
using namespace std::chrono_literals;
namespace {
constexpr const char * const TAG = "BOBBYCLOUD";
} // namespace
#ifdef FEATURE_CLOUD
espcpputils::websocket_client cloudClient;
bool cloudStarted{};
espchrono::millis_clock::time_point lastCreateTry;
espchrono::millis_clock::time_point lastStartTry;
std::string cloudBuffer;
void initCloud()
{
if (settings.cloudSettings.cloudEnabled &&
!stringSettings.cloudUrl.empty() &&
esphttpdutils::urlverify(stringSettings.cloudUrl))
{
createCloud();
if (!cloudClient)
return;
if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED)
return;
startCloud();
}
}
void cloudCollect()
{
if (!cloudClient)
{
cloudBuffer.clear();
return;
}
if (!cloudStarted)
{
cloudBuffer.clear();
return;
}
if (!cloudClient.is_connected())
{
cloudBuffer.clear();
return;
}
if (cloudBuffer.empty())
cloudBuffer = '[';
else
cloudBuffer += ',';
cloudBuffer += fmt::format("[{},{},{}",
std::chrono::milliseconds{espchrono::millis_clock::now().time_since_epoch()}.count(),
std::chrono::milliseconds{espchrono::utc_clock::now().time_since_epoch()}.count(),
heap_caps_get_free_size(MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT));
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
{
if (const auto &result = wifi_stack::get_sta_ap_info(); result)
cloudBuffer += fmt::format(",{}", result->rssi);
else
cloudBuffer += ",null";
}
else
cloudBuffer += ",null";
if (raw_gas)
cloudBuffer += fmt::format(",{}", *raw_gas);
else
cloudBuffer += ",null";
if (raw_brems)
cloudBuffer += fmt::format(",{}", *raw_brems);
else
cloudBuffer += ",null";
if (gas)
cloudBuffer += fmt::format(",{:.1f}", *gas);
else
cloudBuffer += ",null";
if (brems)
cloudBuffer += fmt::format(",{:.1f}", *brems);
else
cloudBuffer += ",null";
constexpr const auto addController = [](const Controller &controller){
if (!controller.feedbackValid)
{
cloudBuffer += ",null";
return;
}
cloudBuffer += fmt::format(",[{:.02f},{:.02f}",
controller.getCalibratedVoltage(),
fixBoardTemp(controller.feedback.boardTemp));
constexpr const auto addMotor = [](const bobbycar::protocol::serial::MotorState &command,
const bobbycar::protocol::serial::MotorFeedback &feedback,
bool invert){
cloudBuffer += fmt::format(",[{},{:.2f},{:.2f},{}]",
command.pwm * (invert?-1:1),
convertToKmh(feedback.speed) * (invert?-1:1),
fixCurrent(feedback.dcLink),
feedback.error);
};
addMotor(controller.command.left, controller.feedback.left, controller.invertLeft);
addMotor(controller.command.right, controller.feedback.right, controller.invertRight);
cloudBuffer += ']';
};
addController(controllers.front);
addController(controllers.back);
cloudBuffer += "]";
}
void cloudSend()
{
if (settings.cloudSettings.cloudEnabled &&
!stringSettings.cloudUrl.empty() &&
esphttpdutils::urlverify(stringSettings.cloudUrl))
{
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;
if (cloudBuffer.empty())
return;
cloudBuffer += ']';
const auto timeout = std::chrono::ceil<espcpputils::ticks>(espchrono::milliseconds32{settings.cloudSettings.cloudTransmitTimeout}).count();
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();
}
else if (cloudClient)
{
destroyCloud();
}
}
void createCloud()
{
ESP_LOGI("BOBBY", "called");
if (cloudClient)
{
ESP_LOGE(TAG, "cloud client already created");
return;
}
lastCreateTry = espchrono::millis_clock::now();
const esp_websocket_client_config_t config = {
.uri = stringSettings.cloudUrl.c_str(),
};
cloudClient = espcpputils::websocket_client{&config};
if (!cloudClient)
{
ESP_LOGE(TAG, "websocket could not be constructed");
return;
}
ESP_LOGI("BOBBY", "cloud client created");
}
void startCloud()
{
ESP_LOGI("BOBBY", "called");
if (!cloudClient)
{
ESP_LOGE(TAG, "cloud client not created");
return;
}
if (cloudStarted)
{
ESP_LOGE(TAG, "cloud client already started");
return;
}
lastStartTry = espchrono::millis_clock::now();
const auto result = cloudClient.start();
ESP_LOG_LEVEL_LOCAL((result == ESP_OK ? ESP_LOG_INFO : ESP_LOG_ERROR), "BOBBY", "cloudClient.start() returned: %s", esp_err_to_name(result));
if (result == ESP_OK)
cloudStarted = true;
}
void destroyCloud()
{
ESP_LOGI("BOBBY", "called");
if (!cloudClient)
{
ESP_LOGE(TAG, "cloud client not created");
return;
}
cloudClient = {};
cloudStarted = false;
}
#endif

View File

@ -1,8 +1,5 @@
#pragma once
// esp-idf includes
#include <esp_log.h>
// 3rdparty lib includes
#include <wrappers/websocket_client.h>
#include <espwifistack.h>
@ -14,247 +11,18 @@
#include "globals.h"
#include "utils.h"
namespace {
#ifdef FEATURE_CLOUD
espcpputils::websocket_client cloudClient;
bool cloudStarted{};
espchrono::millis_clock::time_point lastCreateTry;
espchrono::millis_clock::time_point lastStartTry;
std::string cloudBuffer;
extern espcpputils::websocket_client cloudClient;
extern bool cloudStarted;
extern espchrono::millis_clock::time_point lastCreateTry;
extern espchrono::millis_clock::time_point lastStartTry;
extern std::string cloudBuffer;
void createCloud();
void destroyCloud();
void startCloud();
void initCloud()
{
if (settings.cloudSettings.cloudEnabled &&
!stringSettings.cloudUrl.empty() &&
esphttpdutils::urlverify(stringSettings.cloudUrl))
{
createCloud();
if (!cloudClient)
return;
if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED)
return;
startCloud();
}
}
void cloudCollect()
{
if (!cloudClient)
{
cloudBuffer.clear();
return;
}
if (!cloudStarted)
{
cloudBuffer.clear();
return;
}
if (!cloudClient.is_connected())
{
cloudBuffer.clear();
return;
}
if (cloudBuffer.empty())
cloudBuffer = '[';
else
cloudBuffer += ',';
cloudBuffer += fmt::format("[{},{},{}",
std::chrono::milliseconds{espchrono::millis_clock::now().time_since_epoch()}.count(),
std::chrono::milliseconds{espchrono::utc_clock::now().time_since_epoch()}.count(),
heap_caps_get_free_size(MALLOC_CAP_INTERNAL|MALLOC_CAP_8BIT));
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
{
if (const auto &result = wifi_stack::get_sta_ap_info(); result)
cloudBuffer += fmt::format(",{}", result->rssi);
else
cloudBuffer += ",null";
}
else
cloudBuffer += ",null";
if (raw_gas)
cloudBuffer += fmt::format(",{}", *raw_gas);
else
cloudBuffer += ",null";
if (raw_brems)
cloudBuffer += fmt::format(",{}", *raw_brems);
else
cloudBuffer += ",null";
if (gas)
cloudBuffer += fmt::format(",{:.1f}", *gas);
else
cloudBuffer += ",null";
if (brems)
cloudBuffer += fmt::format(",{:.1f}", *brems);
else
cloudBuffer += ",null";
constexpr const auto addController = [](const Controller &controller){
if (!controller.feedbackValid)
{
cloudBuffer += ",null";
return;
}
cloudBuffer += fmt::format(",[{:.02f},{:.02f}",
controller.getCalibratedVoltage(settings.battery.applyCalibration),
fixBoardTemp(controller.feedback.boardTemp));
constexpr const auto addMotor = [](const bobbycar::protocol::serial::MotorState &command,
const bobbycar::protocol::serial::MotorFeedback &feedback,
bool invert){
cloudBuffer += fmt::format(",[{},{:.2f},{:.2f},{}]",
command.pwm * (invert?-1:1),
convertToKmh(feedback.speed) * (invert?-1:1),
fixCurrent(feedback.dcLink),
feedback.error);
};
addMotor(controller.command.left, controller.feedback.left, controller.invertLeft);
addMotor(controller.command.right, controller.feedback.right, controller.invertRight);
cloudBuffer += ']';
};
addController(controllers.front);
addController(controllers.back);
cloudBuffer += "]";
}
void cloudSend()
{
if (settings.cloudSettings.cloudEnabled &&
!stringSettings.cloudUrl.empty() &&
esphttpdutils::urlverify(stringSettings.cloudUrl))
{
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;
if (cloudBuffer.empty())
return;
cloudBuffer += ']';
const auto timeout = std::chrono::ceil<espcpputils::ticks>(espchrono::milliseconds32{settings.cloudSettings.cloudTransmitTimeout}).count();
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();
}
else if (cloudClient)
{
destroyCloud();
}
}
void createCloud()
{
ESP_LOGI("BOBBY", "called");
if (cloudClient)
{
ESP_LOGE(TAG, "cloud client already created");
return;
}
lastCreateTry = espchrono::millis_clock::now();
const esp_websocket_client_config_t config = {
.uri = stringSettings.cloudUrl.c_str(),
};
cloudClient = espcpputils::websocket_client{&config};
if (!cloudClient)
{
ESP_LOGE(TAG, "websocket could not be constructed");
return;
}
ESP_LOGI("BOBBY", "cloud client created");
}
void startCloud()
{
ESP_LOGI("BOBBY", "called");
if (!cloudClient)
{
ESP_LOGE(TAG, "cloud client not created");
return;
}
if (cloudStarted)
{
ESP_LOGE(TAG, "cloud client already started");
return;
}
lastStartTry = espchrono::millis_clock::now();
const auto result = cloudClient.start();
ESP_LOG_LEVEL_LOCAL((result == ESP_OK ? ESP_LOG_INFO : ESP_LOG_ERROR), "BOBBY", "cloudClient.start() returned: %s", esp_err_to_name(result));
if (result == ESP_OK)
cloudStarted = true;
}
void destroyCloud()
{
ESP_LOGI("BOBBY", "called");
if (!cloudClient)
{
ESP_LOGE(TAG, "cloud client not created");
return;
}
cloudClient = {};
cloudStarted = false;
}
void initCloud();
void cloudCollect();
void cloudSend();
#endif
} // namespace

View File

@ -0,0 +1,30 @@
#include "cloudtexthelpers.h"
// 3rdparty lib includes
#include <fmt/core.h>
// local includes
#include "cloud.h"
#ifdef FEATURE_CLOUD
std::string CloudCreatedText::text() const
{
return fmt::format("created: {}", cloudClient ? "true" : "false");
}
std::string CloudStartedText::text() const
{
std::string text = "started: ";
if (cloudClient)
text += cloudStarted ? "true" : "false";
return text;
}
std::string CloudConnectedText::text() const
{
std::string text = "connected: ";
if (cloudClient)
text += cloudClient.is_connected() ? "true" : "false";
return text;
}
#endif

View File

@ -1,37 +1,24 @@
#pragma once
// 3rdparty lib includes
#include <fmt/core.h>
// local includes
#include "textinterface.h"
#include "cloud.h"
namespace {
#ifdef FEATURE_CLOUD
struct CloudCreatedText : public virtual TextInterface { public: std::string text() const override {
return fmt::format("created: {}", cloudClient ? "true" : "false"); }};
struct CloudStartedText : public virtual TextInterface {
struct CloudCreatedText : public virtual espgui::TextInterface
{
public:
std::string text() const override
{
std::string text = "started: ";
if (cloudClient)
text += cloudStarted ? "true" : "false";
return text;
}
std::string text() const override;
};
struct CloudConnectedText : public virtual TextInterface {
struct CloudStartedText : public virtual espgui::TextInterface
{
public:
std::string text() const override
{
std::string text = "connected: ";
if (cloudClient)
text += cloudClient.is_connected() ? "true" : "false";
return text;
}
std::string text() const override;
};
struct CloudConnectedText : public virtual espgui::TextInterface
{
public:
std::string text() const override;
};
#endif
}

View File

@ -1,5 +1,8 @@
#include "controller.h"
// local includes
#include "globals.h"
Controller::Controller(
#ifdef FEATURE_SERIAL
HardwareSerial &serial,
@ -15,10 +18,10 @@ Controller::Controller(
{
}
float Controller::getCalibratedVoltage(bool applyCalibration) const
float Controller::getCalibratedVoltage() const
{
float voltage = feedback.batVoltage;
if (applyCalibration)
if (settings.battery.applyCalibration)
{
voltage = ((voltage - float(voltageCalib30V)) * (20.f / (float(voltageCalib50V) - float(voltageCalib30V))) + 30.f);
}

View File

@ -53,5 +53,5 @@ struct Controller
FeedbackParser parser{serial, feedbackValid, feedback};
#endif
float getCalibratedVoltage(bool applyCalibration) const;
float getCalibratedVoltage() const;
};

View File

@ -48,7 +48,7 @@ public:
using RightCommand = CommandTexts<LeftCommandGetter>;
//struct BatVoltageText : public virtual TextInterface { public: std::string text() const override { std::string line{"batVoltage: "}; if (controller::get().feedbackValid) line += std::to_string(controller::get().feedback.batVoltage); return line; } };
struct BatVoltageFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"batVoltage: "}; if (controller::get().feedbackValid) line += fmt::format("{:.2f}V", controller::get().getCalibratedVoltage(settings.battery.applyCalibration)); return line; } };
struct BatVoltageFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"batVoltage: "}; if (controller::get().feedbackValid) line += fmt::format("{:.2f}V", controller::get().getCalibratedVoltage()); return line; } };
//struct BoardTempText : public virtual TextInterface { public: std::string text() const override { std::string line{"boardTemp: "}; if (controller::get().feedbackValid) line += std::to_string(controller::get().feedback.boardTemp); return line; } };
struct BoardTempFixedText : public virtual TextInterface { public: std::string text() const override { std::string line{"boardTemp: "}; if (controller::get().feedbackValid) line += fmt::format("{:.2f}C", fixBoardTemp(controller::get().feedback.boardTemp)); return line; } };
struct TimeoutCntSerialText : public virtual TextInterface { public: std::string text() const override { std::string line{"timeoutCntSerial: "}; if (controller::get().feedbackValid) line += std::to_string(controller::get().feedback.timeoutCntSerial); return line; } };

View File

@ -11,11 +11,6 @@
#include "widgets/label.h"
#include "screenmanager.h"
namespace {
class MainMenu;
class MetersDisplay;
class StatusDisplay;
}
namespace {
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
class BmsDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<MainMenu>>, public DummyBack

View File

@ -0,0 +1,272 @@
#include "calibratedisplay.h"
// 3rdparty lib includes
#include <tftinstance.h>
#include <screenmanager.h>
// local includes
#include "displays/statusdisplay.h"
#include "displays/menus/boardcomputerhardwaresettingsmenu.h"
CalibrateDisplay::CalibrateDisplay(bool bootup) :
m_bootup{bootup}
{
}
std::string CalibrateDisplay::text() const
{
return TEXT_CALIBRATE;
}
void CalibrateDisplay::start()
{
Base::start();
m_oldMode = currentMode;
currentMode = &m_mode;
m_selectedButton = 0;
m_status = Status::Begin;
copyFromSettings();
m_gas = std::nullopt;
m_brems = std::nullopt;
}
void CalibrateDisplay::initScreen()
{
Base::initScreen();
espgui::tft.setTextFont(4);
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
espgui::tft.drawString("gas:", 25, 47);
espgui::tft.drawString("brems:", 25, 147);
for (auto &label : m_labels)
label.start();
for (auto &progressBar : m_progressBars)
progressBar.start();
m_renderedButton = -1;
}
void CalibrateDisplay::update()
{
Base::update();
if (raw_gas)
m_gas = cpputils::mapValueClamped<float>(*raw_gas, m_gasMin, m_gasMax, 0., 1000.);
else
m_gas = std::nullopt;
if (raw_brems)
m_brems = cpputils::mapValueClamped<float>(*raw_brems, m_bremsMin, m_bremsMax, 0., 1000.);
else
m_brems = std::nullopt;
}
void CalibrateDisplay::redraw()
{
Base::redraw();
m_labels[0].redraw(m_gas ? fmt::format("{:.02f}", *m_gas) : "?");
m_labels[1].redraw(raw_gas ? std::to_string(*raw_gas) : "?");
if (m_status == Status::GasMin)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[2].redraw(std::to_string(m_gasMin));
if (m_status == Status::GasMin)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
if (m_status == Status::GasMax)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[3].redraw(std::to_string(m_gasMax));
if (m_status == Status::GasMax)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_progressBars[0].redraw(m_gas ? *m_gas : 0);
m_labels[4].redraw(m_brems ? fmt::format("{:.02f}", *m_brems) : "?");
m_labels[5].redraw(raw_brems ? std::to_string(*raw_brems) : "?");
if (m_status == Status::BremsMin)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[6].redraw(std::to_string(m_bremsMin));
if (m_status == Status::BremsMin)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
if (m_status == Status::BremsMax)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[7].redraw(std::to_string(m_bremsMax));
if (m_status == Status::BremsMax)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_progressBars[1].redraw(m_brems ? *m_brems : 0);
m_labels[8].redraw([&](){
switch (m_status)
{
case Status::Begin: return "Start calibrating?";
case Status::GasMin: return "Release gas";
case Status::GasMax: return "Press gas";
case Status::BremsMin: return "Release brems";
case Status::BremsMax: return "Press brems";
case Status::Confirm: return "Verify";
}
__builtin_unreachable();
}());
{
const auto failed = !m_gas || !m_brems || (m_status == Status::Confirm && (*m_gas > 100 || *m_brems > 100));
const auto color = failed ? TFT_DARKGREY : TFT_WHITE;
espgui::tft.setTextColor(color, TFT_BLACK);
m_labels[9].redraw([&](){
switch (m_status)
{
case Status::Begin: return "Yes";
case Status::GasMin:
case Status::GasMax:
case Status::BremsMin:
case Status::BremsMax: return "Next";
case Status::Confirm: return "Save";
}
__builtin_unreachable();
}());
if (m_selectedButton != m_renderedButton && (m_selectedButton == 0 || m_renderedButton == 0))
espgui::tft.drawRect(3, 275, 100, 27, m_selectedButton == 0 ? color : TFT_BLACK);
}
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_labels[10].redraw([&](){
switch (m_status)
{
case Status::Begin: return "No";
case Status::GasMin:
case Status::GasMax:
case Status::BremsMin:
case Status::BremsMax:
case Status::Confirm: return "Abort";
}
__builtin_unreachable();
}());
if (m_selectedButton != m_renderedButton && (m_selectedButton == 1 || m_renderedButton == 1))
espgui::tft.drawRect(123, 275, 100, 27, m_selectedButton == 1 ? TFT_WHITE : TFT_BLACK);
m_renderedButton = m_selectedButton;
}
void CalibrateDisplay::stop()
{
Base::stop();
if (currentMode == &m_mode)
{
// to avoid crash after deconstruction
m_mode.stop();
lastMode = nullptr;
currentMode = m_oldMode;
}
}
void CalibrateDisplay::rotate(int offset)
{
Base::rotate(offset);
m_selectedButton += offset;
if (m_selectedButton < 0)
m_selectedButton = 1;
if (m_selectedButton > 1)
m_selectedButton = 0;
}
void CalibrateDisplay::confirm()
{
switch (m_selectedButton)
{
case 0: // left button pressed
if (!raw_gas || !raw_brems || !m_gas || !m_brems)
return;
switch (m_status)
{
case Status::Begin:
m_status = Status::GasMin;
break;
case Status::GasMin:
m_gasMin = *raw_gas;
m_status = Status::GasMax;
break;
case Status::GasMax:
m_gasMax = *raw_gas;
m_status = Status::BremsMin;
{
const auto dead = (m_gasMax - m_gasMin)/20;
m_gasMin += dead;
m_gasMax -= dead;
}
break;
case Status::BremsMin:
m_bremsMin = *raw_brems;
m_status = Status::BremsMax;
break;
case Status::BremsMax:
m_bremsMax = *raw_brems;
m_status = Status::Confirm;
{
const auto dead = (m_bremsMax - m_bremsMin)/20;
m_bremsMin += dead;
m_bremsMax -= dead;
}
break;
case Status::Confirm:
if (*m_gas > 100 || *m_brems > 100)
return;
copyToSettings();
saveSettings();
if (m_bootup)
espgui::switchScreen<StatusDisplay>();
else
espgui::switchScreen<BoardcomputerHardwareSettingsMenu>();
}
break;
case 1: // right button pressed
back();
}
}
void CalibrateDisplay::back()
{
switch (m_status)
{
case Status::Begin:
if (m_bootup)
espgui::switchScreen<StatusDisplay>();
else
espgui::switchScreen<BoardcomputerHardwareSettingsMenu>();
break;
case Status::GasMin:
case Status::GasMax:
case Status::BremsMin:
case Status::BremsMax:
case Status::Confirm:
m_selectedButton = 0;
m_status = Status::Begin;
copyFromSettings();
}
}
void CalibrateDisplay::copyFromSettings()
{
m_gasMin = settings.boardcomputerHardware.gasMin;
m_gasMax = settings.boardcomputerHardware.gasMax;
m_bremsMin = settings.boardcomputerHardware.bremsMin;
m_bremsMax = settings.boardcomputerHardware.bremsMax;
}
void CalibrateDisplay::copyToSettings()
{
settings.boardcomputerHardware.gasMin = m_gasMin;
settings.boardcomputerHardware.gasMax = m_gasMax;
settings.boardcomputerHardware.bremsMin = m_bremsMin;
settings.boardcomputerHardware.bremsMax = m_bremsMax;
}

View File

@ -7,29 +7,26 @@
// 3rdparty lib includes
#include <fmt/core.h>
#include <cpputils.h>
#include <displaywithtitle.h>
#include <actions/switchscreenaction.h>
#include <widgets/label.h>
#include <widgets/progressbar.h>
// local includes
#include "display.h"
#include "actions/switchscreenaction.h"
#include "globals.h"
#include "utils.h"
#include "texts.h"
#include "widgets/label.h"
#include "widgets/progressbar.h"
#include "modes/ignoreinputmode.h"
namespace {
class StatusDisplay;
class BoardcomputerHardwareSettingsMenu;
}
namespace {
class CalibrateDisplay : public Display
class CalibrateDisplay : public espgui::DisplayWithTitle
{
using Base = espgui::DisplayWithTitle;
public:
CalibrateDisplay() = default;
CalibrateDisplay(bool bootup);
std::string text() const override;
void start() override;
void initScreen() override;
void update() override;
@ -38,9 +35,8 @@ public:
void rotate(int offset) override;
void back() override;
void confirm() override;
void back() override;
private:
void copyFromSettings();
@ -50,26 +46,26 @@ private:
ModeInterface *m_oldMode;
IgnoreInputMode m_mode{0, bobbycar::protocol::ControlType::FieldOrientedControl, bobbycar::protocol::ControlMode::Torque};
std::array<Label, 11> m_labels {{
Label{25, 72}, // 100, 23
Label{145, 72}, // 100, 23
Label{25, 97}, // 100, 23
Label{145, 97}, // 100, 23
std::array<espgui::Label, 11> m_labels {{
espgui::Label{25, 72}, // 100, 23
espgui::Label{145, 72}, // 100, 23
espgui::Label{25, 97}, // 100, 23
espgui::Label{145, 97}, // 100, 23
Label{25, 172}, // 100, 23
Label{145, 172}, // 100, 23
Label{25, 197}, // 100, 23
Label{145, 197}, // 100, 23
espgui::Label{25, 172}, // 100, 23
espgui::Label{145, 172}, // 100, 23
espgui::Label{25, 197}, // 100, 23
espgui::Label{145, 197}, // 100, 23
Label{25, 247}, // 190, 23
espgui::Label{25, 247}, // 190, 23
Label{25, 277}, // 100, 23
Label{145, 277}, // 100, 23
espgui::Label{25, 277}, // 100, 23
espgui::Label{145, 277}, // 100, 23
}};
std::array<ProgressBar, 2> m_progressBars {{
ProgressBar{20, 129, 200, 10, 0, 1000},
ProgressBar{20, 229, 200, 10, 0, 1000}
std::array<espgui::ProgressBar, 2> m_progressBars {{
espgui::ProgressBar{20, 129, 200, 10, 0, 1000},
espgui::ProgressBar{20, 229, 200, 10, 0, 1000}
}};
enum Status {
@ -87,257 +83,3 @@ private:
int16_t m_gasMin, m_gasMax, m_bremsMin, m_bremsMax;
std::optional<float> m_gas, m_brems;
};
CalibrateDisplay::CalibrateDisplay(bool bootup) :
m_bootup{bootup}
{
}
void CalibrateDisplay::start()
{
m_oldMode = currentMode;
currentMode = &m_mode;
m_selectedButton = 0;
m_status = Status::Begin;
copyFromSettings();
m_gas = std::nullopt;
m_brems = std::nullopt;
}
void CalibrateDisplay::initScreen()
{
tft.fillScreen(TFT_BLACK);
tft.setTextFont(4);
tft.setTextColor(TFT_YELLOW);
tft.drawString(TEXT_CALIBRATE, 5, 5, 4);
tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.drawString("gas:", 25, 47);
tft.drawString("brems:", 25, 147);
for (auto &label : m_labels)
label.start();
for (auto &progressBar : m_progressBars)
progressBar.start();
m_renderedButton = -1;
}
void CalibrateDisplay::update()
{
if (raw_gas)
m_gas = cpputils::mapValueClamped<float>(*raw_gas, m_gasMin, m_gasMax, 0., 1000.);
else
m_gas = std::nullopt;
if (raw_brems)
m_brems = cpputils::mapValueClamped<float>(*raw_brems, m_bremsMin, m_bremsMax, 0., 1000.);
else
m_brems = std::nullopt;
}
void CalibrateDisplay::redraw()
{
m_labels[0].redraw(m_gas ? fmt::format("{:.02f}", *m_gas) : "?");
m_labels[1].redraw(raw_gas ? std::to_string(*raw_gas) : "?");
if (m_status == Status::GasMin)
tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[2].redraw(std::to_string(m_gasMin));
if (m_status == Status::GasMin)
tft.setTextColor(TFT_WHITE, TFT_BLACK);
if (m_status == Status::GasMax)
tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[3].redraw(std::to_string(m_gasMax));
if (m_status == Status::GasMax)
tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_progressBars[0].redraw(m_gas ? *m_gas : 0);
m_labels[4].redraw(m_brems ? fmt::format("{:.02f}", *m_brems) : "?");
m_labels[5].redraw(raw_brems ? std::to_string(*raw_brems) : "?");
if (m_status == Status::BremsMin)
tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[6].redraw(std::to_string(m_bremsMin));
if (m_status == Status::BremsMin)
tft.setTextColor(TFT_WHITE, TFT_BLACK);
if (m_status == Status::BremsMax)
tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[7].redraw(std::to_string(m_bremsMax));
if (m_status == Status::BremsMax)
tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_progressBars[1].redraw(m_brems ? *m_brems : 0);
m_labels[8].redraw([&](){
switch (m_status)
{
case Status::Begin: return "Start calibrating?";
case Status::GasMin: return "Release gas";
case Status::GasMax: return "Press gas";
case Status::BremsMin: return "Release brems";
case Status::BremsMax: return "Press brems";
case Status::Confirm: return "Verify";
}
__builtin_unreachable();
}());
{
const auto failed = !m_gas || !m_brems || (m_status == Status::Confirm && (*m_gas > 100 || *m_brems > 100));
const auto color = failed ? TFT_DARKGREY : TFT_WHITE;
tft.setTextColor(color, TFT_BLACK);
m_labels[9].redraw([&](){
switch (m_status)
{
case Status::Begin: return "Yes";
case Status::GasMin:
case Status::GasMax:
case Status::BremsMin:
case Status::BremsMax: return "Next";
case Status::Confirm: return "Save";
}
__builtin_unreachable();
}());
if (m_selectedButton != m_renderedButton && (m_selectedButton == 0 || m_renderedButton == 0))
tft.drawRect(3, 275, 100, 27, m_selectedButton == 0 ? color : TFT_BLACK);
}
tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_labels[10].redraw([&](){
switch (m_status)
{
case Status::Begin: return "No";
case Status::GasMin:
case Status::GasMax:
case Status::BremsMin:
case Status::BremsMax:
case Status::Confirm: return "Abort";
}
__builtin_unreachable();
}());
if (m_selectedButton != m_renderedButton && (m_selectedButton == 1 || m_renderedButton == 1))
tft.drawRect(123, 275, 100, 27, m_selectedButton == 1 ? TFT_WHITE : TFT_BLACK);
m_renderedButton = m_selectedButton;
}
void CalibrateDisplay::stop()
{
if (currentMode == &m_mode)
{
// to avoid crash after deconstruction
m_mode.stop();
lastMode = nullptr;
currentMode = m_oldMode;
}
}
void CalibrateDisplay::rotate(int offset)
{
m_selectedButton += offset;
if (m_selectedButton < 0)
m_selectedButton = 1;
if (m_selectedButton > 1)
m_selectedButton = 0;
}
void CalibrateDisplay::back()
{
switch (m_status)
{
case Status::Begin:
if (m_bootup)
switchScreen<StatusDisplay>();
else
switchScreen<BoardcomputerHardwareSettingsMenu>();
break;
case Status::GasMin:
case Status::GasMax:
case Status::BremsMin:
case Status::BremsMax:
case Status::Confirm:
m_selectedButton = 0;
m_status = Status::Begin;
copyFromSettings();
}
}
void CalibrateDisplay::confirm()
{
switch (m_selectedButton)
{
case 0: // left button pressed
if (!raw_gas || !raw_brems || !m_gas || !m_brems)
return;
switch (m_status)
{
case Status::Begin:
m_status = Status::GasMin;
break;
case Status::GasMin:
m_gasMin = *raw_gas;
m_status = Status::GasMax;
break;
case Status::GasMax:
m_gasMax = *raw_gas;
m_status = Status::BremsMin;
{
const auto dead = (m_gasMax - m_gasMin)/20;
m_gasMin += dead;
m_gasMax -= dead;
}
break;
case Status::BremsMin:
m_bremsMin = *raw_brems;
m_status = Status::BremsMax;
break;
case Status::BremsMax:
m_bremsMax = *raw_brems;
m_status = Status::Confirm;
{
const auto dead = (m_bremsMax - m_bremsMin)/20;
m_bremsMin += dead;
m_bremsMax -= dead;
}
break;
case Status::Confirm:
if (*m_gas > 100 || *m_brems > 100)
return;
copyToSettings();
saveSettings();
if (m_bootup)
switchScreen<StatusDisplay>();
else
switchScreen<BoardcomputerHardwareSettingsMenu>();
}
break;
case 1: // right button pressed
back();
}
}
void CalibrateDisplay::copyFromSettings()
{
m_gasMin = settings.boardcomputerHardware.gasMin;
m_gasMax = settings.boardcomputerHardware.gasMax;
m_bremsMin = settings.boardcomputerHardware.bremsMin;
m_bremsMax = settings.boardcomputerHardware.bremsMax;
}
void CalibrateDisplay::copyToSettings()
{
settings.boardcomputerHardware.gasMin = m_gasMin;
settings.boardcomputerHardware.gasMax = m_gasMax;
settings.boardcomputerHardware.bremsMin = m_bremsMin;
settings.boardcomputerHardware.bremsMax = m_bremsMax;
}
}

View File

@ -0,0 +1,82 @@
#include "calibratevoltagedisplay.h"
// 3rdparty lib includes
#include <fmt/core.h>
#include <actions/toggleboolaction.h>
#include <checkboxicon.h>
// local includes
#include "displays/menus/batterymenu.h"
#include "accessors/settingsaccessors.h"
namespace {
class Save30VCalibrationAction : public virtual espgui::ActionInterface
{
public:
void triggered() override
{
settings.battery.front30VoltCalibration = controllers.front.feedback.batVoltage;
settings.battery.back30VoltCalibration = controllers.back.feedback.batVoltage;
saveSettings();
}
};
class Save50VCalibrationAction : public virtual espgui::ActionInterface
{
public:
void triggered() override
{
settings.battery.front50VoltCalibration = controllers.front.feedback.batVoltage;
settings.battery.back50VoltCalibration = controllers.back.feedback.batVoltage;
saveSettings();
}
};
class ResetCalibrationAction : public virtual espgui::ActionInterface
{
public:
void triggered() override
{
settings.battery.front30VoltCalibration = 3000;
settings.battery.back30VoltCalibration = 3000;
settings.battery.front50VoltCalibration = 5000;
settings.battery.back50VoltCalibration = 5000;
saveSettings();
}
};
float convertToFloat(int16_t value)
{
return value/100.;
}
class BatteryVoltageCalibrationFront30VText : public virtual espgui::TextInterface { public: std::string text() const override { return fmt::format("30V Front: {}", convertToFloat(settings.battery.front30VoltCalibration)); } };
class BatteryVoltageCalibrationBack30VText : public virtual espgui::TextInterface { public: std::string text() const override { return fmt::format("30V Back: {}", convertToFloat(settings.battery.back30VoltCalibration)); } };
class BatteryVoltageCalibrationFront50VText : public virtual espgui::TextInterface { public: std::string text() const override { return fmt::format("50V Front: {}", convertToFloat(settings.battery.front50VoltCalibration)); } };
class BatteryVoltageCalibrationBack50VText : public virtual espgui::TextInterface { public: std::string text() const override { return fmt::format("50V Back: {}", convertToFloat(settings.battery.back50VoltCalibration)); } };
class BatteryVoltageCalibratedText : public virtual espgui::TextInterface { public: std::string text() const override { if (settings.battery.applyCalibration) return fmt::format("F{:.2f}V B{:.2f}", controllers.front.getCalibratedVoltage(), controllers.back.getCalibratedVoltage()); else return "Not activated"; } };
} // namespace
using namespace espgui;
CalibrateVoltageDisplay::CalibrateVoltageDisplay()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGECALIBRATION_30V>, Save30VCalibrationAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGECALIBRATION_50V>, Save50VCalibrationAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_APPLYCALIB>, ToggleBoolAction, CheckboxIcon, BatteryApplyCalibrationAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<BatteryMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryVoltageCalibrationFront30VText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryVoltageCalibrationBack30VText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryVoltageCalibrationFront50VText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryVoltageCalibrationBack50VText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryVoltageCalibratedText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGECALIBRATION_RESET>, ResetCalibrationAction>>();
}
void CalibrateVoltageDisplay::back()
{
switchScreen<BatteryMenu>();
}

View File

@ -14,78 +14,12 @@
#include "widgets/label.h"
#include "globals.h"
using namespace espgui;
class CalibrateVoltageDisplay :
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_BATTERY_CALIBRATE>
{
public:
CalibrateVoltageDisplay();
namespace {
class CalibrateVoltageDisplay;
class BatteryMenu;
class Save30VCalibrationAction : public virtual ActionInterface
{
public:
void triggered() override {
settings.battery.front30VoltCalibration = controllers.front.feedback.batVoltage;
settings.battery.back30VoltCalibration = controllers.back.feedback.batVoltage;
saveSettings();
}
};
class Save50VCalibrationAction : public virtual ActionInterface
{
public:
void triggered() override {
settings.battery.front50VoltCalibration = controllers.front.feedback.batVoltage;
settings.battery.back50VoltCalibration = controllers.back.feedback.batVoltage;
saveSettings();
}
};
class ResetCalibrationAction : public virtual ActionInterface
{
public:
void triggered() override {
settings.battery.front30VoltCalibration = 3000;
settings.battery.back30VoltCalibration = 3000;
settings.battery.front50VoltCalibration = 5000;
settings.battery.back50VoltCalibration = 5000;
saveSettings();
}
};
float convertToFloat(int16_t value)
{
return value/100.;
}
class BatteryVoltageCalibrationFront30VText : public virtual TextInterface { public: std::string text() const override { return fmt::format("30V Front: {}", convertToFloat(settings.battery.front30VoltCalibration)); } };
class BatteryVoltageCalibrationBack30VText : public virtual TextInterface { public: std::string text() const override { return fmt::format("30V Back: {}", convertToFloat(settings.battery.back30VoltCalibration)); } };
class BatteryVoltageCalibrationFront50VText : public virtual TextInterface { public: std::string text() const override { return fmt::format("50V Front: {}", convertToFloat(settings.battery.front50VoltCalibration)); } };
class BatteryVoltageCalibrationBack50VText : public virtual TextInterface { public: std::string text() const override { return fmt::format("50V Back: {}", convertToFloat(settings.battery.back50VoltCalibration)); } };
class BatteryVoltageCalibratedText : public virtual TextInterface { public: std::string text() const override { if (settings.battery.applyCalibration) return fmt::format("F{:.2f}V B{:.2f}", controllers.front.getCalibratedVoltage(settings.battery.applyCalibration), controllers.back.getCalibratedVoltage(settings.battery.applyCalibration)); else return "Not activated"; } };
}
namespace {
class CalibrateVoltageDisplay :
public MenuDisplay,
public StaticText<TEXT_BATTERY_CALIBRATE>,
public BackActionInterface<SwitchScreenAction<BatteryMenu>>
{
public:
CalibrateVoltageDisplay()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGECALIBRATION_30V>, Save30VCalibrationAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGECALIBRATION_50V>, Save50VCalibrationAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_APPLYCALIB>, ToggleBoolAction, CheckboxIcon, BatteryApplyCalibrationAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<BatteryMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryVoltageCalibrationFront30VText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryVoltageCalibrationBack30VText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryVoltageCalibrationFront50VText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryVoltageCalibrationBack50VText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BatteryVoltageCalibratedText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGECALIBRATION_RESET>, ResetCalibrationAction>>();
}
};
} // Namespace
void back() override;
};

View File

@ -0,0 +1,126 @@
#include "gameoflifedisplay.h"
// 3rdparty lib includes
#include <randomutils.h>
#include <esprandom.h>
#include <tftinstance.h>
#include <screenmanager.h>
void GameOfLifeDisplay::start()
{
m_grid = std::make_unique<std::bitset<GRIDX*GRIDY>>();
m_newgrid = std::make_unique<std::bitset<GRIDX*GRIDY>>();
}
void GameOfLifeDisplay::initScreen()
{
espgui::tft.setRotation(3);
espgui::tft.fillScreen(TFT_BLACK);
}
void GameOfLifeDisplay::redraw()
{
if (gen == 0)
{
espgui::tft.fillScreen(TFT_BLACK);
initGrid();
}
computeCA();
drawGrid();
*m_grid = *m_newgrid;
if (++gen == 500)
gen = 0;
}
void GameOfLifeDisplay::stop()
{
espgui::tft.setRotation(0);
m_grid = nullptr;
m_newgrid = nullptr;
}
void GameOfLifeDisplay::confirm()
{
}
void GameOfLifeDisplay::back()
{
}
void GameOfLifeDisplay::drawGrid()
{
uint16_t color = TFT_WHITE;
for (int16_t x = 1; x < GRIDX - 1; x++) {
for (int16_t y = 1; y < GRIDY - 1; y++) {
if (((*m_grid)[index(x,y)]) != ((*m_newgrid)[index(x,y)])) {
if ((*m_newgrid)[index(x,y)] == 1)
color = 0xFFFF; //random(0xFFFF);
else
color = 0;
espgui::tft.fillRect(CELLXY * x, CELLXY * y, CELLXY, CELLXY, color);
}
}
}
}
void GameOfLifeDisplay::initGrid()
{
for (int16_t x = 0; x < GRIDX; x++) {
for (int16_t y = 0; y < GRIDY; y++) {
(*m_newgrid)[index(x,y)] = 0;
if (x == 0 || x == GRIDX - 1 || y == 0 || y == GRIDY - 1)
(*m_grid)[index(x,y)] = 0;
else
{
if (cpputils::randomNumber<uint8_t>(4, espcpputils::esp_random_device{}) == 1)
(*m_grid)[index(x,y)] = 1;
else
(*m_grid)[index(x,y)] = 0;
}
}
}
}
int GameOfLifeDisplay::getNumberOfNeighbors(int x, int y)
{
int n{};
for (auto xOffset : {-1,0,1})
for (auto yOffset : {-1,0,1})
{
if (xOffset == 0 && yOffset == 0)
continue;
const auto new_x = x+xOffset;
const auto new_y = y+yOffset;
if (new_x >= 0 && new_y >= 0 &&
new_x < GRIDX && new_y < GRIDY)
n += (*m_grid)[index(new_x, new_y)];
}
return n;
}
void GameOfLifeDisplay::computeCA()
{
for (int16_t x = 1; x < GRIDX; x++) {
for (int16_t y = 1; y < GRIDY; y++) {
int neighbors = getNumberOfNeighbors(x, y);
if ((*m_grid)[index(x,y)] == true && (neighbors == 2 || neighbors == 3 ))
(*m_newgrid)[index(x,y)] = true;
else if ((*m_grid)[index(x,y)] == 1)
(*m_newgrid)[index(x,y)] = false;
if ((*m_grid)[index(x,y)] == false && (neighbors == 3))
(*m_newgrid)[index(x,y)] = true;
else if ((*m_grid)[index(x,y)] == 0)
(*m_newgrid)[index(x,y)] = false;
}
}
}

View File

@ -4,27 +4,22 @@
#include <bitset>
#include <memory>
// 3rdparty lib includes
#include <randomutils.h>
#include <esprandom.h>
// local includes
#include "display.h"
#include "actions/switchscreenaction.h"
namespace {
class DemosMenu;
}
namespace {
class GameOfLifeDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<DemosMenu>>, public BackActionInterface<SwitchScreenAction<DemosMenu>>
class GameOfLifeDisplay : public espgui::Display
{
using Base = espgui::Display;
public:
void start() override;
void initScreen() override;
void redraw() override;
void stop() override;
void confirm() override;
void back() override;
private:
//Draws the grid on the display
@ -75,114 +70,3 @@ private:
int gen = 0;
};
void GameOfLifeDisplay::start()
{
m_grid = std::make_unique<std::bitset<GRIDX*GRIDY>>();
m_newgrid = std::make_unique<std::bitset<GRIDX*GRIDY>>();
}
void GameOfLifeDisplay::initScreen()
{
tft.setRotation(3);
tft.fillScreen(TFT_BLACK);
}
void GameOfLifeDisplay::redraw()
{
if (gen == 0)
{
tft.fillScreen(TFT_BLACK);
initGrid();
}
computeCA();
drawGrid();
*m_grid = *m_newgrid;
if (++gen == 500)
gen = 0;
}
void GameOfLifeDisplay::stop()
{
tft.setRotation(0);
m_grid = nullptr;
m_newgrid = nullptr;
}
void GameOfLifeDisplay::drawGrid()
{
uint16_t color = TFT_WHITE;
for (int16_t x = 1; x < GRIDX - 1; x++) {
for (int16_t y = 1; y < GRIDY - 1; y++) {
if (((*m_grid)[index(x,y)]) != ((*m_newgrid)[index(x,y)])) {
if ((*m_newgrid)[index(x,y)] == 1)
color = 0xFFFF; //random(0xFFFF);
else
color = 0;
tft.fillRect(CELLXY * x, CELLXY * y, CELLXY, CELLXY, color);
}
}
}
}
void GameOfLifeDisplay::initGrid()
{
for (int16_t x = 0; x < GRIDX; x++) {
for (int16_t y = 0; y < GRIDY; y++) {
(*m_newgrid)[index(x,y)] = 0;
if (x == 0 || x == GRIDX - 1 || y == 0 || y == GRIDY - 1)
(*m_grid)[index(x,y)] = 0;
else
{
if (cpputils::randomNumber<uint8_t>(4, espcpputils::esp_random_device{}) == 1)
(*m_grid)[index(x,y)] = 1;
else
(*m_grid)[index(x,y)] = 0;
}
}
}
}
int GameOfLifeDisplay::getNumberOfNeighbors(int x, int y)
{
int n{};
for (auto xOffset : {-1,0,1})
for (auto yOffset : {-1,0,1})
{
if (xOffset == 0 && yOffset == 0)
continue;
const auto new_x = x+xOffset;
const auto new_y = y+yOffset;
if (new_x >= 0 && new_y >= 0 &&
new_x < GRIDX && new_y < GRIDY)
n += (*m_grid)[index(new_x, new_y)];
}
return n;
}
void GameOfLifeDisplay::computeCA()
{
for (int16_t x = 1; x < GRIDX; x++) {
for (int16_t y = 1; y < GRIDY; y++) {
int neighbors = getNumberOfNeighbors(x, y);
if ((*m_grid)[index(x,y)] == true && (neighbors == 2 || neighbors == 3 ))
(*m_newgrid)[index(x,y)] = true;
else if ((*m_grid)[index(x,y)] == 1)
(*m_newgrid)[index(x,y)] = false;
if ((*m_grid)[index(x,y)] == false && (neighbors == 3))
(*m_newgrid)[index(x,y)] = true;
else if ((*m_grid)[index(x,y)] == 0)
(*m_newgrid)[index(x,y)] = false;
}
}
}
}

View File

@ -11,11 +11,6 @@
#include "widgets/progressbar.h"
#include "modes/ignoreinputmode.h"
namespace {
class StatusDisplay;
class BoardcomputerHardwareSettingsMenu;
}
namespace {
#ifdef FEATURE_GAMETRAK
class GametrakCalibrateDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>, public BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>

View File

@ -0,0 +1,50 @@
#include "garagedisplay.h"
// system includes
// esp-idf includes
#include <esp_log.h>
// 3rdparty lib includes
#include <fmt/core.h>
#include <tftinstance.h>
#include <screenmanager.h>
// local includes
#include "displays/menus/mainmenu.h"
#include "globals.h"
#include "texts.h"
#ifdef FEATURE_GARAGE
void GarageDisplay::start()
{
}
void GarageDisplay::initScreen()
{
espgui::tft.fillScreen(TFT_BLACK);
espgui::tft.setTextFont(4);
espgui::tft.setTextColor(TFT_YELLOW);
espgui::tft.drawString(TEXT_GARAGE, 5, 5, 4);
espgui::tft.fillRect(0, 34, espgui::tft.width(), 3, TFT_WHITE);
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
espgui::tft.drawString("Garage", 20, 100);
}
void GarageDisplay::redraw()
{
}
void GarageDisplay::confirm()
{
}
void GarageDisplay::back()
{
espgui::switchScreen<MainMenu>();
}
#endif

View File

@ -1,62 +1,18 @@
#pragma once
// system includes
// esp-idf includes
#include <esp_log.h>
// 3rdparty lib includes
#include <fmt/core.h>
// local includes
#include "display.h"
#include "actions/switchscreenaction.h"
#include "globals.h"
#include "texts.h"
#include "widgets/label.h"
namespace {
class MainMenu;
}
namespace {
#ifdef FEATURE_GARAGE
class GarageDisplay : public Display, public BackActionInterface<SwitchScreenAction<MainMenu>>
class GarageDisplay : public espgui::Display
{
public:
void start() override;
void initScreen() override;
void redraw() override;
void confirm() override;
void back() override;
private:
};
void GarageDisplay::start()
{
}
void GarageDisplay::initScreen()
{
tft.fillScreen(TFT_BLACK);
tft.setTextFont(4);
tft.setTextColor(TFT_YELLOW);
tft.drawString(TEXT_GARAGE, 5, 5, 4);
tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.drawString("Garage", 20, 100);
}
void GarageDisplay::redraw()
{
}
void GarageDisplay::confirm()
{
}
#endif
}

View File

@ -1,77 +0,0 @@
#pragma once
#include "display.h"
#include "textinterface.h"
#include "widgets/label.h"
#include "widgets/graph.h"
#include "globals.h"
#include "statistics.h"
namespace {
template<size_t COUNT>
class GraphAccessorInterface
{
public:
virtual std::array<std::reference_wrapper<const statistics::ContainerType>, COUNT> getBuffers() const = 0;
};
template<typename T>
class SingleGraphAccessor : public virtual GraphAccessorInterface<1>
{
public:
Graph<200, 1>::Container getBuffers() const
{
return {T{}.getBuffer()};
}
};
template<typename T1, typename T2>
class DualGraphAccessor : public virtual GraphAccessorInterface<2>
{
public:
Graph<200, 2>::Container getBuffers() const
{
return {T1{}.getBuffer(), T2{}.getBuffer()};
}
};
template<size_t COUNT>
class GraphDisplay :
public Display,
public virtual TextInterface,
public virtual GraphAccessorInterface<COUNT>
{
public:
void initScreen() override;
void redraw() override;
private:
static constexpr int screenHeight = 320, topMargin = 40, bottomMargin = 10, labelOffset = -5;
static constexpr int graphHeight = screenHeight-topMargin-bottomMargin;
Label m_titleLabel{5, 5}; // 230, 25
Graph<200, COUNT> m_graph{0, 40, 270};
};
template<size_t COUNT>
void GraphDisplay<COUNT>::initScreen()
{
tft.fillScreen(TFT_BLACK);
m_titleLabel.start();
tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE);
m_graph.start(static_cast<const GraphAccessorInterface<COUNT> &>(*this).getBuffers());
}
template<size_t COUNT>
void GraphDisplay<COUNT>::redraw()
{
tft.setTextFont(4);
tft.setTextColor(TFT_YELLOW, TFT_BLACK);
m_titleLabel.redraw(text());
m_graph.redraw(static_cast<const GraphAccessorInterface<COUNT> &>(*this).getBuffers());
}
}

View File

@ -0,0 +1,242 @@
#include "ledstripcolorsdisplay.h"
// esp-idf includes
#include <esp_log.h>
// 3rdparty lib includes
#include <TFT_eSPI.h>
#include <cpputils.h>
#include <menuitem.h>
#include <actions/switchscreenaction.h>
#include <actioninterface.h>
#include <tftinstance.h>
#include <screenmanager.h>
// local includes
#include "menudisplay.h"
#include "utils.h"
#include "icons/back.h"
#include "icons/bobbycar.h"
#include "texts.h"
#include "actions/dummyaction.h"
#include "globals.h"
#include "displays/menus/ledstripmenu.h"
#ifdef FEATURE_LEDSTRIP
int8_t selected_side = 7;
int8_t selected_color;
bool state_select_color{false};
bool last_state = {false};
const std::array<CRGB, 8> Colors = {
CRGB{0,0,0},
CRGB{255,255,255},
CRGB{255,0,0},
CRGB{255,255,0},
CRGB{0,255,0},
CRGB{0,255,255},
CRGB{0,0,255},
CRGB{255,0,255}
};
const std::array<uint16_t, 8> tft_colors = {
TFT_BLACK,
TFT_WHITE,
TFT_RED,
TFT_YELLOW,
TFT_GREEN,
TFT_CYAN,
TFT_BLUE,
TFT_MAGENTA
};
std::string LedstripColorsDisplay::text() const
{
return TEXT_LEDSTRIPCOLORMENU;
}
void LedstripColorsDisplay::back()
{
if(!state_select_color)
{
espgui::switchScreen<LedstripMenu>();
}
else
{
state_select_color = false;
espgui::tft.fillRect(0, 228, espgui::tft.width(), ((espgui::tft.width() - 40) / 8) + 4, TFT_BLACK);
}
}
void LedstripColorsDisplay::initScreen()
{
Base::initScreen();
espgui::tft.setSwapBytes(true);
espgui::tft.pushImage(70, 60, bobbyicons::bobbycar.WIDTH, bobbyicons::bobbycar.HEIGHT, bobbyicons::bobbycar.buffer);
espgui::tft.setSwapBytes(false);
}
void LedstripColorsDisplay::redraw()
{
Base::redraw();
auto y_pos = ((espgui::tft.width() - 40) / 8 + 4) + 240;
if (last_state != state_select_color)
{
espgui::tft.fillRect(0,y_pos - 1, espgui::tft.width(), 20, TFT_BLACK);
last_state = state_select_color;
}
espgui::tft.setTextFont(2);
espgui::tft.setTextColor(TFT_WHITE);
espgui::tft.drawString(state_select_color ?
"Please select a color!" :
"Please select a side!", 50, y_pos);
if (!already_drew_circle)
{
drawSide(static_cast<Bobbycar_Side>(selected_side), TFT_GOLD);
already_drew_circle = true;
}
}
void LedstripColorsDisplay::rotate(int offset)
{
if (offset < 0)
{
if (state_select_color)
{
selected_color++;
if (selected_color > 7)
{
selected_color = 0;
}
}
else
{
selected_side++;
if (selected_side > 7)
{
selected_side = 0;
}
}
}
else if (offset > 0)
{
if (state_select_color)
{
selected_color--;
if (selected_color < 0)
{
selected_color = 7;
}
}
else
{
selected_side--;
if (selected_side < 0)
{
selected_side = 7;
}
}
}
if (state_select_color)
{
drawColors();
}
else
{
espgui::tft.fillRect(0, 228, espgui::tft.width(), ((espgui::tft.width() - 40) / 8) + 4, TFT_BLACK);
clearSides();
drawSide(static_cast<Bobbycar_Side>(selected_side), TFT_GOLD);
}
}
void LedstripColorsDisplay::confirm()
{
if(!state_select_color)
{
state_select_color = true;
drawColors();
}
else
{
ledstrip_custom_colors[selected_side] = Colors[selected_color];
// Uncomment to close select color menu on color select
/*
state_select_color = false;
espgui::tft.fillRect(0, 228, espgui::tft.width(), ((espgui::tft.width() - 40) / 8) + 4, TFT_BLACK);
*/
}
}
void LedstripColorsDisplay::drawColors()
{
uint16_t width = (espgui::tft.width() - 40);
auto cube_width = width / 8;
espgui::tft.fillRect(0, 228, espgui::tft.width(), cube_width + 4, TFT_BLACK);
espgui::tft.fillRect(21, 231, width - 1, cube_width - 1, TFT_WHITE);
espgui::tft.fillRect(20 + (selected_color * cube_width - 1), 228, cube_width + 4, cube_width + 4, TFT_YELLOW);
for (int index = 0; index < 8; index++)
{
auto offset = index * (cube_width);
espgui::tft.fillRect(22 + offset, 232, cube_width - 4, cube_width - 4, tft_colors[index]);
}
}
void LedstripColorsDisplay::clearSides()
{
for(int index = 0; index < 8; index++)
{
drawSide(static_cast<Bobbycar_Side>(index), TFT_BLACK);
}
}
void LedstripColorsDisplay::drawSide(Bobbycar_Side side, unsigned int color)
{
const auto middle = espgui::tft.width() / 2;
const auto width = bobbyicons::bobbycar.WIDTH;
const auto height = bobbyicons::bobbycar.HEIGHT;
const auto left = middle - (width / 2);
const auto right = middle + (width / 2);
const auto above = 50;
const auto bellow = above + 10 + bobbyicons::bobbycar.HEIGHT;
switch (side) {
case Bobbycar_Side::FRONT:
espgui::tft.fillRect(left, above, width, 5, color);
break;
case Bobbycar_Side::FRONT_LEFT:
espgui::tft.fillRect(left - 10, above + 10, 5, height / 2, color);
espgui::tft.fillRect(left, above, width / 2, 5, color);
break;
case Bobbycar_Side::LEFT:
espgui::tft.fillRect(left - 10, above + 10, 5, height, color);
break;
case Bobbycar_Side::BACK_LEFT:
espgui::tft.fillRect(left - 10, above + 10 + (height / 2), 5, height / 2, color);
espgui::tft.fillRect(left, bellow + 5, width / 2, 5, color);
break;
case Bobbycar_Side::BACK:
espgui::tft.fillRect(left, bellow + 5, width, 5, color);
break;
case Bobbycar_Side::BACK_RIGHT:
espgui::tft.fillRect(right + 5, above + 10 + (height / 2), 5, height / 2, color);
espgui::tft.fillRect(middle, bellow + 5, width / 2, 5, color);
break;
case Bobbycar_Side::RIGHT:
espgui::tft.fillRect(right + 5, above + 10, 5, height, color);
break;
case Bobbycar_Side::FRONT_RIGHT:
espgui::tft.fillRect(right + 5, above + 10, 5, height / 2, color);
espgui::tft.fillRect(middle, above, width / 2, 5, color);
break;
}
// espgui::tft.fillCircle(espgui::tft.width() / 2, 140, 100, TFT_BLACK);
}
#endif

View File

@ -1,57 +1,24 @@
#pragma once
// esp-idf includes
#include <esp_log.h>
// system includes
#include <array>
// 3rdparty lib includes
#include <TFT_eSPI.h>
#include <displaywithtitle.h>
#include <FastLED.h>
#include <cpputils.h>
#include <menuitem.h>
#include <actions/switchscreenaction.h>
#include <actioninterface.h>
// local includes
#include "menudisplay.h"
#include "utils.h"
#include "ledstrip.h"
#include "icons/back.h"
#include "icons/bobbycar.h"
#include "texts.h"
#include "actions/dummyaction.h"
#include "globals.h"
namespace {
class LedstripMenu;
}
#ifdef FEATURE_LEDSTRIP
extern int8_t selected_side;
extern int8_t selected_color;
extern bool state_select_color;
extern bool last_state;
namespace {
static int8_t selected_side = 7;
static int8_t selected_color;
bool state_select_color{false};
bool last_state = {false};
extern const std::array<CRGB, 8> Colors;
const std::array<CRGB, 8> Colors = {
CRGB{0,0,0},
CRGB{255,255,255},
CRGB{255,0,0},
CRGB{255,255,0},
CRGB{0,255,0},
CRGB{0,255,255},
CRGB{0,0,255},
CRGB{255,0,255}
};
const std::array<uint16_t, 8> tft_colors = {
TFT_BLACK,
TFT_WHITE,
TFT_RED,
TFT_YELLOW,
TFT_GREEN,
TFT_CYAN,
TFT_BLUE,
TFT_MAGENTA
};
extern const std::array<uint16_t, 8> tft_colors;
class LedstripColorsDisplay : public espgui::DisplayWithTitle
{
@ -72,195 +39,4 @@ public:
private:
bool already_drew_circle{false};
};
std::string LedstripColorsDisplay::text() const
{
return TEXT_LEDSTRIPCOLORMENU;
}
void LedstripColorsDisplay::back()
{
if(!state_select_color)
{
switchScreen<LedstripMenu>();
}
else
{
state_select_color = false;
tft.fillRect(0, 228, tft.width(), ((tft.width() - 40) / 8) + 4, TFT_BLACK);
}
}
void LedstripColorsDisplay::initScreen()
{
Base::initScreen();
tft.setSwapBytes(true);
tft.pushImage(70, 60, bobbyicons::bobbycar.WIDTH, bobbyicons::bobbycar.HEIGHT, bobbyicons::bobbycar.buffer);
tft.setSwapBytes(false);
}
void LedstripColorsDisplay::redraw()
{
Base::redraw();
auto y_pos = ((tft.width() - 40) / 8 + 4) + 240;
if (last_state != state_select_color)
{
tft.fillRect(0,y_pos - 1, tft.width(), 20, TFT_BLACK);
last_state = state_select_color;
}
tft.setTextFont(2);
tft.setTextColor(TFT_WHITE);
tft.drawString(state_select_color ?
"Please select a color!" :
"Please select a side!", 50, y_pos);
if (!already_drew_circle)
{
drawSide(static_cast<Bobbycar_Side>(selected_side), TFT_GOLD);
already_drew_circle = true;
}
}
void LedstripColorsDisplay::rotate(int offset)
{
if (offset < 0)
{
if (state_select_color)
{
selected_color++;
if (selected_color > 7)
{
selected_color = 0;
}
}
else
{
selected_side++;
if (selected_side > 7)
{
selected_side = 0;
}
}
}
else if (offset > 0)
{
if (state_select_color)
{
selected_color--;
if (selected_color < 0)
{
selected_color = 7;
}
}
else
{
selected_side--;
if (selected_side < 0)
{
selected_side = 7;
}
}
}
if (state_select_color)
{
drawColors();
}
else
{
tft.fillRect(0, 228, tft.width(), ((tft.width() - 40) / 8) + 4, TFT_BLACK);
clearSides();
drawSide(static_cast<Bobbycar_Side>(selected_side), TFT_GOLD);
}
}
void LedstripColorsDisplay::confirm()
{
if(!state_select_color)
{
state_select_color = true;
drawColors();
}
else
{
ledstrip_custom_colors[selected_side] = Colors[selected_color];
// Uncomment to close select color menu on color select
/*
state_select_color = false;
tft.fillRect(0, 228, tft.width(), ((tft.width() - 40) / 8) + 4, TFT_BLACK);
*/
}
}
void LedstripColorsDisplay::drawColors()
{
uint16_t width = (tft.width() - 40);
auto cube_width = width / 8;
tft.fillRect(0, 228, tft.width(), cube_width + 4, TFT_BLACK);
tft.fillRect(21, 231, width - 1, cube_width - 1, TFT_WHITE);
tft.fillRect(20 + (selected_color * cube_width - 1), 228, cube_width + 4, cube_width + 4, TFT_YELLOW);
for (int index = 0; index < 8; index++)
{
auto offset = index * (cube_width);
tft.fillRect(22 + offset, 232, cube_width - 4, cube_width - 4, tft_colors[index]);
}
}
void LedstripColorsDisplay::clearSides()
{
for(int index = 0; index < 8; index++)
{
drawSide(static_cast<Bobbycar_Side>(index), TFT_BLACK);
}
}
void LedstripColorsDisplay::drawSide(Bobbycar_Side side, unsigned int color)
{
const auto middle = tft.width() / 2;
const auto width = bobbyicons::bobbycar.WIDTH;
const auto height = bobbyicons::bobbycar.HEIGHT;
const auto left = middle - (width / 2);
const auto right = middle + (width / 2);
const auto above = 50;
const auto bellow = above + 10 + bobbyicons::bobbycar.HEIGHT;
switch (side) {
case Bobbycar_Side::FRONT:
tft.fillRect(left, above, width, 5, color);
break;
case Bobbycar_Side::FRONT_LEFT:
tft.fillRect(left - 10, above + 10, 5, height / 2, color);
tft.fillRect(left, above, width / 2, 5, color);
break;
case Bobbycar_Side::LEFT:
tft.fillRect(left - 10, above + 10, 5, height, color);
break;
case Bobbycar_Side::BACK_LEFT:
tft.fillRect(left - 10, above + 10 + (height / 2), 5, height / 2, color);
tft.fillRect(left, bellow + 5, width / 2, 5, color);
break;
case Bobbycar_Side::BACK:
tft.fillRect(left, bellow + 5, width, 5, color);
break;
case Bobbycar_Side::BACK_RIGHT:
tft.fillRect(right + 5, above + 10 + (height / 2), 5, height / 2, color);
tft.fillRect(middle, bellow + 5, width / 2, 5, color);
break;
case Bobbycar_Side::RIGHT:
tft.fillRect(right + 5, above + 10, 5, height, color);
break;
case Bobbycar_Side::FRONT_RIGHT:
tft.fillRect(right + 5, above + 10, 5, height / 2, color);
tft.fillRect(middle, above, width / 2, 5, color);
break;
}
// tft.fillCircle(tft.width() / 2, 140, 100, TFT_BLACK);
}
} // Namespace
#endif

View File

@ -0,0 +1,144 @@
#include "lockscreen.h"
// 3rdparty lib includes
#include <tftinstance.h>
#include <screenmanager.h>
// local includes
#include "globals.h"
#include "utils.h"
#include "texts.h"
#include "buttons.h"
#include "displays/menus/mainmenu.h"
void Lockscreen::start()
{
m_numbers = {0,0,0,0};
m_currentIndex = 0;
m_pressed = false;
m_rotated = 0;
m_oldMode = currentMode;
currentMode = &m_mode;
profileButtonDisabled = !settings.lockscreen.allowPresetSwitch;
}
void Lockscreen::initScreen()
{
espgui::tft.fillScreen(TFT_BLACK);
espgui::tft.setTextFont(4);
espgui::tft.setTextColor(TFT_YELLOW);
espgui::tft.drawString(TEXT_LOCKVEHICLE, 5, 5);
espgui::tft.fillRect(0, 34, espgui::tft.width(), 3, TFT_WHITE);
espgui::tft.setTextColor(TFT_WHITE);
espgui::tft.drawString("Enter code to unlock:", 0, 50);
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
for(int i = 0; i <= 3; i++)
{
drawRect(i, 3, TFT_WHITE);
drawRect(i, 4, TFT_WHITE);
}
for (auto &label : m_labels)
label.start();
espgui::tft.setTextFont(7);
drawRect(0, 1, TFT_YELLOW);
drawRect(0, 2, TFT_YELLOW);
m_labels[0].redraw(std::to_string(m_numbers[0]));
}
void Lockscreen::update()
{
// just in case someone changes that settings somehow
profileButtonDisabled = !settings.lockscreen.allowPresetSwitch;
}
void Lockscreen::redraw()
{
if (m_pressed)
{
drawRect(m_currentIndex, 1, TFT_BLACK);
drawRect(m_currentIndex, 2, TFT_BLACK);
if (++m_currentIndex>=4)
{
if (m_numbers == settings.lockscreen.pin)
{
espgui::switchScreen<MainMenu>();
#ifdef LOCKSCREEN_PLUGIN
#pragma message "Activating Lockscreen Plugin"
#include LOCKSCREEN_PLUGIN
#endif
return;
}
m_numbers = {0,0,0,0};
m_currentIndex = 0;
std::for_each(std::begin(m_labels) + 1, std::end(m_labels), [](auto &label){ label.redraw({}); });
}
m_labels[m_currentIndex].redraw(std::to_string(m_numbers[m_currentIndex]));
drawRect(m_currentIndex, 1, TFT_YELLOW);
drawRect(m_currentIndex, 2, TFT_YELLOW);
m_pressed = false;
}
if (m_rotated)
{
m_numbers[m_currentIndex] -= m_rotated;
if (m_numbers[m_currentIndex] < 0)
m_numbers[m_currentIndex]+=10;
else if (m_numbers[m_currentIndex] > 9)
m_numbers[m_currentIndex]-=10;
m_labels[m_currentIndex].redraw(std::to_string(m_numbers[m_currentIndex]));
m_rotated = 0;
}
}
void Lockscreen::stop()
{
Base::stop();
if (currentMode == &m_mode)
{
// to avoid crash after deconstruction
m_mode.stop();
lastMode = nullptr;
currentMode = m_oldMode;
}
profileButtonDisabled = false;
}
void Lockscreen::confirm()
{
m_pressed = true;
}
void Lockscreen::back()
{
}
void Lockscreen::rotate(int offset)
{
m_rotated += offset;
}
void Lockscreen::drawRect(int index, int offset, uint32_t color) const
{
espgui::tft.drawRect(m_labels[index].x()-offset, m_labels[index].y()-offset, boxWidth+(offset*2), boxHeight+(offset*2), color);
}

View File

@ -6,24 +6,15 @@
// local includes
#include "display.h"
#include "widgets/label.h"
#include "globals.h"
#include "utils.h"
#include "texts.h"
#include "modes/ignoreinputmode.h"
#include "buttons.h"
#ifdef LOCKSCREEN_PLUGIN
#include "ledstrip.h"
#endif
namespace {
class MainMenu;
}
namespace {
class Lockscreen : public Display, public DummyBack
class Lockscreen : public espgui::Display
{
using Base = Display;
using Base = espgui::Display;
static constexpr auto boxWidth = 35;
static constexpr auto boxHeight = 50;
@ -37,16 +28,17 @@ public:
void stop() override;
void confirm() override;
void back() override;
void rotate(int offset) override;
private:
void drawRect(int index, int offset, uint32_t color) const;
std::array<Label, 4> m_labels {{
Label{spacing, 100}, // boxWidth, boxHeight
Label{spacing*2+boxWidth, 100}, // boxWidth, boxHeight
Label{spacing*3+boxWidth*2, 100}, // boxWidth, boxHeight
Label{spacing*4+boxWidth*3, 100} // boxWidth, boxHeight
std::array<espgui::Label, 4> m_labels {{
espgui::Label{spacing, 100}, // boxWidth, boxHeight
espgui::Label{spacing*2+boxWidth, 100}, // boxWidth, boxHeight
espgui::Label{spacing*3+boxWidth*2, 100}, // boxWidth, boxHeight
espgui::Label{spacing*4+boxWidth*3, 100} // boxWidth, boxHeight
}};
std::array<int8_t, 4> m_numbers;
@ -59,132 +51,3 @@ private:
ModeInterface *m_oldMode;
IgnoreInputMode m_mode{0, bobbycar::protocol::ControlType::FieldOrientedControl, bobbycar::protocol::ControlMode::Speed};
};
void Lockscreen::start()
{
m_numbers = {0,0,0,0};
m_currentIndex = 0;
m_pressed = false;
m_rotated = 0;
m_oldMode = currentMode;
currentMode = &m_mode;
profileButtonDisabled = !settings.lockscreen.allowPresetSwitch;
}
void Lockscreen::initScreen()
{
tft.fillScreen(TFT_BLACK);
tft.setTextFont(4);
tft.setTextColor(TFT_YELLOW);
tft.drawString(TEXT_LOCKVEHICLE, 5, 5);
tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE);
tft.setTextColor(TFT_WHITE);
tft.drawString("Enter code to unlock:", 0, 50);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
for(int i = 0; i <= 3; i++)
{
drawRect(i, 3, TFT_WHITE);
drawRect(i, 4, TFT_WHITE);
}
for (auto &label : m_labels)
label.start();
tft.setTextFont(7);
drawRect(0, 1, TFT_YELLOW);
drawRect(0, 2, TFT_YELLOW);
m_labels[0].redraw(std::to_string(m_numbers[0]));
}
void Lockscreen::update()
{
// just in case someone changes that settings somehow
profileButtonDisabled = !settings.lockscreen.allowPresetSwitch;
}
void Lockscreen::redraw()
{
if (m_pressed)
{
drawRect(m_currentIndex, 1, TFT_BLACK);
drawRect(m_currentIndex, 2, TFT_BLACK);
if (++m_currentIndex>=4)
{
if (m_numbers == settings.lockscreen.pin)
{
switchScreen<MainMenu>();
#ifdef LOCKSCREEN_PLUGIN
#pragma message "Activating Lockscreen Plugin"
#include LOCKSCREEN_PLUGIN
#endif
return;
}
m_numbers = {0,0,0,0};
m_currentIndex = 0;
std::for_each(std::begin(m_labels) + 1, std::end(m_labels), [](auto &label){ label.redraw({}); });
}
m_labels[m_currentIndex].redraw(std::to_string(m_numbers[m_currentIndex]));
drawRect(m_currentIndex, 1, TFT_YELLOW);
drawRect(m_currentIndex, 2, TFT_YELLOW);
m_pressed = false;
}
if (m_rotated)
{
m_numbers[m_currentIndex] -= m_rotated;
if (m_numbers[m_currentIndex] < 0)
m_numbers[m_currentIndex]+=10;
else if (m_numbers[m_currentIndex] > 9)
m_numbers[m_currentIndex]-=10;
m_labels[m_currentIndex].redraw(std::to_string(m_numbers[m_currentIndex]));
m_rotated = 0;
}
}
void Lockscreen::stop()
{
Base::stop();
if (currentMode == &m_mode)
{
// to avoid crash after deconstruction
m_mode.stop();
lastMode = nullptr;
currentMode = m_oldMode;
}
profileButtonDisabled = false;
}
void Lockscreen::confirm()
{
m_pressed = true;
}
void Lockscreen::rotate(int offset)
{
m_rotated += offset;
}
void Lockscreen::drawRect(int index, int offset, uint32_t color) const
{
tft.drawRect(m_labels[index].x()-offset, m_labels[index].y()-offset, boxWidth+(offset*2), boxHeight+(offset*2), color);
}
}

View File

@ -0,0 +1,69 @@
#include "aboutmenu.h"
// local includes
#include "utils.h"
#include "actions/dummyaction.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "esptexthelpers.h"
#include "displays/menus/settingsmenu.h"
#ifdef FEATURE_OTA
#include <espasyncota.h>
#include <esp_ota_ops.h>
#include "fmt/core.h"
#endif
namespace {
class CurrentVersionText : public virtual espgui::TextInterface
{
public:
std::string text() const override
{
#ifdef FEATURE_OTA
if (const esp_app_desc_t *app_desc = esp_ota_get_app_description())
{
return fmt::format("Version: {}", app_desc->version);
}
#endif
return "Version: 1.0";
};
};
constexpr char TEXT_VERSION[] = "Version: 1.0";
} // namespace
using namespace espgui;
AboutMenu::AboutMenu()
{
constructMenuItem<makeComponent<MenuItem, CurrentVersionText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, HeapTotal8Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, HeapFree8Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, HeapMinFree8Text, StaticFont<2>, DisabledColor, DummyAction>>();
#ifndef HEAP_LRGST_CRASH_TEXT_FIX
constructMenuItem<makeComponent<MenuItem, HeapLargest8Text, StaticFont<2>, DisabledColor, DummyAction>>();
#endif
constructMenuItem<makeComponent<MenuItem, HeapTotal32Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, HeapFree32Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, HeapMinFree32Text, StaticFont<2>, DisabledColor, DummyAction>>();
#ifndef HEAP_LRGST_CRASH_TEXT_FIX
constructMenuItem<makeComponent<MenuItem, HeapLargest32Text, StaticFont<2>, DisabledColor, DummyAction>>();
#endif
constructMenuItem<makeComponent<MenuItem, EspChipRevisionText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspCpuFreqMHzText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspCycleCountText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspSdkVersionText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspFlashChipSizeText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspFlashChipSpeedText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspFlashChipModeText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspSketchSizeText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspSketchMd5Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspFreeSketchSpaceText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void AboutMenu::back()
{
switchScreen<SettingsMenu>();
}

View File

@ -1,73 +1,17 @@
#pragma once
// 3rdparty lib includes
#include <menudisplay.h>
// local includes
#include "menudisplay.h"
#include "utils.h"
#include "actions/dummyaction.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "esptexthelpers.h"
#include "texts.h"
#ifdef FEATURE_OTA
#include <espasyncota.h>
#include <esp_ota_ops.h>
#include "fmt/core.h"
#endif
// forward declares
namespace {
class SettingsMenu;
} // namespace
using namespace espgui;
namespace {
class currentVersionText : public virtual TextInterface { public: std::string text() const override {
#ifdef FEATURE_OTA
if (const esp_app_desc_t *app_desc = esp_ota_get_app_description())
{
return fmt::format("Version: {}", app_desc->version);
}
#endif
return "Version: 1.0";
};
};
constexpr char TEXT_VERSION[] = "Version: 1.0";
class AboutMenu :
public MenuDisplay,
public StaticText<TEXT_ABOUT>,
public BackActionInterface<SwitchScreenAction<SettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_ABOUT>
{
public:
AboutMenu()
{
constructMenuItem<makeComponent<MenuItem, currentVersionText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, HeapTotal8Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, HeapFree8Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, HeapMinFree8Text, StaticFont<2>, DisabledColor, DummyAction>>();
#ifndef HEAP_LRGST_CRASH_TEXT_FIX
constructMenuItem<makeComponent<MenuItem, HeapLargest8Text, StaticFont<2>, DisabledColor, DummyAction>>();
#endif
constructMenuItem<makeComponent<MenuItem, HeapTotal32Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, HeapFree32Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, HeapMinFree32Text, StaticFont<2>, DisabledColor, DummyAction>>();
#ifndef HEAP_LRGST_CRASH_TEXT_FIX
constructMenuItem<makeComponent<MenuItem, HeapLargest32Text, StaticFont<2>, DisabledColor, DummyAction>>();
#endif
constructMenuItem<makeComponent<MenuItem, EspChipRevisionText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspCpuFreqMHzText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspCycleCountText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspSdkVersionText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspFlashChipSizeText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspFlashChipSpeedText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspFlashChipModeText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspSketchSizeText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspSketchMd5Text, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EspFreeSketchSpaceText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
AboutMenu();
void back() override;
};
} // namespace

View File

@ -12,11 +12,6 @@
#include "accessors/settingsaccessors.h"
#include "texts.h"
// forward declares
namespace {
class WifiSettingsMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -0,0 +1,55 @@
#include "batterymenu.h"
// 3rdparty lib includes
#include <changevaluedisplay.h>
// local includes
#include "mainmenu.h"
#include "displays/calibratevoltagedisplay.h"
#include "accessors/settingsaccessors.h"
class CurrentBatteryStatusText : public virtual espgui::TextInterface { public: std::string text() const override { return getBatteryPercentageString(); } };
using BatteryCellSeriesChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<uint8_t>,
espgui::StaticText<TEXT_CELL_SERIES>,
BatterySeriesCellsAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BatteryMenu>>,
espgui::SwitchScreenAction<BatteryMenu>
>;
using BatteryCellParallelChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<uint8_t>,
espgui::StaticText<TEXT_CELL_PARALLEL>,
BatteryParallelCellsAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BatteryMenu>>,
espgui::SwitchScreenAction<BatteryMenu>
>;
using BatteryWHperKMChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<uint16_t>,
espgui::StaticText<TEXT_BATTERY_WHKM>,
BatteryWHperKMAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BatteryMenu>>,
espgui::SwitchScreenAction<BatteryMenu>
>;
using namespace espgui;
BatteryMenu::BatteryMenu()
{
constructMenuItem<makeComponent<MenuItem, CurrentBatteryStatusText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CELL_SERIES, BatterySeriesCellsAccessor>, SwitchScreenAction<BatteryCellSeriesChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CELL_PARALLEL, BatteryParallelCellsAccessor>, SwitchScreenAction<BatteryCellParallelChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BATTERY_WHKM, BatteryWHperKMAccessor>, SwitchScreenAction<BatteryWHperKMChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECT_CELL_TYPE>, SwitchScreenAction<BatteryTypeMenu>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_CALIBRATE>, SwitchScreenAction<CalibrateVoltageDisplay>, StaticMenuItemIcon<&bobbyicons::settings>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void BatteryMenu::back()
{
switchScreen<MainMenu>();
}

View File

@ -1,71 +1,25 @@
#pragma once
// 3rdparty lib includes
#include <menudisplay.h>
#include <menuitem.h>
#include <icons/back.h>
#include <actions/dummyaction.h>
#include <actions/switchscreenaction.h>
// Local includes
#include "menudisplay.h"
#include "utils.h"
#include "menuitem.h"
#include "icons/back.h"
#include "icons/settings.h"
#include "texts.h"
#include "actions/dummyaction.h"
#include "actions/switchscreenaction.h"
#include "mainmenu.h"
#include "battery.h"
#include "selectbatterytypemenu.h"
#include "displays/calibratevoltagedisplay.h"
// Helper
class currentBatteryStatus : public virtual TextInterface { public: std::string text() const override { return getBatteryPercentageString(); } };
class BatteryMenu :
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_BATTERY>
{
public:
BatteryMenu();
using namespace espgui;
namespace {
class BatteryMenu;
class CalibrateVoltageDisplay;
using BatteryCellSeriesChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_CELL_SERIES>,
BatterySeriesCellsAccessor,
BackActionInterface<SwitchScreenAction<BatteryMenu>>,
SwitchScreenAction<BatteryMenu>
>;
using BatteryCellParallelChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_CELL_PARALLEL>,
BatteryParallelCellsAccessor,
BackActionInterface<SwitchScreenAction<BatteryMenu>>,
SwitchScreenAction<BatteryMenu>
>;
using BatteryWHperKMChangeScreen = makeComponent<
ChangeValueDisplay<uint16_t>,
StaticText<TEXT_BATTERY_WHKM>,
BatteryWHperKMAccessor,
BackActionInterface<SwitchScreenAction<BatteryMenu>>,
SwitchScreenAction<BatteryMenu>
>;
}
namespace {
class BatteryMenu :
public MenuDisplay,
public StaticText<TEXT_BATTERY>,
public BackActionInterface<SwitchScreenAction<MainMenu>>
{
public:
BatteryMenu()
{
constructMenuItem<makeComponent<MenuItem, currentBatteryStatus, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CELL_SERIES, BatterySeriesCellsAccessor>, SwitchScreenAction<BatteryCellSeriesChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CELL_PARALLEL, BatteryParallelCellsAccessor>, SwitchScreenAction<BatteryCellParallelChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BATTERY_WHKM, BatteryWHperKMAccessor>, SwitchScreenAction<BatteryWHperKMChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECT_CELL_TYPE>, SwitchScreenAction<BatteryTypeMenu>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_CALIBRATE>, SwitchScreenAction<CalibrateVoltageDisplay>, StaticMenuItemIcon<&bobbyicons::settings>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
};
} // Namespace
void back() override;
};

View File

@ -11,11 +11,6 @@
#include "icons/back.h"
#include "texts.h"
// forward declares
namespace {
class SettingsMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -21,11 +21,6 @@
#include "icons/back.h"
#include "texts.h"
// forward declares
namespace {
class SettingsMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -18,11 +18,6 @@
#include "icons/back.h"
#include "texts.h"
//forward declares
namespace {
class MainMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -0,0 +1,187 @@
#include "boardcomputerhardwaresettingsmenu.h"
// 3rdparty lib includes
#include <fmt/core.h>
#include <changevaluedisplay.h>
#include <actions/dummyaction.h>
#include <actions/switchscreenaction.h>
#include <actions/toggleboolaction.h>
#include <icons/back.h>
#include <checkboxicon.h>
// local includes
#include "utils.h"
#include "icons/lock.h"
#include "accessors/settingsaccessors.h"
#include "displays/menus/lockscreensettingsmenu.h"
#include "displays/calibratedisplay.h"
#include "displays/menus/timersmenu.h"
#include "displays/menus/settingsmenu.h"
namespace {
struct GasText : public virtual espgui::TextInterface
{
public:
std::string text() const override
{
return fmt::format("{}: {}: {}",
"gas",
raw_gas ? std::to_string(*raw_gas) : "?",
gas ? fmt::format("{:.02f}", *gas) : "?");
}
};
struct BremsText : public virtual espgui::TextInterface
{
public:
std::string text() const override
{
return fmt::format("{}: {}: {}",
"brems",
raw_brems ? std::to_string(*raw_brems) : "?",
brems ? fmt::format("{:.02f}", *brems) : "?");
}
};
using SampleCountChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_SAMPLECOUNT>,
SampleCountAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GasMinChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_GASMIN>,
GasMinAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GasMaxChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_GASMAX>,
GasMaxAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using BremsMinChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_BREMSMIN>,
BremsMinAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using BremsMaxChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_BREMSMAX>,
BremsMaxAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW) || defined(FEATURE_DPAD_5WIRESW) || defined(FEATURE_DPAD_5WIRESW_2OUT) || defined (FEATURE_DPAD_6WIRESW)
using DPadDebounceChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<uint8_t>,
espgui::StaticText<TEXT_DPADDEBOUNCE>,
DPadDebounceAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
#endif
#ifdef FEATURE_GAMETRAK
struct GametrakXText : public virtual TextInterface {
public:
std::string text() const override { return fmt::format("gametrakX: {}: {:.02f}", raw_gametrakX, gametrakX); }
};
struct GametrakYText : public virtual TextInterface {
public:
std::string text() const override { return fmt::format("gametrakY: {}: {:.02f}", raw_gametrakY, gametrakY); }
};
struct GametrakDistText : public virtual TextInterface {
public:
std::string text() const override { return fmt::format("gametrakDist: {}: {:.02f}", raw_gametrakDist, gametrakDist); }
};
using GametrakXMinChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_SETGAMETRAKXMIN>,
GametrakXMinAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GametrakXMaxChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_SETGAMETRAKXMAX>,
GametrakXMaxAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GametrakYMinChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_SETGAMETRAKYMIN>,
GametrakYMinAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GametrakYMaxChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_SETGAMETRAKYMAX>,
GametrakYMaxAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GametrakDistMinChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_SETGAMETRAKDISTMIN>,
GametrakDistMinAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GametrakDistMaxChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_SETGAMETRAKDISTMAX>,
GametrakDistMaxAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
#endif
} // namespace
using namespace espgui;
BoardcomputerHardwareSettingsMenu::BoardcomputerHardwareSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKSCREENSETTINGS>, SwitchScreenAction<LockscreenSettingsMenu>, StaticMenuItemIcon<&bobbyicons::lock>>>();
constructMenuItem<makeComponent<MenuItem, GasText, DisabledColor, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BremsText, DisabledColor, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CALIBRATE>, SwitchScreenAction<CalibrateDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SAMPLECOUNT, SampleCountAccessor>, SwitchScreenAction<SampleCountChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_GASMIN, GasMinAccessor>, SwitchScreenAction<GasMinChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_GASMAX, GasMaxAccessor>, SwitchScreenAction<GasMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BREMSMIN, BremsMinAccessor>, SwitchScreenAction<BremsMinChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BREMSMAX, BremsMaxAccessor>, SwitchScreenAction<BremsMaxChangeScreen>>>();
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW) || defined(FEATURE_DPAD_5WIRESW) || defined(FEATURE_DPAD_5WIRESW_2OUT) || defined (FEATURE_DPAD_6WIRESW)
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_DPADDEBOUNCE, DPadDebounceAccessor>, SwitchScreenAction<DPadDebounceChangeScreen>>>();
#endif
#ifdef FEATURE_GAMETRAK
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>,
constructMenuItem<makeComponent<MenuItem, GametrakXText, DisabledColor, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, GametrakYText, DisabledColor, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, GametrakDistText, DisabledColor, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAMETRAKCALIBRATE>, SwitchScreenAction<GametrakCalibrateDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKXMIN>, SwitchScreenAction<GametrakXMinChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKXMAX>, SwitchScreenAction<GametrakXMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKYMIN>, SwitchScreenAction<GametrakYMinChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKYMAX>, SwitchScreenAction<GametrakYMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKDISTMIN>, SwitchScreenAction<GametrakDistMinChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKDISTMAX>, SwitchScreenAction<GametrakDistMaxChangeScreen>>>();
#endif
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_TIMERS>, SwitchScreenAction<TimersMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&icons::back>>>();
}
void BoardcomputerHardwareSettingsMenu::back()
{
switchScreen<SettingsMenu>();
}

View File

@ -1,195 +1,15 @@
#pragma once
// 3rdparty lib includes
#include <fmt/core.h>
// local includes
#include "menudisplay.h"
#include "utils.h"
#include "changevaluedisplay.h"
#include "actions/dummyaction.h"
#include "actions/switchscreenaction.h"
#include "actions/toggleboolaction.h"
#include "icons/lock.h"
#include "icons/back.h"
#include "checkboxicon.h"
#include "texts.h"
#include "accessors/settingsaccessors.h"
// forward declares
namespace {
class BoardcomputerHardwareSettingsMenu;
class LockscreenSettingsMenu;
class CalibrateDisplay;
class GametrakCalibrateDisplay;
class TimersMenu;
class SettingsMenu;
} // namespace
using namespace espgui;
namespace {
struct GasText : public virtual TextInterface {
public:
std::string text() const override
{
return fmt::format("{}: {}: {}",
"gas",
raw_gas ? std::to_string(*raw_gas) : "?",
gas ? fmt::format("{:.02f}", *gas) : "?");
}
};
struct BremsText : public virtual TextInterface {
public:
std::string text() const override
{
return fmt::format("{}: {}: {}",
"brems",
raw_brems ? std::to_string(*raw_brems) : "?",
brems ? fmt::format("{:.02f}", *brems) : "?");
}
};
using SampleCountChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SAMPLECOUNT>,
SampleCountAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GasMinChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_GASMIN>,
GasMinAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GasMaxChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_GASMAX>,
GasMaxAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using BremsMinChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_BREMSMIN>,
BremsMinAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using BremsMaxChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_BREMSMAX>,
BremsMaxAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW) || defined(FEATURE_DPAD_5WIRESW) || defined(FEATURE_DPAD_5WIRESW_2OUT) || defined (FEATURE_DPAD_6WIRESW)
using DPadDebounceChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_DPADDEBOUNCE>,
DPadDebounceAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
#endif
#ifdef FEATURE_GAMETRAK
struct GametrakXText : public virtual TextInterface {
public:
std::string text() const override { return fmt::format("gametrakX: {}: {:.02f}", raw_gametrakX, gametrakX); }
};
struct GametrakYText : public virtual TextInterface {
public:
std::string text() const override { return fmt::format("gametrakY: {}: {:.02f}", raw_gametrakY, gametrakY); }
};
struct GametrakDistText : public virtual TextInterface {
public:
std::string text() const override { return fmt::format("gametrakDist: {}: {:.02f}", raw_gametrakDist, gametrakDist); }
};
using GametrakXMinChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SETGAMETRAKXMIN>,
GametrakXMinAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GametrakXMaxChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SETGAMETRAKXMAX>,
GametrakXMaxAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GametrakYMinChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SETGAMETRAKYMIN>,
GametrakYMinAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GametrakYMaxChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SETGAMETRAKYMAX>,
GametrakYMaxAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GametrakDistMinChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SETGAMETRAKDISTMIN>,
GametrakDistMinAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
using GametrakDistMaxChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SETGAMETRAKDISTMAX>,
GametrakDistMaxAccessor,
BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
SwitchScreenAction<BoardcomputerHardwareSettingsMenu>
>;
#endif
class BoardcomputerHardwareSettingsMenu :
public MenuDisplay,
public StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>,
public BackActionInterface<SwitchScreenAction<SettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>
{
public:
BoardcomputerHardwareSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKSCREENSETTINGS>, SwitchScreenAction<LockscreenSettingsMenu>, StaticMenuItemIcon<&bobbyicons::lock>>>();
constructMenuItem<makeComponent<MenuItem, GasText, DisabledColor, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, BremsText, DisabledColor, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CALIBRATE>, SwitchScreenAction<CalibrateDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SAMPLECOUNT, SampleCountAccessor>, SwitchScreenAction<SampleCountChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_GASMIN, GasMinAccessor>, SwitchScreenAction<GasMinChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_GASMAX, GasMaxAccessor>, SwitchScreenAction<GasMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BREMSMIN, BremsMinAccessor>, SwitchScreenAction<BremsMinChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BREMSMAX, BremsMaxAccessor>, SwitchScreenAction<BremsMaxChangeScreen>>>();
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW) || defined(FEATURE_DPAD_5WIRESW) || defined(FEATURE_DPAD_5WIRESW_2OUT) || defined (FEATURE_DPAD_6WIRESW)
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_DPADDEBOUNCE, DPadDebounceAccessor>, SwitchScreenAction<DPadDebounceChangeScreen>>>();
#endif
#ifdef FEATURE_GAMETRAK
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>,
constructMenuItem<makeComponent<MenuItem, GametrakXText, DisabledColor, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, GametrakYText, DisabledColor, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, GametrakDistText, DisabledColor, StaticFont<2>, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAMETRAKCALIBRATE>, SwitchScreenAction<GametrakCalibrateDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKXMIN>, SwitchScreenAction<GametrakXMinChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKXMAX>, SwitchScreenAction<GametrakXMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKYMIN>, SwitchScreenAction<GametrakYMinChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKYMAX>, SwitchScreenAction<GametrakYMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKDISTMIN>, SwitchScreenAction<GametrakDistMinChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAMETRAKDISTMAX>, SwitchScreenAction<GametrakDistMaxChangeScreen>>>();
#endif
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_TIMERS>, SwitchScreenAction<TimersMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
BoardcomputerHardwareSettingsMenu();
void back() override;
};
} // namespace

View File

@ -0,0 +1,103 @@
#include "buzzermenu.h"
// 3rdparty lib includes
#include "changevaluedisplay.h"
#include "menuitem.h"
#include "actions/switchscreenaction.h"
#include "actions/toggleboolaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
// local includes
#include "utils.h"
#include "globals.h"
#include "accessors/settingsaccessors.h"
#include "displays/menus/settingsmenu.h"
namespace {
struct FrontFreqAccessor : public espgui::RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.front.command.buzzer.freq; } };
using FrontFreqChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<uint8_t>,
espgui::StaticText<TEXT_FRONTFREQ>,
FrontFreqAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BuzzerMenu>>,
espgui::SwitchScreenAction<BuzzerMenu>
>;
struct FrontPatternAccessor : public espgui::RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.front.command.buzzer.pattern; } };
using FrontPatternChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<uint8_t>,
espgui::StaticText<TEXT_FRONTPATTERN>,
FrontPatternAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BuzzerMenu>>,
espgui::SwitchScreenAction<BuzzerMenu>
>;
struct BackFreqAccessor : public espgui::RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.back.command.buzzer.freq; } };
using BackFreqChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<uint8_t>,
espgui::StaticText<TEXT_BACKFREQ>,
BackFreqAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BuzzerMenu>>,
espgui::SwitchScreenAction<BuzzerMenu>
>;
struct BackPatternAccessor : public espgui::RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.back.command.buzzer.pattern; } };
using BackPatternChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<uint8_t>,
espgui::StaticText<TEXT_BACKPATTERN>,
BackPatternAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BuzzerMenu>>,
espgui::SwitchScreenAction<BuzzerMenu>
>;
using ReverseBeepFreq0ChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<uint8_t>,
espgui::StaticText<TEXT_REVERSEBEEPFREQ0>,
ReverseBeepFreq0Accessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BuzzerMenu>>,
espgui::SwitchScreenAction<BuzzerMenu>
>;
using ReverseBeepFreq1ChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<uint8_t>,
espgui::StaticText<TEXT_REVERSEBEEPFREQ1>,
ReverseBeepFreq1Accessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BuzzerMenu>>,
espgui::SwitchScreenAction<BuzzerMenu>
>;
using ReverseBeepDuration0ChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_REVERSEBEEPDURATION0>,
ReverseBeepDuration0Accessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BuzzerMenu>>,
espgui::SwitchScreenAction<BuzzerMenu>
>;
using ReverseBeepDuration1ChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_REVERSEBEEPDURATION1>,
ReverseBeepDuration1Accessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<BuzzerMenu>>,
espgui::SwitchScreenAction<BuzzerMenu>
>;
} // namespace
using namespace espgui;
BuzzerMenu::BuzzerMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTFREQ>, SwitchScreenAction<FrontFreqChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTPATTERN>, SwitchScreenAction<FrontPatternChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKFREQ>, SwitchScreenAction<BackFreqChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKPATTERN>, SwitchScreenAction<BackPatternChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REVERSEBEEP>, ToggleBoolAction, CheckboxIcon, ReverseBeepAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REVERSEBEEPFREQ0>, SwitchScreenAction<ReverseBeepFreq0ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REVERSEBEEPFREQ1>, SwitchScreenAction<ReverseBeepFreq1ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REVERSEBEEPDURATION0>, SwitchScreenAction<ReverseBeepDuration0ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REVERSEBEEPDURATION1>, SwitchScreenAction<ReverseBeepDuration1ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void BuzzerMenu::back()
{
switchScreen<SettingsMenu>();
}

View File

@ -1,110 +1,17 @@
#pragma once
// local includes
// 3rdparty lib includes
#include "menudisplay.h"
#include "utils.h"
#include "changevaluedisplay.h"
#include "menuitem.h"
#include "actions/switchscreenaction.h"
#include "actions/toggleboolaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
// local includes
#include "texts.h"
#include "globals.h"
#include "accessors/settingsaccessors.h"
// forward declares
namespace {
class BuzzerMenu;
class SettingsMenu;
} // namespace
using namespace espgui;
namespace {
struct FrontFreqAccessor : public RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.front.command.buzzer.freq; } };
using FrontFreqChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_FRONTFREQ>,
FrontFreqAccessor,
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
SwitchScreenAction<BuzzerMenu>
>;
struct FrontPatternAccessor : public RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.front.command.buzzer.pattern; } };
using FrontPatternChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_FRONTPATTERN>,
FrontPatternAccessor,
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
SwitchScreenAction<BuzzerMenu>
>;
struct BackFreqAccessor : public RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.back.command.buzzer.freq; } };
using BackFreqChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_BACKFREQ>,
BackFreqAccessor,
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
SwitchScreenAction<BuzzerMenu>
>;
struct BackPatternAccessor : public RefAccessor<uint8_t> { uint8_t &getRef() const override { return controllers.back.command.buzzer.pattern; } };
using BackPatternChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_BACKPATTERN>,
BackPatternAccessor,
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
SwitchScreenAction<BuzzerMenu>
>;
using ReverseBeepFreq0ChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_REVERSEBEEPFREQ0>,
ReverseBeepFreq0Accessor,
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
SwitchScreenAction<BuzzerMenu>
>;
using ReverseBeepFreq1ChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_REVERSEBEEPFREQ1>,
ReverseBeepFreq1Accessor,
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
SwitchScreenAction<BuzzerMenu>
>;
using ReverseBeepDuration0ChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_REVERSEBEEPDURATION0>,
ReverseBeepDuration0Accessor,
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
SwitchScreenAction<BuzzerMenu>
>;
using ReverseBeepDuration1ChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_REVERSEBEEPDURATION1>,
ReverseBeepDuration1Accessor,
BackActionInterface<SwitchScreenAction<BuzzerMenu>>,
SwitchScreenAction<BuzzerMenu>
>;
class BuzzerMenu :
public MenuDisplay,
public StaticText<TEXT_BUZZER>,
public BackActionInterface<SwitchScreenAction<SettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_BUZZER>
{
public:
BuzzerMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTFREQ>, SwitchScreenAction<FrontFreqChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTPATTERN>, SwitchScreenAction<FrontPatternChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKFREQ>, SwitchScreenAction<BackFreqChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKPATTERN>, SwitchScreenAction<BackPatternChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REVERSEBEEP>, ToggleBoolAction, CheckboxIcon, ReverseBeepAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REVERSEBEEPFREQ0>, SwitchScreenAction<ReverseBeepFreq0ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REVERSEBEEPFREQ1>, SwitchScreenAction<ReverseBeepFreq1ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REVERSEBEEPDURATION0>, SwitchScreenAction<ReverseBeepDuration0ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REVERSEBEEPDURATION1>, SwitchScreenAction<ReverseBeepDuration1ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
BuzzerMenu();
void back() override;
};
} // namespace

View File

@ -0,0 +1,74 @@
#include "cloudsettingsmenu.h"
// 3rdparty lib includes
#include <fmt/core.h>
#include "menuitem.h"
#include "changevaluedisplay.h"
#include "actions/switchscreenaction.h"
#include "actions/toggleboolaction.h"
#include "actions/dummyaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
// local includes
#include "cloudtexthelpers.h"
#include "accessors/settingsaccessors.h"
#include "cloud.h"
#include "displays/menus/settingsmenu.h"
#ifdef FEATURE_CLOUD
namespace {
using CloudTransmitTimeoutChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_CLOUDTRANSMITTIMEOUT>,
CloudTransmitTimeoutAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<CloudSettingsMenu>>,
espgui::SwitchScreenAction<CloudSettingsMenu>
>;
struct CloudBufferLengthText : public virtual espgui::TextInterface
{
public:
std::string text() const override
{
return fmt::format("buffer: {}", cloudBuffer.size());
}
};
using CloudCollectRateChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_CLOUDCOLLECTRATE>,
CloudCollectRateAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<CloudSettingsMenu>>,
espgui::SwitchScreenAction<CloudSettingsMenu>
>;
using CloudSendRateChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_CLOUDSENDRATE>,
CloudSendRateAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<CloudSettingsMenu>>,
espgui::SwitchScreenAction<CloudSettingsMenu>
>;
} // namespace
using namespace espgui;
CloudSettingsMenu::CloudSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDENABLED>, ToggleBoolAction, CheckboxIcon, CloudEnabledAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDTRANSMITTIMEOUT>, SwitchScreenAction<CloudTransmitTimeoutChangeScreen>>>();
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<makeComponent<MenuItem, StaticText<TEXT_CLOUDCOLLECTRATE>, SwitchScreenAction<CloudCollectRateChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDSENDRATE>, SwitchScreenAction<CloudSendRateChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void CloudSettingsMenu::back()
{
switchScreen<SettingsMenu>();
}
#endif

View File

@ -1,82 +1,19 @@
#pragma once
// 3rdparty lib includes
#include <fmt/core.h>
#include "menudisplay.h"
// local includes
#include "menudisplay.h"
#include "menuitem.h"
#include "changevaluedisplay.h"
#include "actions/switchscreenaction.h"
#include "actions/toggleboolaction.h"
#include "checkboxicon.h"
#include "cloudtexthelpers.h"
#include "accessors/settingsaccessors.h"
#include "icons/back.h"
#include "texts.h"
#include "accessors/settingsaccessors.h"
#include "cloud.h"
// forward declares
namespace {
class CloudSettingsMenu;
class SettingsMenu;
} // namespace
namespace {
using CloudTransmitTimeoutChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_CLOUDTRANSMITTIMEOUT>,
CloudTransmitTimeoutAccessor,
BackActionInterface<SwitchScreenAction<CloudSettingsMenu>>,
SwitchScreenAction<CloudSettingsMenu>
>;
struct CloudBufferLengthText : public virtual TextInterface {
public:
std::string text() const override
{
return fmt::format("buffer: {}", cloudBuffer.size());
}
};
using CloudCollectRateChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_CLOUDCOLLECTRATE>,
CloudCollectRateAccessor,
BackActionInterface<SwitchScreenAction<CloudSettingsMenu>>,
SwitchScreenAction<CloudSettingsMenu>
>;
using CloudSendRateChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_CLOUDSENDRATE>,
CloudSendRateAccessor,
BackActionInterface<SwitchScreenAction<CloudSettingsMenu>>,
SwitchScreenAction<CloudSettingsMenu>
>;
} // namespace
namespace {
#ifdef FEATURE_CLOUD
class CloudSettingsMenu :
public MenuDisplay,
public StaticText<TEXT_CLOUDSETTINGS>,
public BackActionInterface<SwitchScreenAction<SettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_CLOUDSETTINGS>
{
public:
CloudSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDENABLED>, ToggleBoolAction, CheckboxIcon, CloudEnabledAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDTRANSMITTIMEOUT>, SwitchScreenAction<CloudTransmitTimeoutChangeScreen>>>();
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<makeComponent<MenuItem, StaticText<TEXT_CLOUDCOLLECTRATE>, SwitchScreenAction<CloudCollectRateChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDSENDRATE>, SwitchScreenAction<CloudSendRateChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
CloudSettingsMenu();
void back() override;
};
#endif
} // namespace

View File

@ -10,11 +10,6 @@
#include "texts.h"
#include "debugtexthelpers.h"
// forward declares
namespace {
class DebugMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -0,0 +1,84 @@
#include "controllerhardwaresettingsmenu.h"
// system includes
#include <ratio>
// 3rdparty lib includes
#include "changevaluedisplay.h"
#include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
// local includes
#include "utils.h"
#include "globals.h"
#include "accessors/settingsaccessors.h"
#include "displays/menus/enablemenu.h"
#include "displays/menus/invertmenu.h"
#include "displays/menus/settingsmenu.h"
namespace {
using WheelDiameterMmChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_WHEELDIAMETERMM>,
WheelDiameterMmAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<ControllerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<ControllerHardwareSettingsMenu>
>;
using WheelDiameterInchChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<float>,
espgui::StaticText<TEXT_WHEELDIAMETERINCH>,
WheelDiameterInchAccessor,
espgui::RatioNumberStep<float, std::ratio<1,10>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<ControllerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<ControllerHardwareSettingsMenu>
>;
using NumMagnetPolesChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_NUMMAGNETPOLES>,
NumMagnetPolesAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<ControllerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<ControllerHardwareSettingsMenu>
>;
#ifdef FEATURE_CAN
using CanTransmitTimeoutChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_CANTRANSMITTIMEOUT>,
CanTransmitTimeoutAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<ControllerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<ControllerHardwareSettingsMenu>
>;
using CanReceiveTimeoutChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_CANRECEIVETIMEOUT>,
CanReceiveTimeoutAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<ControllerHardwareSettingsMenu>>,
espgui::SwitchScreenAction<ControllerHardwareSettingsMenu>
>;
#endif
} // namespace
using namespace espgui;
ControllerHardwareSettingsMenu::ControllerHardwareSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETENABLED>, SwitchScreenAction<EnableMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETINVERTED>, SwitchScreenAction<InvertMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_WHEELDIAMETERMM>, SwitchScreenAction<WheelDiameterMmChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_WHEELDIAMETERINCH>, SwitchScreenAction<WheelDiameterInchChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NUMMAGNETPOLES>, SwitchScreenAction<NumMagnetPolesChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SWAPFRONTBACK>, ToggleBoolAction, CheckboxIcon, SwapFrontBackAccessor>>();
#ifdef FEATURE_CAN
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTSENDCAN>, ToggleBoolAction, CheckboxIcon, SendFrontCanCmdAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKSENDCAN>, ToggleBoolAction, CheckboxIcon, SendBackCanCmdAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CANTRANSMITTIMEOUT>, SwitchScreenAction<CanTransmitTimeoutChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CANRECEIVETIMEOUT>, SwitchScreenAction<CanReceiveTimeoutChangeScreen>>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void ControllerHardwareSettingsMenu::back()
{
switchScreen<SettingsMenu>();
}

View File

@ -1,91 +1,17 @@
#pragma once
#include <ratio>
// 3rdparty lib includes
#include "menudisplay.h"
// local includes
#include "menudisplay.h"
#include "utils.h"
#include "changevaluedisplay.h"
#include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
#include "texts.h"
#include "globals.h"
#include "accessors/settingsaccessors.h"
// forward declares
namespace {
class ControllerHardwareSettingsMenu;
class BoardcomputerHardwareSettingsMenu;
class EnableMenu;
class InvertMenu;
class SettingsMenu;
} // namespace
using namespace espgui;
namespace {
using WheelDiameterMmChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_WHEELDIAMETERMM>,
WheelDiameterMmAccessor,
BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
SwitchScreenAction<ControllerHardwareSettingsMenu>
>;
using WheelDiameterInchChangeScreen = makeComponent<
ChangeValueDisplay<float>,
StaticText<TEXT_WHEELDIAMETERINCH>,
WheelDiameterInchAccessor,
RatioNumberStep<float, std::ratio<1,10>>,
BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
SwitchScreenAction<ControllerHardwareSettingsMenu>
>;
using NumMagnetPolesChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_NUMMAGNETPOLES>,
NumMagnetPolesAccessor,
BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
SwitchScreenAction<ControllerHardwareSettingsMenu>
>;
#ifdef FEATURE_CAN
using CanTransmitTimeoutChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_CANTRANSMITTIMEOUT>,
CanTransmitTimeoutAccessor,
BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
SwitchScreenAction<ControllerHardwareSettingsMenu>
>;
using CanReceiveTimeoutChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_CANRECEIVETIMEOUT>,
CanReceiveTimeoutAccessor,
BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
SwitchScreenAction<ControllerHardwareSettingsMenu>
>;
#endif
class ControllerHardwareSettingsMenu :
public MenuDisplay,
public StaticText<TEXT_CONTROLLERHARDWARESETTINGS>,
public BackActionInterface<SwitchScreenAction<SettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_CONTROLLERHARDWARESETTINGS>
{
public:
ControllerHardwareSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETENABLED>, SwitchScreenAction<EnableMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETINVERTED>, SwitchScreenAction<InvertMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_WHEELDIAMETERMM>, SwitchScreenAction<WheelDiameterMmChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_WHEELDIAMETERINCH>, SwitchScreenAction<WheelDiameterInchChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NUMMAGNETPOLES>, SwitchScreenAction<NumMagnetPolesChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SWAPFRONTBACK>, ToggleBoolAction, CheckboxIcon, SwapFrontBackAccessor>>();
#ifdef FEATURE_CAN
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTSENDCAN>, ToggleBoolAction, CheckboxIcon, SendFrontCanCmdAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKSENDCAN>, ToggleBoolAction, CheckboxIcon, SendBackCanCmdAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CANTRANSMITTIMEOUT>, SwitchScreenAction<CanTransmitTimeoutChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CANRECEIVETIMEOUT>, SwitchScreenAction<CanReceiveTimeoutChangeScreen>>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
ControllerHardwareSettingsMenu();
void back() override;
};
} // namespace

View File

@ -9,11 +9,6 @@
#include "icons/back.h"
#include "texts.h"
// forward declares
namespace {
class SettingsMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -0,0 +1,59 @@
#include "debugmenu.h"
// 3rdparty lib includes
#include "menuitem.h"
#include "actions/switchscreenaction.h"
#include "actions/dummyaction.h"
#include "actions/toggleboolaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
// local includes
#include "utils.h"
#include "actions/loadsettingsaction.h"
#include "actions/savesettingsaction.h"
#include "actions/erasenvsaction.h"
#include "icons/lock.h"
#include "debugcolorhelpers.h"
#include "esptexthelpers.h"
#include "displays/menus/commanddebugmenu.h"
#include "displays/menus/motorstatedebugmenu.h"
#include "displays/menus/feedbackdebugmenu.h"
#include "displays/menus/motorfeedbackdebugmenu.h"
#include "displays/menus/dynamicdebugmenu.h"
#include "displays/menus/mainmenu.h"
using namespace espgui;
DebugMenu::DebugMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOADSETTINGS>, LoadSettingsAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SAVESETTINGS>, SaveSettingsAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ERASENVS>, EraseNvsAction>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTCOMMAND>, SwitchScreenAction<FrontCommandDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKCOMMAND>, SwitchScreenAction<BackCommandDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTLEFTCOMMAND>, SwitchScreenAction<FrontLeftMotorStateDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTRIGHTCOMMAND>, SwitchScreenAction<FrontRightMotorStateDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKLEFTCOMMAND>, SwitchScreenAction<BackLeftMotorStateDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKRIGHTCOMMAND>, SwitchScreenAction<BackRightMotorStateDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTFEEDBACK>, SwitchScreenAction<FrontFeedbackDebugMenu>, FrontFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKFEEDBACK>, SwitchScreenAction<BackFeedbackDebugMenu>, BackFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, LastRebootReasonText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTLEFTFEEDBACK>, SwitchScreenAction<FrontLeftMotorFeedbackDebugMenu>, FrontFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTRIGHTFEEDBACK>, SwitchScreenAction<FrontRightMotorFeedbackDebugMenu>, FrontFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKLEFTFEEDBACK>, SwitchScreenAction<BackLeftMotorFeedbackDebugMenu>, BackFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKRIGHTFEEDBACK>, SwitchScreenAction<BackRightMotorFeedbackDebugMenu>, BackFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DYNAMICMENU>, SwitchScreenAction<DynamicDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void DebugMenu::back()
{
switchScreen<MainMenu>();
}

View File

@ -1,76 +1,17 @@
#pragma once
// local includes
// 3rdparty lib includes
#include "menudisplay.h"
#include "utils.h"
#include "menuitem.h"
#include "actions/loadsettingsaction.h"
#include "actions/savesettingsaction.h"
#include "actions/erasenvsaction.h"
#include "actions/switchscreenaction.h"
#include "actions/dummyaction.h"
#include "actions/toggleboolaction.h"
#include "icons/lock.h"
#include "checkboxicon.h"
#include "icons/back.h"
// local includes
#include "texts.h"
#include "debugcolorhelpers.h"
using namespace espgui;
// forward declares
namespace {
class MainMenu;
class FrontCommandDebugMenu;
class BackCommandDebugMenu;
class FrontLeftMotorStateDebugMenu;
class FrontRightMotorStateDebugMenu;
class BackLeftMotorStateDebugMenu;
class BackRightMotorStateDebugMenu;
class FrontFeedbackDebugMenu;
class BackFeedbackDebugMenu;
class FrontLeftMotorFeedbackDebugMenu;
class FrontRightMotorFeedbackDebugMenu;
class BackLeftMotorFeedbackDebugMenu;
class BackRightMotorFeedbackDebugMenu;
class DynamicDebugMenu;
} // namespace
using namespace espgui;
namespace {
class DebugMenu :
public MenuDisplay,
public StaticText<TEXT_DEBUG>,
public BackActionInterface<SwitchScreenAction<MainMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_DEBUG>
{
public:
DebugMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOADSETTINGS>, LoadSettingsAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SAVESETTINGS>, SaveSettingsAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ERASENVS>, EraseNvsAction>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTCOMMAND>, SwitchScreenAction<FrontCommandDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKCOMMAND>, SwitchScreenAction<BackCommandDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTLEFTCOMMAND>, SwitchScreenAction<FrontLeftMotorStateDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTRIGHTCOMMAND>, SwitchScreenAction<FrontRightMotorStateDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKLEFTCOMMAND>, SwitchScreenAction<BackLeftMotorStateDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKRIGHTCOMMAND>, SwitchScreenAction<BackRightMotorStateDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTFEEDBACK>, SwitchScreenAction<FrontFeedbackDebugMenu>, FrontFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKFEEDBACK>, SwitchScreenAction<BackFeedbackDebugMenu>, BackFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, LastRebootReasonText, StaticFont<2>, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTLEFTFEEDBACK>, SwitchScreenAction<FrontLeftMotorFeedbackDebugMenu>, FrontFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTRIGHTFEEDBACK>, SwitchScreenAction<FrontRightMotorFeedbackDebugMenu>, FrontFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKLEFTFEEDBACK>, SwitchScreenAction<BackLeftMotorFeedbackDebugMenu>, BackFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKRIGHTFEEDBACK>, SwitchScreenAction<BackRightMotorFeedbackDebugMenu>, BackFeedbackColor<TFT_WHITE>>>();
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DYNAMICMENU>, SwitchScreenAction<DynamicDebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
DebugMenu();
void back() override;
};
} // namespace

View File

@ -0,0 +1,144 @@
#include "defaultmodesettingsmenu.h"
// 3rdparty lib includes
#include "changevaluedisplay.h"
#include "menuitem.h"
#include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h"
#include "actions/dummyaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
// local includes
#include "utils.h"
#include "changevaluedisplay_unifiedmodelmode.h"
#include "accessors/settingsaccessors.h"
#include "displays/menus/modessettingsmenu.h"
namespace {
using DefaultModeModelModeChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<UnifiedModelMode>,
espgui::StaticText<TEXT_MODELMODE>,
DefaultModeModelModeAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeHybridModelModeChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<UnifiedModelMode>,
espgui::StaticText<TEXT_HYBRIDMODE>,
DefaultModeHybridModelModeAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeSmoothingChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_SMOOTHINGVAL>,
DefaultModeSmoothingAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeFwSmoothingLowerLimitChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_FWSMOOTHING_LIMIT>,
DefaultModeEnableFieldWeakSmoothingLowerLimitAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeFrontPercentageChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_FRONTPERCENTAGE>,
DefaultModeFrontPercentageAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeBackPercentageChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_BACKPERCENTAGE>,
DefaultModeBackPercentageAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeAddSchwelleChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_ADDSCHWELLE>,
DefaultModeAddSchwelleAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeGas1WertChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_ADDGASVAL>,
DefaultModeGas1WertAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeGas2WertChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_SUBGASVAL>,
DefaultModeGas2WertAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeBrems1WertChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_ADDBRAKEVAL>,
DefaultModeBrems1WertAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeBrems2WertChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_SUBBRAKEVAL>,
DefaultModeBrems2WertAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeHybridActivationLimitChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_HYBRIDACTIVATIONLIMIT>,
DefaultModeHybridActivationLimitAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeHybridDeactivationLimitChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_HYBRIDDEACTIVATIONLIMIT>,
DefaultModeHybridDeactivationLimitAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<DefaultModeSettingsMenu>>,
espgui::SwitchScreenAction<DefaultModeSettingsMenu>
>;
} // namespace
using namespace espgui;
DefaultModeSettingsMenu::DefaultModeSettingsMenu()
{
auto diff = std::abs(settings.hybrid.activationLimit - settings.hybrid.deactivationLimit);
if (diff < 20) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LIMITS_TO_NEAR>, StaticFont<2>, StaticColor<TFT_RED>, DummyAction>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODELMODE>, SwitchScreenAction<DefaultModeModelModeChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_HYBRIDMODE>, SwitchScreenAction<DefaultModeHybridModelModeChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SQUAREGAS>, ToggleBoolAction, CheckboxIcon, DefaultModeSquareGasAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SQUAREBREMS>, ToggleBoolAction, CheckboxIcon, DefaultModeSquareBremsAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ENABLESMOOTHINGUP>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableSmoothingUpAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ENABLESMOOTHINGDOWN>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableSmoothingDownAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ENABLEFWSMOOTHINGUP>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableFieldWeakSmoothingUpAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ENABLEFWSMOOTHINGDOWN>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableFieldWeakSmoothingDownAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_HYBRIDENABLE>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableHybridAccessor>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_FWSMOOTHING_LIMIT, DefaultModeEnableFieldWeakSmoothingLowerLimitAccessor>, SwitchScreenAction<DefaultModeFwSmoothingLowerLimitChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMOOTHINGVAL, DefaultModeSmoothingAccessor>, SwitchScreenAction<DefaultModeSmoothingChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_FRONTPERCENTAGE, DefaultModeFrontPercentageAccessor>, SwitchScreenAction<DefaultModeFrontPercentageChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BACKPERCENTAGE, DefaultModeBackPercentageAccessor>, SwitchScreenAction<DefaultModeBackPercentageChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_ADDSCHWELLE, DefaultModeAddSchwelleAccessor>, SwitchScreenAction<DefaultModeAddSchwelleChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SUBGASVAL, DefaultModeGas2WertAccessor>, SwitchScreenAction<DefaultModeGas2WertChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SUBBRAKEVAL, DefaultModeBrems2WertAccessor>, SwitchScreenAction<DefaultModeBrems2WertChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_ADDGASVAL, DefaultModeGas1WertAccessor>, SwitchScreenAction<DefaultModeGas1WertChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_ADDBRAKEVAL, DefaultModeBrems1WertAccessor>, SwitchScreenAction<DefaultModeBrems1WertChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_HYBRIDACTIVATIONLIMIT, DefaultModeHybridActivationLimitAccessor>, SwitchScreenAction<DefaultModeHybridActivationLimitChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_HYBRIDDEACTIVATIONLIMIT, DefaultModeHybridDeactivationLimitAccessor>, SwitchScreenAction<DefaultModeHybridDeactivationLimitChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<ModesSettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void DefaultModeSettingsMenu::back()
{
switchScreen<ModesSettingsMenu>();
}

View File

@ -1,153 +1,17 @@
#pragma once
#include <TFT_eSPI.h>
// 3rdparty lib includes
#include "menudisplay.h"
// local includes
#include "menudisplay.h"
#include "utils.h"
#include "changevaluedisplay.h"
#include "changevaluedisplay_unifiedmodelmode.h"
#include "menuitem.h"
#include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h"
#include "actions/dummyaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
#include "texts.h"
#include "accessors/settingsaccessors.h"
// forward declares
namespace {
class DefaultModeSettingsMenu;
class ModesSettingsMenu;
} // namespace
using namespace espgui;
namespace {
using DefaultModeModelModeChangeDisplay = makeComponent<
ChangeValueDisplay<UnifiedModelMode>,
StaticText<TEXT_MODELMODE>,
DefaultModeModelModeAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeHybridModelModeChangeDisplay = makeComponent<
ChangeValueDisplay<UnifiedModelMode>,
StaticText<TEXT_HYBRIDMODE>,
DefaultModeHybridModelModeAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeSmoothingChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SMOOTHINGVAL>,
DefaultModeSmoothingAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeFwSmoothingLowerLimitChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_FWSMOOTHING_LIMIT>,
DefaultModeEnableFieldWeakSmoothingLowerLimitAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeFrontPercentageChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_FRONTPERCENTAGE>,
DefaultModeFrontPercentageAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeBackPercentageChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_BACKPERCENTAGE>,
DefaultModeBackPercentageAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeAddSchwelleChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_ADDSCHWELLE>,
DefaultModeAddSchwelleAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeGas1WertChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_ADDGASVAL>,
DefaultModeGas1WertAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeGas2WertChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SUBGASVAL>,
DefaultModeGas2WertAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeBrems1WertChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_ADDBRAKEVAL>,
DefaultModeBrems1WertAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeBrems2WertChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SUBBRAKEVAL>,
DefaultModeBrems2WertAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeHybridActivationLimitChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_HYBRIDACTIVATIONLIMIT>,
DefaultModeHybridActivationLimitAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
using DefaultModeHybridDeactivationLimitChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_HYBRIDDEACTIVATIONLIMIT>,
DefaultModeHybridDeactivationLimitAccessor,
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
class DefaultModeSettingsMenu :
public MenuDisplay,
public StaticText<TEXT_DEFAULTMODESETTIGNS>,
public BackActionInterface<SwitchScreenAction<ModesSettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_DEFAULTMODESETTIGNS>
{
public:
DefaultModeSettingsMenu()
{
auto diff = std::abs(settings.hybrid.activationLimit - settings.hybrid.deactivationLimit);
if (diff < 20) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LIMITS_TO_NEAR>, StaticFont<2>, StaticColor<TFT_RED>, DummyAction>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODELMODE>, SwitchScreenAction<DefaultModeModelModeChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_HYBRIDMODE>, SwitchScreenAction<DefaultModeHybridModelModeChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SQUAREGAS>, ToggleBoolAction, CheckboxIcon, DefaultModeSquareGasAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SQUAREBREMS>, ToggleBoolAction, CheckboxIcon, DefaultModeSquareBremsAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ENABLESMOOTHINGUP>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableSmoothingUpAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ENABLESMOOTHINGDOWN>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableSmoothingDownAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ENABLEFWSMOOTHINGUP>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableFieldWeakSmoothingUpAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ENABLEFWSMOOTHINGDOWN>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableFieldWeakSmoothingDownAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_HYBRIDENABLE>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableHybridAccessor>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_FWSMOOTHING_LIMIT, DefaultModeEnableFieldWeakSmoothingLowerLimitAccessor>, SwitchScreenAction<DefaultModeFwSmoothingLowerLimitChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMOOTHINGVAL, DefaultModeSmoothingAccessor>, SwitchScreenAction<DefaultModeSmoothingChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_FRONTPERCENTAGE, DefaultModeFrontPercentageAccessor>, SwitchScreenAction<DefaultModeFrontPercentageChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BACKPERCENTAGE, DefaultModeBackPercentageAccessor>, SwitchScreenAction<DefaultModeBackPercentageChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_ADDSCHWELLE, DefaultModeAddSchwelleAccessor>, SwitchScreenAction<DefaultModeAddSchwelleChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SUBGASVAL, DefaultModeGas2WertAccessor>, SwitchScreenAction<DefaultModeGas2WertChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SUBBRAKEVAL, DefaultModeBrems2WertAccessor>, SwitchScreenAction<DefaultModeBrems2WertChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_ADDGASVAL, DefaultModeGas1WertAccessor>, SwitchScreenAction<DefaultModeGas1WertChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_ADDBRAKEVAL, DefaultModeBrems1WertAccessor>, SwitchScreenAction<DefaultModeBrems1WertChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_HYBRIDACTIVATIONLIMIT, DefaultModeHybridActivationLimitAccessor>, SwitchScreenAction<DefaultModeHybridActivationLimitChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_HYBRIDDEACTIVATIONLIMIT, DefaultModeHybridDeactivationLimitAccessor>, SwitchScreenAction<DefaultModeHybridDeactivationLimitChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<ModesSettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
DefaultModeSettingsMenu();
void back() override;
};
} // namespace

View File

@ -0,0 +1,30 @@
#include "demosmenu.h"
// 3rdparty lib includes
#include "menuitem.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "displays/starfielddisplay.h"
#include "displays/pingpongdisplay.h"
#include "displays/spirodisplay.h"
#include "displays/gameoflifedisplay.h"
#include "displays/menus/mainmenu.h"
// local includes
#include "utils.h"
using namespace espgui;
DemosMenu::DemosMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STARFIELD>, SwitchScreenAction<StarfieldDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PINGPONG>, SwitchScreenAction<PingPongDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SPIRO>, SwitchScreenAction<SpiroDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAMEOFLIFE>, SwitchScreenAction<GameOfLifeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void DemosMenu::back()
{
switchScreen<MainMenu>();
}

View File

@ -1,38 +1,17 @@
#pragma once
// local includes
// 3rdparty lib includes
#include "menudisplay.h"
#include "utils.h"
#include "menuitem.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
// local includes
#include "texts.h"
// forward declares
namespace {
class StarfieldDisplay;
class PingPongDisplay;
class SpiroDisplay;
class GameOfLifeDisplay;
class MainMenu;
} // namespace
using namespace espgui;
namespace {
class DemosMenu :
public MenuDisplay,
public StaticText<TEXT_DEMOS>,
public BackActionInterface<SwitchScreenAction<MainMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_DEMOS>
{
public:
DemosMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STARFIELD>, SwitchScreenAction<StarfieldDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PINGPONG>, SwitchScreenAction<PingPongDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SPIRO>, SwitchScreenAction<SpiroDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAMEOFLIFE>, SwitchScreenAction<GameOfLifeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
DemosMenu();
void back() override;
};
} // namespace

View File

@ -22,11 +22,6 @@
#include "icons/back.h"
#include "texts.h"
// forward declares
namespace {
class DebugMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -11,11 +11,6 @@
#include "texts.h"
#include "accessors/settingsaccessors.h"
// forward declares
namespace {
class ControllerHardwareSettingsMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -11,11 +11,6 @@
#include "debugtexthelpers.h"
#include "debugcolorhelpers.h"
// forward declares
namespace {
class DebugMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -8,11 +8,6 @@
#include "icons/back.h"
#include "texts.h"
// forward declares
namespace {
class ModesSettingsMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -13,12 +13,6 @@
#include "accessors/wifiaccessors.h"
#include "texts.h"
// forward declares
namespace {
class GenericWifiSettingsMenu;
class WifiSettingsMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -0,0 +1,183 @@
#include "graphsmenu.h"
// 3rdparty lib includes
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "graphdisplay.h"
#include "splitgraphdisplay.h"
// local includes
#include "utils.h"
#include "statistics.h"
#include "displays/menus/mainmenu.h"
namespace {
using GasGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<1>,
espgui::StaticText<TEXT_GAS>,
espgui::SingleGraphAccessor<GasStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using BremsGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<1>,
espgui::StaticText<TEXT_BREMS>,
espgui::SingleGraphAccessor<BremsStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using PotisGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<2>,
espgui::StaticText<TEXT_POTIS>,
espgui::DualGraphAccessor<GasStatistics, BremsStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using PotisSplitGraphDisplay = espgui::makeComponent<
espgui::SplitGraphDisplay<1, 1>,
espgui::StaticText<TEXT_POTIS>,
espgui::SingleTopGraphAccessor<GasStatistics>,
espgui::SingleBottomGraphAccessor<BremsStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using AvgSpeedGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<1>,
espgui::StaticText<TEXT_AVGSPEED>,
espgui::SingleGraphAccessor<AvgSpeedStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using AvgSpeedKmhGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<1>,
espgui::StaticText<TEXT_AVGSPEEDKMH>,
espgui::SingleGraphAccessor<AvgSpeedKmhStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using SumCurrentGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<1>,
espgui::StaticText<TEXT_SUMCURRENT>,
espgui::SingleGraphAccessor<SumCurrentStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using FrontVoltageGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<1>,
espgui::StaticText<TEXT_FRONTVOLTAGE>,
espgui::SingleGraphAccessor<FrontVoltageStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using BackVoltageGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<1>,
espgui::StaticText<TEXT_BACKVOLTAGE>,
espgui::SingleGraphAccessor<BackVoltageStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using VoltagesGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<2>,
espgui::StaticText<TEXT_VOLTAGES>,
espgui::DualGraphAccessor<FrontVoltageStatistics, BackVoltageStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using VoltagesSplitGraphDisplay = espgui::makeComponent<
espgui::SplitGraphDisplay<1, 1>,
espgui::StaticText<TEXT_VOLTAGES>,
espgui::SingleTopGraphAccessor<FrontVoltageStatistics>,
espgui::SingleBottomGraphAccessor<BackVoltageStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
#ifdef FEATURE_BMS
using BmsVoltageGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<1>,
espgui::StaticText<TEXT_BMSVOLTAGE>,
espgui::SingleGraphAccessor<BmsVoltageStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using BmsCurrentGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<1>,
espgui::StaticText<TEXT_BMSCURRENT>,
espgui::SingleGraphAccessor<BmsCurrentStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using BmsPowerGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<1>,
espgui::StaticText<TEXT_BMSPOWER>,
espgui::SingleGraphAccessor<BmsPowerStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using SumCurrentsComparisonGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<2>,
espgui::StaticText<TEXT_SUMCURRENTSCOMPARISON>,
DualGraphAccessor<SumCurrentStatistics, BmsCurrentStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
#endif
class MotorCurrentsStatistics : public virtual espgui::GraphAccessorInterface<4>
{
std::array<std::reference_wrapper<const statistics::ContainerType>, 4> getBuffers() const override
{
return {FrontLeftCurrentStatistics{}.getBuffer(), FrontRightCurrentStatistics{}.getBuffer(), BackLeftCurrentStatistics{}.getBuffer(), BackRightCurrentStatistics{}.getBuffer()};
}
};
using MotorCurrentsGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<4>,
espgui::StaticText<TEXT_MOTORCURRENTS>,
MotorCurrentsStatistics,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
using RssiGraphDisplay = espgui::makeComponent<
espgui::GraphDisplay<1>,
espgui::StaticText<TEXT_RSSI>,
espgui::SingleGraphAccessor<RssiStatistics>,
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<GraphsMenu>>,
espgui::BackActionInterface<espgui::SwitchScreenAction<GraphsMenu>>
>;
} // namespace
using namespace espgui;
GraphsMenu::GraphsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAS>, SwitchScreenAction<GasGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BREMS>, SwitchScreenAction<BremsGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POTIS>, SwitchScreenAction<PotisGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POTIS>, SwitchScreenAction<PotisSplitGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_AVGSPEED>, SwitchScreenAction<AvgSpeedGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_AVGSPEEDKMH>, SwitchScreenAction<AvgSpeedKmhGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SUMCURRENT>, SwitchScreenAction<SumCurrentGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTVOLTAGE>, SwitchScreenAction<FrontVoltageGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKVOLTAGE>, SwitchScreenAction<BackVoltageGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGES>, SwitchScreenAction<VoltagesGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGES>, SwitchScreenAction<VoltagesSplitGraphDisplay>>>();
#ifdef FEATURE_BMS
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BMSVOLTAGE>, SwitchScreenAction<BmsVoltageGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BMSCURRENT>, SwitchScreenAction<BmsCurrentGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BMSPOWER>, SwitchScreenAction<BmsPowerGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SUMCURRENTSCOMPARISON>, SwitchScreenAction<SumCurrentsComparisonGraphDisplay>>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOTORCURRENTS>, SwitchScreenAction<MotorCurrentsGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_RSSI>, SwitchScreenAction<RssiGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void GraphsMenu::back()
{
switchScreen<MainMenu>();
}

View File

@ -2,188 +2,14 @@
// local includes
#include "menudisplay.h"
#include "utils.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "texts.h"
#include "displays/graphdisplay.h"
#include "displays/splitgraphdisplay.h"
#include "statistics.h"
// forward declares
namespace {
class MainMenu;
class GraphsMenu;
} // namespace
using namespace espgui;
namespace {
using GasGraphDisplay = makeComponent<
GraphDisplay<1>,
StaticText<TEXT_GAS>,
SingleGraphAccessor<GasStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using BremsGraphDisplay = makeComponent<
GraphDisplay<1>,
StaticText<TEXT_BREMS>,
SingleGraphAccessor<BremsStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using PotisGraphDisplay = makeComponent<
GraphDisplay<2>,
StaticText<TEXT_POTIS>,
DualGraphAccessor<GasStatistics, BremsStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using PotisSplitGraphDisplay = makeComponent<
SplitGraphDisplay<1, 1>,
StaticText<TEXT_POTIS>,
SingleTopGraphAccessor<GasStatistics>,
SingleBottomGraphAccessor<BremsStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using AvgSpeedGraphDisplay = makeComponent<
GraphDisplay<1>,
StaticText<TEXT_AVGSPEED>,
SingleGraphAccessor<AvgSpeedStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using AvgSpeedKmhGraphDisplay = makeComponent<
GraphDisplay<1>,
StaticText<TEXT_AVGSPEEDKMH>,
SingleGraphAccessor<AvgSpeedKmhStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using SumCurrentGraphDisplay = makeComponent<
GraphDisplay<1>,
StaticText<TEXT_SUMCURRENT>,
SingleGraphAccessor<SumCurrentStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using FrontVoltageGraphDisplay = makeComponent<
GraphDisplay<1>,
StaticText<TEXT_FRONTVOLTAGE>,
SingleGraphAccessor<FrontVoltageStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using BackVoltageGraphDisplay = makeComponent<
GraphDisplay<1>,
StaticText<TEXT_BACKVOLTAGE>,
SingleGraphAccessor<BackVoltageStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using VoltagesGraphDisplay = makeComponent<
GraphDisplay<2>,
StaticText<TEXT_VOLTAGES>,
DualGraphAccessor<FrontVoltageStatistics, BackVoltageStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using VoltagesSplitGraphDisplay = makeComponent<
SplitGraphDisplay<1, 1>,
StaticText<TEXT_VOLTAGES>,
SingleTopGraphAccessor<FrontVoltageStatistics>,
SingleBottomGraphAccessor<BackVoltageStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
#ifdef FEATURE_BMS
using BmsVoltageGraphDisplay = makeComponent<
GraphDisplay<1>,
StaticText<TEXT_BMSVOLTAGE>,
SingleGraphAccessor<BmsVoltageStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using BmsCurrentGraphDisplay = makeComponent<
GraphDisplay<1>,
StaticText<TEXT_BMSCURRENT>,
SingleGraphAccessor<BmsCurrentStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using BmsPowerGraphDisplay = makeComponent<
GraphDisplay<1>,
StaticText<TEXT_BMSPOWER>,
SingleGraphAccessor<BmsPowerStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using SumCurrentsComparisonGraphDisplay = makeComponent<
GraphDisplay<2>,
StaticText<TEXT_SUMCURRENTSCOMPARISON>,
DualGraphAccessor<SumCurrentStatistics, BmsCurrentStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
#endif
class MotorCurrentsStatistics : public virtual GraphAccessorInterface<4>
{
std::array<std::reference_wrapper<const statistics::ContainerType>, 4> getBuffers() const override
{
return {FrontLeftCurrentStatistics{}.getBuffer(), FrontRightCurrentStatistics{}.getBuffer(), BackLeftCurrentStatistics{}.getBuffer(), BackRightCurrentStatistics{}.getBuffer()};
}
};
using MotorCurrentsGraphDisplay = makeComponent<
GraphDisplay<4>,
StaticText<TEXT_MOTORCURRENTS>,
MotorCurrentsStatistics,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
using RssiGraphDisplay = makeComponent<
GraphDisplay<1>,
StaticText<TEXT_RSSI>,
SingleGraphAccessor<RssiStatistics>,
ConfirmActionInterface<SwitchScreenAction<GraphsMenu>>,
BackActionInterface<SwitchScreenAction<GraphsMenu>>
>;
class GraphsMenu :
public MenuDisplay,
public StaticText<TEXT_GRAPHS>,
public BackActionInterface<SwitchScreenAction<MainMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_GRAPHS>
{
public:
GraphsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAS>, SwitchScreenAction<GasGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BREMS>, SwitchScreenAction<BremsGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POTIS>, SwitchScreenAction<PotisGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POTIS>, SwitchScreenAction<PotisSplitGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_AVGSPEED>, SwitchScreenAction<AvgSpeedGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_AVGSPEEDKMH>, SwitchScreenAction<AvgSpeedKmhGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SUMCURRENT>, SwitchScreenAction<SumCurrentGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTVOLTAGE>, SwitchScreenAction<FrontVoltageGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKVOLTAGE>, SwitchScreenAction<BackVoltageGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGES>, SwitchScreenAction<VoltagesGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGES>, SwitchScreenAction<VoltagesSplitGraphDisplay>>>();
#ifdef FEATURE_BMS
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BMSVOLTAGE>, SwitchScreenAction<BmsVoltageGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BMSCURRENT>, SwitchScreenAction<BmsCurrentGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BMSPOWER>, SwitchScreenAction<BmsPowerGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SUMCURRENTSCOMPARISON>, SwitchScreenAction<SumCurrentsComparisonGraphDisplay>>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOTORCURRENTS>, SwitchScreenAction<MotorCurrentsGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_RSSI>, SwitchScreenAction<RssiGraphDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
GraphsMenu();
void back() override;
};
} // namespace

View File

@ -11,11 +11,6 @@
#include "texts.h"
#include "accessors/settingsaccessors.h"
// forward declares
namespace {
class ControllerHardwareSettingsMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -0,0 +1,53 @@
#include "larsmmodesettingsmenu.h"
// 3rdparty lib includes
#include "changevaluedisplay.h"
#include "menuitem.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
// local includes
#include "utils.h"
#include "changevaluedisplay_larsmmode_mode.h"
#include "changevaluedisplay_unifiedmodelmode.h"
#include "accessors/settingsaccessors.h"
#include "displays/menus/modessettingsmenu.h"
namespace {
using LarsmModeModelModeChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<UnifiedModelMode>,
espgui::StaticText<TEXT_MODELMODE>,
LarsmModeModelModeAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<LarsmModeSettingsMenu>>,
espgui::SwitchScreenAction<LarsmModeSettingsMenu>
>;
using LarsmModeModeChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<LarsmModeMode>,
espgui::StaticText<TEXT_SETMODE>,
LarsmModeModeAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<LarsmModeSettingsMenu>>,
espgui::SwitchScreenAction<LarsmModeSettingsMenu>
>;
using LarsmModeIterationsChangeDisplay = espgui::makeComponent<
espgui::ChangeValueDisplay<uint8_t>,
espgui::StaticText<TEXT_SETITERATIONS>,
LarsmModeIterationsAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<LarsmModeSettingsMenu>>,
espgui::SwitchScreenAction<LarsmModeSettingsMenu>
>;
} // namespace
using namespace espgui;
LarsmModeSettingsMenu::LarsmModeSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODELMODE>, SwitchScreenAction<LarsmModeModelModeChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETMODE>, SwitchScreenAction<LarsmModeModeChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETITERATIONS>, SwitchScreenAction<LarsmModeIterationsChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<ModesSettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void LarsmModeSettingsMenu::back()
{
switchScreen<ModesSettingsMenu>();
}

View File

@ -1,60 +1,17 @@
#pragma once
// 3rdparty lib includes
// local includes
#include "menudisplay.h"
#include "utils.h"
#include "changevaluedisplay.h"
#include "changevaluedisplay_larsmmode_mode.h"
#include "changevaluedisplay_unifiedmodelmode.h"
#include "menuitem.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "texts.h"
#include "accessors/settingsaccessors.h"
// forward declares
namespace {
class LarsmModeSettingsMenu;
class ModesSettingsMenu;
} // namespace
using namespace espgui;
namespace {
using LarsmModeModelModeChangeDisplay = makeComponent<
ChangeValueDisplay<UnifiedModelMode>,
StaticText<TEXT_MODELMODE>,
LarsmModeModelModeAccessor,
BackActionInterface<SwitchScreenAction<LarsmModeSettingsMenu>>,
SwitchScreenAction<LarsmModeSettingsMenu>
>;
using LarsmModeModeChangeDisplay = makeComponent<
ChangeValueDisplay<LarsmModeMode>,
StaticText<TEXT_SETMODE>,
LarsmModeModeAccessor,
BackActionInterface<SwitchScreenAction<LarsmModeSettingsMenu>>,
SwitchScreenAction<LarsmModeSettingsMenu>
>;
using LarsmModeIterationsChangeDisplay = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_SETITERATIONS>,
LarsmModeIterationsAccessor,
BackActionInterface<SwitchScreenAction<LarsmModeSettingsMenu>>,
SwitchScreenAction<LarsmModeSettingsMenu>
>;
class LarsmModeSettingsMenu :
public MenuDisplay,
public StaticText<TEXT_LARSMMODESETTINGS>,
public BackActionInterface<SwitchScreenAction<ModesSettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_LARSMMODESETTINGS>
{
public:
LarsmModeSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODELMODE>, SwitchScreenAction<LarsmModeModelModeChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETMODE>, SwitchScreenAction<LarsmModeModeChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETITERATIONS>, SwitchScreenAction<LarsmModeIterationsChangeDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<ModesSettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
LarsmModeSettingsMenu();
void back() override;
};
} // namespace

View File

@ -0,0 +1,143 @@
#include "ledstripmenu.h"
// 3rdparty lib includes
#include <FastLED.h>
#include "menuitem.h"
#include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "checkboxicon.h"
#include "changevaluedisplay.h"
#include "actioninterface.h"
// local includes
#include "ledstripselectanimationmenu.h"
#include "ledstripselectblinkmenu.h"
#include "globals.h"
#include "accessors/settingsaccessors.h"
#ifdef FEATURE_LEDSTRIP
#include "ledstrip.h"
#endif
#include "displays/ledstripcolorsdisplay.h"
#include "displays/menus/mainmenu.h"
#ifdef FEATURE_LEDSTRIP
namespace {
using LedsCountChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_LEDSCOUNT>,
LedsCountAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using CenterOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_CENTEROFFSET>,
CenterOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using SmallOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SMALLOFFSET>,
SmallOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using BigOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_BIGOFFSET>,
BigOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using DeziampereChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_LEDSTRIP_MILLIAMP>,
DeziampereAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using StVOOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_STVO_FRONTOFFSET>,
LedsStVOFrontOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using StVOLengthChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_STVO_FRONTLENGTH>,
LedsStVOFrontLengthAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using animationMultiplierChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_ANIMATION_MULTIPLIER>,
AnimationMultiplierAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using ledstripBrightnessChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_LEDSTRIP_BRIGHTNESS>,
LedstripBrightnessAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
class AllCustomLedsOffAction : public virtual ActionInterface
{
public:
void triggered() override
{
for(int index = 0; index < 8; index++)
{
ledstrip_custom_colors[index] = CRGB{0,0,0};
}
}
};
} // namespace
using namespace espgui;
LedstripMenu::LedstripMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIPCOLORMENU>, SwitchScreenAction<LedstripColorsDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDANIMATION>, ToggleBoolAction, CheckboxIcon, EnableLedAnimationAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BRAKELIGHTS>, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKBEEP>, ToggleBoolAction, CheckboxIcon, EnableBeepWhenBlinkAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FULLBLINK>, ToggleBoolAction, CheckboxIcon, EnableFullBlinkAccessor>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP_STVO>, ToggleBoolAction, CheckboxIcon, EnableLedstripStVOAccessor>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STVO_ENABLEFRONTLIGHT>, ToggleBoolAction, CheckboxIcon, EnableLedstripStVOFrontlight>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP_ALLCUSTOMOFF>, AllCustomLedsOffAction>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_STVO_FRONTOFFSET, LedsStVOFrontOffsetAccessor>, SwitchScreenAction<StVOOffsetChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_STVO_FRONTLENGTH, LedsStVOFrontLengthAccessor>, SwitchScreenAction<StVOLengthChangeScreen>>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_MULTIPLIER>, SwitchScreenAction<animationMultiplierChangeScreen>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BIGOFFSET, BigOffsetAccessor>, SwitchScreenAction<BigOffsetChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP_BRIGHTNESS>, SwitchScreenAction<ledstripBrightnessChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSTRIP_MILLIAMP, DeziampereAccessor>, SwitchScreenAction<DeziampereChangeScreen>>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void LedstripMenu::back()
{
switchScreen<MainMenu>();
}
#endif

View File

@ -1,152 +1,19 @@
#pragma once
#include <FastLED.h>
// 3rdparty lib includes
#include "menudisplay.h"
// local includes
#include "menudisplay.h"
#include "menuitem.h"
#include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h"
#include "ledstripselectanimationmenu.h"
#include "ledstripselectblinkmenu.h"
#include "texts.h"
#include "icons/back.h"
#include "checkboxicon.h"
#include "globals.h"
#include "accessors/settingsaccessors.h"
#ifdef FEATURE_LEDSTRIP
#include "ledstrip.h"
#endif
#include "changevaluedisplay.h"
#include "actioninterface.h"
// forward declares
namespace {
class MainWindow;
class LedstripColorsDisplay;
} // namespace
using namespace espgui;
namespace {
#ifdef FEATURE_LEDSTRIP
class LedstripMenu;
class LedstripSelectAnimationMenu;
using LedsCountChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_LEDSCOUNT>,
LedsCountAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using CenterOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_CENTEROFFSET>,
CenterOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using SmallOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SMALLOFFSET>,
SmallOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using BigOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_BIGOFFSET>,
BigOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using DeziampereChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_LEDSTRIP_MILLIAMP>,
DeziampereAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using StVOOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_STVO_FRONTOFFSET>,
LedsStVOFrontOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using StVOLengthChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_STVO_FRONTLENGTH>,
LedsStVOFrontLengthAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using animationMultiplierChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_ANIMATION_MULTIPLIER>,
AnimationMultiplierAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using ledstripBrightnessChangeScreen = makeComponent<
ChangeValueDisplay<uint8_t>,
StaticText<TEXT_LEDSTRIP_BRIGHTNESS>,
LedstripBrightnessAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
class AllCustomLedsOffAction : public virtual ActionInterface
{
public:
void triggered() {
for(int index = 0; index < 8; index++)
{
ledstrip_custom_colors[index] = CRGB{0,0,0};
}
}
};
class LedstripMenu :
public MenuDisplay,
public StaticText<TEXT_LEDSTRIP>,
public BackActionInterface<SwitchScreenAction<MainMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_LEDSTRIP>
{
public:
LedstripMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIPCOLORMENU>, SwitchScreenAction<LedstripColorsDisplay>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDANIMATION>, ToggleBoolAction, CheckboxIcon, EnableLedAnimationAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BRAKELIGHTS>, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKBEEP>, ToggleBoolAction, CheckboxIcon, EnableBeepWhenBlinkAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FULLBLINK>, ToggleBoolAction, CheckboxIcon, EnableFullBlinkAccessor>>();
LedstripMenu();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP_STVO>, ToggleBoolAction, CheckboxIcon, EnableLedstripStVOAccessor>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STVO_ENABLEFRONTLIGHT>, ToggleBoolAction, CheckboxIcon, EnableLedstripStVOFrontlight>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP_ALLCUSTOMOFF>, AllCustomLedsOffAction>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_STVO_FRONTOFFSET, LedsStVOFrontOffsetAccessor>, SwitchScreenAction<StVOOffsetChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_STVO_FRONTLENGTH, LedsStVOFrontLengthAccessor>, SwitchScreenAction<StVOLengthChangeScreen>>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_MULTIPLIER>, SwitchScreenAction<animationMultiplierChangeScreen>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BIGOFFSET, BigOffsetAccessor>, SwitchScreenAction<BigOffsetChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP_BRIGHTNESS>, SwitchScreenAction<ledstripBrightnessChangeScreen>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSTRIP_MILLIAMP, DeziampereAccessor>, SwitchScreenAction<DeziampereChangeScreen>>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void back() override;
};
#endif
} // namespace

View File

@ -14,6 +14,7 @@
#include "ledstrip.h"
#include "ledstripdefines.h"
#ifdef FEATURE_LEDSTRIP
class currentSelectedAnimationText : public virtual TextInterface { public: std::string text() const override {
switch (animation_type) {
case LEDSTRIP_ANIMATION_TYPE_DEFAULTRAINBOW:
@ -32,10 +33,6 @@ class currentSelectedAnimationText : public virtual TextInterface { public: std:
using namespace espgui;
namespace {
class LedstripMenu;
}
namespace {
class LedstripSelectAnimationMenu :
public MenuDisplay,
@ -55,3 +52,4 @@ namespace {
}
};
} // Namespace
#endif

View File

@ -13,6 +13,7 @@
#include "actions/switchscreenaction.h"
#include "ledstripdefines.h"
#ifdef FEATURE_LEDSTRIP
class currentSelectedBlinkAnimationText : public virtual TextInterface { public: std::string text() const override {
switch (blinkAnimation) {
case LEDSTRIP_OVERWRITE_BLINKLEFT:
@ -37,11 +38,7 @@ class currentSelectedBlinkAnimationText : public virtual TextInterface { public:
using namespace espgui;
namespace {
class LedstripMenu;
}
namespace {
namespace {
class LedstripSelectBlinkMenu :
public MenuDisplay,
public StaticText<TEXT_BLINKANIMATION>,
@ -60,3 +57,4 @@ namespace {
}
};
} // Namespace
#endif

View File

@ -0,0 +1,75 @@
#include "limitssettingsmenu.h"
// 3rdparty lib includes
#include "changevaluedisplay.h"
#include "menuitem.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
// local includes
#include "utils.h"
#include "accessors/settingsaccessors.h"
#include "displays/menus/settingsmenu.h"
namespace {
using IMotMaxChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_IMOTMAX>,
IMotMaxAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<LimitsSettingsMenu>>,
espgui::SwitchScreenAction<LimitsSettingsMenu>
>;
using IDcMaxChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_IDCMAX>,
IDcMaxAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<LimitsSettingsMenu>>,
espgui::SwitchScreenAction<LimitsSettingsMenu>
>;
using NMotMaxKmhChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_NMOTMAXKMH>,
NMotMaxKmhAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<LimitsSettingsMenu>>,
espgui::SwitchScreenAction<LimitsSettingsMenu>
>;
using NMotMaxRpmChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_NMOTMAX>,
NMotMaxRpmAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<LimitsSettingsMenu>>,
espgui::SwitchScreenAction<LimitsSettingsMenu>
>;
using FieldWeakMaxChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_FIELDWEAKMAX>,
FieldWeakMaxAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<LimitsSettingsMenu>>,
espgui::SwitchScreenAction<LimitsSettingsMenu>
>;
using PhaseAdvMaxChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int16_t>,
espgui::StaticText<TEXT_PHASEADVMAX>,
PhaseAdvMaxAccessor,
espgui::BackActionInterface<espgui::SwitchScreenAction<LimitsSettingsMenu>>,
espgui::SwitchScreenAction<LimitsSettingsMenu>
>;
} // namespace
using namespace espgui;
LimitsSettingsMenu::LimitsSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_IMOTMAX, IMotMaxAccessor>, SwitchScreenAction<IMotMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_IDCMAX, IDcMaxAccessor>, SwitchScreenAction<IDcMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_NMOTMAXKMH, NMotMaxKmhAccessor>, SwitchScreenAction<NMotMaxKmhChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_NMOTMAX, NMotMaxRpmAccessor>, SwitchScreenAction<NMotMaxRpmChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_FIELDWEAKMAX, FieldWeakMaxAccessor>, SwitchScreenAction<FieldWeakMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_PHASEADVMAX, PhaseAdvMaxAccessor>, SwitchScreenAction<PhaseAdvMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void LimitsSettingsMenu::back()
{
switchScreen<SettingsMenu>();
}

View File

@ -1,82 +1,17 @@
#pragma once
// local includes
// 3rdparty lib includes
#include "menudisplay.h"
#include "utils.h"
#include "changevaluedisplay.h"
#include "menuitem.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
// local includes
#include "texts.h"
#include "accessors/settingsaccessors.h"
// forward declares
namespace {
class LimitsSettingsMenu;
class SettingsMenu;
} // namespace
using namespace espgui;
namespace {
using IMotMaxChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_IMOTMAX>,
IMotMaxAccessor,
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
SwitchScreenAction<LimitsSettingsMenu>
>;
using IDcMaxChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_IDCMAX>,
IDcMaxAccessor,
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
SwitchScreenAction<LimitsSettingsMenu>
>;
using NMotMaxKmhChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_NMOTMAXKMH>,
NMotMaxKmhAccessor,
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
SwitchScreenAction<LimitsSettingsMenu>
>;
using NMotMaxRpmChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_NMOTMAX>,
NMotMaxRpmAccessor,
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
SwitchScreenAction<LimitsSettingsMenu>
>;
using FieldWeakMaxChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_FIELDWEAKMAX>,
FieldWeakMaxAccessor,
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
SwitchScreenAction<LimitsSettingsMenu>
>;
using PhaseAdvMaxChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_PHASEADVMAX>,
PhaseAdvMaxAccessor,
BackActionInterface<SwitchScreenAction<LimitsSettingsMenu>>,
SwitchScreenAction<LimitsSettingsMenu>
>;
class LimitsSettingsMenu :
public MenuDisplay,
public StaticText<TEXT_LIMITSSETTINGS>,
public BackActionInterface<SwitchScreenAction<SettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_LIMITSSETTINGS>
{
public:
LimitsSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_IMOTMAX, IMotMaxAccessor>, SwitchScreenAction<IMotMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_IDCMAX, IDcMaxAccessor>, SwitchScreenAction<IDcMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_NMOTMAXKMH, NMotMaxKmhAccessor>, SwitchScreenAction<NMotMaxKmhChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_NMOTMAX, NMotMaxRpmAccessor>, SwitchScreenAction<NMotMaxRpmChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_FIELDWEAKMAX, FieldWeakMaxAccessor>, SwitchScreenAction<FieldWeakMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_PHASEADVMAX, PhaseAdvMaxAccessor>, SwitchScreenAction<PhaseAdvMaxChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
LimitsSettingsMenu();
void back() override;
};
} // namespace

View File

@ -0,0 +1,65 @@
#include "lockscreensettingsmenu.h"
// 3rdparty lib includes
#include "menuitem.h"
#include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "checkboxicon.h"
#include "changevaluedisplay.h"
// local includes
#include "globals.h"
#include "accessors/settingsaccessors.h"
#include "displays/menus/boardcomputerhardwaresettingsmenu.h"
namespace {
using LockscreenPinDigit0ChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int8_t>,
espgui::StaticText<TEXT_PINDIGIT0>,
LockscreenPinDigitAccessor<0>,
espgui::BackActionInterface<espgui::SwitchScreenAction<LockscreenSettingsMenu>>,
espgui::SwitchScreenAction<LockscreenSettingsMenu>
>;
using LockscreenPinDigit1ChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int8_t>,
espgui::StaticText<TEXT_PINDIGIT1>,
LockscreenPinDigitAccessor<1>,
espgui::BackActionInterface<espgui::SwitchScreenAction<LockscreenSettingsMenu>>,
espgui::SwitchScreenAction<LockscreenSettingsMenu>
>;
using LockscreenPinDigit2ChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int8_t>,
espgui::StaticText<TEXT_PINDIGIT2>,
LockscreenPinDigitAccessor<2>,
espgui::BackActionInterface<espgui::SwitchScreenAction<LockscreenSettingsMenu>>,
espgui::SwitchScreenAction<LockscreenSettingsMenu>
>;
using LockscreenPinDigit3ChangeScreen = espgui::makeComponent<
espgui::ChangeValueDisplay<int8_t>,
espgui::StaticText<TEXT_PINDIGIT3>,
LockscreenPinDigitAccessor<3>,
espgui::BackActionInterface<espgui::SwitchScreenAction<LockscreenSettingsMenu>>,
espgui::SwitchScreenAction<LockscreenSettingsMenu>
>;
} // namespace
using namespace espgui;
LockscreenSettingsMenu::LockscreenSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ALLOWPRESETSWITCH>, ToggleBoolAction, CheckboxIcon, LockscreenAllowPresetSwitchAccessor>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_PINDIGIT0, LockscreenPinDigitAccessor<0>>, SwitchScreenAction<LockscreenPinDigit0ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_PINDIGIT1, LockscreenPinDigitAccessor<1>>, SwitchScreenAction<LockscreenPinDigit1ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_PINDIGIT2, LockscreenPinDigitAccessor<2>>, SwitchScreenAction<LockscreenPinDigit2ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_PINDIGIT3, LockscreenPinDigitAccessor<3>>, SwitchScreenAction<LockscreenPinDigit3ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void LockscreenSettingsMenu::back()
{
switchScreen<BoardcomputerHardwareSettingsMenu>();
}

View File

@ -1,72 +1,17 @@
#pragma once
// local includes
// 3rdparty lib includes
#include "menudisplay.h"
#include "menuitem.h"
#include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h"
// local includes
#include "texts.h"
#include "icons/back.h"
#include "checkboxicon.h"
#include "globals.h"
#include "accessors/settingsaccessors.h"
#include "changevaluedisplay.h"
// forward declares
namespace {
class BoardcomputerHardwareSettingsMenu;
class LockscreenSettingsMenu;
} // namespace
using namespace espgui;
namespace {
using LockscreenPinDigit0ChangeScreen = makeComponent<
ChangeValueDisplay<int8_t>,
StaticText<TEXT_PINDIGIT0>,
LockscreenPinDigitAccessor<0>,
BackActionInterface<SwitchScreenAction<LockscreenSettingsMenu>>,
SwitchScreenAction<LockscreenSettingsMenu>
>;
using LockscreenPinDigit1ChangeScreen = makeComponent<
ChangeValueDisplay<int8_t>,
StaticText<TEXT_PINDIGIT1>,
LockscreenPinDigitAccessor<1>,
BackActionInterface<SwitchScreenAction<LockscreenSettingsMenu>>,
SwitchScreenAction<LockscreenSettingsMenu>
>;
using LockscreenPinDigit2ChangeScreen = makeComponent<
ChangeValueDisplay<int8_t>,
StaticText<TEXT_PINDIGIT2>,
LockscreenPinDigitAccessor<2>,
BackActionInterface<SwitchScreenAction<LockscreenSettingsMenu>>,
SwitchScreenAction<LockscreenSettingsMenu>
>;
using LockscreenPinDigit3ChangeScreen = makeComponent<
ChangeValueDisplay<int8_t>,
StaticText<TEXT_PINDIGIT3>,
LockscreenPinDigitAccessor<3>,
BackActionInterface<SwitchScreenAction<LockscreenSettingsMenu>>,
SwitchScreenAction<LockscreenSettingsMenu>
>;
class LockscreenSettingsMenu :
public MenuDisplay,
public StaticText<TEXT_LOCKSCREENSETTINGS>,
public BackActionInterface<SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_LOCKSCREENSETTINGS>
{
public:
LockscreenSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ALLOWPRESETSWITCH>, ToggleBoolAction, CheckboxIcon, LockscreenAllowPresetSwitchAccessor>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_PINDIGIT0, LockscreenPinDigitAccessor<0>>, SwitchScreenAction<LockscreenPinDigit0ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_PINDIGIT1, LockscreenPinDigitAccessor<1>>, SwitchScreenAction<LockscreenPinDigit1ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_PINDIGIT2, LockscreenPinDigitAccessor<2>>, SwitchScreenAction<LockscreenPinDigit2ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_PINDIGIT3, LockscreenPinDigitAccessor<3>>, SwitchScreenAction<LockscreenPinDigit3ChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
LockscreenSettingsMenu();
void back() override;
};
} // namespace

View File

@ -0,0 +1,90 @@
#include "mainmenu.h"
// 3rdparty lib includes
#include "actions/switchscreenaction.h"
#include "icons/back.h"
// local includes
#include "displays/statusdisplay.h"
#include "displays/menus/selectmodemenu.h"
#include "displays/menus/selectmodemenu.h"
#include "displays/menus/ledstripmenu.h"
#include "actions/modesettingsaction.h"
#include "displays/menus/presetsmenu.h"
#include "displays/menus/profilesmenu.h"
#include "displays/menus/graphsmenu.h"
#include "displays/menus/batterymenu.h"
#include "displays/powersupplydisplay.h"
#include "displays/menus/bmsmenu.h"
#include "displays/menus/settingsmenu.h"
#include "displays/menus/mosfetsmenu.h"
#include "displays/menus/demosmenu.h"
#include "displays/lockscreen.h"
#include "displays/garagedisplay.h"
#include "displays/menus/otamenu.h"
#include "displays/poweroffdisplay.h"
#include "actions/rebootaction.h"
#include "displays/menus/debugmenu.h"
#include "icons/battery.h"
#include "icons/modes.h"
#include "icons/presets.h"
#include "icons/graph.h"
#ifdef FEATURE_BMS
#include "icons/bms.h"
#endif
#include "icons/settings.h"
#include "icons/lock.h"
#include "icons/demos.h"
#ifdef FEATURE_OTA
#include "icons/update.h"
#endif
#ifdef FEATURE_LEDSTRIP
#include "icons/neopixel.h"
#endif
#include "icons/poweroff.h"
#include "icons/reboot.h"
using namespace espgui;
MainMenu::MainMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STATUS>, SwitchScreenAction<StatusDisplay>, StaticMenuItemIcon<&espgui::icons::back>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTMODE>, SwitchScreenAction<SelectModeMenu>, StaticMenuItemIcon<&bobbyicons::modes>>>();
#ifdef FEATURE_LEDSTRIP
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&bobbyicons::neopixel>>>();
#endif
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESETTINGS>, ModeSettingsAction>>(); }
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PRESETS>, SwitchScreenAction<PresetsMenu>, StaticMenuItemIcon<&bobbyicons::presets>>>(); }
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILES>, SwitchScreenAction<ProfilesMenu>>>(); }
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GRAPHS>, SwitchScreenAction<GraphsMenu>, StaticMenuItemIcon<&bobbyicons::graph>>>(); }
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY>, SwitchScreenAction<BatteryMenu>, StaticMenuItemIcon<&bobbyicons::battery>>>(); }
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY)
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POWERSUPPLY>, SwitchScreenAction<PowerSupplyDisplay>>>(); }
#endif
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BMS>, SwitchScreenAction<BmsMenu>, StaticMenuItemIcon<&bobbyicons::bms>>>(); }
#endif
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETTINGS>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&bobbyicons::settings>>>(); }
#ifdef FEATURE_MOSFETS
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFETS>, SwitchScreenAction<MosfetsMenu>>>(); }
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEMOS>, SwitchScreenAction<DemosMenu>, StaticMenuItemIcon<&bobbyicons::demos>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKVEHICLE>, SwitchScreenAction<Lockscreen>, StaticMenuItemIcon<&bobbyicons::lock>>>();
#ifdef FEATURE_GARAGE
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GARAGE>, SwitchScreenAction<GarageDisplay>>>(); }
#endif
#ifdef FEATURE_OTA
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_UPDATE>, SwitchScreenAction<OtaMenu>, StaticMenuItemIcon<&bobbyicons::update>>>(); }
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POWEROFF>, SwitchScreenAction<PoweroffDisplay>, StaticMenuItemIcon<&bobbyicons::poweroff>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REBOOT>, RebootAction, StaticMenuItemIcon<&bobbyicons::reboot>>>();
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEBUG>, SwitchScreenAction<DebugMenu>>>(); }
#ifdef MAINMENU_PLUGIN
GMEN1
#endif
}
void MainMenu::back()
{
switchScreen<StatusDisplay>();
}

View File

@ -1,55 +1,16 @@
#pragma once
// local includes
// 3rdparty lib includes
#include "menudisplay.h"
#include "menuitem.h"
#include "batterymenu.h"
#include "actions/switchscreenaction.h"
#include "actions/modesettingsaction.h"
#include "actions/rebootaction.h"
// local includes
#include "texts.h"
#include "icons/back.h"
#include "icons/battery.h"
#include "icons/modes.h"
#include "icons/presets.h"
#include "icons/graph.h"
#ifdef FEATURE_BMS
#include "icons/bms.h"
#endif
#include "icons/settings.h"
#include "icons/lock.h"
#include "icons/demos.h"
#ifdef FEATURE_OTA
#include "icons/update.h"
#endif
#ifdef FEATURE_LEDSTRIP
#include "icons/neopixel.h"
#endif
#include "icons/poweroff.h"
#include "icons/reboot.h"
#ifdef MAINMENU_PLUGIN
#include MAINMENU_PLUGIN
#endif
// forward declares
namespace {
class StatusDisplay;
class SelectModeMenu;
class LedstripMenu;
class ProfilesMenu;
class PresetsMenu;
class GraphsMenu;
class PowerSupplyDisplay;
class BmsMenu;
class SettingsMenu;
class Lockscreen;
class MosfetsMenu;
class DemosMenu;
class GarageDisplay;
class OtaMenu;
class PoweroffDisplay;
class DebugMenu;
class BatteryMenu;
#ifdef MAINMENU_PLUGIN
GMEN2
#endif
@ -60,51 +21,12 @@ class BatteryMenu;
#endif
} // namespace
using namespace espgui;
namespace {
class MainMenu :
public MenuDisplay,
public StaticText<TEXT_MAINMENU>,
public BackActionInterface<SwitchScreenAction<StatusDisplay>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_MAINMENU>
{
public:
MainMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STATUS>, SwitchScreenAction<StatusDisplay>, StaticMenuItemIcon<&espgui::icons::back>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTMODE>, SwitchScreenAction<SelectModeMenu>, StaticMenuItemIcon<&bobbyicons::modes>>>();
#ifdef FEATURE_LEDSTRIP
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&bobbyicons::neopixel>>>();
#endif
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESETTINGS>, ModeSettingsAction>>(); }
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PRESETS>, SwitchScreenAction<PresetsMenu>, StaticMenuItemIcon<&bobbyicons::presets>>>(); }
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILES>, SwitchScreenAction<ProfilesMenu>>>(); }
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GRAPHS>, SwitchScreenAction<GraphsMenu>, StaticMenuItemIcon<&bobbyicons::graph>>>(); }
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY>, SwitchScreenAction<BatteryMenu>, StaticMenuItemIcon<&bobbyicons::battery>>>(); }
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY)
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POWERSUPPLY>, SwitchScreenAction<PowerSupplyDisplay>>>(); }
#endif
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BMS>, SwitchScreenAction<BmsMenu>, StaticMenuItemIcon<&bobbyicons::bms>>>(); }
#endif
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETTINGS>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&bobbyicons::settings>>>(); }
#ifdef FEATURE_MOSFETS
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFETS>, SwitchScreenAction<MosfetsMenu>>>(); }
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEMOS>, SwitchScreenAction<DemosMenu>, StaticMenuItemIcon<&bobbyicons::demos>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKVEHICLE>, SwitchScreenAction<Lockscreen>, StaticMenuItemIcon<&bobbyicons::lock>>>();
#ifdef FEATURE_GARAGE
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GARAGE>, SwitchScreenAction<GarageDisplay>>>(); }
#endif
#ifdef FEATURE_OTA
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_UPDATE>, SwitchScreenAction<OtaMenu>, StaticMenuItemIcon<&bobbyicons::update>>>(); }
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POWEROFF>, SwitchScreenAction<PoweroffDisplay>, StaticMenuItemIcon<&bobbyicons::poweroff>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REBOOT>, RebootAction, StaticMenuItemIcon<&bobbyicons::reboot>>>();
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEBUG>, SwitchScreenAction<DebugMenu>>>(); }
#ifdef MAINMENU_PLUGIN
GMEN1
#endif
}
MainMenu();
void back() override;
};
} // namespace

View File

@ -0,0 +1,31 @@
#include "modessettingsmenu.h"
// 3rdparty lib includes
#include "menuitem.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
// local includes
#include "displays/menus/defaultmodesettingsmenu.h"
#include "displays/menus/tempomatmodesettingsmenu.h"
#include "displays/menus/larsmmodesettingsmenu.h"
#include "displays/menus/gametrakmodesettingsmenu.h"
#include "displays/menus/settingsmenu.h"
using namespace espgui;
ModesSettingsMenu::ModesSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEFAULTMODESETTIGNS>, SwitchScreenAction<DefaultModeSettingsMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_TEMPOMATMODESETTINGS>, SwitchScreenAction<TempomatModeSettingsMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LARSMMODESETTINGS>, SwitchScreenAction<LarsmModeSettingsMenu>>>();
#ifdef FEATURE_GAMETRAK
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAMETRAKMODESETTINGS>, SwitchScreenAction<GametrakModeSettingsMenu>>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void ModesSettingsMenu::back()
{
switchScreen<SettingsMenu>();
}

View File

@ -2,38 +2,16 @@
// local includes
#include "menudisplay.h"
#include "menuitem.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
// local includes
#include "texts.h"
// forward declares
namespace {
class DefaultModeSettingsMenu;
class TempomatModeSettingsMenu;
class LarsmModeSettingsMenu;
class GametrakModeSettingsMenu;
class SettingsMenu;
} // namespace
using namespace espgui;
namespace {
class ModesSettingsMenu :
public MenuDisplay,
public StaticText<TEXT_MODESSETTINGS>,
public BackActionInterface<SwitchScreenAction<SettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_MODESSETTINGS>
{
public:
ModesSettingsMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEFAULTMODESETTIGNS>, SwitchScreenAction<DefaultModeSettingsMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_TEMPOMATMODESETTINGS>, SwitchScreenAction<TempomatModeSettingsMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LARSMMODESETTINGS>, SwitchScreenAction<LarsmModeSettingsMenu>>>();
#ifdef FEATURE_GAMETRAK
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAMETRAKMODESETTINGS>, SwitchScreenAction<GametrakModeSettingsMenu>>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
ModesSettingsMenu();
void back() override;
};
} // namespace

View File

@ -11,11 +11,6 @@
#include "texts.h"
#include "types.h"
// forward declares
namespace {
class MainMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -11,11 +11,6 @@
#include "debugtexthelpers.h"
#include "debugcolorhelpers.h"
// forward declares
namespace {
class DebugMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -10,11 +10,6 @@
#include "texts.h"
#include "debugtexthelpers.h"
// forward declares
namespace {
class DebugMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -0,0 +1,48 @@
#include "otamenu.h"
// 3rdparty lib includes
#include "actioninterface.h"
#include "actions/dummyaction.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
// local includes
#include "utils.h"
#include "icons/update.h"
#include "icons/presets.h"
#include "buildserver.h"
#include "displays/menus/selectotabuildmenu.h"
#include "displays/updatedisplay.h"
#include "displays/menus/selectbuildservermenu.h"
#include "displays/menus/mainmenu.h"
#ifdef FEATURE_OTA
namespace {
class RedownloadJsonAction : public virtual espgui::ActionInterface
{
public:
void triggered() override
{
redownload = true;
}
};
} // namespace
using namespace espgui;
OtaMenu::OtaMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTBUILD>, SwitchScreenAction<SelectBuildMenu>, StaticMenuItemIcon<&bobbyicons::presets>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_UPDATENOW>, SwitchScreenAction<UpdateDisplay>, StaticMenuItemIcon<&bobbyicons::update>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTBUILDSERVERMENU>, SwitchScreenAction<SelectBuildServerMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REDOWNLOAD>, RedownloadJsonAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void OtaMenu::back()
{
switchScreen<MainMenu>();
}
#endif

View File

@ -1,49 +1,17 @@
#pragma once
// local includes
// 3rdparty lib includes
#include "menudisplay.h"
#include "actioninterface.h"
#include "utils.h"
#include "actions/dummyaction.h"
#include "icons/back.h"
#include "icons/update.h"
#include "icons/presets.h"
// local includes
#include "texts.h"
#include "buildserver.h"
// forward declares
namespace {
class MainMenu;
class UpdateDisplay;
class SelectBuildMenu;
class SelectBuildServerMenu;
} // namespace
using namespace espgui;
namespace {
class RedownloadJsonAction : public virtual ActionInterface {
public:
void triggered() override {
redownload = true;
}
};
class OtaMenu :
public MenuDisplay,
public StaticText<TEXT_UPDATE>,
public BackActionInterface<SwitchScreenAction<MainMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_UPDATE>
{
public:
OtaMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTBUILD>, SwitchScreenAction<SelectBuildMenu>, StaticMenuItemIcon<&bobbyicons::presets>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_UPDATENOW>, SwitchScreenAction<UpdateDisplay>, StaticMenuItemIcon<&bobbyicons::update>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTBUILDSERVERMENU>, SwitchScreenAction<SelectBuildServerMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REDOWNLOAD>, RedownloadJsonAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
OtaMenu();
void back() override;
};
} // namespace

View File

@ -12,11 +12,6 @@
#include "presets.h"
#include "globals.h"
// forward declares
namespace {
class MainMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -7,11 +7,6 @@
#include "icons/back.h"
#include "texts.h"
// forward declares
namespace {
class MainMenu;
} // namespace
using namespace espgui;
namespace {

View File

@ -0,0 +1,35 @@
#include "selectbatterytypemenu.h"
// local includes
#include "battery.h"
#include "globals.h"
#include "utils.h"
#include "displays/menus/batterymenu.h"
namespace {
class CurrentBatteryTypeText : public virtual espgui::TextInterface { public: std::string text() const override { return getBatteryCellTypeString(); } };
template<BatteryCellType T>
class BatterySelectTypeAction : public virtual espgui::ActionInterface
{
public:
void triggered() override { settings.battery.cellType = uint8_t(T); saveSettings(); }
};
} // namespace
using namespace espgui;
BatteryTypeMenu::BatteryTypeMenu()
{
constructMenuItem<makeComponent<MenuItem, CurrentBatteryTypeText, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_TYPE_22P>, BatterySelectTypeAction<BatteryCellType::_22P>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_TYPE_HG2>, BatterySelectTypeAction<BatteryCellType::HG2>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_TYPE_MH1>, BatterySelectTypeAction<BatteryCellType::MH1>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_TYPE_VTC5>, BatterySelectTypeAction<BatteryCellType::VTC5>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void BatteryTypeMenu::back()
{
espgui::switchScreen<BatteryMenu>();
}

View File

@ -1,48 +1,23 @@
#pragma once
// 3rdparty lib includes
#include <menudisplay.h>
#include <menuitem.h>
#include <icons/back.h>
#include <actions/switchscreenaction.h>
#include <actioninterface.h>
// Local includes
#include "menudisplay.h"
#include "utils.h"
#include "menuitem.h"
#include "icons/back.h"
#include "texts.h"
#include "actions/switchscreenaction.h"
#include "batterymenu.h"
#include "battery.h"
#include "actioninterface.h"
#include "displays/menus/mainmenu.h"
// Helper
class currentBatteryType : public virtual TextInterface { public: std::string text() const override { return getBatteryCellTypeString(); } };
class BatteryTypeMenu :
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_SELECT_CELL_TYPE>
{
public:
BatteryTypeMenu();
using namespace espgui;
namespace {
class BatteryTypeMenu;
class BatteryMenu;
template<BatteryCellType T>
class BatterySelectTypeAction : public virtual ActionInterface
{
public:
void triggered() override { settings.battery.cellType = uint8_t(T); saveSettings(); }
};
} // namespace
namespace {
class BatteryTypeMenu :
public MenuDisplay,
public StaticText<TEXT_SELECT_CELL_TYPE>,
public BackActionInterface<SwitchScreenAction<BatteryMenu>>
{
public:
BatteryTypeMenu()
{
constructMenuItem<makeComponent<MenuItem, currentBatteryType, DisabledColor, DummyAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_TYPE_22P>, BatterySelectTypeAction<BatteryCellType::_22P>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_TYPE_HG2>, BatterySelectTypeAction<BatteryCellType::HG2>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_TYPE_MH1>, BatterySelectTypeAction<BatteryCellType::MH1>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERY_TYPE_VTC5>, BatterySelectTypeAction<BatteryCellType::VTC5>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
};
} // Namespace
void back() override;
};

View File

@ -0,0 +1,73 @@
#include "selectbuildservermenu.h"
// esp-idf includes
#include <esp_log.h>
// 3rdparty lib includes
#include <fmt/core.h>
#include <actions/switchscreenaction.h>
// local includes
#include "displays/menus/settingsmenu.h"
#ifdef FEATURE_OTA
namespace {
class BuildserverMenuItem : public espgui::MenuItem
{
public:
std::string text() const override { return m_buildserver_name; }
void setBuildserverName(std::string &&buildserver_name) { m_buildserver_name = std::move(buildserver_name); }
void setBuildserverName(const std::string &buildserver_name) { m_buildserver_name = buildserver_name; }
void setBuildserverUrl(std::string &&buildserver_url) { m_buildserver_url = std::move(buildserver_url); }
void setBuildserverUrl(const std::string &buildserver_url) { m_buildserver_url = buildserver_url; }
void triggered() override
{
stringSettings.otaServerUrl = m_buildserver_url;
if (m_buildserver_url.substr(m_buildserver_url.length() - 4) == ".bin")
{
stringSettings.otaUrl = m_buildserver_url;
}
saveSettings();
redownload = true;
url_for_latest.clear();
url_for_hashes.clear();
availableVersions = {};
}
private:
std::string m_buildserver_url;
std::string m_buildserver_name;
};
} // namespace
using namespace espgui;
SelectBuildServerMenu::SelectBuildServerMenu()
{
for (const auto &otaServer : stringSettings.otaServers)
{
std::string url = otaServer.url;
std::string name = (otaServer.name.empty()) ? url : otaServer.name;
if (!name.empty())
{
auto &menuitem = constructMenuItem<BuildserverMenuItem>();
menuitem.setBuildserverName(name);
menuitem.setBuildserverUrl(url);
}
}
if (menuItemCount() < 1)
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NOBUILDSERVERCONFIGURED>, DefaultFont, StaticColor<TFT_RED>, DummyAction>>();
}
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void SelectBuildServerMenu::back()
{
espgui::switchScreen<SettingsMenu>();
}
#endif

View File

@ -1,87 +1,24 @@
#pragma once
// 3rdparty lib includes
#include <TFT_eSPI.h>
#include <menudisplay.h>
#include <actions/dummyaction.h>
#include <icons/back.h>
// local includes
#include "menudisplay.h"
#include "utils.h"
#include "actions/dummyaction.h"
#include "icons/back.h"
#include "texts.h"
#include "globals.h"
#include "buildserver.h"
// Debugging
#include "esp_log.h"
#include "fmt/core.h"
// forward declares
namespace {
class SettingsMenu;
} // namespace
using namespace espgui;
namespace {
class BuildserverMenuItem : public MenuItem
{
public:
std::string text() const override { return m_buildserver_name; }
void setBuildserverName(std::string &&buildserver_name) { m_buildserver_name = std::move(buildserver_name); }
void setBuildserverName(const std::string &buildserver_name) { m_buildserver_name = buildserver_name; }
void setBuildserverUrl(std::string &&buildserver_url) { m_buildserver_url = std::move(buildserver_url); }
void setBuildserverUrl(const std::string &buildserver_url) { m_buildserver_url = buildserver_url; }
void triggered() override
{
stringSettings.otaServerUrl = m_buildserver_url;
if (m_buildserver_url.substr(m_buildserver_url.length() - 4) == ".bin")
{
stringSettings.otaUrl = m_buildserver_url;
}
saveSettings();
redownload = true;
url_for_latest.clear();
url_for_hashes.clear();
availableVersions = {};
}
private:
std::string m_buildserver_url;
std::string m_buildserver_name;
};
#ifdef FEATURE_OTA
class SelectBuildServerMenu :
public MenuDisplay,
public StaticText<TEXT_SELECTBUILDSERVERMENU>,
public BackActionInterface<SwitchScreenAction<SettingsMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_SELECTBUILDSERVERMENU>
{
public:
SelectBuildServerMenu() {
SelectBuildServerMenu();
for (const auto &otaServer : stringSettings.otaServers)
{
std::string url = otaServer.url;
std::string name = (otaServer.name.empty()) ? url : otaServer.name;
if (!name.empty()) {
auto &menuitem = constructMenuItem<BuildserverMenuItem>();
menuitem.setBuildserverName(name);
menuitem.setBuildserverUrl(url);
}
}
if (menuItemCount() < 1)
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_NOBUILDSERVERCONFIGURED>, DefaultFont, StaticColor<TFT_RED>, DummyAction>>();
}
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void back() override;
};
} // namespace
#endif

View File

@ -0,0 +1,67 @@
#include "selectmodemenu.h"
// local includes
#include "utils.h"
#include "actions/multiaction.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
#include "globals.h"
#include "modes/defaultmode.h"
#include "modes/tempomatmode.h"
#include "modes/larsmmode.h"
#include "modes/remotecontrolmode.h"
#include "modes/gametrakmode.h"
#include "accessors/globalaccessors.h"
#include "displays/menus/mainmenu.h"
namespace {
template<typename T1, T1 &target, typename T2, T2 value>
class SetterAction : public espgui::ActionInterface
{
public:
void triggered() override { target = value; }
};
using SetDefaultModeAction = SetterAction<ModeInterface*, currentMode, DefaultMode*, &modes::defaultMode>;
using SetTempomatModeAction = SetterAction<ModeInterface*, currentMode, TempomatMode*, &modes::tempomatMode>;
using SetLarsmModeAction = SetterAction<ModeInterface*, currentMode, LarsmMode*, &modes::larsmMode>;
using SetRemoteControlModeAction = SetterAction<ModeInterface*, currentMode, RemoteControlMode*, &modes::remoteControlMode>;
#ifdef FEATURE_GAMETRAK
using SetGametrakModeAction = SetterAction<ModeInterface*, currentMode, GametrakMode*, &modes::gametrakMode>;
#endif
} // namespace
using namespace espgui;
SelectModeMenu::SelectModeMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEFAULT>, MultiAction<SetDefaultModeAction, SwitchScreenAction<MainMenu>>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_TEMPOMAT, AvgSpeedAccessor>, MultiAction<SetTempomatModeAction, SwitchScreenAction<MainMenu>>>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LARSM>, MultiAction<SetLarsmModeAction, SwitchScreenAction<MainMenu>>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REMOTECONTROL>, MultiAction<SetRemoteControlModeAction, SwitchScreenAction<MainMenu>>>>(); }
#ifdef FEATURE_GAMETRAK
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAMETRAK>, MultiAction<SetGametrakModeAction, SwitchScreenAction<MainMenu>>>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void SelectModeMenu::start()
{
Base::start();
if (currentMode == &modes::defaultMode)
setSelectedIndex(0);
else if (currentMode == &modes::tempomatMode)
setSelectedIndex(1);
else if (currentMode == &modes::larsmMode)
setSelectedIndex(2);
else
{
//Serial.printf("Unknown mode: %s", currentMode?currentMode->displayName():"");
setSelectedIndex(3);
}
}
void SelectModeMenu::back()
{
switchScreen<MainMenu>();
}

View File

@ -1,79 +1,20 @@
#pragma once
// local includes
// 3rdparty lib includes
#include "menudisplay.h"
#include "utils.h"
#include "actions/multiaction.h"
#include "actions/switchscreenaction.h"
#include "icons/back.h"
// local includes
#include "texts.h"
#include "globals.h"
#include "modes/defaultmode.h"
#include "modes/tempomatmode.h"
#include "modes/larsmmode.h"
#include "modes/remotecontrolmode.h"
#include "modes/gametrakmode.h"
// forward declares
namespace {
class MainMenu;
} // namespace
using namespace espgui;
namespace {
template<typename T1, T1 &target, typename T2, T2 value>
class SetterAction : public ActionInterface
{
public:
void triggered() override { target = value; }
};
using SetDefaultModeAction = SetterAction<ModeInterface*, currentMode, DefaultMode*, &modes::defaultMode>;
using SetTempomatModeAction = SetterAction<ModeInterface*, currentMode, TempomatMode*, &modes::tempomatMode>;
using SetLarsmModeAction = SetterAction<ModeInterface*, currentMode, LarsmMode*, &modes::larsmMode>;
using SetRemoteControlModeAction = SetterAction<ModeInterface*, currentMode, RemoteControlMode*, &modes::remoteControlMode>;
#ifdef FEATURE_GAMETRAK
using SetGametrakModeAction = SetterAction<ModeInterface*, currentMode, GametrakMode*, &modes::gametrakMode>;
#endif
class SelectModeMenu :
public MenuDisplay,
public StaticText<TEXT_SELECTMODE>,
public BackActionInterface<SwitchScreenAction<MainMenu>>
public espgui::MenuDisplay,
public espgui::StaticText<TEXT_SELECTMODE>
{
using Base = MenuDisplay;
using Base = espgui::MenuDisplay;
public:
SelectModeMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEFAULT>, MultiAction<SetDefaultModeAction, SwitchScreenAction<MainMenu>>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_TEMPOMAT, AvgSpeedAccessor>, MultiAction<SetTempomatModeAction, SwitchScreenAction<MainMenu>>>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LARSM>, MultiAction<SetLarsmModeAction, SwitchScreenAction<MainMenu>>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REMOTECONTROL>, MultiAction<SetRemoteControlModeAction, SwitchScreenAction<MainMenu>>>>(); }
#ifdef FEATURE_GAMETRAK
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAMETRAK>, MultiAction<SetGametrakModeAction, SwitchScreenAction<MainMenu>>>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
SelectModeMenu();
void start() override;
void back() override;
};
void SelectModeMenu::start()
{
Base::start();
if (currentMode == &modes::defaultMode)
setSelectedIndex(0);
else if (currentMode == &modes::tempomatMode)
setSelectedIndex(1);
else if (currentMode == &modes::larsmMode)
setSelectedIndex(2);
else
{
//Serial.printf("Unknown mode: %s", currentMode?currentMode->displayName():"");
setSelectedIndex(3);
}
}
} // namespace

View File

@ -18,13 +18,9 @@
#define MESSAGE(text) constructMenuItem<makeComponent<MenuItem, StaticText<text>, DefaultFont, StaticColor<TFT_RED>, DummyAction>>()
// forward declares
namespace {
class OtaMenu;
} // namespace
using namespace espgui;
#ifdef FEATURE_OTA
namespace {
// ToDo: if (request_failed) => MESSAGE("An error occurred")
@ -152,3 +148,4 @@ void SelectBuildMenu::buildMenuRequestError(std::string error)
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<OtaMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
} // namespace
#endif

View File

@ -0,0 +1,94 @@
#include "settingsmenu.h"
// Arduino includes
#include <Arduino.h>
// 3rdparty lib includes
#include "actions/toggleboolaction.h"
#include "actions/switchscreenaction.h"
#include "checkboxicon.h"
#include "icons/back.h"
// local includes
#include "utils.h"
#include "icons/wifi.h"
#if defined(FEATURE_BLUETOOTH) || defined(FEATURE_BLE)
#include "icons/bluetooth.h"
#endif
#include "icons/time.h"
#include "icons/hardware.h"
#include "icons/buzzer.h"
#include "icons/info.h"
#include "icons/demos.h"
#include "icons/update.h"
#include "globals.h"
#include "accessors/settingsaccessors.h"
#include "displays/menus/limitssettingsmenu.h"
#include "displays/menus/wifisettingsmenu.h"
#include "displays/menus/bluetoothsettingsmenu.h"
#include "displays/menus/blesettingsmenu.h"
#include "displays/menus/cloudsettingsmenu.h"
#include "displays/menus/selectbuildservermenu.h"
#include "displays/menus/timesettingsmenu.h"
#include "displays/menus/modessettingsmenu.h"
#include "displays/menus/controllerhardwaresettingsmenu.h"
#include "displays/menus/boardcomputerhardwaresettingsmenu.h"
#include "displays/menus/buzzermenu.h"
#include "displays/menus/crashmenu.h"
#include "displays/menus/aboutmenu.h"
#include "displays/menus/mainmenu.h"
namespace {
#ifdef FEATURE_LEDBACKLIGHT
struct BacklightAccessor : public virtual espgui::AccessorInterface<bool>
{
bool getValue() const override { return digitalRead(PINS_LEDBACKLIGHT) != ledBacklightInverted; }
void setValue(bool value) override { digitalWrite(PINS_LEDBACKLIGHT, value != ledBacklightInverted); }
};
#endif
struct FrontLedAccessor : public espgui::RefAccessor<bool> { bool &getRef() const override { return controllers.front.command.led; } };
struct BackLedAccessor : public espgui::RefAccessor<bool> { bool &getRef() const override { return controllers.back.command.led; } };
} // namespace
using namespace espgui;
SettingsMenu::SettingsMenu()
{
#ifdef FEATURE_LEDBACKLIGHT
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKLIGHT>, ToggleBoolAction, CheckboxIcon, BacklightAccessor>>();
#endif
if (!simplified)
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LIMITSSETTINGS>, SwitchScreenAction<LimitsSettingsMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_WIFISETTINGS>, SwitchScreenAction<WifiSettingsMenu>, StaticMenuItemIcon<&bobbyicons::wifi>>>();
#ifdef FEATURE_BLUETOOTH
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHSETTINGS>, SwitchScreenAction<BluetoothSettingsMenu>, StaticMenuItemIcon<&bobbyicons::bluetooth>>>();
#endif
#ifdef FEATURE_BLE
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLESETTINGS>, SwitchScreenAction<BleSettingsMenu>, StaticMenuItemIcon<&bobbyicons::bluetooth>>>();
#endif
#ifdef FEATURE_CLOUD
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CLOUDSETTINGS>, SwitchScreenAction<CloudSettingsMenu>>>();
#endif
#ifdef FEATURE_OTA
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTBUILDSERVERMENU>, SwitchScreenAction<SelectBuildServerMenu>, StaticMenuItemIcon<&bobbyicons::update>>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_TIME>, SwitchScreenAction<TimeSettingsMenu>, StaticMenuItemIcon<&bobbyicons::time>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESSETTINGS>, SwitchScreenAction<ModesSettingsMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CONTROLLERHARDWARESETTINGS>, SwitchScreenAction<ControllerHardwareSettingsMenu>, StaticMenuItemIcon<&bobbyicons::hardware>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&bobbyicons::hardware>>>();
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_AUTOCONNECTBMS>, ToggleBoolAction, CheckboxIcon, AutoConnectBmsAccessor>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BUZZER>, SwitchScreenAction<BuzzerMenu>, StaticMenuItemIcon<&bobbyicons::buzzer>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTLED>, ToggleBoolAction, CheckboxIcon, FrontLedAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKLED>, ToggleBoolAction, CheckboxIcon, BackLedAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CRASHMENU>, SwitchScreenAction<CrashMenu>, StaticMenuItemIcon<&bobbyicons::demos>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ABOUT>, SwitchScreenAction<AboutMenu>, StaticMenuItemIcon<&bobbyicons::info>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void SettingsMenu::back()
{
switchScreen<MainMenu>();
}

Some files were not shown because too many files have changed in this diff Show More