Added hybrid mode
This commit is contained in:
@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <TFT_eSPI.h>
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "menudisplay.h"
|
#include "menudisplay.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
@ -8,6 +10,7 @@
|
|||||||
#include "menuitem.h"
|
#include "menuitem.h"
|
||||||
#include "actions/toggleboolaction.h"
|
#include "actions/toggleboolaction.h"
|
||||||
#include "actions/switchscreenaction.h"
|
#include "actions/switchscreenaction.h"
|
||||||
|
#include "actions/dummyaction.h"
|
||||||
#include "checkboxicon.h"
|
#include "checkboxicon.h"
|
||||||
#include "icons/back.h"
|
#include "icons/back.h"
|
||||||
#include "texts.h"
|
#include "texts.h"
|
||||||
@ -122,6 +125,8 @@ class DefaultModeSettingsMenu :
|
|||||||
public:
|
public:
|
||||||
DefaultModeSettingsMenu()
|
DefaultModeSettingsMenu()
|
||||||
{
|
{
|
||||||
|
auto diff = std::abs(settings.hybrid.activationLimit - settings.hybrid.deactivationLimit);
|
||||||
|
if (diff < 20) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LIMITS_TO_NEAR>, StaticFont<2>, StaticColor<TFT_RED>, DummyAction>>(); }
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODELMODE>, SwitchScreenAction<DefaultModeModelModeChangeDisplay>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODELMODE>, SwitchScreenAction<DefaultModeModelModeChangeDisplay>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_HYBRIDMODE>, SwitchScreenAction<DefaultModeHybridModelModeChangeDisplay>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_HYBRIDMODE>, SwitchScreenAction<DefaultModeHybridModelModeChangeDisplay>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SQUAREGAS>, ToggleBoolAction, CheckboxIcon, DefaultModeSquareGasAccessor>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SQUAREGAS>, ToggleBoolAction, CheckboxIcon, DefaultModeSquareGasAccessor>>();
|
||||||
|
@ -23,6 +23,7 @@ public:
|
|||||||
|
|
||||||
bool waitForGasLoslass{false};
|
bool waitForGasLoslass{false};
|
||||||
bool waitForBremsLoslass{false};
|
bool waitForBremsLoslass{false};
|
||||||
|
bool hybridModeActivated{false};
|
||||||
|
|
||||||
private:
|
private:
|
||||||
espchrono::millis_clock::time_point lastTime{espchrono::millis_clock::now()};
|
espchrono::millis_clock::time_point lastTime{espchrono::millis_clock::now()};
|
||||||
@ -128,7 +129,36 @@ void DefaultMode::update()
|
|||||||
lastPwm = pwm;
|
lastPwm = pwm;
|
||||||
lastTime = now;
|
lastTime = now;
|
||||||
|
|
||||||
const auto pair = split(settings.defaultMode.modelMode);
|
auto pair = split(settings.defaultMode.modelMode);
|
||||||
|
|
||||||
|
if (settings.hybrid.enable)
|
||||||
|
{
|
||||||
|
auto activationLimit = settings.hybrid.activationLimit;
|
||||||
|
auto deactivationLimit = settings.hybrid.deactivationLimit;
|
||||||
|
auto diff = std::abs(activationLimit - deactivationLimit);
|
||||||
|
|
||||||
|
if (diff < 20)
|
||||||
|
{
|
||||||
|
int half = (diff / 2) + 0.5;
|
||||||
|
deactivationLimit -= half;
|
||||||
|
activationLimit += half;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!hybridModeActivated && (pwm > activationLimit))
|
||||||
|
{
|
||||||
|
hybridModeActivated = true;
|
||||||
|
}
|
||||||
|
else if (hybridModeActivated && (pwm < deactivationLimit))
|
||||||
|
{
|
||||||
|
hybridModeActivated = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hybridModeActivated)
|
||||||
|
{
|
||||||
|
pair = split(settings.hybrid.hybridMode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (bobbycar::protocol::serial::MotorState &motor : motorsInController(controllers.front))
|
for (bobbycar::protocol::serial::MotorState &motor : motorsInController(controllers.front))
|
||||||
{
|
{
|
||||||
motor.ctrlTyp = pair.first;
|
motor.ctrlTyp = pair.first;
|
||||||
|
@ -214,6 +214,7 @@ constexpr char TEXT_ADDBRAKEVAL[] = "Sub Brake";
|
|||||||
constexpr char TEXT_HYBRIDENABLE[] = "Enable Hybrid mode";
|
constexpr char TEXT_HYBRIDENABLE[] = "Enable Hybrid mode";
|
||||||
constexpr char TEXT_HYBRIDACTIVATIONLIMIT[] = "Hybrid activation-limit";
|
constexpr char TEXT_HYBRIDACTIVATIONLIMIT[] = "Hybrid activation-limit";
|
||||||
constexpr char TEXT_HYBRIDDEACTIVATIONLIMIT[] = "Hybrid deactivation-limit";
|
constexpr char TEXT_HYBRIDDEACTIVATIONLIMIT[] = "Hybrid deactivation-limit";
|
||||||
|
constexpr char TEXT_LIMITS_TO_NEAR[] = "Hybrid limits too near (>20)";
|
||||||
//constexpr char TEXT_BACK[] = "Back";
|
//constexpr char TEXT_BACK[] = "Back";
|
||||||
|
|
||||||
//DynamicDebugMenu
|
//DynamicDebugMenu
|
||||||
|
Reference in New Issue
Block a user