DefaultMode tempomat preperations
This commit is contained in:
@ -1,5 +1,8 @@
|
||||
set(headers
|
||||
accessorinterface.h
|
||||
accessors/globalaccessors.h
|
||||
accessors/settingsaccessors.h
|
||||
accessors/wifiaccessors.h
|
||||
actioninterface.h
|
||||
actions/backproxyaction.h
|
||||
actions/bluetoothbeginaction.h
|
||||
@ -12,6 +15,7 @@ set(headers
|
||||
actions/bmsturnoffdischargeaction.h
|
||||
actions/bmsturnonchargeaction.h
|
||||
actions/bmsturnondischargeaction.h
|
||||
actions/defaultmodeapplycurrspeedaction.h
|
||||
actions/dummyaction.h
|
||||
actions/erasenvsaction.h
|
||||
actions/loadsettingsaction.h
|
||||
@ -136,7 +140,6 @@ set(headers
|
||||
widgets/vumeter.h
|
||||
widgets/graph.h
|
||||
widgets/label.h
|
||||
wifiaccessors.h
|
||||
esptexthelpers.h
|
||||
presets.h
|
||||
bluetoothtexthelpers.h
|
||||
@ -159,7 +162,6 @@ set(headers
|
||||
ota.h
|
||||
serialhandler.h
|
||||
settings.h
|
||||
settingsaccessors.h
|
||||
settingspersister.h
|
||||
settingsutils.h
|
||||
statistics.h
|
||||
|
17
main/accessors/globalaccessors.h
Normal file
17
main/accessors/globalaccessors.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
// local includes
|
||||
#include "accessorinterface.h"
|
||||
#include "globals.h"
|
||||
#include "modes/defaultmode.h"
|
||||
|
||||
namespace {
|
||||
|
||||
struct AvgSpeedAccessor : public RefAccessor<float> { float &getRef() const override { return avgSpeed; } };
|
||||
struct AvgSpeedKmhAccessor : public RefAccessor<float> { float &getRef() const override { return avgSpeedKmh; } };
|
||||
struct SumCurrentAccessor : public RefAccessor<float> { float &getRef() const override { return sumCurrent; } };
|
||||
|
||||
struct DefaultModeCruiseCtrlEnaAccessor : public RefAccessor<bool> { bool &getRef() const override { return modes::defaultMode.cruiseCtrlEna; } };
|
||||
struct DefaultModenCruiseMotTgtAccessor : public RefAccessor<int16_t> { int16_t &getRef() const override { return modes::defaultMode.nCruiseMotTgt; } };
|
||||
|
||||
} // namespace
|
17
main/actions/defaultmodeapplycurrspeedaction.h
Normal file
17
main/actions/defaultmodeapplycurrspeedaction.h
Normal file
@ -0,0 +1,17 @@
|
||||
#pragma once
|
||||
|
||||
// local includes
|
||||
#include "actioninterface.h"
|
||||
#include "globals.h"
|
||||
#include "modes/defaultmode.h"
|
||||
|
||||
namespace {
|
||||
class DefaultModeApplyCurrentSpeedAction : public virtual ActionInterface
|
||||
{
|
||||
public:
|
||||
void triggered() override
|
||||
{
|
||||
modes::defaultMode.nCruiseMotTgt = avgSpeed;
|
||||
}
|
||||
};
|
||||
} // namespace
|
@ -14,7 +14,7 @@
|
||||
#endif
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "bluetoothtexthelpers.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "icons/back.h"
|
||||
#include "checkboxicon.h"
|
||||
#include "texts.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "globals.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
|
@ -12,7 +12,7 @@
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "globals.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
|
@ -10,7 +10,9 @@
|
||||
#include "checkboxicon.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
#include "accessors/globalaccessors.h"
|
||||
#include "actions/defaultmodeapplycurrspeedaction.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
@ -21,68 +23,76 @@ class ModesSettingsMenu;
|
||||
namespace {
|
||||
using DefaultModeModelModeChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<UnifiedModelMode>,
|
||||
StaticText<TEXT_SETMODELMODE>,
|
||||
StaticText<TEXT_MODELMODE>,
|
||||
DefaultModeModelModeAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeSmoothingChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETSMOOTHING>,
|
||||
StaticText<TEXT_SMOOTHINGVAL>,
|
||||
DefaultModeSmoothingAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeFrontPercentageChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETFRONTPERCENTAGE>,
|
||||
StaticText<TEXT_FRONTPERCENTAGE>,
|
||||
DefaultModeFrontPercentageAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeBackPercentageChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETBACKPERCENTAGE>,
|
||||
StaticText<TEXT_BACKPERCENTAGE>,
|
||||
DefaultModeBackPercentageAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeAddSchwelleChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETADDSCHWELLE>,
|
||||
StaticText<TEXT_ADDSCHWELLE>,
|
||||
DefaultModeAddSchwelleAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeGas1WertChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETGAS1WERT>,
|
||||
StaticText<TEXT_ADDGASVAL>,
|
||||
DefaultModeGas1WertAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeGas2WertChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETGAS2WERT>,
|
||||
StaticText<TEXT_SUBGASVAL>,
|
||||
DefaultModeGas2WertAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeBrems1WertChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETBREMS1WERT>,
|
||||
StaticText<TEXT_ADDBRAKEVAL>,
|
||||
DefaultModeBrems1WertAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
using DefaultModeBrems2WertChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_SETBREMS2WERT>,
|
||||
StaticText<TEXT_SUBBRAKEVAL>,
|
||||
DefaultModeBrems2WertAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
|
||||
using DefaultModeCruiseMotTgtChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_NCRUISEMOTTGT>,
|
||||
DefaultModenCruiseMotTgtAccessor,
|
||||
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
|
||||
SwitchScreenAction<DefaultModeSettingsMenu>
|
||||
>;
|
||||
|
||||
class DefaultModeSettingsMenu :
|
||||
public MenuDisplay,
|
||||
public StaticText<TEXT_DEFAULTMODESETTIGNS>,
|
||||
@ -91,19 +101,22 @@ class DefaultModeSettingsMenu :
|
||||
public:
|
||||
DefaultModeSettingsMenu()
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETMODELMODE>, SwitchScreenAction<DefaultModeModelModeChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SQUAREGAS>, ToggleBoolAction, CheckboxIcon, DefaultModeSquareGasAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SQUAREBREMS>, ToggleBoolAction, CheckboxIcon, DefaultModeSquareBremsAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ENABLESMOOTHING>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableSmoothingAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETSMOOTHING>, SwitchScreenAction<DefaultModeSmoothingChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETFRONTPERCENTAGE>, SwitchScreenAction<DefaultModeFrontPercentageChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETBACKPERCENTAGE>, SwitchScreenAction<DefaultModeBackPercentageChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETADDSCHWELLE>, SwitchScreenAction<DefaultModeAddSchwelleChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAS1WERT>, SwitchScreenAction<DefaultModeGas1WertChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETGAS2WERT>, SwitchScreenAction<DefaultModeGas2WertChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETBREMS1WERT>, SwitchScreenAction<DefaultModeBrems1WertChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETBREMS2WERT>, SwitchScreenAction<DefaultModeBrems2WertChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<ModesSettingsMenu>, StaticMenuItemIcon<&icons::back>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODELMODE>, SwitchScreenAction<DefaultModeModelModeChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CRUISECTRLENA>, ToggleBoolAction, CheckboxIcon, DefaultModeCruiseCtrlEnaAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_NCRUISEMOTTGT, DefaultModenCruiseMotTgtAccessor>, SwitchScreenAction<DefaultModeCruiseMotTgtChangeDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_APPLYCURRSPEED, AvgSpeedAccessor>, DefaultModeApplyCurrentSpeedAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SQUAREGAS>, ToggleBoolAction, CheckboxIcon, DefaultModeSquareGasAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SQUAREBREMS>, ToggleBoolAction, CheckboxIcon, DefaultModeSquareBremsAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ENABLESMOOTHING>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableSmoothingAccessor>>();
|
||||
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, StaticText<TEXT_BACK>, SwitchScreenAction<ModesSettingsMenu>, StaticMenuItemIcon<&icons::back>>>();
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "checkboxicon.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "checkboxicon.h"
|
||||
#include "icons/back.h"
|
||||
#include "wifitexthelpers.h"
|
||||
#include "wifiaccessors.h"
|
||||
#include "accessors/wifiaccessors.h"
|
||||
#include "texts.h"
|
||||
|
||||
// forward declares
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "checkboxicon.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
@ -19,7 +19,7 @@ class ModesSettingsMenu;
|
||||
namespace {
|
||||
using LarsmModeModelModeChangeDisplay = makeComponent<
|
||||
ChangeValueDisplay<UnifiedModelMode>,
|
||||
StaticText<TEXT_SETMODELMODE>,
|
||||
StaticText<TEXT_MODELMODE>,
|
||||
LarsmModeModelModeAccessor,
|
||||
BackActionInterface<SwitchScreenAction<LarsmModeSettingsMenu>>,
|
||||
SwitchScreenAction<LarsmModeSettingsMenu>
|
||||
@ -47,7 +47,7 @@ class LarsmModeSettingsMenu :
|
||||
public:
|
||||
LarsmModeSettingsMenu()
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETMODELMODE>, SwitchScreenAction<LarsmModeModelModeChangeDisplay>>>();
|
||||
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<&icons::back>>>();
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
@ -17,12 +17,6 @@ class SettingsMenu;
|
||||
} // namespace
|
||||
|
||||
namespace {
|
||||
template<const char *Tprefix, typename Taccessor>
|
||||
struct TextWithValueHelper : public virtual TextInterface
|
||||
{
|
||||
std::string text() const override { return Tprefix + (' ' + std::to_string(Taccessor{}.getValue())); }
|
||||
};
|
||||
|
||||
using IMotMaxChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<int16_t>,
|
||||
StaticText<TEXT_IMOTMAX>,
|
||||
|
@ -16,7 +16,7 @@
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "globals.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
|
@ -13,7 +13,7 @@
|
||||
#include "checkboxicon.h"
|
||||
#include "icons/back.h"
|
||||
#include "wifitexthelpers.h"
|
||||
#include "wifiaccessors.h"
|
||||
#include "accessors/wifiaccessors.h"
|
||||
#include "texts.h"
|
||||
|
||||
// forward declares
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
@ -19,7 +19,7 @@ class ModesSettingsMenu;
|
||||
namespace {
|
||||
using TempomatModeModelModeChangeScreen = makeComponent<
|
||||
ChangeValueDisplay<UnifiedModelMode>,
|
||||
StaticText<TEXT_SETMODELMODE>,
|
||||
StaticText<TEXT_MODELMODE>,
|
||||
TempomatModeModelModeAccessor,
|
||||
BackActionInterface<SwitchScreenAction<TempomatModeSettingsMenu>>,
|
||||
SwitchScreenAction<TempomatModeSettingsMenu>
|
||||
@ -33,8 +33,8 @@ class TempomatModeSettingsMenu :
|
||||
public:
|
||||
TempomatModeSettingsMenu()
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SETMODELMODE>, SwitchScreenAction<TempomatModeModelModeChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<ModesSettingsMenu>, StaticMenuItemIcon<&icons::back>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODELMODE>, SwitchScreenAction<TempomatModeModelModeChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<ModesSettingsMenu>, StaticMenuItemIcon<&icons::back>>>();
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "actions/switchscreenaction.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include "icons/scan.h"
|
||||
#include "icons/back.h"
|
||||
#include "texts.h"
|
||||
#include "settingsaccessors.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
|
||||
// forward declares
|
||||
namespace {
|
||||
|
@ -13,7 +13,10 @@
|
||||
namespace {
|
||||
class DefaultMode : public ModeInterface
|
||||
{
|
||||
using Base = ModeInterface;
|
||||
|
||||
public:
|
||||
void start() override;
|
||||
void update() override;
|
||||
|
||||
const char *displayName() const override { return "Default"; }
|
||||
@ -21,6 +24,9 @@ public:
|
||||
bool waitForGasLoslass{false};
|
||||
bool waitForBremsLoslass{false};
|
||||
|
||||
bool cruiseCtrlEna{false};
|
||||
int16_t nCruiseMotTgt{0};
|
||||
|
||||
private:
|
||||
espchrono::millis_clock::time_point lastTime{espchrono::millis_clock::now()};
|
||||
float lastPwm{0};
|
||||
@ -30,6 +36,13 @@ namespace modes {
|
||||
DefaultMode defaultMode;
|
||||
}
|
||||
|
||||
void DefaultMode::start()
|
||||
{
|
||||
Base::start();
|
||||
cruiseCtrlEna = false;
|
||||
nCruiseMotTgt = 0;
|
||||
}
|
||||
|
||||
void DefaultMode::update()
|
||||
{
|
||||
if (!gas || !brems)
|
||||
@ -41,6 +54,8 @@ void DefaultMode::update()
|
||||
motor.ctrlTyp = bobbycar::protocol::ControlType::FieldOrientedControl;
|
||||
motor.ctrlMod = bobbycar::protocol::ControlMode::OpenMode;
|
||||
motor.pwm = 0;
|
||||
motor.cruiseCtrlEna = false;
|
||||
motor.nCruiseMotTgt = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -100,12 +115,16 @@ void DefaultMode::update()
|
||||
motor.ctrlTyp = pair.first;
|
||||
motor.ctrlMod = pair.second;
|
||||
motor.pwm = pwm / 100. * settings.defaultMode.frontPercentage;
|
||||
motor.cruiseCtrlEna = cruiseCtrlEna;
|
||||
motor.nCruiseMotTgt = nCruiseMotTgt;
|
||||
}
|
||||
for (bobbycar::protocol::serial::MotorState &motor : motorsInController(controllers.back))
|
||||
{
|
||||
motor.ctrlTyp = pair.first;
|
||||
motor.ctrlMod = pair.second;
|
||||
motor.pwm = pwm / 100. * settings.defaultMode.backPercentage;
|
||||
motor.cruiseCtrlEna = cruiseCtrlEna;
|
||||
motor.nCruiseMotTgt = nCruiseMotTgt;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,8 @@ namespace {
|
||||
#ifdef FEATURE_GAMETRAK
|
||||
class GametrakMode : public ModeInterface
|
||||
{
|
||||
using Base = ModeInterface;
|
||||
|
||||
public:
|
||||
void start() override;
|
||||
void update() override;
|
||||
@ -36,6 +38,7 @@ GametrakMode gametrakMode;
|
||||
|
||||
void GametrakMode::start()
|
||||
{
|
||||
Base::start();
|
||||
m_flag = false;
|
||||
}
|
||||
|
||||
@ -50,6 +53,8 @@ void GametrakMode::update()
|
||||
motor.ctrlTyp = bobbycar::protocol::ControlType::FieldOrientedControl;
|
||||
motor.ctrlMod = bobbycar::protocol::ControlMode::OpenMode;
|
||||
motor.pwm = 0;
|
||||
motor.cruiseCtrlEna = false;
|
||||
motor.nCruiseMotTgt = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -84,6 +89,8 @@ void GametrakMode::update()
|
||||
motor.ctrlTyp = bobbycar::protocol::ControlType::FieldOrientedControl;
|
||||
motor.ctrlMod = bobbycar::protocol::ControlMode::Speed;
|
||||
motor.pwm = pwm;
|
||||
motor.cruiseCtrlEna = false;
|
||||
motor.nCruiseMotTgt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,8 @@ void IgnoreInputMode::update()
|
||||
motor.ctrlTyp = m_ctrlTyp;
|
||||
motor.ctrlMod = m_ctrlMod;
|
||||
motor.pwm = m_pwm;
|
||||
motor.cruiseCtrlEna = false;
|
||||
motor.nCruiseMotTgt = 0;
|
||||
}
|
||||
|
||||
fixCommonParams();
|
||||
|
@ -9,6 +9,8 @@
|
||||
namespace {
|
||||
class LarsmMode : public ModeInterface
|
||||
{
|
||||
using Base = ModeInterface;
|
||||
|
||||
public:
|
||||
void start() override;
|
||||
void update() override;
|
||||
@ -28,6 +30,8 @@ LarsmMode larsmMode;
|
||||
|
||||
void LarsmMode::start()
|
||||
{
|
||||
Base::start();
|
||||
|
||||
adc1_filtered = 0.f;
|
||||
adc2_filtered = 0.f;
|
||||
speed = 0;
|
||||
@ -45,6 +49,8 @@ void LarsmMode::update()
|
||||
motor.ctrlTyp = bobbycar::protocol::ControlType::FieldOrientedControl;
|
||||
motor.ctrlMod = bobbycar::protocol::ControlMode::OpenMode;
|
||||
motor.pwm = 0;
|
||||
motor.cruiseCtrlEna = false;
|
||||
motor.nCruiseMotTgt = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -115,6 +121,8 @@ void LarsmMode::update()
|
||||
motor.ctrlTyp = pair.first;
|
||||
motor.ctrlMod = pair.second;
|
||||
motor.pwm = speed + weak;
|
||||
motor.cruiseCtrlEna = false;
|
||||
motor.nCruiseMotTgt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,8 @@
|
||||
namespace {
|
||||
class TempomatMode : public ModeInterface
|
||||
{
|
||||
using Base = ModeInterface;
|
||||
|
||||
public:
|
||||
void start() override;
|
||||
void update() override;
|
||||
@ -27,6 +29,7 @@ TempomatMode tempomatMode;
|
||||
|
||||
void TempomatMode::start()
|
||||
{
|
||||
Base::start();
|
||||
pwm = 0;
|
||||
}
|
||||
|
||||
@ -41,6 +44,8 @@ void TempomatMode::update()
|
||||
motor.ctrlTyp = bobbycar::protocol::ControlType::FieldOrientedControl;
|
||||
motor.ctrlMod = bobbycar::protocol::ControlMode::OpenMode;
|
||||
motor.pwm = 0;
|
||||
motor.cruiseCtrlEna = false;
|
||||
motor.nCruiseMotTgt = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -62,6 +67,8 @@ void TempomatMode::update()
|
||||
motor.ctrlTyp = pair.first;
|
||||
motor.ctrlMod = pair.second;
|
||||
motor.pwm = pwm;
|
||||
motor.cruiseCtrlEna = false;
|
||||
motor.nCruiseMotTgt = 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
// system includes
|
||||
#include <string>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
|
||||
// local includes
|
||||
#include "utils.h"
|
||||
|
||||
namespace {
|
||||
@ -80,4 +85,10 @@ public:
|
||||
return text;
|
||||
}
|
||||
};
|
||||
|
||||
template<const char *Tprefix, typename Taccessor>
|
||||
struct TextWithValueHelper : public virtual TextInterface
|
||||
{
|
||||
std::string text() const override { return fmt::format("{} {}", Tprefix, Taccessor{}.getValue()); }
|
||||
};
|
||||
}
|
||||
|
25
main/texts.h
25
main/texts.h
@ -146,18 +146,21 @@ constexpr char TEXT_DYNAMICMENU[] = "Dynamic menu";
|
||||
|
||||
//DefaultModeSettingsMenu
|
||||
//constexpr char TEXT_DEFAULTMODESETTINGS[] = "Default mode settings";
|
||||
constexpr char TEXT_SETMODELMODE[] = "Set model mode";
|
||||
constexpr char TEXT_MODELMODE[] = "Model mode";
|
||||
constexpr char TEXT_CRUISECTRLENA[] = "Enable tempomat";
|
||||
constexpr char TEXT_NCRUISEMOTTGT[] = "Tempomat";
|
||||
constexpr char TEXT_APPLYCURRSPEED[] = "Apply";
|
||||
constexpr char TEXT_SQUAREGAS[] = "Square gas";
|
||||
constexpr char TEXT_SQUAREBREMS[] = "Square brems";
|
||||
constexpr char TEXT_ENABLESMOOTHING[] = "Enable smoothing";
|
||||
constexpr char TEXT_SETSMOOTHING[] = "Set smoothing";
|
||||
constexpr char TEXT_SETFRONTPERCENTAGE[] = "Set front percentage";
|
||||
constexpr char TEXT_SETBACKPERCENTAGE[] = "Set back percentage";
|
||||
constexpr char TEXT_SETADDSCHWELLE[] = "Set add Schwelle";
|
||||
constexpr char TEXT_SETGAS1WERT[] = "Set Gas 1 Wert";
|
||||
constexpr char TEXT_SETGAS2WERT[] = "Set Gas 2 Wert";
|
||||
constexpr char TEXT_SETBREMS1WERT[] = "Set Brems 1 Wert";
|
||||
constexpr char TEXT_SETBREMS2WERT[] = "Set Brems 2 Wert";
|
||||
constexpr char TEXT_SMOOTHINGVAL[] = "Smoothing";
|
||||
constexpr char TEXT_FRONTPERCENTAGE[] = "Front %";
|
||||
constexpr char TEXT_BACKPERCENTAGE[] = "Back %";
|
||||
constexpr char TEXT_ADDSCHWELLE[] = "Add/Sub Lim";
|
||||
constexpr char TEXT_SUBGASVAL[] = "Add Gas";
|
||||
constexpr char TEXT_SUBBRAKEVAL[] = "Add Brake";
|
||||
constexpr char TEXT_ADDGASVAL[] = "Sub Gas";
|
||||
constexpr char TEXT_ADDBRAKEVAL[] = "Sub Brake";
|
||||
//constexpr char TEXT_BACK[] = "Back";
|
||||
|
||||
//DynamicDebugMenu
|
||||
@ -211,7 +214,7 @@ constexpr char TEXT_INVERTBACKRIGHT[] = "Invert back right";
|
||||
|
||||
//LarsmModeSettingsMenu
|
||||
constexpr char TEXT_LARSMMODESETTINGS[] = "Larsm mode settings";
|
||||
//constexpr char TEXT_SETMODELMODE[] = "Set model mode";
|
||||
//constexpr char TEXT_MODELMODE[] = "Model mode";
|
||||
constexpr char TEXT_SETMODE[] = "Set mode";
|
||||
constexpr char TEXT_SETITERATIONS[] = "Set iterations";
|
||||
//constexpr char TEXT_BACK[] = "Back";
|
||||
@ -232,7 +235,7 @@ constexpr char TEXT_MOSFET2[] = "Mosfet2";
|
||||
|
||||
//TempomatModeSettingsMenu
|
||||
//constexpr char TEXT_TEMPOMATMODESETTINGS[] = "Tempomat mode settings";
|
||||
//constexpr char TEXT_SETMODELMODE[] = "Set model mode";
|
||||
//constexpr char TEXT_MODELMODE[] = "Model mode";
|
||||
//constexpr char TEXT_BACK[] = "Back";
|
||||
|
||||
//WiFiSettingsMenu
|
||||
|
Reference in New Issue
Block a user