implement invert for vesc controller; add menu items
This commit is contained in:
@ -35,13 +35,14 @@ struct Controller {
|
|||||||
|
|
||||||
#ifdef VESC_CONTROLLER
|
#ifdef VESC_CONTROLLER
|
||||||
struct VescController {
|
struct VescController {
|
||||||
VescController(HardwareSerial &serial, bool &enable) :
|
VescController(HardwareSerial &serial, bool &enable, bool &invert) :
|
||||||
serial{serial}, enable{enable}
|
serial{serial}, enable{enable}, invert{invert}
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
std::reference_wrapper<HardwareSerial> serial;
|
std::reference_wrapper<HardwareSerial> serial;
|
||||||
bool &enable;
|
bool &enable;
|
||||||
|
bool &invert;
|
||||||
|
|
||||||
bldcMeasure values;
|
bldcMeasure values;
|
||||||
|
|
||||||
|
@ -56,6 +56,7 @@ class SettingsMenu :
|
|||||||
makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHSETTINGS>, SwitchScreenAction<BluetoothSettingsMenu>, StaticMenuItemIcon<&icons::bluetooth>>,
|
makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHSETTINGS>, SwitchScreenAction<BluetoothSettingsMenu>, StaticMenuItemIcon<&icons::bluetooth>>,
|
||||||
#ifdef GLUMP_CONTROLLER
|
#ifdef GLUMP_CONTROLLER
|
||||||
makeComponent<MenuItem, StaticText<TEXT_MODESSETTINGS>, SwitchScreenAction<ModesSettingsMenu>>,
|
makeComponent<MenuItem, StaticText<TEXT_MODESSETTINGS>, SwitchScreenAction<ModesSettingsMenu>>,
|
||||||
|
#endif
|
||||||
makeComponent<MenuItem, StaticText<TEXT_CONTROLLERHARDWARESETTINGS>, SwitchScreenAction<ControllerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
|
makeComponent<MenuItem, StaticText<TEXT_CONTROLLERHARDWARESETTINGS>, SwitchScreenAction<ControllerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
|
||||||
makeComponent<MenuItem, StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
|
makeComponent<MenuItem, StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,8 +35,8 @@ Controller back{Serial2, settings.controllerHardware.enableBackLeft, settings.co
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef VESC_CONTROLLER
|
#ifdef VESC_CONTROLLER
|
||||||
VescController one{Serial1, settings.controllerHardware.enableOne};
|
VescController one{Serial1, settings.controllerHardware.enableOne, settings.controllerHardware.invertOne};
|
||||||
VescController two{Serial2, settings.controllerHardware.enableTwo};
|
VescController two{Serial2, settings.controllerHardware.enableTwo, settings.controllerHardware.invertTwo};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct {
|
struct {
|
||||||
|
@ -103,8 +103,8 @@ union X {
|
|||||||
FrontRightMotorFeedbackDebugMenu frontRightMotorFeedbackDebugMenu;
|
FrontRightMotorFeedbackDebugMenu frontRightMotorFeedbackDebugMenu;
|
||||||
BackLeftMotorFeedbackDebugMenu backLeftMotorFeedbackDebugMenu;
|
BackLeftMotorFeedbackDebugMenu backLeftMotorFeedbackDebugMenu;
|
||||||
BackRightMotorFeedbackDebugMenu backRightMotorFeedbackDebugMenu;
|
BackRightMotorFeedbackDebugMenu backRightMotorFeedbackDebugMenu;
|
||||||
BoardcomputerHardwareSettingsMenu boardcomputerHardwareSettingsMenu;
|
|
||||||
#endif
|
#endif
|
||||||
|
BoardcomputerHardwareSettingsMenu boardcomputerHardwareSettingsMenu;
|
||||||
PresetsMenu presetsMenu;
|
PresetsMenu presetsMenu;
|
||||||
|
|
||||||
#ifdef GLUMP_CONTROLLER
|
#ifdef GLUMP_CONTROLLER
|
||||||
@ -232,8 +232,10 @@ template<> decltype(displays.bmsMenu) &
|
|||||||
#endif
|
#endif
|
||||||
#ifdef GLUMP_CONTROLLER
|
#ifdef GLUMP_CONTROLLER
|
||||||
template<> decltype(displays.buzzerMenu) &getRefByType<decltype(displays.buzzerMenu)>() { return displays.buzzerMenu; }
|
template<> decltype(displays.buzzerMenu) &getRefByType<decltype(displays.buzzerMenu)>() { return displays.buzzerMenu; }
|
||||||
|
#endif
|
||||||
template<> decltype(displays.boardcomputerHardwareSettingsMenu) &getRefByType<decltype(displays.boardcomputerHardwareSettingsMenu)>() { return displays.boardcomputerHardwareSettingsMenu; }
|
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.controllerHardwareSettingsMenu) &getRefByType<decltype(displays.controllerHardwareSettingsMenu)>() { return displays.controllerHardwareSettingsMenu; }
|
||||||
|
#ifdef GLUMP_CONTROLLER
|
||||||
template<> decltype(displays.frontCommandDebugMenu) &getRefByType<decltype(displays.frontCommandDebugMenu)>() { return displays.frontCommandDebugMenu; }
|
template<> decltype(displays.frontCommandDebugMenu) &getRefByType<decltype(displays.frontCommandDebugMenu)>() { return displays.frontCommandDebugMenu; }
|
||||||
template<> decltype(displays.backCommandDebugMenu) &getRefByType<decltype(displays.backCommandDebugMenu)>() { return displays.backCommandDebugMenu; }
|
template<> decltype(displays.backCommandDebugMenu) &getRefByType<decltype(displays.backCommandDebugMenu)>() { return displays.backCommandDebugMenu; }
|
||||||
#endif
|
#endif
|
||||||
|
@ -279,7 +279,7 @@ void sendCommands()
|
|||||||
SetSerialPort(&controller.serial.get());
|
SetSerialPort(&controller.serial.get());
|
||||||
SetDebugSerialPort(NULL);
|
SetDebugSerialPort(NULL);
|
||||||
|
|
||||||
float current = mapfloat(controller.pwm, -1000, 1000, -settings.limits.iMotMax, settings.limits.iMotMax);
|
float current = mapfloat(controller.pwm * (controller.invert ? -1. : 1.), -1000, 1000, -settings.limits.iMotMax, settings.limits.iMotMax);
|
||||||
|
|
||||||
Serial.println(String{"New current "} + current);
|
Serial.println(String{"New current "} + current);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user