vesc control

This commit is contained in:
Patrick Pichler
2020-05-30 19:18:20 +02:00
committed by 0xFEEDC0DE64
parent 053b324617
commit 4dda961d88
45 changed files with 508 additions and 25 deletions

View File

@ -85,6 +85,7 @@ build_flags =
-DDEVICE_PREFIX=bobbyquad
-DFEATURE_WEBSERVER
-DFEATURE_3WIRESW
-DGLUMP_CONTROLLER
-DPINS_3WIRESW_OUT=0
-DPINS_3WIRESW_IN1=16
-DPINS_3WIRESW_IN2=27
@ -198,6 +199,7 @@ build_flags =
${peters_platine.build_flags}
${default_limits.build_flags}
-DDEVICE_PREFIX=bobbyquad
-DVESC_CONTROLLER
-DFEATURE_WEBSERVER
; -DFEATURE_3WIRESW
; -DPINS_3WIRESW_OUT=0

View File

@ -137,8 +137,10 @@ void ChangeValueDisplay<Tvalue>::confirm()
#include "changevaluedisplay_bool.h"
#include "changevaluedisplay_bluetoothmode.h"
#ifdef GLUMP_CONTROLLER
#include "changevaluedisplay_controlmode.h"
#include "changevaluedisplay_controltype.h"
#include "changevaluedisplay_larsmmode_mode.h"
#endif
#include "changevaluedisplay_wifi_mode_t.h"
#include "changevaluedisplay_wifi_power_t.h"

View File

@ -8,6 +8,7 @@
#include "icons/back.h"
#include "texts.h"
#ifdef GLUMP_CONTROLLER
namespace {
template<>
class ChangeValueDisplay<ControlMode> :
@ -62,3 +63,4 @@ void ChangeValueDisplay<ControlMode>::itemPressed(int index)
triggered();
}
}
#endif

View File

@ -8,6 +8,7 @@
#include "icons/back.h"
#include "texts.h"
#ifdef GLUMP_CONTROLLER
namespace {
template<>
class ChangeValueDisplay<ControlType> :
@ -58,3 +59,4 @@ void ChangeValueDisplay<ControlType>::itemPressed(int index)
triggered();
}
}
#endif

View File

@ -9,6 +9,7 @@
#include "texts.h"
#include "modes/larsmmode.h"
#ifdef GLUMP_CONTROLLER
namespace {
template<>
class ChangeValueDisplay<LarsmModeMode> :
@ -63,3 +64,4 @@ void ChangeValueDisplay<LarsmModeMode>::itemPressed(int index)
triggered();
}
}
#endif

View File

@ -2,13 +2,19 @@
#include <functional>
#include <Arduino.h>
#include <WString.h>
#include "bobbycar-protocol/protocol.h"
#include "feedbackparser.h"
#include "VescUartControl-VESC6/VescUart.h"
class HardwareSerial;
namespace {
#ifdef GLUMP_CONTROLLER
struct Controller {
Controller(HardwareSerial &serial, bool &enableLeft, bool &enableRight, bool &invertLeft, bool &invertRight) :
serial{serial}, enableLeft{enableLeft}, enableRight{enableRight}, invertLeft{invertLeft}, invertRight{invertRight}
@ -25,4 +31,37 @@ struct Controller {
FeedbackParser parser{serial, feedbackValid, feedback};
};
#endif
#ifdef VESC_CONTROLLER
struct VescController {
VescController(HardwareSerial &serial, bool &enable) :
serial{serial}, enable{enable}
{
}
std::reference_wrapper<HardwareSerial> serial;
bool &enable;
bldcMeasure values;
float pwm = 0;
// Command command{};
//
// bool feedbackValid{};
// Feedback feedback{};
//
// FeedbackParser parser{serial, feedbackValid, feedback};
void update() {
SetSerialPort(&serial.get());
SetDebugSerialPort(NULL);
VescUartGetValue(values);
Serial.println(String{"Duty now "} + values.dutyNow);
}
};
#endif
}

View File

@ -3,6 +3,7 @@
#include "colorinterface.h"
#include "globals.h"
#ifdef GLUMP_CONTROLLER
namespace {
template<Controller &Tcontroller, int TsuccessColor>
class FeedbackColor : public virtual ColorInterface { public: int color() const { return Tcontroller.feedbackValid ? TsuccessColor : TFT_RED; } };
@ -13,3 +14,4 @@ using FrontFeedbackColor = FeedbackColor<front, TsuccessColor>;
template<int TsuccessColor>
using BackFeedbackColor = FeedbackColor<back, TsuccessColor>;
}
#endif

View File

@ -4,6 +4,7 @@
#include "globals.h"
#include "utils.h"
#ifdef GLUMP_CONTROLLER
namespace {
template<Controller &controller>
struct ControllerTexts
@ -88,3 +89,4 @@ struct ControllerTexts
using FrontTexts = ControllerTexts<front>;
using BackTexts = ControllerTexts<back>;
}
#endif

View File

@ -38,7 +38,13 @@ public:
private:
const bool m_bootup{false};
ModeInterface *m_oldMode;
IgnoreInputMode m_mode{0, ControlType::FieldOrientedControl, ControlMode::Torque};
IgnoreInputMode m_mode{
0,
#ifdef GLUMP_CONTROLLER
ControlType::FieldOrientedControl,
ControlMode::Torque
#endif
};
std::array<Label, 4> m_labels {{
Label{25, 50}, // 100, 23
@ -104,14 +110,24 @@ void CalibrateDisplay::stop()
void CalibrateDisplay::back()
{
if (!m_bootup)
#ifdef GLUMP_CONTROLLER
switchScreen<BoardcomputerHardwareSettingsMenu>();
#endif
#ifdef VESC_CONTROLLER
switchScreen<StatusDisplay>();
#endif
}
void CalibrateDisplay::triggered()
{
#ifdef GLUMP_CONTROLLER
if (m_bootup)
switchScreen<StatusDisplay>();
else
switchScreen<BoardcomputerHardwareSettingsMenu>();
#endif
#ifdef VESC_CONTROLLER
switchScreen<StatusDisplay>();
#endif
}
}

View File

@ -50,7 +50,13 @@ private:
int m_rotated;
ModeInterface *m_oldMode;
IgnoreInputMode m_mode{0, ControlType::FieldOrientedControl, ControlMode::Speed};
IgnoreInputMode m_mode{
0,
#ifdef GLUMP_CONTROLLER
ControlType::FieldOrientedControl,
ControlMode::Speed
#endif
};
};
void Lockscreen::start()

View File

@ -13,6 +13,7 @@
#include "globals.h"
#include "settingsaccessors.h"
#ifdef GLUMP_CONTROLLER
namespace {
class BuzzerMenu;
class SettingsMenu;
@ -102,3 +103,4 @@ class BuzzerMenu :
>
{};
}
#endif

View File

@ -10,6 +10,7 @@
#include "texts.h"
#include "debugtexthelpers.h"
#ifdef GLUMP_CONTROLLER
namespace {
class DebugMenu;
}
@ -32,3 +33,4 @@ class CommandDebugMenu :
class FrontCommandDebugMenu : public CommandDebugMenu<TEXT_FRONTCOMMAND, FrontTexts> {};
class BackCommandDebugMenu : public CommandDebugMenu<TEXT_BACKCOMMAND, BackTexts> {};
}
#endif

View File

@ -56,7 +56,9 @@ class ControllerHardwareSettingsMenu :
makeComponent<MenuItem, StaticText<TEXT_WHEELDIAMETERMM>, SwitchScreenAction<WheelDiameterMmChangeScreen>>,
makeComponent<MenuItem, StaticText<TEXT_WHEELDIAMETERINCH>, SwitchScreenAction<WheelDiameterInchChangeScreen>>,
makeComponent<MenuItem, StaticText<TEXT_NUMMAGNETPOLES>, SwitchScreenAction<NumMagnetPolesChangeScreen>>,
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_SWAPFRONTBACK>, ToggleBoolAction, CheckboxIcon, SwapFrontBackAccessor>,
#endif
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&icons::back>>
>
{};

View File

@ -17,6 +17,7 @@
namespace {
class MainMenu;
#ifdef GLUMP_CONTROLLER
class FrontCommandDebugMenu;
class BackCommandDebugMenu;
class FrontLeftMotorStateDebugMenu;
@ -29,6 +30,7 @@ class FrontLeftMotorFeedbackDebugMenu;
class FrontRightMotorFeedbackDebugMenu;
class BackLeftMotorFeedbackDebugMenu;
class BackRightMotorFeedbackDebugMenu;
#endif
class DynamicDebugMenu;
}
@ -41,6 +43,7 @@ class DebugMenu :
makeComponent<MenuItem, StaticText<TEXT_LOADSETTINGS>, LoadSettingsAction>,
makeComponent<MenuItem, StaticText<TEXT_SAVESETTINGS>, SaveSettingsAction>,
makeComponent<MenuItem, StaticText<nullptr>, DummyAction>,
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_FRONTCOMMAND>, SwitchScreenAction<FrontCommandDebugMenu>>,
makeComponent<MenuItem, StaticText<TEXT_BACKCOMMAND>, SwitchScreenAction<BackCommandDebugMenu>>,
makeComponent<MenuItem, StaticText<nullptr>, DummyAction>,
@ -56,6 +59,7 @@ class DebugMenu :
makeComponent<MenuItem, StaticText<TEXT_FRONTRIGHTFEEDBACK>, SwitchScreenAction<FrontRightMotorFeedbackDebugMenu>, FrontFeedbackColor<TFT_WHITE>>,
makeComponent<MenuItem, StaticText<TEXT_BACKLEFTFEEDBACK>, SwitchScreenAction<BackLeftMotorFeedbackDebugMenu>, BackFeedbackColor<TFT_WHITE>>,
makeComponent<MenuItem, StaticText<TEXT_BACKRIGHTFEEDBACK>, SwitchScreenAction<BackRightMotorFeedbackDebugMenu>, BackFeedbackColor<TFT_WHITE>>,
#endif
makeComponent<MenuItem, StaticText<nullptr>, DummyAction>,
makeComponent<MenuItem, StaticText<TEXT_DYNAMICMENU>, SwitchScreenAction<DynamicDebugMenu>>,
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&icons::back>>

View File

@ -18,6 +18,7 @@ class ModesSettingsMenu;
}
namespace {
#ifdef GLUMP_CONTROLLER
using DefaultModeCtrlTypChangeDisplay = makeComponent<
ChangeValueDisplay<ControlType>,
StaticText<TEXT_SETCONTROLTYPE>,
@ -32,6 +33,7 @@ using DefaultModeCtrlModChangeDisplay = makeComponent<
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
#endif
using DefaultModeSmoothingChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SETSMOOTHING>,
@ -39,6 +41,7 @@ using DefaultModeSmoothingChangeDisplay = makeComponent<
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
#ifdef GLUMP_CONTROLLER
using DefaultModeFrontPercentageChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SETFRONTPERCENTAGE>,
@ -53,6 +56,7 @@ using DefaultModeBackPercentageChangeDisplay = makeComponent<
BackActionInterface<SwitchScreenAction<DefaultModeSettingsMenu>>,
SwitchScreenAction<DefaultModeSettingsMenu>
>;
#endif
using DefaultModeAddSchwelleChangeDisplay = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SETADDSCHWELLE>,
@ -94,12 +98,16 @@ class DefaultModeSettingsMenu :
public StaticText<TEXT_DEFAULTMODESETTIGNS>,
public BackActionInterface<SwitchScreenAction<ModesSettingsMenu>>,
public StaticMenuDefinition<
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_SETCONTROLTYPE>, SwitchScreenAction<DefaultModeCtrlTypChangeDisplay>>,
makeComponent<MenuItem, StaticText<TEXT_SETCONTROLMODE>, SwitchScreenAction<DefaultModeCtrlModChangeDisplay>>,
#endif
makeComponent<MenuItem, StaticText<TEXT_ENABLESMOOTHING>, ToggleBoolAction, CheckboxIcon, DefaultModeEnableSmoothingAccessor>,
makeComponent<MenuItem, StaticText<TEXT_SETSMOOTHING>, SwitchScreenAction<DefaultModeSmoothingChangeDisplay>>,
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_SETFRONTPERCENTAGE>, SwitchScreenAction<DefaultModeFrontPercentageChangeDisplay>>,
makeComponent<MenuItem, StaticText<TEXT_SETBACKPERCENTAGE>, SwitchScreenAction<DefaultModeBackPercentageChangeDisplay>>,
#endif
makeComponent<MenuItem, StaticText<TEXT_SETADDSCHWELLE>, SwitchScreenAction<DefaultModeAddSchwelleChangeDisplay>>,
makeComponent<MenuItem, StaticText<TEXT_SETGAS1WERT>, SwitchScreenAction<DefaultModeGas1WertChangeDisplay>>,
makeComponent<MenuItem, StaticText<TEXT_SETGAS2WERT>, SwitchScreenAction<DefaultModeGas2WertChangeDisplay>>,

View File

@ -21,11 +21,17 @@ class EnableMenu :
public StaticText<TEXT_SETENABLED>,
public BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
public StaticMenuDefinition<
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_ENABLEFRONTLEFT>, ToggleBoolAction, CheckboxIcon, FrontLeftEnabledAccessor>,
makeComponent<MenuItem, StaticText<TEXT_ENABLEFRONTRIGHT>, ToggleBoolAction, CheckboxIcon, FrontRightEnabledAccessor>,
makeComponent<MenuItem, StaticText<TEXT_ENABLEBACKLEFT>, ToggleBoolAction, CheckboxIcon, BackLeftEnabledAccessor>,
makeComponent<MenuItem, StaticText<TEXT_ENABLEBACKRIGHT>, ToggleBoolAction, CheckboxIcon, BackRightEnabledAccessor>,
#endif
#ifdef VESC_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_ENABLEBACKRIGHT>, ToggleBoolAction, CheckboxIcon, OneEnabledAccessor>,
makeComponent<MenuItem, StaticText<TEXT_ENABLEBACKRIGHT>, ToggleBoolAction, CheckboxIcon, TwoEnabledAccessor>,
#endif
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<ControllerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::back>>
>
{};
}
}

View File

@ -11,6 +11,7 @@
#include "debugtexthelpers.h"
#include "debugcolorhelpers.h"
#ifdef GLUMP_CONTROLLER
namespace {
class DebugMenu;
}
@ -33,3 +34,4 @@ class FeedbackDebugMenu :
class FrontFeedbackDebugMenu : public FeedbackDebugMenu<TEXT_FRONTFEEDBACK, FrontTexts, FrontFeedbackColor> {};
class BackFeedbackDebugMenu : public FeedbackDebugMenu<TEXT_BACKFEEDBACK, BackTexts, FrontFeedbackColor> {}; }
#endif

View File

@ -21,8 +21,12 @@ using AvgSpeedGraphDisplay = makeComponent<GraphDisplay<1>, StaticText<TEXT_AVGS
using AvgSpeedKmhGraphDisplay = makeComponent<GraphDisplay<1>, StaticText<TEXT_AVGSPEEDKMH>, MultiStatisticsSingleImpl, AvgSpeedKmhStatistics>;
using SumCurrentGraphDisplay = makeComponent<GraphDisplay<1>, StaticText<TEXT_SUMCURRENT>, MultiStatisticsSingleImpl, SumCurrentStatistics>;
using SumAbsoluteCurrentGraphDisplay = makeComponent<GraphDisplay<1>, StaticText<TEXT_SUMABSOLUTECURRENT>, MultiStatisticsSingleImpl, SumAbsoluteCurrentStatistics>;
#ifdef GLUMP_CONTROLLER
using FrontVoltageGraphDisplay = makeComponent<GraphDisplay<1>, StaticText<TEXT_FRONTVOLTAGE>, MultiStatisticsSingleImpl, FrontVoltageStatistics>;
using BackVoltageGraphDisplay = makeComponent<GraphDisplay<1>, StaticText<TEXT_BACKVOLTAGE>, MultiStatisticsSingleImpl, BackVoltageStatistics>;
#endif
#ifdef FEATURE_BMS
using BmsVoltageGraphDisplay = makeComponent<GraphDisplay<1>, StaticText<TEXT_BMSVOLTAGE>, MultiStatisticsSingleImpl, BmsVoltageStatistics>;
using BmsCurrentGraphDisplay = makeComponent<GraphDisplay<1>, StaticText<TEXT_BMSCURRENT>, MultiStatisticsSingleImpl, BmsCurrentStatistics>;
@ -37,7 +41,7 @@ class SumCurrentsComparisonStatistics : public virtual MultiStatisticsInterface<
};
using SumCurrentsComparisonGraphDisplay = makeComponent<GraphDisplay<2>, StaticText<TEXT_SUMCURRENTSCOMPARISON>, SumCurrentsComparisonStatistics>;
#endif
#ifdef GLUMP_CONTROLLER
class MotorCurrentsStatistics : public virtual MultiStatisticsInterface<4>
{
std::array<std::reference_wrapper<const statistics::ContainerType>, 4> getBuffers() const override
@ -46,6 +50,7 @@ class MotorCurrentsStatistics : public virtual MultiStatisticsInterface<4>
}
};
using MotorCurrentsGraphDisplay = makeComponent<GraphDisplay<4>, StaticText<TEXT_MOTORCURRENTS>, MotorCurrentsStatistics>;
#endif
class GraphsMenu :
public MenuDisplay,
@ -58,15 +63,19 @@ class GraphsMenu :
makeComponent<MenuItem, StaticText<TEXT_AVGSPEEDKMH>, SwitchScreenAction<AvgSpeedKmhGraphDisplay>>,
makeComponent<MenuItem, StaticText<TEXT_SUMCURRENT>, SwitchScreenAction<SumCurrentGraphDisplay>>,
makeComponent<MenuItem, StaticText<TEXT_SUMABSOLUTECURRENT>, SwitchScreenAction<SumAbsoluteCurrentGraphDisplay>>,
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_FRONTVOLTAGE>, SwitchScreenAction<FrontVoltageGraphDisplay>>,
makeComponent<MenuItem, StaticText<TEXT_BACKVOLTAGE>, SwitchScreenAction<BackVoltageGraphDisplay>>,
#endif
#ifdef FEATURE_BMS
makeComponent<MenuItem, StaticText<TEXT_BMSVOLTAGE>, SwitchScreenAction<BmsVoltageGraphDisplay>>,
makeComponent<MenuItem, StaticText<TEXT_BMSCURRENT>, SwitchScreenAction<BmsCurrentGraphDisplay>>,
makeComponent<MenuItem, StaticText<TEXT_BMSPOWER>, SwitchScreenAction<BmsPowerGraphDisplay>>,
makeComponent<MenuItem, StaticText<TEXT_SUMCURRENTSCOMPARISON>, SwitchScreenAction<SumCurrentsComparisonGraphDisplay>>,
#endif
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_MOTORCURRENTS>, SwitchScreenAction<MotorCurrentsGraphDisplay>>,
#endif
makeComponent<MenuItem, StaticText<TEXT_DUALGRAPHS>, SwitchScreenAction<DualGraphDisplay>>,
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&icons::back>>
>

View File

@ -21,11 +21,17 @@ class InvertMenu :
public StaticText<TEXT_SETINVERTED>,
public BackActionInterface<SwitchScreenAction<ControllerHardwareSettingsMenu>>,
public StaticMenuDefinition<
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_INVERTFRONTLEFT>, ToggleBoolAction, CheckboxIcon, FrontLeftInvertedAccessor>,
makeComponent<MenuItem, StaticText<TEXT_INVERTFRONTRIGHT>, ToggleBoolAction, CheckboxIcon, FrontRightInvertedAccessor>,
makeComponent<MenuItem, StaticText<TEXT_INVERTBACKLEFT>, ToggleBoolAction, CheckboxIcon, BackLeftInvertedAccessor>,
makeComponent<MenuItem, StaticText<TEXT_INVERTBACKRIGHT>, ToggleBoolAction, CheckboxIcon, BackRightInvertedAccessor>,
#endif
#ifdef VESC_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_INVERTFRONTLEFT>, ToggleBoolAction, CheckboxIcon, OneInvertedAccessor>,
makeComponent<MenuItem, StaticText<TEXT_INVERTFRONTRIGHT>, ToggleBoolAction, CheckboxIcon, TwoInvertedAccessor>,
#endif
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<ControllerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::back>>
>
{};
}
}

View File

@ -10,6 +10,7 @@
#include "texts.h"
#include "settingsaccessors.h"
#ifdef GLUMP_CONTROLLER
namespace {
class LarsmModeSettingsMenu;
class ModesSettingsMenu;
@ -42,3 +43,4 @@ class LarsmModeSettingsMenu :
>
{};
}
#endif

View File

@ -38,7 +38,9 @@ class MainMenu :
public BackActionInterface<SwitchScreenAction<StatusDisplay>>,
public StaticMenuDefinition<
makeComponent<MenuItem, StaticText<TEXT_STATUS>, SwitchScreenAction<StatusDisplay>, StaticMenuItemIcon<&icons::back>>,
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_SELECTMODE>, SwitchScreenAction<SelectModeMenu>, StaticMenuItemIcon<&icons::modes>>,
#endif
makeComponent<MenuItem, StaticText<TEXT_PRESETS>, SwitchScreenAction<PresetsMenu>, StaticMenuItemIcon<&icons::presets>>,
makeComponent<MenuItem, StaticText<TEXT_GRAPHS>, SwitchScreenAction<GraphsMenu>, StaticMenuItemIcon<&icons::graph>>,
#ifdef FEATURE_BMS
@ -50,7 +52,9 @@ class MainMenu :
makeComponent<MenuItem, StaticText<TEXT_MOSFETS>, SwitchScreenAction<MosfetsMenu>, StaticMenuItemIcon<&icons::lock>>, // TODO icon
#endif
makeComponent<MenuItem, StaticText<TEXT_DEMOS>, SwitchScreenAction<DemosMenu>, StaticMenuItemIcon<&icons::demos>>,
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_POWEROFF>, SwitchScreenAction<PoweroffDisplay>, StaticMenuItemIcon<&icons::poweroff>>,
#endif
makeComponent<MenuItem, StaticText<TEXT_REBOOT>, RebootAction, StaticMenuItemIcon<&icons::reboot>>,
makeComponent<MenuItem, StaticText<TEXT_DEBUG>, SwitchScreenAction<DebugMenu>>
>

View File

@ -10,7 +10,9 @@
namespace {
class DefaultModeSettingsMenu;
class TempomatModeSettingsMenu;
#ifdef GLUMP_CONTROLLER
class LarsmModeSettingsMenu;
#endif
class GametrakModeSettingsMenu;
class SettingsMenu;
}
@ -23,7 +25,9 @@ class ModesSettingsMenu :
public StaticMenuDefinition<
makeComponent<MenuItem, StaticText<TEXT_DEFAULTMODESETTIGNS>, SwitchScreenAction<DefaultModeSettingsMenu>>,
makeComponent<MenuItem, StaticText<TEXT_TEMPOMATMODESETTINGS>, SwitchScreenAction<TempomatModeSettingsMenu>>,
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_LARSMMODESETTINGS>, SwitchScreenAction<LarsmModeSettingsMenu>>,
#endif
#ifdef FEATURE_GAMETRAK
makeComponent<MenuItem, StaticText<TEXT_GAMETRAKMODESETTINGS>, SwitchScreenAction<GametrakModeSettingsMenu>>,
#endif

View File

@ -11,6 +11,7 @@
#include "debugtexthelpers.h"
#include "debugcolorhelpers.h"
#ifdef GLUMP_CONTROLLER
namespace {
class DebugMenu;
}
@ -39,3 +40,4 @@ class FrontRightMotorFeedbackDebugMenu : public MotorFeedbackDebugMenu<TEXT_FRON
class BackLeftMotorFeedbackDebugMenu : public MotorFeedbackDebugMenu<TEXT_BACKLEFTFEEDBACK, BackTexts::LeftFeedback, BackFeedbackColor> {};
class BackRightMotorFeedbackDebugMenu : public MotorFeedbackDebugMenu<TEXT_BACKRIGHTFEEDBACK, BackTexts::RightFeedback, BackFeedbackColor> {};
}
#endif

View File

@ -10,6 +10,7 @@
#include "texts.h"
#include "debugtexthelpers.h"
#ifdef GLUMP_CONTROLLER
namespace {
class DebugMenu;
}
@ -39,3 +40,4 @@ class FrontRightMotorStateDebugMenu : public MotorStateDebugMenu<TEXT_FRONTRIGHT
class BackLeftMotorStateDebugMenu : public MotorStateDebugMenu<TEXT_BACKLEFTCOMMAND, BackTexts::LeftCommand> {};
class BackRightMotorStateDebugMenu : public MotorStateDebugMenu<TEXT_BACKRIGHTCOMMAND, BackTexts::RightCommand> {};
}
#endif

View File

@ -55,7 +55,9 @@ class PresetsMenu :
makeComponent<MenuItem, StaticText<TEXT_KIDSLIMITS>, ApplyLimitsPresetAction<&presets::kidsLimits>>,
makeComponent<MenuItem, StaticText<TEXT_DEFAULTCONTROLLERHARDWARE>, ApplyControllerHardwarePresetAction<&presets::defaultControllerHardware>>,
makeComponent<MenuItem, StaticText<TEXT_MOSFETSOFFCONTROLLERHARDWARE>, ApplyControllerHardwarePresetAction<&presets::mosfetsOffControllerHardware>>,
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_SPINNERCONTROLLERHARDWARE>, ApplyControllerHardwarePresetAction<&presets::spinnerControllerHardware>>,
#endif
makeComponent<MenuItem, StaticText<TEXT_DEFAULTBOARDCOMPUTERHARDWARE>, ApplyBoardcomputerHardwarePresetAction<&presets::defaultBoardcomputerHardware>>,
makeComponent<MenuItem, StaticText<TEXT_STREET>, DisabledColor, DummyAction>,
makeComponent<MenuItem, StaticText<TEXT_SIDEWALK>, DisabledColor, DummyAction>,

View File

@ -14,6 +14,7 @@
#include "modes/larsmmode.h"
#include "modes/gametrakmode.h"
#ifdef GLUMP_CONTROLLER
namespace {
class MainMenu;
}
@ -69,3 +70,4 @@ void SelectModeMenu::start()
}
}
}
#endif

View File

@ -32,6 +32,7 @@ class MainMenu;
}
namespace {
#ifdef GLUMP_CONTROLLER
class SettingsMenu;
using BluetoothModeChangeDisplay = makeComponent<
ChangeValueDisplay<BluetoothMode>,
@ -43,6 +44,7 @@ using BluetoothModeChangeDisplay = makeComponent<
struct FrontLedAccessor : public RefAccessor<bool> { bool &getRef() const override { return front.command.led; } };
struct BackLedAccessor : public RefAccessor<bool> { bool &getRef() const override { return back.command.led; } };
#endif
class SettingsMenu :
public MenuDisplay,
@ -52,16 +54,20 @@ class SettingsMenu :
makeComponent<MenuItem, StaticText<TEXT_LIMITSSETTINGS>, SwitchScreenAction<LimitsSettingsMenu>>,
makeComponent<MenuItem, StaticText<TEXT_WIFISETTINGS>, SwitchScreenAction<WifiSettingsMenu>, StaticMenuItemIcon<&icons::wifi>>,
makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHSETTINGS>, SwitchScreenAction<BluetoothSettingsMenu>, StaticMenuItemIcon<&icons::bluetooth>>,
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_MODESSETTINGS>, SwitchScreenAction<ModesSettingsMenu>>,
makeComponent<MenuItem, StaticText<TEXT_CONTROLLERHARDWARESETTINGS>, SwitchScreenAction<ControllerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
makeComponent<MenuItem, StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
#endif
makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHMODE>, SwitchScreenAction<BluetoothModeChangeDisplay>>,
#ifdef FEATURE_BMS
makeComponent<MenuItem, StaticText<TEXT_AUTOCONNECTBMS>, ToggleBoolAction, CheckboxIcon, AutoConnectBmsAccessor>,
#endif
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_BUZZER>, SwitchScreenAction<BuzzerMenu>, StaticMenuItemIcon<&icons::buzzer>>,
makeComponent<MenuItem, StaticText<TEXT_FRONTLED>, ToggleBoolAction, CheckboxIcon, FrontLedAccessor>,
makeComponent<MenuItem, StaticText<TEXT_BACKLED>, ToggleBoolAction, CheckboxIcon, BackLedAccessor>,
#endif
makeComponent<MenuItem, StaticText<TEXT_ABOUT>, SwitchScreenAction<AboutMenu>, StaticMenuItemIcon<&icons::info>>,
makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&icons::back>>
>

View File

@ -10,6 +10,7 @@
#include "texts.h"
#include "settingsaccessors.h"
#ifdef GLUMP_CONTROLLER
namespace {
class TempomatModeSettingsMenu;
class ModesSettingsMenu;
@ -42,3 +43,4 @@ class TempomatModeSettingsMenu :
>
{};
}
#endif

View File

@ -7,6 +7,7 @@
#include "globals.h"
#include "texts.h"
#ifdef GLUMP_CONTROLLER
namespace {
class MainMenu;
}
@ -60,3 +61,4 @@ void PoweroffDisplay::stop()
controller.command.poweroff = false;
}
}
#endif

View File

@ -35,21 +35,34 @@ private:
{
public:
BoardStatus(int y) :
m_y{y},
m_labelLeftPwm{65, y}, // 80, 22
m_y{y}
#ifdef GLUMP_CONTROLLER
,m_labelLeftPwm{65, y}, // 80, 22
m_labelRightPwm{155, y}, // 80, 22
m_labelVoltage{30, y+25}, // 85, 22
m_labelTemperature{150, y+25}, // 85, 22
m_leftMotor{y+50},
m_rightMotor{y+75}
#endif
#ifdef VESC_CONTROLLER
,m_labelPwm{65, y}, // 80, 22
m_labelSpeed{135, y+50}
#endif
{}
void start();
#ifdef GLUMP_CONTROLLER
void redraw(const Controller &controller);
#endif
#ifdef VESC_CONTROLLER
void redraw(const VescController &controller);
#endif
private:
void drawWarning();
#ifdef GLUMP_CONTROLLER
class MotorStatus
{
public:
@ -69,9 +82,16 @@ private:
Label m_labelSpeed;
Label m_labelHallSensors;
};
#endif
const int m_y;
#ifdef VESC_CONTROLLER
Label m_labelPwm;
Label m_labelSpeed;
#endif
#ifdef GLUMP_CONTROLLER
bool m_lastFeedbackValid{};
Label m_labelLeftPwm;
@ -82,6 +102,7 @@ private:
MotorStatus m_leftMotor;
MotorStatus m_rightMotor;
#endif
};
Label m_labelRawGas{45, 0}; // 40, 15
@ -92,18 +113,27 @@ private:
Label m_labelBrems{90, 15}; // 60, 15
ProgressBar m_progressBarBrems{150, 15, 90, 15, 0, 1000};
#ifdef GLUMP_CONTROLLER
BoardStatus m_frontStatus{42};
BoardStatus m_backStatus{142};
#endif
#ifdef VESC_CONTROLLER
BoardStatus m_one{42};
BoardStatus m_two{142};
#endif
static const constexpr int bottomLines[4] { 251, 266, 281, 296 };
Label m_labelWifiStatus{35, bottomLines[0]}; // 120, 15
Label m_labelLimit0{205, bottomLines[0]}; // 35, 15
Label m_labelIpAddress{25, bottomLines[1]}; // 130, 15
#ifdef GLUMP_CONTROLLER
Label m_labelLimit1{205, bottomLines[1]}; // 35, 15
#endif
Label m_labelPerformance{85, bottomLines[2]}; // 40, 15
Label m_labelMode{165, bottomLines[2]}; // 75, 15
Label m_labelName{40, bottomLines[3]}; // 40, 15
static const constexpr int bottomLines[4] { 251, 266, 281, 296 };
};
void StatusDisplay::initScreen()
@ -121,8 +151,15 @@ void StatusDisplay::initScreen()
m_labelBrems.start();
m_progressBarBrems.start();
#ifdef GLUMP_CONTROLLER
m_frontStatus.start();
m_backStatus.start();
#endif
#ifdef VESC_CONTROLLER
m_one.start();
m_two.start();
#endif
tft.setTextFont(2);
tft.drawString("WiFi:", 0, bottomLines[0]);
@ -131,9 +168,17 @@ void StatusDisplay::initScreen()
m_labelLimit0.start();
tft.drawString("IP:", 0, bottomLines[1]);
m_labelIpAddress.start();
<<<<<<< HEAD
tft.drawString("Limit1:", 160, bottomLines[1]);
m_labelLimit1.start();
tft.drawString("Performance:", 0, bottomLines[2]);
=======
#ifdef GLUMP_CONTROLLER
tft.drawString("Limit1:", 160, 281);
m_labelLimit1.start();
#endif
tft.drawString("Performance:", 0, 296);
>>>>>>> b343056... vesc control
m_labelPerformance.start();
tft.drawString("Mode:", 125, bottomLines[2]);
m_labelMode.start();
@ -153,14 +198,28 @@ void StatusDisplay::redraw()
m_labelBrems.redraw(String{brems});
m_progressBarBrems.redraw(brems);
#ifdef GLUMP_CONTROLLER
m_frontStatus.redraw(::front);
m_backStatus.redraw(::back);
#endif
#ifdef VESC_CONTROLLER
m_one.redraw(::one);
m_two.redraw(::two);
#endif
tft.setTextFont(2);
m_labelWifiStatus.redraw(toString(WiFi.status()));
#ifdef GLUMP_CONTROLLER
m_labelLimit0.redraw(String{front.command.left.iMotMax} + "A");
#endif
#ifdef VESC_CONTROLLER
m_labelLimit0.redraw(String{settings.limits.iMotMax} + "A");
#endif
m_labelIpAddress.redraw(WiFi.localIP().toString());
#ifdef GLUMP_CONTROLLER
m_labelLimit1.redraw(String{front.command.left.iDcMax} + "A");
#endif
m_labelPerformance.redraw(String{performance.last});
m_labelMode.redraw(currentMode->displayName());
m_labelName.redraw(&deviceName[0]);
@ -181,12 +240,15 @@ void StatusDisplay::rotate(int offset)
void StatusDisplay::BoardStatus::start()
{
tft.setTextFont(4);
#ifdef GLUMP_CONTROLLER
tft.drawString("pwm:", 0, m_y);
m_labelLeftPwm.start();
m_labelRightPwm.start();
drawWarning();
#endif
}
#ifdef GLUMP_CONTROLLER
void StatusDisplay::BoardStatus::redraw(const Controller &controller)
{
tft.setTextFont(4);
@ -227,6 +289,24 @@ void StatusDisplay::BoardStatus::redraw(const Controller &controller)
m_rightMotor.redraw(controller.feedback.right);
}
}
#endif
#ifdef VESC_CONTROLLER
void StatusDisplay::BoardStatus::redraw(const VescController &controller) {
tft.setTextFont(4);
m_labelPwm.redraw(String{controller.pwm});
tft.fillRect(0, m_y+25, tft.width(), 75, TFT_BLACK);
tft.setTextColor(TFT_WHITE);
m_labelSpeed.redraw(String{convertToKmh(controller.values.rpm)});
tft.setTextColor(TFT_WHITE, TFT_BLACK);
}
#endif
void StatusDisplay::BoardStatus::drawWarning()
{
@ -239,6 +319,7 @@ void StatusDisplay::BoardStatus::drawWarning()
tft.setSwapBytes(settings.boardcomputerHardware.swapScreenBytes);
}
#ifdef GLUMP_CONTROLLER
void StatusDisplay::BoardStatus::MotorStatus::start()
{
m_labelError.start();
@ -262,4 +343,5 @@ void StatusDisplay::BoardStatus::MotorStatus::redraw(const MotorFeedback &motor)
tft.setTextColor(TFT_WHITE, TFT_BLACK);
}
#endif
}

View File

@ -7,6 +7,7 @@
#include "bobbycar-protocol/protocol.h"
#ifdef GLUMP_CONTROLLER
namespace {
class FeedbackParser
{
@ -84,3 +85,4 @@ private:
Feedback &m_feedback, m_newFeedback;
};
}
#endif

View File

@ -29,8 +29,15 @@ char deviceName[32];
Settings settings;
SettingsSaver settingsSaver;
#ifdef GLUMP_CONTROLLER
Controller front{Serial1, settings.controllerHardware.enableFrontLeft, settings.controllerHardware.enableFrontRight, settings.controllerHardware.invertFrontLeft, settings.controllerHardware.invertFrontRight};
Controller back{Serial2, settings.controllerHardware.enableBackLeft, settings.controllerHardware.enableBackRight, settings.controllerHardware.invertBackLeft, settings.controllerHardware.invertBackRight};
#endif
#ifdef VESC_CONTROLLER
VescController one{Serial1, settings.controllerHardware.enableOne};
VescController two{Serial2, settings.controllerHardware.enableTwo};
#endif
struct {
unsigned long lastTime = millis();

View File

@ -72,7 +72,9 @@ void setup()
if (settingsSaver.init())
loadSettings();
#ifdef GLUMP_CONTROLLER
updateSwapFrontBack();
#endif
{
uint8_t macAddress[6];
@ -107,16 +109,26 @@ void setup()
} else if (settings.bluetoothMode == BluetoothMode::Slave)
BluetoothBeginAction{}.triggered();
#ifdef GLUMP_CONTROLLER
front.serial.get().begin(38400, SERIAL_8N1, PINS_RX1, PINS_TX1);
back.serial.get().begin(38400, SERIAL_8N1, PINS_RX2, PINS_TX2);
#endif
#ifdef VESC_CONTROLLER
one.serial.get().begin(57600, SERIAL_8N1, PINS_RX1, PINS_TX1);
two.serial.get().begin(57600, SERIAL_8N1, PINS_RX2, PINS_TX2);
Serial.println("vesc begin");
#endif
raw_gas = 0;
raw_brems = 0;
gas = 0;
brems = 0;
#ifdef GLUMP_CONTROLLER
for (Controller &controller : controllers())
controller.command.buzzer = {};
#endif
currentMode = &modes::defaultMode;
@ -194,8 +206,15 @@ void loop()
performance.lastTime = now;
}
#ifdef GLUMP_CONTROLLER
for (Controller &controller : controllers())
controller.parser.update();
#endif
#ifdef VESC_CONTROLLER
for (VescController &controller : controllers())
controller.update();
#endif
handleSerial();

View File

@ -75,6 +75,7 @@ void DefaultMode::update()
lastPwm = pwm;
lastTime = now;
#ifdef GLUMP_CONTROLLER
for (Controller &controller : controllers())
for (MotorState &motor : motorsInController(controller))
{
@ -82,8 +83,18 @@ void DefaultMode::update()
motor.ctrlMod = settings.defaultMode.ctrlMod;
motor.pwm = pwm / 100. * (&controller == &front ? settings.defaultMode.frontPercentage : settings.defaultMode.backPercentage);
}
#endif
#ifdef VESC_CONTROLLER
for (VescController &controller : controllers()) {
controller.pwm = pwm;
Serial.println(String{"new pwm "} + pwm);
}
#endif
#ifdef GLUMP_CONTROLLER
fixCommonParams();
#endif
sendCommands();
}

View File

@ -5,15 +5,26 @@
#include "utils.h"
#include "bobbycar-protocol/protocol.h"
#include "../controller.h"
#include "../utils.h"
namespace {
class IgnoreInputMode : public ModeInterface
{
public:
#ifdef GLUMP_CONTROLLER
IgnoreInputMode(int16_t pwm, ControlType ctrlTyp, ControlMode ctrlMod) :
m_pwm{pwm}, m_ctrlTyp{ctrlTyp}, m_ctrlMod{ctrlMod}
{
}
#endif
#ifdef VESC_CONTROLLER
IgnoreInputMode(int16_t pwm) :
m_pwm{pwm}
{
}
#endif
void update() override;
@ -21,12 +32,15 @@ public:
private:
const int16_t m_pwm;
#ifdef GLUMP_CONTROLLER
const ControlType m_ctrlTyp;
const ControlMode m_ctrlMod;
#endif
};
void IgnoreInputMode::update()
{
#ifdef GLUMP_CONTROLLER
for (MotorState &motor : motors())
{
motor.ctrlTyp = m_ctrlTyp;
@ -35,6 +49,13 @@ void IgnoreInputMode::update()
}
fixCommonParams();
#endif
#ifdef VESC_CONTROLLER
for (VescController &controller : controllers()) {
controller.pwm = m_pwm;
}
#endif
sendCommands();
}

View File

@ -6,6 +6,7 @@
#include "bobbycar-protocol/protocol.h"
#ifdef GLUMP_CONTROLLER
namespace {
class LarsmMode : public ModeInterface
{
@ -108,3 +109,4 @@ void LarsmMode::update()
sendCommands();
}
}
#endif

View File

@ -42,7 +42,7 @@ void TempomatMode::update()
}
pwm += (gas/1000.) - (brems/1000.);
#ifdef GLUMP_CONTROLLER
for (MotorState &motor : motors())
{
motor.ctrlTyp = settings.tempomatMode.ctrlTyp;
@ -51,6 +51,13 @@ void TempomatMode::update()
}
fixCommonParams();
#endif
#ifdef VESC_CONTROLLER
for (VescController &controller : controllers()) {
controller.pwm = pwm;
}
#endif
sendCommands();
}

View File

@ -20,6 +20,7 @@ constexpr Settings::Limits kidsLimits {
};
constexpr Settings::ControllerHardware defaultControllerHardware {
#ifdef GLUMP_CONTROLLER
.enableFrontLeft = true,
.enableFrontRight = true,
.enableBackLeft = true,
@ -30,12 +31,23 @@ constexpr Settings::ControllerHardware defaultControllerHardware {
.invertBackLeft = false,
.invertBackRight = true,
.swapFrontBack = false,
#endif
#ifdef VESC_CONTROLLER
.enableOne = true,
.enableTwo = true,
.invertOne = true,
.invertTwo = true,
#endif
.wheelDiameter = 165,
.numMagnetPoles = 15,
.swapFrontBack = false
};
constexpr Settings::ControllerHardware mosfetsOffControllerHardware {
#ifdef GLUMP_CONTROLLER
.enableFrontLeft = false,
.enableFrontRight = false,
.enableBackLeft = false,
@ -46,11 +58,22 @@ constexpr Settings::ControllerHardware mosfetsOffControllerHardware {
.invertBackLeft = false,
.invertBackRight = true,
.swapFrontBack = false,
#endif
#ifdef VESC_CONTROLLER
.enableOne = false,
.enableTwo = false,
.invertOne = false,
.invertTwo = false,
#endif
.wheelDiameter = 165,
.numMagnetPoles = 15,
.swapFrontBack = false
};
#ifdef GLUMP_CONTROLLER
constexpr Settings::ControllerHardware spinnerControllerHardware {
.enableFrontLeft = true,
.enableFrontRight = true,
@ -62,10 +85,12 @@ constexpr Settings::ControllerHardware spinnerControllerHardware {
.invertBackLeft = false,
.invertBackRight = false,
.swapFrontBack = false,
.wheelDiameter = 165,
.numMagnetPoles = 15,
.swapFrontBack = false
};
#endif
constexpr Settings::BoardcomputerHardware defaultBoardcomputerHardware {
.sampleCount = 100,
@ -85,8 +110,10 @@ constexpr Settings::BoardcomputerHardware defaultBoardcomputerHardware {
};
constexpr Settings::DefaultMode defaultDefaultMode {
#ifdef GLUMP_CONTROLLER
.ctrlTyp = ControlType::FieldOrientedControl,
.ctrlMod = ControlMode::Torque,
#endif
.enableSmoothing = true,
.smoothing = 20,
.frontPercentage = 100,
@ -98,6 +125,7 @@ constexpr Settings::DefaultMode defaultDefaultMode {
.brems2_wert = 750
};
#ifdef GLUMP_CONTROLLER
constexpr Settings::TempomatMode defaultTempomatMode {
.ctrlTyp = ControlType::FieldOrientedControl,
.ctrlMod = ControlMode::Speed
@ -107,6 +135,7 @@ constexpr Settings::LarsmMode defaultLarsmMode {
.mode = LarsmModeMode::Mode4,
.iterations = 100
};
#endif
constexpr Settings defaultSettings{
#ifdef FEATURE_BMS
@ -122,7 +151,10 @@ constexpr Settings defaultSettings{
.controllerHardware = defaultControllerHardware,
.boardcomputerHardware = defaultBoardcomputerHardware,
.defaultMode = defaultDefaultMode,
#ifdef GLUMP_CONTROLLER
.tempomatMode = defaultTempomatMode,
.larsmMode = defaultLarsmMode
#endif
};
}

View File

@ -61,26 +61,35 @@ union X {
#ifdef FEATURE_BMS
BmsMenu bmsMenu;
#endif
#ifdef GLUMP_CONTROLLER
BuzzerMenu buzzerMenu;
FrontCommandDebugMenu frontCommandDebugMenu;
BackCommandDebugMenu backCommandDebugMenu;
#endif
ControllerHardwareSettingsMenu controllerHardwareSettingsMenu;
DebugMenu debugMenu;
DefaultModeSettingsMenu defaultModeSettingsMenu;
DemosMenu demosMenu;
DynamicDebugMenu dynamicDebugMenu;
EnableMenu enableMenu;
#ifdef GLUMP_CONTROLLER
FrontFeedbackDebugMenu frontFeedbackDebugMenu;
BackFeedbackDebugMenu backFeedbackDebugMenu;
#endif
#ifdef FEATURE_GAMETRAK
GametrakModeSettingsMenu gametrakModeSettingsMenu;
#endif
GenericWifiSettingsMenu genericWifiSettingsMenu;
GraphsMenu graphsMenu;
InvertMenu invertMenu;
#ifdef GLUMP_CONTROLLER
LarsmModeSettingsMenu larsmModeSettingsMenu;
#endif
LimitsSettingsMenu limitsSettingsMenu;
MainMenu mainMenu;
#ifdef GLUMP_CONTROLLER
TempomatModeSettingsMenu tempomatModeSettingsMenu;
ModesSettingsMenu modesSettingsMenu;
#ifdef FEATURE_MOSFETS
@ -95,8 +104,13 @@ union X {
BackLeftMotorFeedbackDebugMenu backLeftMotorFeedbackDebugMenu;
BackRightMotorFeedbackDebugMenu backRightMotorFeedbackDebugMenu;
BoardcomputerHardwareSettingsMenu boardcomputerHardwareSettingsMenu;
#endif
PresetsMenu presetsMenu;
#ifdef GLUMP_CONTROLLER
SelectModeMenu selectModeMenu;
#endif
SettingsMenu settingsMenu;
StationWifiSettingsMenu stationWifiSettingsMenu;
WifiScanMenu wifiScanMenu;
@ -114,7 +128,9 @@ union X {
Lockscreen lockScreen;
MetersDisplay metersDisplay;
PingPongDisplay pingPongDisplay;
#ifdef GLUMP_CONTROLLER
PoweroffDisplay poweroffDisplay;
#endif
SpiroDisplay spiroDisplay;
StarfieldDisplay starFieldDisplay;
StatusDisplay statusDisplay;
@ -124,6 +140,7 @@ union X {
BluetoothModeChangeDisplay bluetoothModeChangeDisplay;
#ifdef GLUMP_CONTROLLER
FrontFreqChangeScreen changeFrontFreq;
FrontPatternChangeScreen changeFrontPattern;
BackFreqChangeScreen changeBackFreq;
@ -132,6 +149,7 @@ union X {
ReverseBeepFreq1ChangeScreen changeReverseBeepFreq1;
ReverseBeepDuration0ChangeScreen changeReverseBeepDuration0;
ReverseBeepDuration1ChangeScreen changeReverseBeepDuration1;
#endif
IMotMaxChangeScreen changeIMotMax;
IDcMaxChangeScreen changeIDcMax;
@ -144,22 +162,28 @@ union X {
WheelDiameterInchChangeScreen wheelDiameterInchChangeScreen;
NumMagnetPolesChangeScreen numMagnetPolesChangeScreen;
#ifdef GLUMP_CONTROLLER
DefaultModeCtrlTypChangeDisplay changeDefaultModeCtrlTyp;
DefaultModeCtrlModChangeDisplay changeDefaultModeCtrlMod;
#endif
DefaultModeSmoothingChangeDisplay changeDefaultModeSmoothing;
#ifdef GLUMP_CONTROLLER
DefaultModeFrontPercentageChangeDisplay changeDefaultModeFrontPercentage;
DefaultModeBackPercentageChangeDisplay changeDefaultModeBackPercentage;
#endif
DefaultModeAddSchwelleChangeDisplay changeDefaultModeAddSchwelle;
DefaultModeGas1WertChangeDisplay changeDefaultModeGas1Wert;
DefaultModeGas2WertChangeDisplay changeDefaultModeGas2Wert;
DefaultModeBrems1WertChangeDisplay changeDefaultModeBrems1Wert;
DefaultModeBrems2WertChangeDisplay changeDefaultModeBrems2Wert;
#ifdef GLUMP_CONTROLLER
TempomatModeCtrlTypChangeScreen changeManualModeCtrlTyp;
TempomatModeCtrlModChangeScreen changeManualModeCtrlMod;
LarsmModeModeChangeDisplay larsmModeModeChangeDisplay;
LarsmModeIterationsChangeDisplay larsmModeIterationsChangeDisplay;
#endif
SampleCountChangeScreen sampleCountChangeScreen;
GasMinChangeScreen changeGasMin;
@ -184,15 +208,19 @@ union X {
AvgSpeedKmhGraphDisplay avgSpeedKmhGraphDisplay;
SumCurrentGraphDisplay sumCurrentGraphDisplay;
SumAbsoluteCurrentGraphDisplay sumAbsoluteCurrentGraphDisplay;
#ifdef GLUMP_CONTROLLER
FrontVoltageGraphDisplay frontVoltageGraphDisplay;
BackVoltageGraphDisplay backVoltageGraphDisplay;
#endif
#ifdef FEATURE_BMS
BmsVoltageGraphDisplay bmsVoltageGraphDisplay;
BmsCurrentGraphDisplay bmsCurrentGraphDisplay;
BmsPowerGraphDisplay bmsPowerGraphDisplay;
SumCurrentsComparisonGraphDisplay sumCurrentsComparisonGraphDisplay;
#endif
#ifdef GLUMP_CONTROLLER
MotorCurrentsGraphDisplay motorCurrentsGraphDisplay;
#endif
} displays;
template<typename T> T &getRefByType() = delete;
@ -202,27 +230,35 @@ template<> decltype(displays.bluetoothSettingsMenu) &
#ifdef FEATURE_BMS
template<> decltype(displays.bmsMenu) &getRefByType<decltype(displays.bmsMenu)>() { return displays.bmsMenu; }
#endif
#ifdef GLUMP_CONTROLLER
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.controllerHardwareSettingsMenu) &getRefByType<decltype(displays.controllerHardwareSettingsMenu)>() { return displays.controllerHardwareSettingsMenu; }
template<> decltype(displays.frontCommandDebugMenu) &getRefByType<decltype(displays.frontCommandDebugMenu)>() { return displays.frontCommandDebugMenu; }
template<> decltype(displays.backCommandDebugMenu) &getRefByType<decltype(displays.backCommandDebugMenu)>() { return displays.backCommandDebugMenu; }
#endif
template<> decltype(displays.debugMenu) &getRefByType<decltype(displays.debugMenu)>() { return displays.debugMenu; }
template<> decltype(displays.defaultModeSettingsMenu) &getRefByType<decltype(displays.defaultModeSettingsMenu)>() { return displays.defaultModeSettingsMenu; }
template<> decltype(displays.demosMenu) &getRefByType<decltype(displays.demosMenu)>() { return displays.demosMenu; }
template<> decltype(displays.dynamicDebugMenu) &getRefByType<decltype(displays.dynamicDebugMenu)>() { return displays.dynamicDebugMenu; }
template<> decltype(displays.enableMenu) &getRefByType<decltype(displays.enableMenu)>() { return displays.enableMenu; }
#ifdef GLUMP_CONTROLLER
template<> decltype(displays.frontFeedbackDebugMenu) &getRefByType<decltype(displays.frontFeedbackDebugMenu)>() { return displays.frontFeedbackDebugMenu; }
template<> decltype(displays.backFeedbackDebugMenu) &getRefByType<decltype(displays.backFeedbackDebugMenu)>() { return displays.backFeedbackDebugMenu; }
#endif
#ifdef FEATURE_GAMETRAK
template<> decltype(displays.gametrakModeSettingsMenu) &getRefByType<decltype(displays.gametrakModeSettingsMenu)>() { return displays.gametrakModeSettingsMenu; }
#endif
template<> decltype(displays.genericWifiSettingsMenu) &getRefByType<decltype(displays.genericWifiSettingsMenu)>() { return displays.genericWifiSettingsMenu; }
template<> decltype(displays.graphsMenu) &getRefByType<decltype(displays.graphsMenu)>() { return displays.graphsMenu; }
template<> decltype(displays.invertMenu) &getRefByType<decltype(displays.invertMenu)>() { return displays.invertMenu; }
#ifdef GLUMP_CONTROLLER
template<> decltype(displays.larsmModeSettingsMenu) &getRefByType<decltype(displays.larsmModeSettingsMenu)>() { return displays.larsmModeSettingsMenu; }
#endif
template<> decltype(displays.limitsSettingsMenu) &getRefByType<decltype(displays.limitsSettingsMenu)>() { return displays.limitsSettingsMenu; }
template<> decltype(displays.mainMenu) &getRefByType<decltype(displays.mainMenu)>() { return displays.mainMenu; }
#ifdef GLUMP_CONTROLLER
template<> decltype(displays.tempomatModeSettingsMenu) &getRefByType<decltype(displays.tempomatModeSettingsMenu)>() { return displays.tempomatModeSettingsMenu; }
template<> decltype(displays.modesSettingsMenu) &getRefByType<decltype(displays.modesSettingsMenu)>() { return displays.modesSettingsMenu; }
#ifdef FEATURE_MOSFETS
@ -236,8 +272,11 @@ template<> decltype(displays.frontLeftMotorFeedbackDebugMenu) &
template<> decltype(displays.frontRightMotorFeedbackDebugMenu) &getRefByType<decltype(displays.frontRightMotorFeedbackDebugMenu)>() { return displays.frontRightMotorFeedbackDebugMenu; }
template<> decltype(displays.backLeftMotorFeedbackDebugMenu) &getRefByType<decltype(displays.backLeftMotorFeedbackDebugMenu)>() { return displays.backLeftMotorFeedbackDebugMenu; }
template<> decltype(displays.backRightMotorFeedbackDebugMenu) &getRefByType<decltype(displays.backRightMotorFeedbackDebugMenu)>() { return displays.backRightMotorFeedbackDebugMenu; }
#endif
template<> decltype(displays.presetsMenu) &getRefByType<decltype(displays.presetsMenu)>() { return displays.presetsMenu; }
#ifdef GLUMP_CONTROLLER
template<> decltype(displays.selectModeMenu) &getRefByType<decltype(displays.selectModeMenu)>() { return displays.selectModeMenu; }
#endif
template<> decltype(displays.settingsMenu) &getRefByType<decltype(displays.settingsMenu)>() { return displays.settingsMenu; }
template<> decltype(displays.stationWifiSettingsMenu) &getRefByType<decltype(displays.stationWifiSettingsMenu)>() { return displays.stationWifiSettingsMenu; }
template<> decltype(displays.wifiScanMenu) &getRefByType<decltype(displays.wifiScanMenu)>() { return displays.wifiScanMenu; }
@ -255,7 +294,9 @@ template<> decltype(displays.gametrakCalibrateDisplay) &
template<> decltype(displays.lockScreen) &getRefByType<decltype(displays.lockScreen)>() { return displays.lockScreen; }
template<> decltype(displays.metersDisplay) &getRefByType<decltype(displays.metersDisplay)>() { return displays.metersDisplay; }
template<> decltype(displays.pingPongDisplay) &getRefByType<decltype(displays.pingPongDisplay)>() { return displays.pingPongDisplay; }
#ifdef GLUMP_CONTROLLER
template<> decltype(displays.poweroffDisplay) &getRefByType<decltype(displays.poweroffDisplay)>() { return displays.poweroffDisplay; }
#endif
template<> decltype(displays.spiroDisplay) &getRefByType<decltype(displays.spiroDisplay)>() { return displays.spiroDisplay; }
template<> decltype(displays.starFieldDisplay) &getRefByType<decltype(displays.starFieldDisplay)>() { return displays.starFieldDisplay; }
template<> decltype(displays.statusDisplay) &getRefByType<decltype(displays.statusDisplay)>() { return displays.statusDisplay; }
@ -265,6 +306,7 @@ template<> decltype(displays.updateDisplay) &
template<> decltype(displays.bluetoothModeChangeDisplay) &getRefByType<decltype(displays.bluetoothModeChangeDisplay)>() { return displays.bluetoothModeChangeDisplay; }
#ifdef GLUMP_CONTROLLER
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.changeBackFreq) &getRefByType<decltype(displays.changeBackFreq)>() { return displays.changeBackFreq; }
@ -273,6 +315,7 @@ template<> decltype(displays.changeReverseBeepFreq0) &
template<> decltype(displays.changeReverseBeepFreq1) &getRefByType<decltype(displays.changeReverseBeepFreq1)>() { return displays.changeReverseBeepFreq1; }
template<> decltype(displays.changeReverseBeepDuration0) &getRefByType<decltype(displays.changeReverseBeepDuration0)>() { return displays.changeReverseBeepDuration0; }
template<> decltype(displays.changeReverseBeepDuration1) &getRefByType<decltype(displays.changeReverseBeepDuration1)>() { return displays.changeReverseBeepDuration1; }
#endif
template<> decltype(displays.changeIMotMax) &getRefByType<decltype(displays.changeIMotMax)>() { return displays.changeIMotMax; }
template<> decltype(displays.changeIDcMax) &getRefByType<decltype(displays.changeIDcMax)>() { return displays.changeIDcMax; }
@ -285,6 +328,7 @@ template<> decltype(displays.wheelDiameterMmChangeScreen) &
template<> decltype(displays.wheelDiameterInchChangeScreen) &getRefByType<decltype(displays.wheelDiameterInchChangeScreen)>() { return displays.wheelDiameterInchChangeScreen; }
template<> decltype(displays.numMagnetPolesChangeScreen) &getRefByType<decltype(displays.numMagnetPolesChangeScreen)>() { return displays.numMagnetPolesChangeScreen; }
#ifdef GLUMP_CONTROLLER
template<> decltype(displays.changeDefaultModeCtrlTyp) &getRefByType<decltype(displays.changeDefaultModeCtrlTyp)>() { return displays.changeDefaultModeCtrlTyp; }
template<> decltype(displays.changeDefaultModeCtrlMod) &getRefByType<decltype(displays.changeDefaultModeCtrlMod)>() { return displays.changeDefaultModeCtrlMod; }
template<> decltype(displays.changeDefaultModeSmoothing) &getRefByType<decltype(displays.changeDefaultModeSmoothing)>() { return displays.changeDefaultModeSmoothing; }
@ -301,7 +345,7 @@ template<> decltype(displays.changeManualModeCtrlMod) &
template<> decltype(displays.larsmModeModeChangeDisplay) &getRefByType<decltype(displays.larsmModeModeChangeDisplay)>() { return displays.larsmModeModeChangeDisplay; }
template<> decltype(displays.larsmModeIterationsChangeDisplay) &getRefByType<decltype(displays.larsmModeIterationsChangeDisplay)>() { return displays.larsmModeIterationsChangeDisplay; }
#endif
template<> decltype(displays.sampleCountChangeScreen) &getRefByType<decltype(displays.sampleCountChangeScreen)>() { return displays.sampleCountChangeScreen; }
template<> decltype(displays.changeGasMin) &getRefByType<decltype(displays.changeGasMin)>() { return displays.changeGasMin; }
template<> decltype(displays.changeGasMax) &getRefByType<decltype(displays.changeGasMax)>() { return displays.changeGasMax; }
@ -325,15 +369,19 @@ template<> decltype(displays.avgSpeedGraphDisplay) &
template<> decltype(displays.avgSpeedKmhGraphDisplay) &getRefByType<decltype(displays.avgSpeedKmhGraphDisplay)>() { return displays.avgSpeedKmhGraphDisplay; }
template<> decltype(displays.sumCurrentGraphDisplay) &getRefByType<decltype(displays.sumCurrentGraphDisplay)>() { return displays.sumCurrentGraphDisplay; }
template<> decltype(displays.sumAbsoluteCurrentGraphDisplay) &getRefByType<decltype(displays.sumAbsoluteCurrentGraphDisplay)>() { return displays.sumAbsoluteCurrentGraphDisplay; }
#ifdef GLUMP_CONTROLLER
template<> decltype(displays.frontVoltageGraphDisplay) &getRefByType<decltype(displays.frontVoltageGraphDisplay)>() { return displays.frontVoltageGraphDisplay; }
template<> decltype(displays.backVoltageGraphDisplay) &getRefByType<decltype(displays.backVoltageGraphDisplay)>() { return displays.backVoltageGraphDisplay; }
#endif
#ifdef FEATURE_BMS
template<> decltype(displays.bmsVoltageGraphDisplay) &getRefByType<decltype(displays.bmsVoltageGraphDisplay)>() { return displays.bmsVoltageGraphDisplay; }
template<> decltype(displays.bmsCurrentGraphDisplay) &getRefByType<decltype(displays.bmsCurrentGraphDisplay)>() { return displays.bmsCurrentGraphDisplay; }
template<> decltype(displays.bmsPowerGraphDisplay) &getRefByType<decltype(displays.bmsPowerGraphDisplay)>() { return displays.bmsPowerGraphDisplay; }
template<> decltype(displays.sumCurrentsComparisonGraphDisplay) &getRefByType<decltype(displays.sumCurrentsComparisonGraphDisplay)>() { return displays.sumCurrentsComparisonGraphDisplay; }
#endif
#ifdef GLUMP_CONTROLLER
template<> decltype(displays.motorCurrentsGraphDisplay) &getRefByType<decltype(displays.motorCurrentsGraphDisplay)>() { return displays.motorCurrentsGraphDisplay; }
#endif
void deconstructScreen()

View File

@ -39,6 +39,7 @@ void handleSerial()
case 'I':
tft.init();
break;
#ifdef GLUMP_CONTROLLER
case 'p':
case 'P':
{
@ -55,6 +56,7 @@ void handleSerial()
controller.command.led = !firstLed;
break;
}
#endif
case 'r':
case 'R':
loadSettings();
@ -63,6 +65,7 @@ void handleSerial()
case 'S':
saveSettings();
break;
#ifdef GLUMP_CONTROLLER
case '0':
case '1':
case '2':
@ -76,6 +79,7 @@ void handleSerial()
for (Controller &controller : controllers())
controller.command.buzzer.freq = c-'0';
break;
#endif
case 'A':
InputDispatcher::rotate(-1);
break;

View File

@ -7,7 +7,9 @@
#include "bluetoothmode.h"
namespace {
#ifdef GLUMP_CONTROLLER
enum class LarsmModeMode : uint8_t { Mode1, Mode2, Mode3, Mode4 };
#endif
struct Settings
{
@ -32,12 +34,19 @@ struct Settings
} limits;
struct ControllerHardware {
#ifdef GLUMP_CONTROLLER
bool enableFrontLeft, enableFrontRight, enableBackLeft, enableBackRight;
bool invertFrontLeft, invertFrontRight, invertBackLeft, invertBackRight;
bool swapFrontBack;
#endif
#ifdef VESC_CONTROLLER
bool enableOne, enableTwo;
bool invertOne, invertTwo;
#endif
int16_t wheelDiameter; // in mm
int16_t numMagnetPoles; // virtual RPM per one real RPM
bool swapFrontBack;
} controllerHardware;
struct BoardcomputerHardware {
@ -50,8 +59,10 @@ struct Settings
} boardcomputerHardware;
struct DefaultMode {
#ifdef GLUMP_CONTROLLER
ControlType ctrlTyp;
ControlMode ctrlMod;
#endif
bool enableSmoothing;
int16_t smoothing;
int16_t frontPercentage;
@ -64,15 +75,18 @@ struct Settings
} defaultMode;
struct TempomatMode {
#ifdef GLUMP_CONTROLLER
ControlType ctrlTyp;
ControlMode ctrlMod;
#endif
} tempomatMode;
#ifdef GLUMP_CONTROLLER
struct LarsmMode {
LarsmModeMode mode;
uint8_t iterations;
} larsmMode;
#endif
template<typename T>
void executeForEverySetting(T &&callable);
@ -99,6 +113,7 @@ void Settings::executeForEverySetting(T &&callable)
callable("fieldWeakMax", limits.fieldWeakMax);
callable("phaseAdvMax", limits.phaseAdvMax);
#ifdef GLUMP_CONTROLLER
callable("enableFrontLeft", controllerHardware.enableFrontLeft);
callable("enableFrontRigh", controllerHardware.enableFrontRight);
callable("enableBackLeft", controllerHardware.enableBackLeft);
@ -110,6 +125,12 @@ void Settings::executeForEverySetting(T &&callable)
callable("invertBackRight", controllerHardware.invertBackRight);
callable("swapFrontBack", controllerHardware.swapFrontBack);
#endif
#ifdef VESC_CONTROLLER
callable("enableOne", controllerHardware.enableOne);
callable("enableTwo", controllerHardware.enableTwo);
#endif
callable("sampleCount", boardcomputerHardware.sampleCount);
callable("gasMin", boardcomputerHardware.gasMin);
@ -126,6 +147,7 @@ void Settings::executeForEverySetting(T &&callable)
#endif
callable("swapScreenBytes", boardcomputerHardware.swapScreenBytes);
#ifdef GLUMP_CONTROLLER
callable("default.ctrlTyp", defaultMode.ctrlTyp);
callable("default.ctrlMod", defaultMode.ctrlMod);
callable("default.enableS", defaultMode.enableSmoothing);
@ -143,5 +165,6 @@ void Settings::executeForEverySetting(T &&callable)
callable("larsm.mode", larsmMode.mode);
callable("larsm.iters", larsmMode.iterations);
#endif
}
}

View File

@ -33,6 +33,7 @@ struct NMotMaxRpmAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &g
struct FieldWeakMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.limits.fieldWeakMax; } };
struct PhaseAdvMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.limits.phaseAdvMax; } };
#ifdef GLUMP_CONTROLLER
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 BackLeftEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.enableBackLeft; } };
@ -42,6 +43,14 @@ struct FrontLeftInvertedAccessor : public RefAccessorSaveSettings<bool> { bool &
struct FrontRightInvertedAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.invertFrontRight; } };
struct BackLeftInvertedAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.invertBackLeft; } };
struct BackRightInvertedAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.invertBackRight; } };
#endif
#ifdef VESC_CONTROLLER
struct OneEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.enableOne; } };
struct TwoEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.enableTwo; } };
struct OneInvertedAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.invertOne; } };
struct TwoInvertedAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.invertTwo; } };
#endif
struct WheelDiameterMmAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.controllerHardware.wheelDiameter; } };
struct WheelDiameterInchAccessor : public virtual AccessorInterface<float>
@ -50,10 +59,13 @@ struct WheelDiameterInchAccessor : public virtual AccessorInterface<float>
void setValue(float value) override { settings.controllerHardware.wheelDiameter = convertFromInch(value); saveSettings(); }
};
struct NumMagnetPolesAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.controllerHardware.numMagnetPoles; } };
#ifdef GLUMP_CONTROLLER
struct SwapFrontBackAccessor : public RefAccessorSaveSettings<bool> {
bool &getRef() const override { return settings.controllerHardware.swapFrontBack; }
void setValue(bool value) override { RefAccessorSaveSettings<bool>::setValue(value); updateSwapFrontBack(); };
};
#endif
struct SampleCountAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.sampleCount; } };
struct GasMinAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.boardcomputerHardware.gasMin; } };
@ -70,8 +82,10 @@ struct GametrakDistMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16
#endif
struct SwapScreenBytesAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.boardcomputerHardware.swapScreenBytes; } };
#ifdef GLUMP_CONTROLLER
struct DefaultModeCtrlTypAccessor : public RefAccessorSaveSettings<ControlType> { ControlType &getRef() const override { return settings.defaultMode.ctrlTyp; } };
struct DefaultModeCtrlModAccessor : public RefAccessorSaveSettings<ControlMode> { ControlMode &getRef() const override { return settings.defaultMode.ctrlMod; } };
#endif
struct DefaultModeEnableSmoothingAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.defaultMode.enableSmoothing; } };
struct DefaultModeSmoothingAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.defaultMode.smoothing; } };
struct DefaultModeFrontPercentageAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.defaultMode.frontPercentage; } };
@ -82,9 +96,11 @@ struct DefaultModeGas2WertAccessor : public RefAccessorSaveSettings<int16_t> { i
struct DefaultModeBrems1WertAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.defaultMode.brems1_wert; } };
struct DefaultModeBrems2WertAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.defaultMode.brems2_wert; } };
#ifdef GLUMP_CONTROLLER
struct TempomatModeCtrlTypAccessor : public RefAccessorSaveSettings<ControlType> { ControlType &getRef() const override { return settings.tempomatMode.ctrlTyp; } };
struct TempomatModeCtrlModAccessor : public RefAccessorSaveSettings<ControlMode> { ControlMode &getRef() const override { return settings.tempomatMode.ctrlMod; } };
struct LarsmModeModeAccessor : public RefAccessorSaveSettings<LarsmModeMode> { LarsmModeMode &getRef() const override { return settings.larsmMode.mode; } };
struct LarsmModeIterationsAccessor : public RefAccessorSaveSettings<uint8_t> { uint8_t &getRef() const override { return settings.larsmMode.iterations; } };
#endif
}

View File

@ -68,6 +68,7 @@ template<> struct nvsGetterHelper<bool> { static esp_err_t nvs_get(nvs_handle ha
*out_value = tempValue;
return err;
}};
#ifdef GLUMP_CONTROLLER
template<> struct nvsGetterHelper<ControlType> { static esp_err_t nvs_get(nvs_handle handle, const char* key, ControlType* out_value)
{
uint8_t tempValue;
@ -92,6 +93,7 @@ template<> struct nvsGetterHelper<LarsmModeMode> { static esp_err_t nvs_get(nvs_
*out_value = LarsmModeMode(tempValue);
return err;
}};
#endif
template<> struct nvsGetterHelper<BluetoothMode> { static esp_err_t nvs_get(nvs_handle handle, const char* key, BluetoothMode* out_value)
{
uint8_t tempValue;
@ -126,6 +128,7 @@ template<> struct nvsSetterHelper<uint16_t> { static constexpr auto nvs_set = &n
template<> struct nvsSetterHelper<int32_t> { static constexpr auto nvs_set = &nvs_set_i32; };
template<> struct nvsSetterHelper<uint32_t> { static constexpr auto nvs_set = &nvs_set_u32; };
template<> struct nvsSetterHelper<bool> { static constexpr auto nvs_set = &nvs_set_u8; };
#ifdef GLUMP_CONTROLLER
template<> struct nvsSetterHelper<ControlType> { static esp_err_t nvs_set(nvs_handle handle, const char* key, ControlType value)
{
return nvs_set_u8(handle, key, uint8_t(value));
@ -138,6 +141,7 @@ template<> struct nvsSetterHelper<LarsmModeMode> { static esp_err_t nvs_set(nvs_
{
return nvs_set_u8(handle, key, uint8_t(value));
}};
#endif
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));

View File

@ -9,7 +9,11 @@
namespace {
namespace statistics {
using ContainerType = ring_buffer<float, 200>;
ContainerType gas, brems, avgSpeed, avgSpeedKmh, sumCurrent, sumAbsoluteCurrent, frontVoltage, backVoltage, frontLeftCurrent, frontRightCurrent, backLeftCurrent, backRightCurrent
ContainerType gas, brems, avgSpeed, avgSpeedKmh, sumCurrent, sumAbsoluteCurrent
#ifdef GLUMP_CONTROLLER
, frontVoltage, backVoltage, frontLeftCurrent, frontRightCurrent, backLeftCurrent, backRightCurrent
#endif
#ifdef FEATURE_BMS
, bmsVoltage, bmsCurrent, bmsPower
#endif
@ -24,6 +28,7 @@ void pushStats()
statistics::avgSpeedKmh.push_back(avgSpeedKmh);
statistics::sumCurrent.push_back(sumCurrent);
statistics::sumAbsoluteCurrent.push_back(sumAbsoluteCurrent);
#ifdef GLUMP_CONTROLLER
if (front.feedbackValid)
{
statistics::frontVoltage.push_back(fixBatVoltage(front.feedback.batVoltage));
@ -36,6 +41,7 @@ void pushStats()
statistics::backLeftCurrent.push_back(fixCurrent(back.feedback.left.current));
statistics::backRightCurrent.push_back(fixCurrent(back.feedback.right.current));
}
#endif
#ifdef FEATURE_BMS
statistics::bmsVoltage.push_back(bms::voltage);
statistics::bmsCurrent.push_back(bms::current);
@ -62,15 +68,19 @@ using AvgSpeedStatistics = BufferAccessorImpl<statistics::avgSpeed>;
using AvgSpeedKmhStatistics = BufferAccessorImpl<statistics::avgSpeedKmh>;
using SumCurrentStatistics = BufferAccessorImpl<statistics::sumCurrent>;
using SumAbsoluteCurrentStatistics = BufferAccessorImpl<statistics::sumAbsoluteCurrent>;
#ifdef GLUMP_CONTROLLER
using FrontVoltageStatistics = BufferAccessorImpl<statistics::frontVoltage>;
using BackVoltageStatistics = BufferAccessorImpl<statistics::backVoltage>;
#endif
#ifdef FEATURE_BMS
using BmsVoltageStatistics = BufferAccessorImpl<statistics::bmsVoltage>;
using BmsCurrentStatistics = BufferAccessorImpl<statistics::bmsCurrent>;
using BmsPowerStatistics = BufferAccessorImpl<statistics::bmsPower>;
#endif
#ifdef GLUMP_CONTROLLER
using FrontLeftCurrentStatistics = BufferAccessorImpl<statistics::frontLeftCurrent>;
using FrontRightCurrentStatistics = BufferAccessorImpl<statistics::frontRightCurrent>;
using BackLeftCurrentStatistics = BufferAccessorImpl<statistics::backLeftCurrent>;
using BackRightCurrentStatistics = BufferAccessorImpl<statistics::backRightCurrent>;
#endif
}

View File

@ -8,6 +8,7 @@
#include "display.h"
#include "globals.h"
#include "VescUartControl-VESC6/VescUart.h"
namespace {
bool currentlyReverseBeeping;
@ -63,10 +64,12 @@ float fixBoardTemp(int16_t value)
return value/10.;
}
#ifdef GLUMP_CONTROLLER
String hallString(const MotorFeedback &motor)
{
return String{} + (motor.hallA ? '1' : '0') + (motor.hallB ? '1' : '0') + (motor.hallC ? '1' : '0');
}
#endif
template<typename T>
String toString(T value)
@ -80,6 +83,7 @@ String toString<bool>(bool value)
return value ? "true" : "false";
}
#ifdef GLUMP_CONTROLLER
template<>
String toString<ControlType>(ControlType value)
{
@ -104,6 +108,7 @@ String toString<ControlMode>(ControlMode value)
}
return String("Unknown: ") + int(value);
}
#endif
template<>
String toString<wl_status_t>(wl_status_t value)
@ -138,6 +143,7 @@ String toString<ota_error_t>(ota_error_t value)
return String("Unknown: ") + int(value);
}
#ifdef GLUMP_CONTROLLER
std::array<std::reference_wrapper<Controller>, 2> controllers()
{
return {front, back};
@ -245,25 +251,44 @@ void sendCommands()
}
}
template<typename T, typename... Args>
void switchScreen(Args&&... args);
void updateSwapFrontBack()
{
front.serial = settings.controllerHardware.swapFrontBack ? Serial2 : Serial1;
back.serial = settings.controllerHardware.swapFrontBack ? Serial1 : Serial2;
}
#endif
void loadSettings()
#ifdef VESC_CONTROLLER
std::array<std::reference_wrapper<VescController>, 2> controllers()
{
settingsSaver.load(settings);
return {one, two};
}
void saveSettings()
{
settingsSaver.save(settings);
float mapfloat(float x, float in_min, float in_max, float out_min, float out_max) {
float r = (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
if (r < out_min)r = out_min;
if (r > out_max)r = out_max;
return r;
}
void sendCommands()
{
for (VescController &controller : controllers())
{
SetSerialPort(&controller.serial.get());
SetDebugSerialPort(NULL);
float current = mapfloat(controller.pwm, -1000, 1000, -settings.limits.iMotMax, settings.limits.iMotMax);
Serial.println(String{"New current "} + current);
VescUartSetCurrent(current);
}
}
#endif
void updateAccumulators()
{
avgSpeed = 0.f;
@ -271,6 +296,7 @@ void updateAccumulators()
sumAbsoluteCurrent = 0.f;
uint8_t count{0};
#ifdef GLUMP_CONTROLLER
for (const Controller &controller : controllers())
{
if (!controller.feedbackValid)
@ -290,6 +316,17 @@ void updateAccumulators()
count +=2;
}
#endif
#ifdef VESC_CONTROLLER
for (VescController &controller : controllers()) {
avgSpeed += controller.values.rpm;
sumCurrent += controller.values.avgMotorCurrent;
sumAbsoluteCurrent += std::abs(controller.values.avgMotorCurrent);
count += 2;
}
#endif
if (count)
avgSpeed /= count;
@ -300,6 +337,20 @@ void updateAccumulators()
avgSpeedKmh = convertToKmh(avgSpeed);
}
template<typename T, typename... Args>
void switchScreen(Args&&... args);
void loadSettings()
{
settingsSaver.load(settings);
}
void saveSettings()
{
settingsSaver.save(settings);
}
void readPotis()
{
const auto sampleMultipleTimes = [](int pin){