Made bluetooth related features optional to save some storage
This commit is contained in:
@@ -20,7 +20,6 @@ platform_packages =
|
|||||||
lib_deps =
|
lib_deps =
|
||||||
TFT_eSPI
|
TFT_eSPI
|
||||||
https://github.com/Ferdi265/cxx-ring-buffer
|
https://github.com/Ferdi265/cxx-ring-buffer
|
||||||
https://github.com/0xFEEDC0DE64/optional
|
|
||||||
|
|
||||||
lib_compat_mode = strict
|
lib_compat_mode = strict
|
||||||
build_unflags =
|
build_unflags =
|
||||||
@@ -152,7 +151,8 @@ build_flags =
|
|||||||
-DDEFAULT_GASMAX=3700
|
-DDEFAULT_GASMAX=3700
|
||||||
-DDEFAULT_BREMSMIN=1300
|
-DDEFAULT_BREMSMIN=1300
|
||||||
-DDEFAULT_BREMSMAX=4000
|
-DDEFAULT_BREMSMAX=4000
|
||||||
-DFEATURE_BMS
|
; -DFEATURE_BLUETOOTH
|
||||||
|
; -DFEATURE_BMS
|
||||||
; -DFEATURE_GAMETRAK
|
; -DFEATURE_GAMETRAK
|
||||||
; -DPINS_GAMETRAKX=34
|
; -DPINS_GAMETRAKX=34
|
||||||
; -DPINS_GAMETRAKY=39
|
; -DPINS_GAMETRAKY=39
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
class BluetoothBeginAction : public virtual ActionInterface
|
class BluetoothBeginAction : public virtual ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -18,4 +19,5 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
class BluetoothBeginMasterAction : public virtual ActionInterface
|
class BluetoothBeginMasterAction : public virtual ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -18,4 +19,5 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -6,7 +6,7 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
#ifdef FEATURE_BMS
|
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
|
||||||
class BluetoothConnectBmsAction : public virtual ActionInterface
|
class BluetoothConnectBmsAction : public virtual ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -6,6 +6,7 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
class BluetoothDisconnectAction : public virtual ActionInterface
|
class BluetoothDisconnectAction : public virtual ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -18,4 +19,5 @@ public:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
class BluetoothEndAction : public virtual ActionInterface
|
class BluetoothEndAction : public virtual ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -12,4 +13,5 @@ public:
|
|||||||
bluetoothSerial.end();
|
bluetoothSerial.end();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
#include "globals.h"
|
#include "globals.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
class BluetoothFlushAction : public virtual ActionInterface
|
class BluetoothFlushAction : public virtual ActionInterface
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -12,4 +13,5 @@ public:
|
|||||||
bluetoothSerial.flush();
|
bluetoothSerial.flush();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -3,10 +3,12 @@
|
|||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
enum class BluetoothMode : uint8_t
|
enum class BluetoothMode : uint8_t
|
||||||
{
|
{
|
||||||
Off,
|
Off,
|
||||||
Master,
|
Master,
|
||||||
Slave
|
Slave
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -5,6 +5,7 @@
|
|||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
template<const char *Ttext, typename TreturnType, TreturnType (BluetoothSerial::*Tmethod)()>
|
template<const char *Ttext, typename TreturnType, TreturnType (BluetoothSerial::*Tmethod)()>
|
||||||
using BluetoothStatusTextHelper = StatusTextHelper<Ttext, BluetoothSerial, &bluetoothSerial, TreturnType, Tmethod>;
|
using BluetoothStatusTextHelper = StatusTextHelper<Ttext, BluetoothSerial, &bluetoothSerial, TreturnType, Tmethod>;
|
||||||
|
|
||||||
@@ -34,4 +35,5 @@ class BluetoothIsReadyMasterText : public virtual TextInterface {
|
|||||||
public:
|
public:
|
||||||
String text() const override { return String{"isReady (M): "} + toString(bluetoothSerial.isReady(true)); }
|
String text() const override { return String{"isReady (M): "} + toString(bluetoothSerial.isReady(true)); }
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,7 @@
|
|||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
#ifdef FEATURE_BMS
|
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
|
||||||
namespace bms {
|
namespace bms {
|
||||||
constexpr auto autoReconnect = false; // causes hangs when not available
|
constexpr auto autoReconnect = false; // causes hangs when not available
|
||||||
|
|
||||||
|
@@ -136,7 +136,9 @@ void ChangeValueDisplay<Tvalue>::confirm()
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "changevaluedisplay_bool.h"
|
#include "changevaluedisplay_bool.h"
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
#include "changevaluedisplay_bluetoothmode.h"
|
#include "changevaluedisplay_bluetoothmode.h"
|
||||||
|
#endif
|
||||||
#include "changevaluedisplay_controlmode.h"
|
#include "changevaluedisplay_controlmode.h"
|
||||||
#include "changevaluedisplay_controltype.h"
|
#include "changevaluedisplay_controltype.h"
|
||||||
#include "changevaluedisplay_larsmmode_mode.h"
|
#include "changevaluedisplay_larsmmode_mode.h"
|
||||||
|
@@ -8,9 +8,12 @@
|
|||||||
#include "actions/backproxyaction.h"
|
#include "actions/backproxyaction.h"
|
||||||
#include "icons/back.h"
|
#include "icons/back.h"
|
||||||
#include "texts.h"
|
#include "texts.h"
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
#include "bluetoothmode.h"
|
#include "bluetoothmode.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
template<>
|
template<>
|
||||||
class ChangeValueDisplay<BluetoothMode> :
|
class ChangeValueDisplay<BluetoothMode> :
|
||||||
public MenuDisplay,
|
public MenuDisplay,
|
||||||
@@ -83,4 +86,5 @@ void ChangeValueDisplay<BluetoothMode>::start()
|
|||||||
setSelectedIndex(4);
|
setSelectedIndex(4);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -14,7 +14,7 @@ class MetersDisplay;
|
|||||||
class StatusDisplay;
|
class StatusDisplay;
|
||||||
}
|
}
|
||||||
namespace {
|
namespace {
|
||||||
#ifdef FEATURE_BMS
|
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
|
||||||
class BmsDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<MainMenu>>, public DummyBack
|
class BmsDisplay : public Display, public ConfirmActionInterface<SwitchScreenAction<MainMenu>>, public DummyBack
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -5,11 +5,13 @@
|
|||||||
#include "staticmenudefinition.h"
|
#include "staticmenudefinition.h"
|
||||||
#include "menuitem.h"
|
#include "menuitem.h"
|
||||||
#include "actions/dummyaction.h"
|
#include "actions/dummyaction.h"
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
#include "actions/bluetoothbeginaction.h"
|
#include "actions/bluetoothbeginaction.h"
|
||||||
#include "actions/bluetoothbeginmasteraction.h"
|
#include "actions/bluetoothbeginmasteraction.h"
|
||||||
#include "actions/bluetoothflushaction.h"
|
#include "actions/bluetoothflushaction.h"
|
||||||
#include "actions/bluetoothendaction.h"
|
#include "actions/bluetoothendaction.h"
|
||||||
#include "actions/bluetoothdisconnectaction.h"
|
#include "actions/bluetoothdisconnectaction.h"
|
||||||
|
#endif
|
||||||
#include "actions/switchscreenaction.h"
|
#include "actions/switchscreenaction.h"
|
||||||
#include "bluetoothtexthelpers.h"
|
#include "bluetoothtexthelpers.h"
|
||||||
#include "settingsaccessors.h"
|
#include "settingsaccessors.h"
|
||||||
@@ -21,6 +23,7 @@ class SettingsMenu;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
class BluetoothSettingsMenu;
|
class BluetoothSettingsMenu;
|
||||||
|
|
||||||
using AutoBluetoothModeChangeDisplay = makeComponent<
|
using AutoBluetoothModeChangeDisplay = makeComponent<
|
||||||
@@ -50,4 +53,5 @@ class BluetoothSettingsMenu :
|
|||||||
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&icons::back>>
|
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&icons::back>>
|
||||||
>
|
>
|
||||||
{};
|
{};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
@@ -4,8 +4,10 @@
|
|||||||
#include "staticmenudefinition.h"
|
#include "staticmenudefinition.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
#include "menuitem.h"
|
#include "menuitem.h"
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
#include "actions/bluetoothconnectbmsaction.h"
|
#include "actions/bluetoothconnectbmsaction.h"
|
||||||
#include "actions/bluetoothdisconnectaction.h"
|
#include "actions/bluetoothdisconnectaction.h"
|
||||||
|
#endif
|
||||||
#include "actions/dummyaction.h"
|
#include "actions/dummyaction.h"
|
||||||
#include "actions/bmsturnonchargeaction.h"
|
#include "actions/bmsturnonchargeaction.h"
|
||||||
#include "actions/bmsturnoffchargeaction.h"
|
#include "actions/bmsturnoffchargeaction.h"
|
||||||
@@ -21,7 +23,7 @@ class MainMenu;
|
|||||||
}
|
}
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
#ifdef FEATURE_BMS
|
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
|
||||||
class BmsMenu :
|
class BmsMenu :
|
||||||
public MenuDisplay,
|
public MenuDisplay,
|
||||||
public StaticText<TEXT_BMS>,
|
public StaticText<TEXT_BMS>,
|
||||||
|
@@ -9,7 +9,9 @@
|
|||||||
#include "actions/switchscreenaction.h"
|
#include "actions/switchscreenaction.h"
|
||||||
#include "checkboxicon.h"
|
#include "checkboxicon.h"
|
||||||
#include "icons/wifi.h"
|
#include "icons/wifi.h"
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
#include "icons/bluetooth.h"
|
#include "icons/bluetooth.h"
|
||||||
|
#endif
|
||||||
#include "icons/hardware.h"
|
#include "icons/hardware.h"
|
||||||
#include "icons/buzzer.h"
|
#include "icons/buzzer.h"
|
||||||
#include "icons/info.h"
|
#include "icons/info.h"
|
||||||
@@ -40,11 +42,13 @@ class SettingsMenu :
|
|||||||
public StaticMenuDefinition<
|
public StaticMenuDefinition<
|
||||||
makeComponent<MenuItem, StaticText<TEXT_LIMITSSETTINGS>, SwitchScreenAction<LimitsSettingsMenu>>,
|
makeComponent<MenuItem, StaticText<TEXT_LIMITSSETTINGS>, SwitchScreenAction<LimitsSettingsMenu>>,
|
||||||
makeComponent<MenuItem, StaticText<TEXT_WIFISETTINGS>, SwitchScreenAction<WifiSettingsMenu>, StaticMenuItemIcon<&icons::wifi>>,
|
makeComponent<MenuItem, StaticText<TEXT_WIFISETTINGS>, SwitchScreenAction<WifiSettingsMenu>, StaticMenuItemIcon<&icons::wifi>>,
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHSETTINGS>, SwitchScreenAction<BluetoothSettingsMenu>, StaticMenuItemIcon<&icons::bluetooth>>,
|
makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHSETTINGS>, SwitchScreenAction<BluetoothSettingsMenu>, StaticMenuItemIcon<&icons::bluetooth>>,
|
||||||
|
#endif
|
||||||
makeComponent<MenuItem, StaticText<TEXT_MODESSETTINGS>, SwitchScreenAction<ModesSettingsMenu>>,
|
makeComponent<MenuItem, StaticText<TEXT_MODESSETTINGS>, SwitchScreenAction<ModesSettingsMenu>>,
|
||||||
makeComponent<MenuItem, StaticText<TEXT_CONTROLLERHARDWARESETTINGS>, SwitchScreenAction<ControllerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
|
makeComponent<MenuItem, StaticText<TEXT_CONTROLLERHARDWARESETTINGS>, SwitchScreenAction<ControllerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
|
||||||
makeComponent<MenuItem, StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
|
makeComponent<MenuItem, StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
|
||||||
#ifdef FEATURE_BMS
|
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
|
||||||
makeComponent<MenuItem, StaticText<TEXT_AUTOCONNECTBMS>, ToggleBoolAction, CheckboxIcon, AutoConnectBmsAccessor>,
|
makeComponent<MenuItem, StaticText<TEXT_AUTOCONNECTBMS>, ToggleBoolAction, CheckboxIcon, AutoConnectBmsAccessor>,
|
||||||
#endif
|
#endif
|
||||||
makeComponent<MenuItem, StaticText<TEXT_BUZZER>, SwitchScreenAction<BuzzerMenu>, StaticMenuItemIcon<&icons::buzzer>>,
|
makeComponent<MenuItem, StaticText<TEXT_BUZZER>, SwitchScreenAction<BuzzerMenu>, StaticMenuItemIcon<&icons::buzzer>>,
|
||||||
|
@@ -2,7 +2,9 @@
|
|||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
#include <BluetoothSerial.h>
|
#include <BluetoothSerial.h>
|
||||||
|
#endif
|
||||||
#include <WiFiType.h>
|
#include <WiFiType.h>
|
||||||
#include <TFT_eSPI.h>
|
#include <TFT_eSPI.h>
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
@@ -57,7 +59,9 @@ struct {
|
|||||||
int last{0};
|
int last{0};
|
||||||
} performance;
|
} performance;
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
BluetoothSerial bluetoothSerial;
|
BluetoothSerial bluetoothSerial;
|
||||||
|
#endif
|
||||||
|
|
||||||
TFT_eSPI tft = TFT_eSPI();
|
TFT_eSPI tft = TFT_eSPI();
|
||||||
|
|
||||||
|
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
namespace icons {
|
namespace icons {
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
const Icon<24, 24> bluetooth{{
|
const Icon<24, 24> bluetooth{{
|
||||||
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x120F, 0x1A50, 0x0000, 0x01CF, 0x2AB1, 0x3B12, 0x4333, 0x4333, 0x3AF2, 0x2AB1, 0x01EF, // 0x0010 (16) pixels
|
0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x120F, 0x1A50, 0x0000, 0x01CF, 0x2AB1, 0x3B12, 0x4333, 0x4333, 0x3AF2, 0x2AB1, 0x01EF, // 0x0010 (16) pixels
|
||||||
0x0000, 0x1A50, 0x1210, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1210, 0x018E, 0x0007, 0x2AB1, // 0x0020 (32) pixels
|
0x0000, 0x1A50, 0x1210, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x1210, 0x018E, 0x0007, 0x2AB1, // 0x0020 (32) pixels
|
||||||
@@ -42,5 +43,6 @@ const Icon<24, 24> bluetooth{{
|
|||||||
0x19ED, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0230 (560) pixels
|
0x19ED, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0230 (560) pixels
|
||||||
0x00A6, 0x21EC, 0x2A6F, 0x32B1, 0x32B1, 0x2A6F, 0x19EC, 0x00A6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0240 (576) pixels
|
0x00A6, 0x21EC, 0x2A6F, 0x32B1, 0x32B1, 0x2A6F, 0x19EC, 0x00A6, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, // 0x0240 (576) pixels
|
||||||
}};
|
}};
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -23,9 +23,11 @@
|
|||||||
#include "presets.h"
|
#include "presets.h"
|
||||||
#include "statistics.h"
|
#include "statistics.h"
|
||||||
#include "actions/wifisoftapaction.h"
|
#include "actions/wifisoftapaction.h"
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
#include "actions/bluetoothbeginaction.h"
|
#include "actions/bluetoothbeginaction.h"
|
||||||
#include "actions/bluetoothbeginmasteraction.h"
|
#include "actions/bluetoothbeginmasteraction.h"
|
||||||
#include "actions/bluetoothconnectbmsaction.h"
|
#include "actions/bluetoothconnectbmsaction.h"
|
||||||
|
#endif
|
||||||
#include "bobby_webserver.h"
|
#include "bobby_webserver.h"
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
@@ -123,6 +125,7 @@ void setup()
|
|||||||
if (!WiFi.begin("realraum", "r3alraum"))
|
if (!WiFi.begin("realraum", "r3alraum"))
|
||||||
Serial.println("Could not begin WiFi");
|
Serial.println("Could not begin WiFi");
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Master)
|
if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Master)
|
||||||
{
|
{
|
||||||
bootLabel.redraw("bluetooth begin master");
|
bootLabel.redraw("bluetooth begin master");
|
||||||
@@ -140,6 +143,7 @@ void setup()
|
|||||||
bootLabel.redraw("bluetooth begin");
|
bootLabel.redraw("bluetooth begin");
|
||||||
BluetoothBeginAction{}.triggered();
|
BluetoothBeginAction{}.triggered();
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bootLabel.redraw("front Serial begin");
|
bootLabel.redraw("front Serial begin");
|
||||||
controllers.front.serial.get().begin(38400, SERIAL_8N1, PINS_RX1, PINS_TX1);
|
controllers.front.serial.get().begin(38400, SERIAL_8N1, PINS_RX1, PINS_TX1);
|
||||||
|
@@ -56,9 +56,11 @@ constexpr Settings::WifiSettings defaultWifiSettings {
|
|||||||
.autoEnableAp = true
|
.autoEnableAp = true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
constexpr Settings::BluetoothSettings defaultBluetoothSettings {
|
constexpr Settings::BluetoothSettings defaultBluetoothSettings {
|
||||||
.autoBluetoothMode = BluetoothMode::Master
|
.autoBluetoothMode = BluetoothMode::Master
|
||||||
};
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
constexpr Settings::ControllerHardware spinnerControllerHardware {
|
constexpr Settings::ControllerHardware spinnerControllerHardware {
|
||||||
.enableFrontLeft = true,
|
.enableFrontLeft = true,
|
||||||
@@ -156,7 +158,9 @@ constexpr Settings defaultSettings{
|
|||||||
.reverseBeepDuration1 = 500,
|
.reverseBeepDuration1 = 500,
|
||||||
.limits = defaultLimits,
|
.limits = defaultLimits,
|
||||||
.wifiSettings = defaultWifiSettings,
|
.wifiSettings = defaultWifiSettings,
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
.bluetoothSettings = defaultBluetoothSettings,
|
.bluetoothSettings = defaultBluetoothSettings,
|
||||||
|
#endif
|
||||||
.controllerHardware = defaultControllerHardware,
|
.controllerHardware = defaultControllerHardware,
|
||||||
.boardcomputerHardware = defaultBoardcomputerHardware,
|
.boardcomputerHardware = defaultBoardcomputerHardware,
|
||||||
.defaultMode = defaultDefaultMode,
|
.defaultMode = defaultDefaultMode,
|
||||||
|
@@ -1,10 +1,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <include/tl/optional.hpp>
|
#include <optional>
|
||||||
|
|
||||||
#include "displays/menus/aboutmenu.h"
|
#include "displays/menus/aboutmenu.h"
|
||||||
#include "displays/menus/accesspointwifisettingsmenu.h"
|
#include "displays/menus/accesspointwifisettingsmenu.h"
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
#include "displays/menus/bluetoothsettingsmenu.h"
|
#include "displays/menus/bluetoothsettingsmenu.h"
|
||||||
|
#endif
|
||||||
#include "displays/menus/bmsmenu.h"
|
#include "displays/menus/bmsmenu.h"
|
||||||
#include "displays/menus/buzzermenu.h"
|
#include "displays/menus/buzzermenu.h"
|
||||||
#include "displays/menus/commanddebugmenu.h"
|
#include "displays/menus/commanddebugmenu.h"
|
||||||
@@ -64,9 +66,11 @@ union X {
|
|||||||
|
|
||||||
AboutMenu aboutMenu;
|
AboutMenu aboutMenu;
|
||||||
AccessPointWifiSettingsMenu accessPointWifiSettingsMenu;
|
AccessPointWifiSettingsMenu accessPointWifiSettingsMenu;
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
BluetoothSettingsMenu bluetoothSettingsMenu;
|
BluetoothSettingsMenu bluetoothSettingsMenu;
|
||||||
#ifdef FEATURE_BMS
|
#ifdef FEATURE_BMS
|
||||||
BmsMenu bmsMenu;
|
BmsMenu bmsMenu;
|
||||||
|
#endif
|
||||||
#endif
|
#endif
|
||||||
BuzzerMenu buzzerMenu;
|
BuzzerMenu buzzerMenu;
|
||||||
FrontCommandDebugMenu frontCommandDebugMenu;
|
FrontCommandDebugMenu frontCommandDebugMenu;
|
||||||
@@ -135,7 +139,9 @@ union X {
|
|||||||
|
|
||||||
AutoWifiModeChangeDisplay autoWifiModeChangeDisplay;
|
AutoWifiModeChangeDisplay autoWifiModeChangeDisplay;
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
AutoBluetoothModeChangeDisplay autoBluetoothModeChangeDisplay;
|
AutoBluetoothModeChangeDisplay autoBluetoothModeChangeDisplay;
|
||||||
|
#endif
|
||||||
|
|
||||||
FrontFreqChangeScreen changeFrontFreq;
|
FrontFreqChangeScreen changeFrontFreq;
|
||||||
FrontPatternChangeScreen changeFrontPattern;
|
FrontPatternChangeScreen changeFrontPattern;
|
||||||
@@ -222,10 +228,12 @@ union X {
|
|||||||
template<typename T> T &getRefByType() = delete;
|
template<typename T> T &getRefByType() = delete;
|
||||||
template<> decltype(displays.aboutMenu) &getRefByType<decltype(displays.aboutMenu)>() { return displays.aboutMenu; }
|
template<> decltype(displays.aboutMenu) &getRefByType<decltype(displays.aboutMenu)>() { return displays.aboutMenu; }
|
||||||
template<> decltype(displays.accessPointWifiSettingsMenu) &getRefByType<decltype(displays.accessPointWifiSettingsMenu)>() { return displays.accessPointWifiSettingsMenu; }
|
template<> decltype(displays.accessPointWifiSettingsMenu) &getRefByType<decltype(displays.accessPointWifiSettingsMenu)>() { return displays.accessPointWifiSettingsMenu; }
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
template<> decltype(displays.bluetoothSettingsMenu) &getRefByType<decltype(displays.bluetoothSettingsMenu)>() { return displays.bluetoothSettingsMenu; }
|
template<> decltype(displays.bluetoothSettingsMenu) &getRefByType<decltype(displays.bluetoothSettingsMenu)>() { return displays.bluetoothSettingsMenu; }
|
||||||
#ifdef FEATURE_BMS
|
#ifdef FEATURE_BMS
|
||||||
template<> decltype(displays.bmsMenu) &getRefByType<decltype(displays.bmsMenu)>() { return displays.bmsMenu; }
|
template<> decltype(displays.bmsMenu) &getRefByType<decltype(displays.bmsMenu)>() { return displays.bmsMenu; }
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
template<> decltype(displays.buzzerMenu) &getRefByType<decltype(displays.buzzerMenu)>() { return displays.buzzerMenu; }
|
template<> decltype(displays.buzzerMenu) &getRefByType<decltype(displays.buzzerMenu)>() { return displays.buzzerMenu; }
|
||||||
template<> decltype(displays.boardcomputerHardwareSettingsMenu) &getRefByType<decltype(displays.boardcomputerHardwareSettingsMenu)>() { return displays.boardcomputerHardwareSettingsMenu; }
|
template<> decltype(displays.boardcomputerHardwareSettingsMenu) &getRefByType<decltype(displays.boardcomputerHardwareSettingsMenu)>() { return displays.boardcomputerHardwareSettingsMenu; }
|
||||||
template<> decltype(displays.controllerHardwareSettingsMenu) &getRefByType<decltype(displays.controllerHardwareSettingsMenu)>() { return displays.controllerHardwareSettingsMenu; }
|
template<> decltype(displays.controllerHardwareSettingsMenu) &getRefByType<decltype(displays.controllerHardwareSettingsMenu)>() { return displays.controllerHardwareSettingsMenu; }
|
||||||
@@ -294,7 +302,9 @@ template<> decltype(displays.updateDisplay) &
|
|||||||
|
|
||||||
template<> decltype(displays.autoWifiModeChangeDisplay) &getRefByType<decltype(displays.autoWifiModeChangeDisplay)>() { return displays.autoWifiModeChangeDisplay; }
|
template<> decltype(displays.autoWifiModeChangeDisplay) &getRefByType<decltype(displays.autoWifiModeChangeDisplay)>() { return displays.autoWifiModeChangeDisplay; }
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
template<> decltype(displays.autoBluetoothModeChangeDisplay) &getRefByType<decltype(displays.autoBluetoothModeChangeDisplay)>() { return displays.autoBluetoothModeChangeDisplay; }
|
template<> decltype(displays.autoBluetoothModeChangeDisplay) &getRefByType<decltype(displays.autoBluetoothModeChangeDisplay)>() { return displays.autoBluetoothModeChangeDisplay; }
|
||||||
|
#endif
|
||||||
|
|
||||||
template<> decltype(displays.changeFrontFreq) &getRefByType<decltype(displays.changeFrontFreq)>() { return displays.changeFrontFreq; }
|
template<> decltype(displays.changeFrontFreq) &getRefByType<decltype(displays.changeFrontFreq)>() { return displays.changeFrontFreq; }
|
||||||
template<> decltype(displays.changeFrontPattern) &getRefByType<decltype(displays.changeFrontPattern)>() { return displays.changeFrontPattern; }
|
template<> decltype(displays.changeFrontPattern) &getRefByType<decltype(displays.changeFrontPattern)>() { return displays.changeFrontPattern; }
|
||||||
|
@@ -6,7 +6,9 @@
|
|||||||
|
|
||||||
#include "bobbycar-protocol/protocol.h"
|
#include "bobbycar-protocol/protocol.h"
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
#include "bluetoothmode.h"
|
#include "bluetoothmode.h"
|
||||||
|
#endif
|
||||||
#include "unifiedmodelmode.h"
|
#include "unifiedmodelmode.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -37,9 +39,11 @@ struct Settings
|
|||||||
bool autoEnableAp;
|
bool autoEnableAp;
|
||||||
} wifiSettings;
|
} wifiSettings;
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
struct BluetoothSettings {
|
struct BluetoothSettings {
|
||||||
BluetoothMode autoBluetoothMode;
|
BluetoothMode autoBluetoothMode;
|
||||||
} bluetoothSettings;
|
} bluetoothSettings;
|
||||||
|
#endif
|
||||||
|
|
||||||
struct ControllerHardware {
|
struct ControllerHardware {
|
||||||
bool enableFrontLeft, enableFrontRight, enableBackLeft, enableBackRight;
|
bool enableFrontLeft, enableFrontRight, enableBackLeft, enableBackRight;
|
||||||
@@ -119,7 +123,9 @@ void Settings::executeForEverySetting(T &&callable)
|
|||||||
callable("fieldWeakMax", limits.fieldWeakMax);
|
callable("fieldWeakMax", limits.fieldWeakMax);
|
||||||
callable("phaseAdvMax", limits.phaseAdvMax);
|
callable("phaseAdvMax", limits.phaseAdvMax);
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
callable("autoBluetoothMo", bluetoothSettings.autoBluetoothMode);
|
callable("autoBluetoothMo", bluetoothSettings.autoBluetoothMode);
|
||||||
|
#endif
|
||||||
|
|
||||||
callable("autoWifiMode", wifiSettings.autoWifiMode);
|
callable("autoWifiMode", wifiSettings.autoWifiMode);
|
||||||
callable("autoEnableAp", wifiSettings.autoEnableAp);
|
callable("autoEnableAp", wifiSettings.autoEnableAp);
|
||||||
|
@@ -35,7 +35,9 @@ struct PhaseAdvMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &
|
|||||||
struct AutoWifiModeAccessor : public RefAccessorSaveSettings<wifi_mode_t> { wifi_mode_t &getRef() const override { return settings.wifiSettings.autoWifiMode; } };
|
struct AutoWifiModeAccessor : public RefAccessorSaveSettings<wifi_mode_t> { wifi_mode_t &getRef() const override { return settings.wifiSettings.autoWifiMode; } };
|
||||||
struct AutoEnableApAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.wifiSettings.autoEnableAp; } };
|
struct AutoEnableApAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.wifiSettings.autoEnableAp; } };
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
struct AutoBluetoothModeAccessor : public RefAccessorSaveSettings<BluetoothMode> { BluetoothMode &getRef() const override { return settings.bluetoothSettings.autoBluetoothMode; } };
|
struct AutoBluetoothModeAccessor : public RefAccessorSaveSettings<BluetoothMode> { BluetoothMode &getRef() const override { return settings.bluetoothSettings.autoBluetoothMode; } };
|
||||||
|
#endif
|
||||||
|
|
||||||
struct FrontLeftEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.enableFrontLeft; } };
|
struct FrontLeftEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.enableFrontLeft; } };
|
||||||
struct FrontRightEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.enableFrontRight; } };
|
struct FrontRightEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.enableFrontRight; } };
|
||||||
|
@@ -6,10 +6,12 @@
|
|||||||
#include <nvs_flash.h>
|
#include <nvs_flash.h>
|
||||||
#include <nvs.h>
|
#include <nvs.h>
|
||||||
|
|
||||||
#include <include/tl/optional.hpp>
|
#include <optional>
|
||||||
|
|
||||||
#include "settings.h"
|
#include "settings.h"
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
#include "bluetoothmode.h"
|
#include "bluetoothmode.h"
|
||||||
|
#endif
|
||||||
#include "unifiedmodelmode.h"
|
#include "unifiedmodelmode.h"
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -23,14 +25,14 @@ public:
|
|||||||
bool load(Settings &settings);
|
bool load(Settings &settings);
|
||||||
bool save(Settings &settings);
|
bool save(Settings &settings);
|
||||||
|
|
||||||
tl::optional<uint8_t> currentlyOpenProfileIndex() const;
|
std::optional<uint8_t> currentlyOpenProfileIndex() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
struct CurrentlyOpenProfile {
|
struct CurrentlyOpenProfile {
|
||||||
nvs_handle handle;
|
nvs_handle handle;
|
||||||
uint8_t profileIndex;
|
uint8_t profileIndex;
|
||||||
};
|
};
|
||||||
tl::optional<CurrentlyOpenProfile> m_profile;
|
std::optional<CurrentlyOpenProfile> m_profile;
|
||||||
};
|
};
|
||||||
|
|
||||||
bool SettingsPersister::init()
|
bool SettingsPersister::init()
|
||||||
@@ -95,7 +97,7 @@ void SettingsPersister::closeProfile()
|
|||||||
|
|
||||||
nvs_close(m_profile->handle);
|
nvs_close(m_profile->handle);
|
||||||
|
|
||||||
m_profile = tl::nullopt;
|
m_profile = std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> struct nvsGetterHelper;
|
template<typename T> struct nvsGetterHelper;
|
||||||
@@ -137,6 +139,7 @@ template<> struct nvsGetterHelper<LarsmModeMode> { static esp_err_t nvs_get(nvs_
|
|||||||
*out_value = LarsmModeMode(tempValue);
|
*out_value = LarsmModeMode(tempValue);
|
||||||
return err;
|
return err;
|
||||||
}};
|
}};
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
template<> struct nvsGetterHelper<BluetoothMode> { static esp_err_t nvs_get(nvs_handle handle, const char* key, BluetoothMode* out_value)
|
template<> struct nvsGetterHelper<BluetoothMode> { static esp_err_t nvs_get(nvs_handle handle, const char* key, BluetoothMode* out_value)
|
||||||
{
|
{
|
||||||
uint8_t tempValue;
|
uint8_t tempValue;
|
||||||
@@ -145,6 +148,7 @@ template<> struct nvsGetterHelper<BluetoothMode> { static esp_err_t nvs_get(nvs_
|
|||||||
*out_value = BluetoothMode(tempValue);
|
*out_value = BluetoothMode(tempValue);
|
||||||
return err;
|
return err;
|
||||||
}};
|
}};
|
||||||
|
#endif
|
||||||
template<> struct nvsGetterHelper<UnifiedModelMode> { static esp_err_t nvs_get(nvs_handle handle, const char* key, UnifiedModelMode* out_value)
|
template<> struct nvsGetterHelper<UnifiedModelMode> { static esp_err_t nvs_get(nvs_handle handle, const char* key, UnifiedModelMode* out_value)
|
||||||
{
|
{
|
||||||
uint8_t tempValue;
|
uint8_t tempValue;
|
||||||
@@ -205,10 +209,12 @@ template<> struct nvsSetterHelper<LarsmModeMode> { static esp_err_t nvs_set(nvs_
|
|||||||
{
|
{
|
||||||
return nvs_set_u8(handle, key, uint8_t(value));
|
return nvs_set_u8(handle, key, uint8_t(value));
|
||||||
}};
|
}};
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
template<> struct nvsSetterHelper<BluetoothMode> { static esp_err_t nvs_set(nvs_handle handle, const char* key, BluetoothMode value)
|
template<> struct nvsSetterHelper<BluetoothMode> { static esp_err_t nvs_set(nvs_handle handle, const char* key, BluetoothMode value)
|
||||||
{
|
{
|
||||||
return nvs_set_u8(handle, key, uint8_t(value));
|
return nvs_set_u8(handle, key, uint8_t(value));
|
||||||
}};
|
}};
|
||||||
|
#endif
|
||||||
template<> struct nvsSetterHelper<UnifiedModelMode> { static esp_err_t nvs_set(nvs_handle handle, const char* key, UnifiedModelMode value)
|
template<> struct nvsSetterHelper<UnifiedModelMode> { static esp_err_t nvs_set(nvs_handle handle, const char* key, UnifiedModelMode value)
|
||||||
{
|
{
|
||||||
return nvs_set_u8(handle, key, uint8_t(value));
|
return nvs_set_u8(handle, key, uint8_t(value));
|
||||||
@@ -242,11 +248,11 @@ bool SettingsPersister::save(Settings &settings)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
tl::optional<uint8_t> SettingsPersister::currentlyOpenProfileIndex() const
|
std::optional<uint8_t> SettingsPersister::currentlyOpenProfileIndex() const
|
||||||
{
|
{
|
||||||
if (m_profile)
|
if (m_profile)
|
||||||
return m_profile->profileIndex;
|
return m_profile->profileIndex;
|
||||||
|
|
||||||
return tl::nullopt;
|
return std::nullopt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -13,6 +13,7 @@ constexpr char TEXT_WIFISOFTAPDISCONNECTWIFIOFF[] = "softAPdisconnect() wifioff"
|
|||||||
constexpr char TEXT_WIFISOFTAPENABLEIPV6[] = "softAPenableIpV6()";
|
constexpr char TEXT_WIFISOFTAPENABLEIPV6[] = "softAPenableIpV6()";
|
||||||
//constexpr char TEXT_BACK[] = "Back";
|
//constexpr char TEXT_BACK[] = "Back";
|
||||||
|
|
||||||
|
#ifdef FEATURE_BLUETOOTH
|
||||||
//BluetoothSettingsMenu
|
//BluetoothSettingsMenu
|
||||||
constexpr char TEXT_BLUETOOTHSETTINGS[] = "Bluetooth settings";
|
constexpr char TEXT_BLUETOOTHSETTINGS[] = "Bluetooth settings";
|
||||||
constexpr char TEXT_BLUETOOTHBEGIN[] = "begin()";
|
constexpr char TEXT_BLUETOOTHBEGIN[] = "begin()";
|
||||||
@@ -24,6 +25,7 @@ constexpr char TEXT_AUTOBLUETOOTHMODE[] = "Auto bluetooth mode";
|
|||||||
//constexpr char TEXT_BACK[] = "Back";
|
//constexpr char TEXT_BACK[] = "Back";
|
||||||
|
|
||||||
//BmsMenu
|
//BmsMenu
|
||||||
|
#ifdef FEATURE_BMS
|
||||||
constexpr char TEXT_BMS[] = "BMS";
|
constexpr char TEXT_BMS[] = "BMS";
|
||||||
constexpr char TEXT_CONNECTBMS[] = "Connect BMS";
|
constexpr char TEXT_CONNECTBMS[] = "Connect BMS";
|
||||||
constexpr char TEXT_DISCONNECTBMS[] = "Disonnect BMS";
|
constexpr char TEXT_DISCONNECTBMS[] = "Disonnect BMS";
|
||||||
@@ -32,6 +34,8 @@ constexpr char TEXT_TURNOFFCHARGE[] = "Turn off charge";
|
|||||||
constexpr char TEXT_TURNONDISCHARGE[] = "Turn on discharge";
|
constexpr char TEXT_TURNONDISCHARGE[] = "Turn on discharge";
|
||||||
constexpr char TEXT_TURNOFFDISCHARGE[] = "Turn off discharge";
|
constexpr char TEXT_TURNOFFDISCHARGE[] = "Turn off discharge";
|
||||||
//constexpr char TEXT_BACK[] = "Back";
|
//constexpr char TEXT_BACK[] = "Back";
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
//DebugMenu
|
//DebugMenu
|
||||||
constexpr char TEXT_LOADSETTINGS[] = "Load settings";
|
constexpr char TEXT_LOADSETTINGS[] = "Load settings";
|
||||||
|
Reference in New Issue
Block a user