implement invert for vesc controller; add menu items

This commit is contained in:
Patrick Pichler
2020-05-30 23:21:12 +02:00
committed by 0xFEEDC0DE64
parent 4dda961d88
commit 4077185010
5 changed files with 10 additions and 6 deletions

View File

@ -35,13 +35,14 @@ struct Controller {
#ifdef VESC_CONTROLLER
struct VescController {
VescController(HardwareSerial &serial, bool &enable) :
serial{serial}, enable{enable}
VescController(HardwareSerial &serial, bool &enable, bool &invert) :
serial{serial}, enable{enable}, invert{invert}
{
}
std::reference_wrapper<HardwareSerial> serial;
bool &enable;
bool &invert;
bldcMeasure values;

View File

@ -56,6 +56,7 @@ class SettingsMenu :
makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHSETTINGS>, SwitchScreenAction<BluetoothSettingsMenu>, StaticMenuItemIcon<&icons::bluetooth>>,
#ifdef GLUMP_CONTROLLER
makeComponent<MenuItem, StaticText<TEXT_MODESSETTINGS>, SwitchScreenAction<ModesSettingsMenu>>,
#endif
makeComponent<MenuItem, StaticText<TEXT_CONTROLLERHARDWARESETTINGS>, SwitchScreenAction<ControllerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
makeComponent<MenuItem, StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&icons::hardware>>,
#endif

View File

@ -35,8 +35,8 @@ Controller back{Serial2, settings.controllerHardware.enableBackLeft, settings.co
#endif
#ifdef VESC_CONTROLLER
VescController one{Serial1, settings.controllerHardware.enableOne};
VescController two{Serial2, settings.controllerHardware.enableTwo};
VescController one{Serial1, settings.controllerHardware.enableOne, settings.controllerHardware.invertOne};
VescController two{Serial2, settings.controllerHardware.enableTwo, settings.controllerHardware.invertTwo};
#endif
struct {

View File

@ -103,8 +103,8 @@ union X {
FrontRightMotorFeedbackDebugMenu frontRightMotorFeedbackDebugMenu;
BackLeftMotorFeedbackDebugMenu backLeftMotorFeedbackDebugMenu;
BackRightMotorFeedbackDebugMenu backRightMotorFeedbackDebugMenu;
BoardcomputerHardwareSettingsMenu boardcomputerHardwareSettingsMenu;
#endif
BoardcomputerHardwareSettingsMenu boardcomputerHardwareSettingsMenu;
PresetsMenu presetsMenu;
#ifdef GLUMP_CONTROLLER
@ -232,8 +232,10 @@ template<> decltype(displays.bmsMenu) &
#endif
#ifdef GLUMP_CONTROLLER
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.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.backCommandDebugMenu) &getRefByType<decltype(displays.backCommandDebugMenu)>() { return displays.backCommandDebugMenu; }
#endif

View File

@ -279,7 +279,7 @@ void sendCommands()
SetSerialPort(&controller.serial.get());
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);