Merge pull request #105 from bobbycar-graz/simplified

Added simplified mode
This commit is contained in:
Peter Pötzi
2021-10-09 23:50:06 +02:00
committed by GitHub
12 changed files with 103 additions and 53 deletions

1
.gitignore vendored
View File

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

View File

@ -115,3 +115,8 @@ set(BOBBYCAR_BUILDFLAGS
-DLEDSTRIP_ANIMATION_DEFAULT=1 -DLEDSTRIP_ANIMATION_DEFAULT=1
-DLEDS_PER_METER=60 -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 -DLEDSTRIP_ANIMATION_DEFAULT=2
-DLEDS_PER_METER=144 -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 "globals.h"
#include "buttons.h" #include "buttons.h"
#ifdef CAN_PLUGIN
#pragma message "Activating Can Plugin"
#include CAN_PLUGIN
#endif
namespace can { namespace can {
namespace { namespace {
std::optional<int16_t> can_gas, can_brems; std::optional<int16_t> can_gas, can_brems;
espchrono::millis_clock::time_point last_can_gas{}, last_can_brems{}; espchrono::millis_clock::time_point last_can_gas{}, last_can_brems{};
@ -366,24 +372,36 @@ void sendCanCommands()
if (back) send(MotorController<true, true>::Command::CtrlMod, back->command.right.ctrlMod); if (back) send(MotorController<true, true>::Command::CtrlMod, back->command.right.ctrlMod);
break; break;
case 3: case 3:
#if defined(HAS_SIMPLIFIED)
SIMPLIFIED_IMOTMAX
#endif
if (front) send(MotorController<false, false>::Command::IMotMax, front->command.left.iMotMax); 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 (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, false>::Command::IMotMax, back->command.left.iMotMax);
if (back) send(MotorController<true, true>::Command::IMotMax, back->command.right.iMotMax); if (back) send(MotorController<true, true>::Command::IMotMax, back->command.right.iMotMax);
break; break;
case 4: case 4:
#if defined(HAS_SIMPLIFIED)
SIMPLIFIED_IDCMAX
#endif
if (front) send(MotorController<false, false>::Command::IDcMax, front->command.left.iDcMax); 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 (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, false>::Command::IDcMax, back->command.left.iDcMax);
if (back) send(MotorController<true, true>::Command::IDcMax, back->command.right.iDcMax); if (back) send(MotorController<true, true>::Command::IDcMax, back->command.right.iDcMax);
break; break;
case 5: case 5:
#if defined(HAS_SIMPLIFIED)
SIMPLIFIED_NMOTMAX
#endif
if (front) send(MotorController<false, false>::Command::NMotMax, front->command.left.nMotMax); 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 (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, false>::Command::NMotMax, back->command.left.nMotMax);
if (back) send(MotorController<true, true>::Command::NMotMax, back->command.right.nMotMax); if (back) send(MotorController<true, true>::Command::NMotMax, back->command.right.nMotMax);
break; break;
case 6: case 6:
#if defined(HAS_SIMPLIFIED)
SIMPLIFIED_FIELDWEAKMAX
#endif
if (front) send(MotorController<false, false>::Command::FieldWeakMax, front->command.left.fieldWeakMax); 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 (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, false>::Command::FieldWeakMax, back->command.left.fieldWeakMax);

View File

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

View File

@ -82,11 +82,11 @@ public:
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FULLBLINK>, ToggleBoolAction, CheckboxIcon, EnableFullBlinkAccessor>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FULLBLINK>, ToggleBoolAction, CheckboxIcon, EnableFullBlinkAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLINKANIMATION>, SwitchScreenAction<LedstripSelectBlinkMenu>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>(); if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>(); }
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>(); if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>(); }
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>(); if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>(); }
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BIGOFFSET, BigOffsetAccessor>, SwitchScreenAction<BigOffsetChangeScreen>>>(); if (!simplified) { constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BIGOFFSET, BigOffsetAccessor>, SwitchScreenAction<BigOffsetChangeScreen>>>(); }
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSTRIP_MILLIAMP, DeziampereAccessor>, SwitchScreenAction<DeziampereChangeScreen>>>(); if (!simplified) { 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_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
} }
}; };

View File

@ -62,31 +62,31 @@ public:
#ifdef FEATURE_LEDSTRIP #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 #endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESETTINGS>, ModeSettingsAction>>(); if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESETTINGS>, ModeSettingsAction>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PRESETS>, SwitchScreenAction<PresetsMenu>, StaticMenuItemIcon<&icons::presets>>>(); if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PRESETS>, SwitchScreenAction<PresetsMenu>, StaticMenuItemIcon<&icons::presets>>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_PROFILES>, SwitchScreenAction<ProfilesMenu>>>(); if (!simplified) { 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_GRAPHS>, SwitchScreenAction<GraphsMenu>, StaticMenuItemIcon<&icons::graph>>>(); }
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY) #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 #endif
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS) #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 #endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETTINGS>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&icons::settings>>>(); if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETTINGS>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&icons::settings>>>(); }
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKVEHICLE>, SwitchScreenAction<Lockscreen>, StaticMenuItemIcon<&icons::lock>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LOCKVEHICLE>, SwitchScreenAction<Lockscreen>, StaticMenuItemIcon<&icons::lock>>>();
#ifdef FEATURE_MOSFETS #ifdef FEATURE_MOSFETS
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFETS>, SwitchScreenAction<MosfetsMenu>>>(); if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MOSFETS>, SwitchScreenAction<MosfetsMenu>>>(); }
#endif #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 #ifdef FEATURE_GARAGE
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GARAGE>, SwitchScreenAction<GarageDisplay>>>(); if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GARAGE>, SwitchScreenAction<GarageDisplay>>>(); }
#endif #endif
#ifdef FEATURE_OTA #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 #endif
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POWEROFF>, SwitchScreenAction<PoweroffDisplay>, StaticMenuItemIcon<&icons::poweroff>>>(); 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_REBOOT>, RebootAction, StaticMenuItemIcon<&icons::reboot>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEBUG>, SwitchScreenAction<DebugMenu>>>(); if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEBUG>, SwitchScreenAction<DebugMenu>>>(); }
} }
}; };
} // namespace } // namespace

View File

@ -48,9 +48,9 @@ public:
SelectModeMenu() SelectModeMenu()
{ {
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEFAULT>, MultiAction<SetDefaultModeAction, SwitchScreenAction<MainMenu>>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEFAULT>, MultiAction<SetDefaultModeAction, SwitchScreenAction<MainMenu>>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_TEMPOMAT, AvgSpeedAccessor>, MultiAction<SetTempomatModeAction, 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>>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LARSM>, MultiAction<SetLarsmModeAction, SwitchScreenAction<MainMenu>>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REMOTECONTROL>, MultiAction<SetRemoteControlModeAction, SwitchScreenAction<MainMenu>>>>(); if (!simplified) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REMOTECONTROL>, MultiAction<SetRemoteControlModeAction, SwitchScreenAction<MainMenu>>>>(); }
#ifdef FEATURE_GAMETRAK #ifdef FEATURE_GAMETRAK
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAMETRAK>, MultiAction<SetGametrakModeAction, SwitchScreenAction<MainMenu>>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_GAMETRAK>, MultiAction<SetGametrakModeAction, SwitchScreenAction<MainMenu>>>>();
#endif #endif

View File

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

View File

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

View File

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

View File

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