simplified mode

This commit is contained in:
Peter Poetzi
2021-10-09 15:57:43 +02:00
parent 2e21cc5889
commit 0b758da0f0
12 changed files with 103 additions and 53 deletions

1
.gitignore vendored
View File

@ -7,5 +7,6 @@ desktop.ini
/config.cmake
/sdkconfig
/sdkconfig.old*
/ignore
/.idea
/.ccache

View File

@ -115,3 +115,8 @@ set(BOBBYCAR_BUILDFLAGS
-DLEDSTRIP_ANIMATION_DEFAULT=1
-DLEDS_PER_METER=60
)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake")
message(WARNING "Including lockscreen_plugin")
endif()

View File

@ -95,3 +95,8 @@ set(BOBBYCAR_BUILDFLAGS
-DLEDSTRIP_ANIMATION_DEFAULT=2
-DLEDS_PER_METER=144
)
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake")
include("${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake")
message(WARNING "Including lockscreen_plugin")
endif()

View File

@ -17,7 +17,13 @@
#include "globals.h"
#include "buttons.h"
#ifdef CAN_PLUGIN
#pragma message "Activating Can Plugin"
#include CAN_PLUGIN
#endif
namespace can {
namespace {
std::optional<int16_t> can_gas, can_brems;
espchrono::millis_clock::time_point last_can_gas{}, last_can_brems{};
@ -366,28 +372,40 @@ void sendCanCommands()
if (back) send(MotorController<true, true>::Command::CtrlMod, back->command.right.ctrlMod);
break;
case 3:
if (front) send(MotorController<false, false>::Command::IMotMax, front->command.left.iMotMax);
if (front) send(MotorController<false, true>::Command::IMotMax, front->command.right.iMotMax);
if (back) send(MotorController<true, false>::Command::IMotMax, back->command.left.iMotMax);
if (back) send(MotorController<true, true>::Command::IMotMax, back->command.right.iMotMax);
#if defined(HAS_SIMPLIFIED)
SIMPLIFIED_IMOTMAX
#endif
if (front) send(MotorController<false, false>::Command::IMotMax, front->command.left.iMotMax);
if (front) send(MotorController<false, true>::Command::IMotMax, front->command.right.iMotMax);
if (back) send(MotorController<true, false>::Command::IMotMax, back->command.left.iMotMax);
if (back) send(MotorController<true, true>::Command::IMotMax, back->command.right.iMotMax);
break;
case 4:
if (front) send(MotorController<false, false>::Command::IDcMax, front->command.left.iDcMax);
if (front) send(MotorController<false, true>::Command::IDcMax, front->command.right.iDcMax);
if (back) send(MotorController<true, false>::Command::IDcMax, back->command.left.iDcMax);
if (back) send(MotorController<true, true>::Command::IDcMax, back->command.right.iDcMax);
#if defined(HAS_SIMPLIFIED)
SIMPLIFIED_IDCMAX
#endif
if (front) send(MotorController<false, false>::Command::IDcMax, front->command.left.iDcMax);
if (front) send(MotorController<false, true>::Command::IDcMax, front->command.right.iDcMax);
if (back) send(MotorController<true, false>::Command::IDcMax, back->command.left.iDcMax);
if (back) send(MotorController<true, true>::Command::IDcMax, back->command.right.iDcMax);
break;
case 5:
if (front) send(MotorController<false, false>::Command::NMotMax, front->command.left.nMotMax);
if (front) send(MotorController<false, true>::Command::NMotMax, front->command.right.nMotMax);
if (back) send(MotorController<true, false>::Command::NMotMax, back->command.left.nMotMax);
if (back) send(MotorController<true, true>::Command::NMotMax, back->command.right.nMotMax);
#if defined(HAS_SIMPLIFIED)
SIMPLIFIED_NMOTMAX
#endif
if (front) send(MotorController<false, false>::Command::NMotMax, front->command.left.nMotMax);
if (front) send(MotorController<false, true>::Command::NMotMax, front->command.right.nMotMax);
if (back) send(MotorController<true, false>::Command::NMotMax, back->command.left.nMotMax);
if (back) send(MotorController<true, true>::Command::NMotMax, back->command.right.nMotMax);
break;
case 6:
if (front) send(MotorController<false, false>::Command::FieldWeakMax, front->command.left.fieldWeakMax);
if (front) send(MotorController<false, true>::Command::FieldWeakMax, front->command.right.fieldWeakMax);
if (back) send(MotorController<true, false>::Command::FieldWeakMax, back->command.left.fieldWeakMax);
if (back) send(MotorController<true, true>::Command::FieldWeakMax, back->command.right.fieldWeakMax);
#if defined(HAS_SIMPLIFIED)
SIMPLIFIED_FIELDWEAKMAX
#endif
if (front) send(MotorController<false, false>::Command::FieldWeakMax, front->command.left.fieldWeakMax);
if (front) send(MotorController<false, true>::Command::FieldWeakMax, front->command.right.fieldWeakMax);
if (back) send(MotorController<true, false>::Command::FieldWeakMax, back->command.left.fieldWeakMax);
if (back) send(MotorController<true, true>::Command::FieldWeakMax, back->command.right.fieldWeakMax);
break;
case 7:
if (front) send(MotorController<false, false>::Command::PhaseAdvMax, front->command.left.phaseAdvMax);

View File

@ -12,6 +12,10 @@
#include "modes/ignoreinputmode.h"
#include "buttons.h"
#ifdef LOCKSCREEN_PLUGIN
#include "ledstrip.h"
#endif
namespace {
class MainMenu;
}
@ -118,6 +122,10 @@ void Lockscreen::redraw()
if (m_numbers == settings.lockscreen.pin)
{
switchScreen<MainMenu>();
#ifdef LOCKSCREEN_PLUGIN
#pragma message "Activating Lockscreen Plugin"
#include LOCKSCREEN_PLUGIN
#endif
return;
}

View File

@ -76,18 +76,18 @@ class LedstripMenu :
public:
LedstripMenu()
{
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>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BIGOFFSET, BigOffsetAccessor>, SwitchScreenAction<BigOffsetChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSTRIP_MILLIAMP, DeziampereAccessor>, SwitchScreenAction<DeziampereChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
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>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>();
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, TextWithValueHelper<TEXT_LEDSTRIP_MILLIAMP, DeziampereAccessor>, SwitchScreenAction<DeziampereChangeScreen>>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
};
#endif

View File

@ -57,36 +57,36 @@ class MainMenu :
public:
MainMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STATUS>, SwitchScreenAction<StatusDisplay>, StaticMenuItemIcon<&espgui::icons::back>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTMODE>, SwitchScreenAction<SelectModeMenu>, StaticMenuItemIcon<&icons::modes>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_STATUS>, SwitchScreenAction<StatusDisplay>, StaticMenuItemIcon<&espgui::icons::back>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTMODE>, SwitchScreenAction<SelectModeMenu>, StaticMenuItemIcon<&icons::modes>>>();
#ifdef FEATURE_LEDSTRIP
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&icons::neopixel>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDSTRIP>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&icons::neopixel>>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESETTINGS>, ModeSettingsAction>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PRESETS>, SwitchScreenAction<PresetsMenu>, StaticMenuItemIcon<&icons::presets>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILES>, SwitchScreenAction<ProfilesMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GRAPHS>, SwitchScreenAction<GraphsMenu>, StaticMenuItemIcon<&icons::graph>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESETTINGS>, ModeSettingsAction>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PRESETS>, SwitchScreenAction<PresetsMenu>, StaticMenuItemIcon<&icons::presets>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILES>, SwitchScreenAction<ProfilesMenu>>>(); }
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GRAPHS>, SwitchScreenAction<GraphsMenu>, StaticMenuItemIcon<&icons::graph>>>(); }
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY)
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POWERSUPPLY>, SwitchScreenAction<PowerSupplyDisplay>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POWERSUPPLY>, SwitchScreenAction<PowerSupplyDisplay>>>(); }
#endif
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BMS>, SwitchScreenAction<BmsMenu>, StaticMenuItemIcon<&icons::bms>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BMS>, SwitchScreenAction<BmsMenu>, StaticMenuItemIcon<&icons::bms>>>(); }
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETTINGS>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&icons::settings>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKVEHICLE>, SwitchScreenAction<Lockscreen>, StaticMenuItemIcon<&icons::lock>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETTINGS>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&icons::settings>>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKVEHICLE>, SwitchScreenAction<Lockscreen>, StaticMenuItemIcon<&icons::lock>>>();
#ifdef FEATURE_MOSFETS
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFETS>, SwitchScreenAction<MosfetsMenu>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFETS>, SwitchScreenAction<MosfetsMenu>>>(); }
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEMOS>, SwitchScreenAction<DemosMenu>, StaticMenuItemIcon<&icons::demos>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEMOS>, SwitchScreenAction<DemosMenu>, StaticMenuItemIcon<&icons::demos>>>();
#ifdef FEATURE_GARAGE
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GARAGE>, SwitchScreenAction<GarageDisplay>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GARAGE>, SwitchScreenAction<GarageDisplay>>>(); }
#endif
#ifdef FEATURE_OTA
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_UPDATE>, SwitchScreenAction<UpdateDisplay>, StaticMenuItemIcon<&icons::update>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_UPDATE>, SwitchScreenAction<UpdateDisplay>, StaticMenuItemIcon<&icons::update>>>(); }
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POWEROFF>, SwitchScreenAction<PoweroffDisplay>, StaticMenuItemIcon<&icons::poweroff>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REBOOT>, RebootAction, StaticMenuItemIcon<&icons::reboot>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEBUG>, SwitchScreenAction<DebugMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POWEROFF>, SwitchScreenAction<PoweroffDisplay>, StaticMenuItemIcon<&icons::poweroff>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REBOOT>, RebootAction, StaticMenuItemIcon<&icons::reboot>>>();
if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEBUG>, SwitchScreenAction<DebugMenu>>>(); }
}
};
} // namespace

View File

@ -47,14 +47,14 @@ class SelectModeMenu :
public:
SelectModeMenu()
{
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEFAULT>, MultiAction<SetDefaultModeAction, SwitchScreenAction<MainMenu>>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_TEMPOMAT, AvgSpeedAccessor>, MultiAction<SetTempomatModeAction, SwitchScreenAction<MainMenu>>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LARSM>, MultiAction<SetLarsmModeAction, SwitchScreenAction<MainMenu>>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REMOTECONTROL>, MultiAction<SetRemoteControlModeAction, SwitchScreenAction<MainMenu>>>>();
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>>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAMETRAK>, MultiAction<SetGametrakModeAction, SwitchScreenAction<MainMenu>>>>();
#endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
}
void start() override;

View File

@ -41,6 +41,12 @@ float avgSpeed, avgSpeedKmh, sumCurrent;
char deviceName[32] = STRING(DEVICE_PREFIX) "_ERR";
#if defined(SIMPLIFIED_TRIGGER_TRIGGERONPRESET)
bool simplified = true;
#else
bool simplified = false;
#endif
Settings settings;
StringSettings stringSettings;
SettingsPersister settingsPersister;

View File

@ -29,7 +29,6 @@ struct Settings
#ifdef FEATURE_BMS
bool autoConnectBms;
#endif
struct Buzzer {
bool reverseBeep;
uint8_t reverseBeepFreq0;

View File

@ -13,6 +13,13 @@ void switchProfile(uint8_t index)
settings = presets::defaultSettings;
stringSettings = presets::makeDefaultStringSettings();
#ifdef SIMPLIFIED_TRIGGER_TRIGGERONPRESET
if (index == SIMPLIFIED_TRIGGER_TRIGGERONPRESET)
{
simplified = true;
}
#endif
if (!settingsPersister.openProfile(index))
{
ESP_LOGE("BOBBY", "openProfile() failed");

View File

@ -238,6 +238,7 @@ bool loadSettings()
bool saveSettings()
{
if (simplified) return true;
bool result{true};
if (!settingsPersister.save(settings))
result = false;