Motor inverted presets are now part of platformio.ini
This commit is contained in:
@ -43,6 +43,13 @@ build_flags =
|
|||||||
-DDEFAULT_FIELDWEAKMAX=5
|
-DDEFAULT_FIELDWEAKMAX=5
|
||||||
-DDEFAULT_FIELDADVMAX=40
|
-DDEFAULT_FIELDADVMAX=40
|
||||||
|
|
||||||
|
[default_wheels_inverted]
|
||||||
|
build_flags =
|
||||||
|
-DDEFAULT_INVERTFRONTLEFT=false
|
||||||
|
-DDEFAULT_INVERTFRONTRIGHT=true
|
||||||
|
-DDEFAULT_INVERTBACKLEFT=false
|
||||||
|
-DDEFAULT_INVERTBACKRIGHT=true
|
||||||
|
|
||||||
[peters_platine_common]
|
[peters_platine_common]
|
||||||
build_flags =
|
build_flags =
|
||||||
-DILI9341_DRIVER=1
|
-DILI9341_DRIVER=1
|
||||||
@ -108,6 +115,10 @@ build_flags =
|
|||||||
-DPINS_TX1=5
|
-DPINS_TX1=5
|
||||||
-DPINS_RX2=22
|
-DPINS_RX2=22
|
||||||
-DPINS_TX2=23
|
-DPINS_TX2=23
|
||||||
|
-DDEFAULT_INVERTFRONTLEFT=false
|
||||||
|
-DDEFAULT_INVERTFRONTRIGHT=true
|
||||||
|
-DDEFAULT_INVERTBACKLEFT=true
|
||||||
|
-DDEFAULT_INVERTBACKRIGHT=false
|
||||||
; -DFEATURE_MOSFETS
|
; -DFEATURE_MOSFETS
|
||||||
; -DPINS_MOSFET0=18
|
; -DPINS_MOSFET0=18
|
||||||
; -DPINS_MOSFET1=19
|
; -DPINS_MOSFET1=19
|
||||||
@ -178,6 +189,7 @@ build_flags =
|
|||||||
${peters_platine.build_flags}
|
${peters_platine.build_flags}
|
||||||
${ota_common.build_flags}
|
${ota_common.build_flags}
|
||||||
${default_limits.build_flags}
|
${default_limits.build_flags}
|
||||||
|
${default_wheels_inverted.build_flags}
|
||||||
-DDEVICE_PREFIX=bobbycar
|
-DDEVICE_PREFIX=bobbycar
|
||||||
-DAP_PASSWORD=Passwort_123
|
-DAP_PASSWORD=Passwort_123
|
||||||
-DFEATURE_WEBSERVER
|
-DFEATURE_WEBSERVER
|
||||||
@ -236,6 +248,7 @@ build_flags =
|
|||||||
${peters_platine.build_flags}
|
${peters_platine.build_flags}
|
||||||
${ota_common.build_flags}
|
${ota_common.build_flags}
|
||||||
${default_limits.build_flags}
|
${default_limits.build_flags}
|
||||||
|
${default_wheels_inverted.build_flags}
|
||||||
-DDEVICE_PREFIX=bobbyquad
|
-DDEVICE_PREFIX=bobbyquad
|
||||||
-DAP_PASSWORD=Passwort_123
|
-DAP_PASSWORD=Passwort_123
|
||||||
-DFEATURE_WEBSERVER
|
-DFEATURE_WEBSERVER
|
||||||
@ -284,6 +297,7 @@ build_flags =
|
|||||||
-DSPI_FREQUENCY=20000000
|
-DSPI_FREQUENCY=20000000
|
||||||
-DSPI_TOUCH_FREQUENCY=2500000
|
-DSPI_TOUCH_FREQUENCY=2500000
|
||||||
-DDEFAULT_SWAPSCREENBYTES=false
|
-DDEFAULT_SWAPSCREENBYTES=false
|
||||||
|
${default_wheels_inverted.build_flags}
|
||||||
; TODO: actually assign pins
|
; TODO: actually assign pins
|
||||||
-DPINS_RX1=22
|
-DPINS_RX1=22
|
||||||
-DPINS_TX1=25
|
-DPINS_TX1=25
|
||||||
@ -311,6 +325,7 @@ build_flags =
|
|||||||
${peters_platine_reversed.build_flags}
|
${peters_platine_reversed.build_flags}
|
||||||
${ota_common.build_flags}
|
${ota_common.build_flags}
|
||||||
${default_limits.build_flags}
|
${default_limits.build_flags}
|
||||||
|
${default_wheels_inverted.build_flags}
|
||||||
-DDEVICE_PREFIX=bobbycar
|
-DDEVICE_PREFIX=bobbycar
|
||||||
-DAP_PASSWORD=Passwort_123
|
-DAP_PASSWORD=Passwort_123
|
||||||
-DFEATURE_WEBSERVER
|
-DFEATURE_WEBSERVER
|
||||||
|
41
src/actions/erasenvsaction.h
Normal file
41
src/actions/erasenvsaction.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <HardwareSerial.h>
|
||||||
|
|
||||||
|
#include "actioninterface.h"
|
||||||
|
#include "globals.h"
|
||||||
|
#include "presets.h"
|
||||||
|
|
||||||
|
namespace {
|
||||||
|
class EraseNvsAction : public virtual ActionInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
void triggered() override
|
||||||
|
{
|
||||||
|
const auto profile = settingsPersister.currentlyOpenProfileIndex();
|
||||||
|
|
||||||
|
if (!settingsPersister.erase())
|
||||||
|
{
|
||||||
|
Serial.println("EraseNvsAction::triggered() erase failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
settings = presets::defaultSettings;
|
||||||
|
|
||||||
|
if (!profile)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!settingsPersister.openProfile(*profile))
|
||||||
|
{
|
||||||
|
Serial.println("EraseNvsAction::triggered() openProfile failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!settingsPersister.load(settings))
|
||||||
|
{
|
||||||
|
Serial.println("EraseNvsAction::triggered() load failed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
@ -6,6 +6,7 @@
|
|||||||
#include "menuitem.h"
|
#include "menuitem.h"
|
||||||
#include "actions/loadsettingsaction.h"
|
#include "actions/loadsettingsaction.h"
|
||||||
#include "actions/savesettingsaction.h"
|
#include "actions/savesettingsaction.h"
|
||||||
|
#include "actions/erasenvsaction.h"
|
||||||
#include "actions/switchscreenaction.h"
|
#include "actions/switchscreenaction.h"
|
||||||
#include "actions/dummyaction.h"
|
#include "actions/dummyaction.h"
|
||||||
#include "actions/toggleboolaction.h"
|
#include "actions/toggleboolaction.h"
|
||||||
@ -40,6 +41,7 @@ class DebugMenu :
|
|||||||
public StaticMenuDefinition<
|
public StaticMenuDefinition<
|
||||||
makeComponent<MenuItem, StaticText<TEXT_LOADSETTINGS>, LoadSettingsAction>,
|
makeComponent<MenuItem, StaticText<TEXT_LOADSETTINGS>, LoadSettingsAction>,
|
||||||
makeComponent<MenuItem, StaticText<TEXT_SAVESETTINGS>, SaveSettingsAction>,
|
makeComponent<MenuItem, StaticText<TEXT_SAVESETTINGS>, SaveSettingsAction>,
|
||||||
|
makeComponent<MenuItem, StaticText<TEXT_ERASENVS>, EraseNvsAction>,
|
||||||
makeComponent<MenuItem, StaticText<nullptr>, DummyAction>,
|
makeComponent<MenuItem, StaticText<nullptr>, DummyAction>,
|
||||||
makeComponent<MenuItem, StaticText<TEXT_FRONTCOMMAND>, SwitchScreenAction<FrontCommandDebugMenu>>,
|
makeComponent<MenuItem, StaticText<TEXT_FRONTCOMMAND>, SwitchScreenAction<FrontCommandDebugMenu>>,
|
||||||
makeComponent<MenuItem, StaticText<TEXT_BACKCOMMAND>, SwitchScreenAction<BackCommandDebugMenu>>,
|
makeComponent<MenuItem, StaticText<TEXT_BACKCOMMAND>, SwitchScreenAction<BackCommandDebugMenu>>,
|
||||||
|
@ -99,6 +99,7 @@ private:
|
|||||||
Label m_labelPerformance{85, bottomLines[2]}; // 40, 15
|
Label m_labelPerformance{85, bottomLines[2]}; // 40, 15
|
||||||
Label m_labelMode{165, bottomLines[2]}; // 75, 15
|
Label m_labelMode{165, bottomLines[2]}; // 75, 15
|
||||||
Label m_labelName{40, bottomLines[3]}; // 40, 15
|
Label m_labelName{40, bottomLines[3]}; // 40, 15
|
||||||
|
Label m_labelProfile{205, bottomLines[3]}; // 35, 15
|
||||||
|
|
||||||
static const constexpr int bottomLines[4] { 251, 266, 281, 296 };
|
static const constexpr int bottomLines[4] { 251, 266, 281, 296 };
|
||||||
};
|
};
|
||||||
@ -136,6 +137,7 @@ void StatusDisplay::initScreen()
|
|||||||
m_labelMode.start();
|
m_labelMode.start();
|
||||||
tft.drawString("Name:", 0, bottomLines[3]);
|
tft.drawString("Name:", 0, bottomLines[3]);
|
||||||
m_labelName.start();
|
m_labelName.start();
|
||||||
|
m_labelProfile.start();
|
||||||
|
|
||||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
}
|
}
|
||||||
@ -161,6 +163,8 @@ void StatusDisplay::redraw()
|
|||||||
m_labelPerformance.redraw(String{performance.last});
|
m_labelPerformance.redraw(String{performance.last});
|
||||||
m_labelMode.redraw(currentMode->displayName());
|
m_labelMode.redraw(currentMode->displayName());
|
||||||
m_labelName.redraw(&deviceName[0]);
|
m_labelName.redraw(&deviceName[0]);
|
||||||
|
const auto profile = settingsPersister.currentlyOpenProfileIndex();
|
||||||
|
m_labelProfile.redraw(profile?String{*profile}:"-");
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusDisplay::rotate(int offset)
|
void StatusDisplay::rotate(int offset)
|
||||||
|
@ -127,7 +127,8 @@ void setup()
|
|||||||
BluetoothConnectBmsAction{}.triggered();
|
BluetoothConnectBmsAction{}.triggered();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} else if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Slave)
|
}
|
||||||
|
else if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Slave)
|
||||||
{
|
{
|
||||||
bootLabel.redraw("bluetooth begin");
|
bootLabel.redraw("bluetooth begin");
|
||||||
BluetoothBeginAction{}.triggered();
|
BluetoothBeginAction{}.triggered();
|
||||||
@ -150,6 +151,7 @@ void setup()
|
|||||||
currentMode = &modes::defaultMode;
|
currentMode = &modes::defaultMode;
|
||||||
|
|
||||||
#ifdef FEATURE_OTA
|
#ifdef FEATURE_OTA
|
||||||
|
bootLabel.redraw("ota");
|
||||||
initOta();
|
initOta();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -25,10 +25,10 @@ constexpr Settings::ControllerHardware defaultControllerHardware {
|
|||||||
.enableBackLeft = true,
|
.enableBackLeft = true,
|
||||||
.enableBackRight = true,
|
.enableBackRight = true,
|
||||||
|
|
||||||
.invertFrontLeft = false,
|
.invertFrontLeft = DEFAULT_INVERTFRONTLEFT,
|
||||||
.invertFrontRight = true,
|
.invertFrontRight = DEFAULT_INVERTFRONTRIGHT,
|
||||||
.invertBackLeft = false,
|
.invertBackLeft = DEFAULT_INVERTBACKLEFT,
|
||||||
.invertBackRight = true,
|
.invertBackRight = DEFAULT_INVERTBACKRIGHT,
|
||||||
|
|
||||||
.wheelDiameter = 165,
|
.wheelDiameter = 165,
|
||||||
.numMagnetPoles = 15,
|
.numMagnetPoles = 15,
|
||||||
@ -41,10 +41,10 @@ constexpr Settings::ControllerHardware mosfetsOffControllerHardware {
|
|||||||
.enableBackLeft = false,
|
.enableBackLeft = false,
|
||||||
.enableBackRight = false,
|
.enableBackRight = false,
|
||||||
|
|
||||||
.invertFrontLeft = false,
|
.invertFrontLeft = DEFAULT_INVERTFRONTLEFT,
|
||||||
.invertFrontRight = true,
|
.invertFrontRight = DEFAULT_INVERTFRONTRIGHT,
|
||||||
.invertBackLeft = false,
|
.invertBackLeft = DEFAULT_INVERTBACKLEFT,
|
||||||
.invertBackRight = true,
|
.invertBackRight = DEFAULT_INVERTBACKRIGHT,
|
||||||
|
|
||||||
.wheelDiameter = 165,
|
.wheelDiameter = 165,
|
||||||
.numMagnetPoles = 15,
|
.numMagnetPoles = 15,
|
||||||
@ -57,7 +57,7 @@ constexpr Settings::WifiSettings defaultWifiSettings {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constexpr Settings::BluetoothSettings defaultBluetoothSettings {
|
constexpr Settings::BluetoothSettings defaultBluetoothSettings {
|
||||||
.autoBluetoothMode = BluetoothMode::Off
|
.autoBluetoothMode = BluetoothMode::Master
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Settings::ControllerHardware spinnerControllerHardware {
|
constexpr Settings::ControllerHardware spinnerControllerHardware {
|
||||||
@ -66,10 +66,10 @@ constexpr Settings::ControllerHardware spinnerControllerHardware {
|
|||||||
.enableBackLeft = true,
|
.enableBackLeft = true,
|
||||||
.enableBackRight = true,
|
.enableBackRight = true,
|
||||||
|
|
||||||
.invertFrontLeft = false,
|
.invertFrontLeft = DEFAULT_INVERTFRONTLEFT,
|
||||||
.invertFrontRight = false,
|
.invertFrontRight = !DEFAULT_INVERTFRONTRIGHT,
|
||||||
.invertBackLeft = false,
|
.invertBackLeft = DEFAULT_INVERTBACKLEFT,
|
||||||
.invertBackRight = false,
|
.invertBackRight = !DEFAULT_INVERTBACKRIGHT,
|
||||||
|
|
||||||
.wheelDiameter = 165,
|
.wheelDiameter = 165,
|
||||||
.numMagnetPoles = 15,
|
.numMagnetPoles = 15,
|
||||||
|
@ -54,7 +54,7 @@
|
|||||||
#include "icons/logo.h"
|
#include "icons/logo.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
Label bootLabel{32, 250, TFT_WHITE};
|
Label bootLabel{32, 250};
|
||||||
|
|
||||||
union X {
|
union X {
|
||||||
X() {}
|
X() {}
|
||||||
@ -407,10 +407,11 @@ void initScreen()
|
|||||||
{
|
{
|
||||||
tft.init();
|
tft.init();
|
||||||
tft.fillScreen(TFT_WHITE);
|
tft.fillScreen(TFT_WHITE);
|
||||||
tft.setTextColor(TFT_BLACK);
|
tft.setTextColor(TFT_BLACK, TFT_WHITE);
|
||||||
|
tft.setTextFont(4);
|
||||||
tft.pushImage(0, 40, icons::logo.WIDTH, icons::logo.HEIGHT, icons::logo.buffer);
|
tft.pushImage(0, 40, icons::logo.WIDTH, icons::logo.HEIGHT, icons::logo.buffer);
|
||||||
tft.drawString("Bobbycar-OS", 32, 200, 4);
|
tft.drawString("Bobbycar-OS", 32, 200);
|
||||||
tft.drawString("booting...", 32, 225, 4);
|
tft.drawString("booting...", 32, 225);
|
||||||
bootLabel.start();
|
bootLabel.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,12 +17,20 @@ class SettingsPersister
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
bool init();
|
bool init();
|
||||||
|
bool erase();
|
||||||
bool openProfile(uint8_t index);
|
bool openProfile(uint8_t index);
|
||||||
|
void closeProfile();
|
||||||
bool load(Settings &settings);
|
bool load(Settings &settings);
|
||||||
bool save(Settings &settings);
|
bool save(Settings &settings);
|
||||||
|
|
||||||
|
tl::optional<uint8_t> currentlyOpenProfileIndex() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
tl::optional<nvs_handle> m_handle;
|
struct CurrentlyOpenProfile {
|
||||||
|
nvs_handle handle;
|
||||||
|
uint8_t profileIndex;
|
||||||
|
};
|
||||||
|
tl::optional<CurrentlyOpenProfile> m_profile;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool SettingsPersister::init()
|
bool SettingsPersister::init()
|
||||||
@ -32,14 +40,7 @@ bool SettingsPersister::init()
|
|||||||
{
|
{
|
||||||
Serial.printf("nvs_flash_init() returned: %s, trying to erase\r\n", esp_err_to_name(err));
|
Serial.printf("nvs_flash_init() returned: %s, trying to erase\r\n", esp_err_to_name(err));
|
||||||
|
|
||||||
err = nvs_flash_erase();
|
return erase();
|
||||||
if (err != ESP_OK)
|
|
||||||
{
|
|
||||||
Serial.printf("nvs_flash_erase() returned: %s, aborting\r\n", esp_err_to_name(err));
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
err = nvs_flash_init();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err != ESP_OK)
|
if (err != ESP_OK)
|
||||||
@ -51,13 +52,28 @@ bool SettingsPersister::init()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool SettingsPersister::erase()
|
||||||
|
{
|
||||||
|
esp_err_t err = nvs_flash_erase();
|
||||||
|
if (err != ESP_OK)
|
||||||
|
{
|
||||||
|
Serial.printf("nvs_flash_erase() returned: %s, aborting\r\n", esp_err_to_name(err));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
err = nvs_flash_init();
|
||||||
|
if (err != ESP_OK)
|
||||||
|
{
|
||||||
|
Serial.printf("nvs_flash_init() returned: %s\r\n", esp_err_to_name(err));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
bool SettingsPersister::openProfile(uint8_t index)
|
bool SettingsPersister::openProfile(uint8_t index)
|
||||||
{
|
{
|
||||||
if (m_handle)
|
closeProfile();
|
||||||
{
|
|
||||||
nvs_close(*m_handle);
|
|
||||||
m_handle = tl::nullopt;
|
|
||||||
}
|
|
||||||
|
|
||||||
nvs_handle handle;
|
nvs_handle handle;
|
||||||
esp_err_t err = nvs_open((String{"bobbycar"}+index).c_str(), NVS_READWRITE, &handle);
|
esp_err_t err = nvs_open((String{"bobbycar"}+index).c_str(), NVS_READWRITE, &handle);
|
||||||
@ -67,11 +83,21 @@ bool SettingsPersister::openProfile(uint8_t index)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_handle = handle;
|
m_profile = {handle, index};
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SettingsPersister::closeProfile()
|
||||||
|
{
|
||||||
|
if (!m_profile)
|
||||||
|
return;
|
||||||
|
|
||||||
|
nvs_close(m_profile->handle);
|
||||||
|
|
||||||
|
m_profile = tl::nullopt;
|
||||||
|
}
|
||||||
|
|
||||||
template<typename T> struct nvsGetterHelper;
|
template<typename T> struct nvsGetterHelper;
|
||||||
template<> struct nvsGetterHelper<int8_t> { static constexpr auto nvs_get = &nvs_get_i8; };
|
template<> struct nvsGetterHelper<int8_t> { static constexpr auto nvs_get = &nvs_get_i8; };
|
||||||
template<> struct nvsGetterHelper<uint8_t> { static constexpr auto nvs_get = &nvs_get_u8; };
|
template<> struct nvsGetterHelper<uint8_t> { static constexpr auto nvs_get = &nvs_get_u8; };
|
||||||
@ -138,9 +164,9 @@ template<> struct nvsGetterHelper<wifi_mode_t> { static esp_err_t nvs_get(nvs_ha
|
|||||||
|
|
||||||
bool SettingsPersister::load(Settings &settings)
|
bool SettingsPersister::load(Settings &settings)
|
||||||
{
|
{
|
||||||
if (!m_handle)
|
if (!m_profile)
|
||||||
{
|
{
|
||||||
Serial.println("");
|
Serial.println("SettingsPersister::load() no profile open currently!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +174,7 @@ bool SettingsPersister::load(Settings &settings)
|
|||||||
|
|
||||||
settings.executeForEverySetting([&](const char *key, auto &value)
|
settings.executeForEverySetting([&](const char *key, auto &value)
|
||||||
{
|
{
|
||||||
esp_err_t err = nvsGetterHelper<std::remove_reference_t<decltype(value)>>::nvs_get(*m_handle, key, &value);
|
esp_err_t err = nvsGetterHelper<std::remove_reference_t<decltype(value)>>::nvs_get(m_profile->handle, key, &value);
|
||||||
if (err != ESP_OK)
|
if (err != ESP_OK)
|
||||||
{
|
{
|
||||||
Serial.printf("nvs_get_i32() for %s returned: %s\r\n", key, esp_err_to_name(err));
|
Serial.printf("nvs_get_i32() for %s returned: %s\r\n", key, esp_err_to_name(err));
|
||||||
@ -194,9 +220,9 @@ template<> struct nvsSetterHelper<wifi_mode_t> { static esp_err_t nvs_set(nvs_ha
|
|||||||
|
|
||||||
bool SettingsPersister::save(Settings &settings)
|
bool SettingsPersister::save(Settings &settings)
|
||||||
{
|
{
|
||||||
if (!m_handle)
|
if (!m_profile)
|
||||||
{
|
{
|
||||||
Serial.println("");
|
Serial.println("SettingsPersister::save() no profile open currently!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -204,7 +230,7 @@ bool SettingsPersister::save(Settings &settings)
|
|||||||
|
|
||||||
settings.executeForEverySetting([&](const char *key, auto value)
|
settings.executeForEverySetting([&](const char *key, auto value)
|
||||||
{
|
{
|
||||||
esp_err_t err = nvsSetterHelper<decltype(value)>::nvs_set(*m_handle, key, value);
|
esp_err_t err = nvsSetterHelper<decltype(value)>::nvs_set(m_profile->handle, key, value);
|
||||||
if (err != ESP_OK)
|
if (err != ESP_OK)
|
||||||
{
|
{
|
||||||
Serial.printf("nvs_get_i32() for %s returned: %s\r\n", key, esp_err_to_name(err));
|
Serial.printf("nvs_get_i32() for %s returned: %s\r\n", key, esp_err_to_name(err));
|
||||||
@ -215,4 +241,12 @@ bool SettingsPersister::save(Settings &settings)
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
tl::optional<uint8_t> SettingsPersister::currentlyOpenProfileIndex() const
|
||||||
|
{
|
||||||
|
if (m_profile)
|
||||||
|
return m_profile->profileIndex;
|
||||||
|
|
||||||
|
return tl::nullopt;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,6 +36,7 @@ constexpr char TEXT_TURNOFFDISCHARGE[] = "Turn off discharge";
|
|||||||
//DebugMenu
|
//DebugMenu
|
||||||
constexpr char TEXT_LOADSETTINGS[] = "Load settings";
|
constexpr char TEXT_LOADSETTINGS[] = "Load settings";
|
||||||
constexpr char TEXT_SAVESETTINGS[] = "Save settings";
|
constexpr char TEXT_SAVESETTINGS[] = "Save settings";
|
||||||
|
constexpr char TEXT_ERASENVS[] = "Erase NVS";
|
||||||
constexpr char TEXT_FRONTCOMMAND[] = "Front command";
|
constexpr char TEXT_FRONTCOMMAND[] = "Front command";
|
||||||
constexpr char TEXT_BACKCOMMAND[] = "Back command";
|
constexpr char TEXT_BACKCOMMAND[] = "Back command";
|
||||||
constexpr char TEXT_FRONTLEFTCOMMAND[] = "Front left command";
|
constexpr char TEXT_FRONTLEFTCOMMAND[] = "Front left command";
|
||||||
|
@ -8,7 +8,7 @@ namespace {
|
|||||||
class Label
|
class Label
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Label(int x, int y, uint32_t backgroundColor = TFT_BLACK);
|
Label(int x, int y);
|
||||||
|
|
||||||
int x() const { return m_x; };
|
int x() const { return m_x; };
|
||||||
int y() const { return m_y; };
|
int y() const { return m_y; };
|
||||||
@ -20,7 +20,6 @@ public:
|
|||||||
private:
|
private:
|
||||||
const int m_x;
|
const int m_x;
|
||||||
const int m_y;
|
const int m_y;
|
||||||
const uint32_t m_backgroundColor;
|
|
||||||
|
|
||||||
String m_lastStr;
|
String m_lastStr;
|
||||||
int m_lastFont;
|
int m_lastFont;
|
||||||
@ -30,10 +29,9 @@ private:
|
|||||||
int m_lastHeight;
|
int m_lastHeight;
|
||||||
};
|
};
|
||||||
|
|
||||||
Label::Label(int x, int y, uint32_t backgroundColor) :
|
Label::Label(int x, int y) :
|
||||||
m_x{x},
|
m_x{x},
|
||||||
m_y{y},
|
m_y{y}
|
||||||
m_backgroundColor{backgroundColor}
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -79,7 +77,7 @@ void Label::redraw(const String &str, bool forceRedraw)
|
|||||||
void Label::clear()
|
void Label::clear()
|
||||||
{
|
{
|
||||||
if (m_lastWidth || m_lastHeight)
|
if (m_lastWidth || m_lastHeight)
|
||||||
tft.fillRect(m_x, m_y, m_lastWidth, m_lastHeight, m_backgroundColor);
|
tft.fillRect(m_x, m_y, m_lastWidth, m_lastHeight, tft.textbgcolor);
|
||||||
|
|
||||||
start();
|
start();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user