transfered settings.bleSettings and settings.controllerHardware
This commit is contained in:
@@ -9,11 +9,6 @@
|
|||||||
#include "accessorhelpers.h"
|
#include "accessorhelpers.h"
|
||||||
#include "newsettings.h"
|
#include "newsettings.h"
|
||||||
|
|
||||||
// Bms
|
|
||||||
#ifdef FEATURE_BMS
|
|
||||||
struct AutoConnectBmsAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.autoConnectBms; } };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Bluetooth
|
// Bluetooth
|
||||||
struct BluetoothNameAccessor : public NewSettingsAccessor<std::string> { ConfigWrapper<std::string> &getConfig() const override { return configs.bluetoothName; } };
|
struct BluetoothNameAccessor : public NewSettingsAccessor<std::string> { ConfigWrapper<std::string> &getConfig() const override { return configs.bluetoothName; } };
|
||||||
|
|
||||||
@@ -42,14 +37,9 @@ 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 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; } };
|
struct PhaseAdvMaxAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.limits.phaseAdvMax; } };
|
||||||
|
|
||||||
// Bluetooth
|
|
||||||
#ifdef FEATURE_BLUETOOTH
|
|
||||||
struct AutoBluetoothModeAccessor : public RefAccessorSaveSettings<BluetoothMode> { BluetoothMode &getRef() const override { return settings.bluetoothSettings.autoBluetoothMode; } };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Bluetooth Low Energy
|
// Bluetooth Low Energy
|
||||||
#ifdef FEATURE_BLE
|
#ifdef FEATURE_BLE
|
||||||
struct BleEnabledAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.bleSettings.bleEnabled; } };
|
struct BleEnabledAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.bleSettings.bleEnabled; } };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Cloud
|
// Cloud
|
||||||
@@ -81,32 +71,38 @@ struct FrontRightInvertedAccessor : public RefAccessorSaveSettings<bool> { bool
|
|||||||
struct BackLeftInvertedAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.invertBackLeft; } };
|
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; } };
|
struct BackRightInvertedAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.invertBackRight; } };
|
||||||
|
|
||||||
struct WheelDiameterMmAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.controllerHardware.wheelDiameter; } };
|
struct WheelDiameterMmAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.controllerHardware.wheelDiameter; } };
|
||||||
struct WheelDiameterInchAccessor : public virtual espgui::AccessorInterface<float>
|
struct WheelDiameterInchAccessor : public virtual espgui::AccessorInterface<float>
|
||||||
{
|
{
|
||||||
float getValue() const override { return convertToInch(settings.controllerHardware.wheelDiameter); }
|
float getValue() const override { return convertToInch(configs.controllerHardware.wheelDiameter.value); }
|
||||||
espgui::AccessorInterface<int16_t>::setter_result_t setValue(float value) override
|
espgui::AccessorInterface<int16_t>::setter_result_t setValue(float value) override
|
||||||
{
|
{
|
||||||
settings.controllerHardware.wheelDiameter = convertFromInch(value);
|
// settings.controllerHardware.wheelDiameter = convertFromInch(value);
|
||||||
if (!saveSettings())
|
// if (!saveSettings())
|
||||||
return tl::make_unexpected("saveSettings() failed!");
|
// return tl::make_unexpected("saveSettings() failed!");
|
||||||
return {};
|
// return {};
|
||||||
|
return configs.write_config(configs.controllerHardware.wheelDiameter, convertFromInch(value));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
struct NumMagnetPolesAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.controllerHardware.numMagnetPoles; } };
|
struct NumMagnetPolesAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.controllerHardware.numMagnetPoles; } };
|
||||||
struct SwapFrontBackAccessor : public RefAccessorSaveSettings<bool> {
|
struct SwapFrontBackAccessor : public virtual espgui::AccessorInterface<bool> {
|
||||||
bool &getRef() const override { return settings.controllerHardware.swapFrontBack; }
|
bool getValue() const override { return configs.controllerHardware.swapFrontBack.value; }
|
||||||
|
setter_result_t setValue(bool value) override
|
||||||
|
{
|
||||||
|
const auto err = configs.write_config(configs.controllerHardware.swapFrontBack, value);
|
||||||
#ifdef FEATURE_SERIAL
|
#ifdef FEATURE_SERIAL
|
||||||
void setValue(bool value) override { RefAccessorSaveSettings<bool>::setValue(value); updateSwapFrontBack(); };
|
updateSwapFrontBack();
|
||||||
#endif
|
#endif
|
||||||
|
return err;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// CAN
|
// CAN
|
||||||
#ifdef FEATURE_CAN
|
#ifdef FEATURE_CAN
|
||||||
struct SendFrontCanCmdAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.sendFrontCanCmd; } };
|
struct SendFrontCanCmdAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.controllerHardware.sendFrontCanCmd; } };
|
||||||
struct SendBackCanCmdAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.controllerHardware.sendBackCanCmd; } };
|
struct SendBackCanCmdAccessor : public NewSettingsAccessor<bool> { ConfigWrapper<bool> &getConfig() const override { return configs.controllerHardware.sendBackCanCmd; } };
|
||||||
struct CanTransmitTimeoutAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.controllerHardware.canTransmitTimeout; } };
|
struct CanTransmitTimeoutAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.controllerHardware.canTransmitTimeout; } };
|
||||||
struct CanReceiveTimeoutAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.controllerHardware.canReceiveTimeout; } };
|
struct CanReceiveTimeoutAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.controllerHardware.canReceiveTimeout; } };
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Input devices
|
// Input devices
|
||||||
|
@@ -109,14 +109,14 @@ void destroyBle()
|
|||||||
|
|
||||||
void initBle()
|
void initBle()
|
||||||
{
|
{
|
||||||
if (settings.bleSettings.bleEnabled)
|
if (configs.bleSettings.bleEnabled.value)
|
||||||
createBle();
|
createBle();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void handleBle()
|
void handleBle()
|
||||||
{
|
{
|
||||||
if (settings.bleSettings.bleEnabled)
|
if (configs.bleSettings.bleEnabled.value)
|
||||||
{
|
{
|
||||||
if (!pServer)
|
if (!pServer)
|
||||||
createBle();
|
createBle();
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
#include "bluetooth_bobby.h"
|
#include "bluetooth_bobby.h"
|
||||||
|
|
||||||
|
// compilation will be broken as there is no config parameter
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#ifdef FEATURE_BLUETOOTH
|
#ifdef FEATURE_BLUETOOTH
|
||||||
#include "actions/bluetoothbeginaction.h"
|
#include "actions/bluetoothbeginaction.h"
|
||||||
@@ -7,24 +9,25 @@
|
|||||||
#ifdef FEATURE_BMS
|
#ifdef FEATURE_BMS
|
||||||
#include "actions/bluetoothconnectbmsaction.h"
|
#include "actions/bluetoothconnectbmsaction.h"
|
||||||
#endif
|
#endif
|
||||||
|
#include "bluetoothmode.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef FEATURE_BLUETOOTH
|
#ifdef FEATURE_BLUETOOTH
|
||||||
void bluetooth_init()
|
void bluetooth_init()
|
||||||
{
|
{
|
||||||
if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Master)
|
if (configs.bluetooth.autoBluetoothMode.value == BluetoothMode::Master)
|
||||||
{
|
{
|
||||||
bootLabel.redraw("bluetooth begin master");
|
bootLabel.redraw("bluetooth begin master");
|
||||||
BluetoothBeginMasterAction{}.triggered();
|
BluetoothBeginMasterAction{}.triggered();
|
||||||
#ifdef FEATURE_BMS
|
#ifdef FEATURE_BMS
|
||||||
if (settings.autoConnectBms)
|
if (configs.autoConnectBms.value)
|
||||||
{
|
{
|
||||||
bootLabel.redraw("connect BMS");
|
bootLabel.redraw("connect BMS");
|
||||||
BluetoothConnectBmsAction{}.triggered();
|
BluetoothConnectBmsAction{}.triggered();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else if (settings.bluetoothSettings.autoBluetoothMode == BluetoothMode::Slave)
|
else if (configs.bluetooth.autoBluetoothMode.value == BluetoothMode::Slave)
|
||||||
{
|
{
|
||||||
bootLabel.redraw("bluetooth begin");
|
bootLabel.redraw("bluetooth begin");
|
||||||
BluetoothBeginAction{}.triggered();
|
BluetoothBeginAction{}.triggered();
|
||||||
|
@@ -1,12 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#ifdef FEATURE_BLUETOOTH
|
|
||||||
enum class BluetoothMode : uint8_t
|
enum class BluetoothMode : uint8_t
|
||||||
{
|
{
|
||||||
Off,
|
Off,
|
||||||
Master,
|
Master,
|
||||||
Slave
|
Slave
|
||||||
};
|
};
|
||||||
#endif
|
|
||||||
|
14
main/can.cpp
14
main/can.cpp
@@ -193,7 +193,7 @@ bool parseBoardcomputerCanMessage(const twai_message_t &message)
|
|||||||
bool tryParseCanInput()
|
bool tryParseCanInput()
|
||||||
{
|
{
|
||||||
twai_message_t message;
|
twai_message_t message;
|
||||||
const auto timeout = std::chrono::ceil<espcpputils::ticks>(espchrono::milliseconds32{settings.controllerHardware.canReceiveTimeout}).count();
|
const auto timeout = std::chrono::ceil<espcpputils::ticks>(espchrono::milliseconds32{configs.controllerHardware.canReceiveTimeout.value}).count();
|
||||||
if (const auto result = twai_receive(&message, timeout); result != ESP_OK)
|
if (const auto result = twai_receive(&message, timeout); result != ESP_OK)
|
||||||
{
|
{
|
||||||
if (result != ESP_ERR_TIMEOUT)
|
if (result != ESP_ERR_TIMEOUT)
|
||||||
@@ -210,8 +210,8 @@ bool tryParseCanInput()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Controller &front = settings.controllerHardware.swapFrontBack ? controllers.back : controllers.front;
|
Controller &front = configs.controllerHardware.swapFrontBack.value ? controllers.back : controllers.front;
|
||||||
Controller &back = settings.controllerHardware.swapFrontBack ? controllers.front : controllers.back;
|
Controller &back = configs.controllerHardware.swapFrontBack.value ? controllers.front : controllers.back;
|
||||||
|
|
||||||
if (parseMotorControllerCanMessage<false>(message, front))
|
if (parseMotorControllerCanMessage<false>(message, front))
|
||||||
{
|
{
|
||||||
@@ -269,7 +269,7 @@ void sendCanCommands()
|
|||||||
std::fill(std::begin(message.data), std::end(message.data), 0);
|
std::fill(std::begin(message.data), std::end(message.data), 0);
|
||||||
std::memcpy(message.data, &value, sizeof(value));
|
std::memcpy(message.data, &value, sizeof(value));
|
||||||
|
|
||||||
const auto timeout = std::chrono::ceil<espcpputils::ticks>(espchrono::milliseconds32{settings.controllerHardware.canTransmitTimeout}).count();
|
const auto timeout = std::chrono::ceil<espcpputils::ticks>(espchrono::milliseconds32{configs.controllerHardware.canTransmitTimeout.value}).count();
|
||||||
|
|
||||||
const auto timestamp_before = espchrono::millis_clock::now();
|
const auto timestamp_before = espchrono::millis_clock::now();
|
||||||
const auto result = twai_transmit(&message, timeout);
|
const auto result = twai_transmit(&message, timeout);
|
||||||
@@ -313,13 +313,13 @@ void sendCanCommands()
|
|||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
const bool swap = settings.controllerHardware.swapFrontBack;
|
const bool swap = configs.controllerHardware.swapFrontBack.value;
|
||||||
const Controller *front =
|
const Controller *front =
|
||||||
(swap ? settings.controllerHardware.sendBackCanCmd : settings.controllerHardware.sendFrontCanCmd ) ?
|
(swap ? configs.controllerHardware.sendBackCanCmd.value : configs.controllerHardware.sendFrontCanCmd.value ) ?
|
||||||
(swap ? &controllers.back : &controllers.front) :
|
(swap ? &controllers.back : &controllers.front) :
|
||||||
nullptr;
|
nullptr;
|
||||||
const Controller *back =
|
const Controller *back =
|
||||||
(swap ? settings.controllerHardware.sendFrontCanCmd : settings.controllerHardware.sendBackCanCmd ) ?
|
(swap ? configs.controllerHardware.sendFrontCanCmd.value : configs.controllerHardware.sendBackCanCmd.value ) ?
|
||||||
(swap ? &controllers.front : &controllers.back) :
|
(swap ? &controllers.front : &controllers.back) :
|
||||||
nullptr;
|
nullptr;
|
||||||
|
|
||||||
|
@@ -1,5 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
// compilation will be broken as there is no config parameter
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "changevaluedisplay.h"
|
#include "changevaluedisplay.h"
|
||||||
#ifdef FEATURE_BLUETOOTH
|
#ifdef FEATURE_BLUETOOTH
|
||||||
@@ -27,13 +29,13 @@ namespace {
|
|||||||
#ifdef FEATURE_BLUETOOTH
|
#ifdef FEATURE_BLUETOOTH
|
||||||
class BluetoothSettingsMenu;
|
class BluetoothSettingsMenu;
|
||||||
|
|
||||||
using AutoBluetoothModeChangeDisplay = makeComponent<
|
//using AutoBluetoothModeChangeDisplay = makeComponent<
|
||||||
ChangeValueDisplay<BluetoothMode>,
|
// ChangeValueDisplay<BluetoothMode>,
|
||||||
StaticText<TEXT_AUTOBLUETOOTHMODE>,
|
// StaticText<TEXT_AUTOBLUETOOTHMODE>,
|
||||||
AutoBluetoothModeAccessor,
|
// AutoBluetoothModeAccessor,
|
||||||
BackActionInterface<SwitchScreenAction<BluetoothSettingsMenu>>,
|
// BackActionInterface<SwitchScreenAction<BluetoothSettingsMenu>>,
|
||||||
SwitchScreenAction<BluetoothSettingsMenu>
|
// SwitchScreenAction<BluetoothSettingsMenu>
|
||||||
>;
|
//>;
|
||||||
|
|
||||||
class BluetoothSettingsMenu :
|
class BluetoothSettingsMenu :
|
||||||
public BobbyMenuDisplay,
|
public BobbyMenuDisplay,
|
||||||
@@ -53,7 +55,7 @@ public:
|
|||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHFLUSH>, BluetoothFlushAction>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHFLUSH>, BluetoothFlushAction>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHEND>, BluetoothEndAction>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHEND>, BluetoothEndAction>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHDISCONNECT>, BluetoothDisconnectAction>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BLUETOOTHDISCONNECT>, BluetoothDisconnectAction>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_AUTOBLUETOOTHMODE>, SwitchScreenAction<AutoBluetoothModeChangeDisplay>>>();
|
// constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_AUTOBLUETOOTHMODE>, SwitchScreenAction<AutoBluetoothModeChangeDisplay>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<SettingsMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -110,9 +110,9 @@ SettingsMenu::SettingsMenu()
|
|||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESSETTINGS>, SwitchScreenAction<ModesSettingsMenu>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MODESSETTINGS>, SwitchScreenAction<ModesSettingsMenu>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CONTROLLERHARDWARESETTINGS>, SwitchScreenAction<ControllerHardwareSettingsMenu>, StaticMenuItemIcon<&bobbyicons::hardware>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CONTROLLERHARDWARESETTINGS>, SwitchScreenAction<ControllerHardwareSettingsMenu>, StaticMenuItemIcon<&bobbyicons::hardware>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&bobbyicons::hardware>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BOARDCOMPUTERHARDWARESETTINGS>, SwitchScreenAction<BoardcomputerHardwareSettingsMenu>, StaticMenuItemIcon<&bobbyicons::hardware>>>();
|
||||||
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
|
//#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_AUTOCONNECTBMS>, BobbyCheckbox, AutoConnectBmsAccessor>>();
|
// constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_AUTOCONNECTBMS>, BobbyCheckbox, AutoConnectBmsAccessor>>();
|
||||||
#endif
|
//#endif
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BUZZER>, SwitchScreenAction<BuzzerMenu>, StaticMenuItemIcon<&bobbyicons::buzzer>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BUZZER>, SwitchScreenAction<BuzzerMenu>, StaticMenuItemIcon<&bobbyicons::buzzer>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTLED>, BobbyCheckbox, FrontLedAccessor>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_FRONTLED>, BobbyCheckbox, FrontLedAccessor>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKLED>, BobbyCheckbox, BackLedAccessor>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACKLED>, BobbyCheckbox, BackLedAccessor>>();
|
||||||
|
@@ -20,6 +20,9 @@
|
|||||||
#include <espchrono.h>
|
#include <espchrono.h>
|
||||||
#include <makearray.h>
|
#include <makearray.h>
|
||||||
|
|
||||||
|
// local includes
|
||||||
|
#include "bluetoothmode.h"
|
||||||
|
|
||||||
using namespace espconfig;
|
using namespace espconfig;
|
||||||
|
|
||||||
std::string defaultHostname();
|
std::string defaultHostname();
|
||||||
@@ -176,6 +179,21 @@ public:
|
|||||||
ConfigWrapper<std::string> dns_announce_key {std::string{}, DoReset, {}, "dnsAnnounceKey" };
|
ConfigWrapper<std::string> dns_announce_key {std::string{}, DoReset, {}, "dnsAnnounceKey" };
|
||||||
ConfigWrapper<std::string> webserverPassword {std::string{}, DoReset, {}, "websPassword" };
|
ConfigWrapper<std::string> webserverPassword {std::string{}, DoReset, {}, "websPassword" };
|
||||||
|
|
||||||
|
// old settings
|
||||||
|
struct {
|
||||||
|
ConfigWrapper<bool> bleEnabled {true, DoReset, {}, "bleEnabled" };
|
||||||
|
} bleSettings;
|
||||||
|
struct {
|
||||||
|
ConfigWrapper<int16_t> wheelDiameter {DEFAULT_WHEELDIAMETER, DoReset, {}, "wheelDiameter" };
|
||||||
|
ConfigWrapper<int16_t> numMagnetPoles {15, DoReset, {}, "numMagnetPoles" };
|
||||||
|
ConfigWrapper<bool> swapFrontBack {false, DoReset, {}, "swapFrontBack" };
|
||||||
|
ConfigWrapper<bool> sendFrontCanCmd {true, DoReset, {}, "sendFrontCanCmd" };
|
||||||
|
ConfigWrapper<bool> sendBackCanCmd {true, DoReset, {}, "sendBackCanCmd" };
|
||||||
|
ConfigWrapper<int16_t> canTransmitTimeout {200, DoReset, {}, "canTransmitTime" };
|
||||||
|
ConfigWrapper<int16_t> canReceiveTimeout {0, DoReset, {}, "canReceiveTimeo" };
|
||||||
|
} controllerHardware;
|
||||||
|
// end old settings
|
||||||
|
|
||||||
ConfigWrapper<uint32_t> ledStripMaxMilliamps {3000, DoReset, {}, "ledMaxMilliamps" };
|
ConfigWrapper<uint32_t> ledStripMaxMilliamps {3000, DoReset, {}, "ledMaxMilliamps" };
|
||||||
|
|
||||||
#define NEW_SETTINGS(x) \
|
#define NEW_SETTINGS(x) \
|
||||||
@@ -365,6 +383,15 @@ public:
|
|||||||
x(dns_announce_key) \
|
x(dns_announce_key) \
|
||||||
x(webserverPassword) \
|
x(webserverPassword) \
|
||||||
\
|
\
|
||||||
|
x(bleSettings.bleEnabled) \
|
||||||
|
\
|
||||||
|
x(controllerHardware.wheelDiameter) \
|
||||||
|
x(controllerHardware.numMagnetPoles) \
|
||||||
|
x(controllerHardware.swapFrontBack) \
|
||||||
|
x(controllerHardware.sendFrontCanCmd) \
|
||||||
|
x(controllerHardware.sendBackCanCmd) \
|
||||||
|
x(controllerHardware.canTransmitTimeout) \
|
||||||
|
x(controllerHardware.canReceiveTimeout) \
|
||||||
//x(ledStripMaxMilliamps)
|
//x(ledStripMaxMilliamps)
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
113
main/presets.h
113
main/presets.h
@@ -18,11 +18,11 @@ using namespace std::chrono_literals;
|
|||||||
|
|
||||||
namespace presets {
|
namespace presets {
|
||||||
constexpr Settings::Limits defaultLimits {
|
constexpr Settings::Limits defaultLimits {
|
||||||
.iMotMax = DEFAULT_IMOTMAX,
|
.iMotMax = DEFAULT_IMOTMAX, // profileSetting
|
||||||
.iDcMax = DEFAULT_IDCMAX,
|
.iDcMax = DEFAULT_IDCMAX, // profileSetting
|
||||||
.nMotMax = DEFAULT_NMOTMAX,
|
.nMotMax = DEFAULT_NMOTMAX, // profileSetting
|
||||||
.fieldWeakMax = DEFAULT_FIELDWEAKMAX,
|
.fieldWeakMax = DEFAULT_FIELDWEAKMAX, // profileSetting
|
||||||
.phaseAdvMax = DEFAULT_FIELDADVMAX
|
.phaseAdvMax = DEFAULT_FIELDADVMAX // profileSetting
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Settings::Limits kidsLimits {
|
constexpr Settings::Limits kidsLimits {
|
||||||
@@ -34,25 +34,15 @@ constexpr Settings::Limits kidsLimits {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constexpr Settings::ControllerHardware defaultControllerHardware {
|
constexpr Settings::ControllerHardware defaultControllerHardware {
|
||||||
.enableFrontLeft = true,
|
.enableFrontLeft = true, // profileSetting
|
||||||
.enableFrontRight = true,
|
.enableFrontRight = true, // profileSetting
|
||||||
.enableBackLeft = true,
|
.enableBackLeft = true, // profileSetting
|
||||||
.enableBackRight = true,
|
.enableBackRight = true, // profileSetting
|
||||||
|
|
||||||
.invertFrontLeft = DEFAULT_INVERTFRONTLEFT,
|
.invertFrontLeft = DEFAULT_INVERTFRONTLEFT, // profileSetting
|
||||||
.invertFrontRight = DEFAULT_INVERTFRONTRIGHT,
|
.invertFrontRight = DEFAULT_INVERTFRONTRIGHT, // profileSetting
|
||||||
.invertBackLeft = DEFAULT_INVERTBACKLEFT,
|
.invertBackLeft = DEFAULT_INVERTBACKLEFT, // profileSetting
|
||||||
.invertBackRight = DEFAULT_INVERTBACKRIGHT,
|
.invertBackRight = DEFAULT_INVERTBACKRIGHT, // profileSetting
|
||||||
|
|
||||||
.wheelDiameter = DEFAULT_WHEELDIAMETER,
|
|
||||||
.numMagnetPoles = 15,
|
|
||||||
.swapFrontBack = false,
|
|
||||||
#ifdef FEATURE_CAN
|
|
||||||
.sendFrontCanCmd = true,
|
|
||||||
.sendBackCanCmd = true,
|
|
||||||
.canTransmitTimeout = 200,
|
|
||||||
.canReceiveTimeout = 0,
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Settings::ControllerHardware mosfetsOffControllerHardware {
|
constexpr Settings::ControllerHardware mosfetsOffControllerHardware {
|
||||||
@@ -65,30 +55,8 @@ constexpr Settings::ControllerHardware mosfetsOffControllerHardware {
|
|||||||
.invertFrontRight = DEFAULT_INVERTFRONTRIGHT,
|
.invertFrontRight = DEFAULT_INVERTFRONTRIGHT,
|
||||||
.invertBackLeft = DEFAULT_INVERTBACKLEFT,
|
.invertBackLeft = DEFAULT_INVERTBACKLEFT,
|
||||||
.invertBackRight = DEFAULT_INVERTBACKRIGHT,
|
.invertBackRight = DEFAULT_INVERTBACKRIGHT,
|
||||||
|
|
||||||
.wheelDiameter = 165,
|
|
||||||
.numMagnetPoles = 15,
|
|
||||||
.swapFrontBack = false,
|
|
||||||
#ifdef FEATURE_CAN
|
|
||||||
.sendFrontCanCmd = true,
|
|
||||||
.sendBackCanCmd = true,
|
|
||||||
.canTransmitTimeout = 200,
|
|
||||||
.canReceiveTimeout = 0,
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef FEATURE_BLUETOOTH
|
|
||||||
constexpr Settings::BluetoothSettings defaultBluetoothSettings {
|
|
||||||
.autoBluetoothMode = BluetoothMode::Master
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEATURE_BLE
|
|
||||||
constexpr Settings::BleSettings defaultBleSettings {
|
|
||||||
.bleEnabled = true
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
constexpr Settings::ControllerHardware spinnerControllerHardware {
|
constexpr Settings::ControllerHardware spinnerControllerHardware {
|
||||||
.enableFrontLeft = true,
|
.enableFrontLeft = true,
|
||||||
.enableFrontRight = true,
|
.enableFrontRight = true,
|
||||||
@@ -99,16 +67,6 @@ constexpr Settings::ControllerHardware spinnerControllerHardware {
|
|||||||
.invertFrontRight = !DEFAULT_INVERTFRONTRIGHT,
|
.invertFrontRight = !DEFAULT_INVERTFRONTRIGHT,
|
||||||
.invertBackLeft = DEFAULT_INVERTBACKLEFT,
|
.invertBackLeft = DEFAULT_INVERTBACKLEFT,
|
||||||
.invertBackRight = !DEFAULT_INVERTBACKRIGHT,
|
.invertBackRight = !DEFAULT_INVERTBACKRIGHT,
|
||||||
|
|
||||||
.wheelDiameter = 165,
|
|
||||||
.numMagnetPoles = 15,
|
|
||||||
.swapFrontBack = false,
|
|
||||||
#ifdef FEATURE_CAN
|
|
||||||
.sendFrontCanCmd = true,
|
|
||||||
.sendBackCanCmd = true,
|
|
||||||
.canTransmitTimeout = 200,
|
|
||||||
.canReceiveTimeout = 0,
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Settings::BoardcomputerHardware::TimersSettings defaultTimersSettings {
|
constexpr Settings::BoardcomputerHardware::TimersSettings defaultTimersSettings {
|
||||||
@@ -151,22 +109,22 @@ constexpr Settings::UdpCloudSettings defaultUdpCloudSettings {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
constexpr Settings::DefaultMode defaultDefaultMode {
|
constexpr Settings::DefaultMode defaultDefaultMode {
|
||||||
.modelMode = UnifiedModelMode::FocTorque,
|
.modelMode = UnifiedModelMode::FocTorque, // profileSetting
|
||||||
.squareGas = true,
|
.squareGas = true,
|
||||||
.squareBrems = true,
|
.squareBrems = true,
|
||||||
.enableSmoothingUp = true,
|
.enableSmoothingUp = true, // profileSetting
|
||||||
.enableSmoothingDown = true,
|
.enableSmoothingDown = true, // profileSetting
|
||||||
.enableFieldWeakSmoothingUp = false,
|
.enableFieldWeakSmoothingUp = false, // profileSetting
|
||||||
.enableFieldWeakSmoothingDown = false,
|
.enableFieldWeakSmoothingDown = false, // profileSetting
|
||||||
.smoothing = 20,
|
.smoothing = 20, // profileSetting
|
||||||
.frontPercentage = 100,
|
.frontPercentage = 100, // profileSetting
|
||||||
.backPercentage = 100,
|
.backPercentage = 100, // profileSetting
|
||||||
.add_schwelle = 750,
|
.add_schwelle = 750, // profileSetting
|
||||||
.gas1_wert = 1250,
|
.gas1_wert = 1250, // profileSetting
|
||||||
.gas2_wert = 1250,
|
.gas2_wert = 1250, // profileSetting
|
||||||
.brems1_wert = 250,
|
.brems1_wert = 250, // profileSetting
|
||||||
.brems2_wert = 750,
|
.brems2_wert = 750, // profileSetting
|
||||||
.fwSmoothLowerLimit = 800
|
.fwSmoothLowerLimit = 800 // profileSetting
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Settings::DefaultMode sinusoidalDefaultMode {
|
constexpr Settings::DefaultMode sinusoidalDefaultMode {
|
||||||
@@ -189,13 +147,13 @@ constexpr Settings::DefaultMode sinusoidalDefaultMode {
|
|||||||
};
|
};
|
||||||
|
|
||||||
constexpr Settings::TempomatMode defaultTempomatMode {
|
constexpr Settings::TempomatMode defaultTempomatMode {
|
||||||
.modelMode = UnifiedModelMode::FocSpeed
|
.modelMode = UnifiedModelMode::FocSpeed // profileSetting
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Settings::LarsmMode defaultLarsmMode {
|
constexpr Settings::LarsmMode defaultLarsmMode {
|
||||||
.modelMode = UnifiedModelMode::Commutation,
|
.modelMode = UnifiedModelMode::Commutation, // profileSetting
|
||||||
.mode = LarsmModeMode::Mode4,
|
.mode = LarsmModeMode::Mode4, // profileSetting
|
||||||
.iterations = 100
|
.iterations = 100 // profileSetting
|
||||||
};
|
};
|
||||||
|
|
||||||
constexpr Settings::MotortestMode defaultMotortestMode {
|
constexpr Settings::MotortestMode defaultMotortestMode {
|
||||||
@@ -283,16 +241,7 @@ constexpr Settings::ESPNOW defaultEspNowSettings {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
constexpr Settings defaultSettings {
|
constexpr Settings defaultSettings {
|
||||||
#ifdef FEATURE_BMS
|
|
||||||
.autoConnectBms = false,
|
|
||||||
#endif
|
|
||||||
.limits = defaultLimits,
|
.limits = defaultLimits,
|
||||||
#ifdef FEATURE_BLUETOOTH
|
|
||||||
.bluetoothSettings = defaultBluetoothSettings,
|
|
||||||
#endif
|
|
||||||
#ifdef FEATURE_BLE
|
|
||||||
.bleSettings = defaultBleSettings,
|
|
||||||
#endif
|
|
||||||
.controllerHardware = defaultControllerHardware,
|
.controllerHardware = defaultControllerHardware,
|
||||||
.boardcomputerHardware = defaultBoardcomputerHardware,
|
.boardcomputerHardware = defaultBoardcomputerHardware,
|
||||||
#ifdef FEATURE_CLOUD
|
#ifdef FEATURE_CLOUD
|
||||||
|
103
main/settings.h
103
main/settings.h
@@ -17,9 +17,6 @@
|
|||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "bobbycar-common.h"
|
#include "bobbycar-common.h"
|
||||||
#ifdef FEATURE_BLUETOOTH
|
|
||||||
#include "bluetoothmode.h"
|
|
||||||
#endif
|
|
||||||
#include "unifiedmodelmode.h"
|
#include "unifiedmodelmode.h"
|
||||||
#include "handbremse.h"
|
#include "handbremse.h"
|
||||||
#include "ledstrip.h"
|
#include "ledstrip.h"
|
||||||
@@ -27,45 +24,17 @@
|
|||||||
|
|
||||||
struct Settings
|
struct Settings
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_BMS
|
|
||||||
bool autoConnectBms;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct Limits {
|
struct Limits {
|
||||||
int16_t iMotMax; // [A] Maximum motor current limit
|
int16_t iMotMax; // [A] Maximum motor current limit // profileSetting
|
||||||
int16_t iDcMax; // [A] Maximum DC Link current limit (This is the current protection. Above this value, current chopping is applied. To avoid this make sure that I_DC_MAX = I_MOT_MAX + 2A)
|
int16_t iDcMax; // [A] Maximum DC Link current limit (This is the current protection. Above this value, current chopping is applied. To avoid this make sure that I_DC_MAX = I_MOT_MAX + 2A) // profileSetting
|
||||||
int16_t nMotMax; // [rpm] Maximum motor speed limit
|
int16_t nMotMax; // [rpm] Maximum motor speed limit // profileSetting
|
||||||
int16_t fieldWeakMax; // [A] Maximum Field Weakening D axis current (only for FOC). Higher current results in higher maximum speed.
|
int16_t fieldWeakMax; // [A] Maximum Field Weakening D axis current (only for FOC). Higher current results in higher maximum speed. // profileSetting
|
||||||
int16_t phaseAdvMax; // [deg] Maximum Phase Advance angle (only for SIN). Higher angle results in higher maximum speed.
|
int16_t phaseAdvMax; // [deg] Maximum Phase Advance angle (only for SIN). Higher angle results in higher maximum speed. // profileSetting
|
||||||
} limits;
|
} limits;
|
||||||
|
|
||||||
#ifdef FEATURE_BLUETOOTH
|
|
||||||
struct BluetoothSettings {
|
|
||||||
BluetoothMode autoBluetoothMode;
|
|
||||||
} bluetoothSettings;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEATURE_BLE
|
|
||||||
struct BleSettings {
|
|
||||||
bool bleEnabled;
|
|
||||||
} bleSettings;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct ControllerHardware {
|
struct ControllerHardware {
|
||||||
bool enableFrontLeft, enableFrontRight, enableBackLeft, enableBackRight;
|
bool enableFrontLeft, enableFrontRight, enableBackLeft, enableBackRight; // profileSetting
|
||||||
bool invertFrontLeft, invertFrontRight, invertBackLeft, invertBackRight;
|
bool invertFrontLeft, invertFrontRight, invertBackLeft, invertBackRight; // profileSetting
|
||||||
|
|
||||||
int16_t wheelDiameter; // in mm
|
|
||||||
int16_t numMagnetPoles; // virtual RPM per one real RPM
|
|
||||||
|
|
||||||
bool swapFrontBack;
|
|
||||||
|
|
||||||
#ifdef FEATURE_CAN
|
|
||||||
bool sendFrontCanCmd;
|
|
||||||
bool sendBackCanCmd;
|
|
||||||
int16_t canTransmitTimeout; // in ms
|
|
||||||
int16_t canReceiveTimeout; // in ms
|
|
||||||
#endif
|
|
||||||
} controllerHardware;
|
} controllerHardware;
|
||||||
|
|
||||||
struct BoardcomputerHardware {
|
struct BoardcomputerHardware {
|
||||||
@@ -102,32 +71,32 @@ struct Settings
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
struct DefaultMode {
|
struct DefaultMode {
|
||||||
UnifiedModelMode modelMode;
|
UnifiedModelMode modelMode; // profileSetting
|
||||||
bool squareGas;
|
bool squareGas;
|
||||||
bool squareBrems;
|
bool squareBrems;
|
||||||
bool enableSmoothingUp;
|
bool enableSmoothingUp; // profileSetting
|
||||||
bool enableSmoothingDown;
|
bool enableSmoothingDown; // profileSetting
|
||||||
bool enableFieldWeakSmoothingUp;
|
bool enableFieldWeakSmoothingUp; // profileSetting
|
||||||
bool enableFieldWeakSmoothingDown;
|
bool enableFieldWeakSmoothingDown; // profileSetting
|
||||||
int16_t smoothing;
|
int16_t smoothing; // profileSetting
|
||||||
int16_t frontPercentage;
|
int16_t frontPercentage; // profileSetting
|
||||||
int16_t backPercentage;
|
int16_t backPercentage; // profileSetting
|
||||||
int16_t add_schwelle;
|
int16_t add_schwelle; // profileSetting
|
||||||
int16_t gas1_wert;
|
int16_t gas1_wert; // profileSetting
|
||||||
int16_t gas2_wert;
|
int16_t gas2_wert; // profileSetting
|
||||||
int16_t brems1_wert;
|
int16_t brems1_wert; // profileSetting
|
||||||
int16_t brems2_wert;
|
int16_t brems2_wert; // profileSetting
|
||||||
int16_t fwSmoothLowerLimit;
|
int16_t fwSmoothLowerLimit; // profileSetting
|
||||||
} defaultMode;
|
} defaultMode;
|
||||||
|
|
||||||
struct TempomatMode {
|
struct TempomatMode {
|
||||||
UnifiedModelMode modelMode;
|
UnifiedModelMode modelMode; // profileSetting
|
||||||
} tempomatMode;
|
} tempomatMode;
|
||||||
|
|
||||||
struct LarsmMode {
|
struct LarsmMode {
|
||||||
UnifiedModelMode modelMode;
|
UnifiedModelMode modelMode; // profileSetting
|
||||||
LarsmModeMode mode;
|
LarsmModeMode mode; // profileSetting
|
||||||
uint8_t iterations;
|
uint8_t iterations; // profileSetting
|
||||||
} larsmMode;
|
} larsmMode;
|
||||||
|
|
||||||
struct MotortestMode {
|
struct MotortestMode {
|
||||||
@@ -214,28 +183,6 @@ struct Settings
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
void Settings::executeForEveryCommonSetting(T &&callable)
|
void Settings::executeForEveryCommonSetting(T &&callable)
|
||||||
{
|
{
|
||||||
#ifdef FEATURE_BMS
|
|
||||||
callable("autoConnectBms", autoConnectBms);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEATURE_BLUETOOTH
|
|
||||||
callable("autoBluetoothMo", bluetoothSettings.autoBluetoothMode);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEATURE_BLE
|
|
||||||
callable("bleEnabled", bleSettings.bleEnabled);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
callable("wheelDiameter", controllerHardware.wheelDiameter);
|
|
||||||
callable("numMagnetPoles", controllerHardware.numMagnetPoles);
|
|
||||||
callable("swapFrontBack", controllerHardware.swapFrontBack);
|
|
||||||
#ifdef FEATURE_CAN
|
|
||||||
callable("sendFrontCanCmd", controllerHardware.sendFrontCanCmd);
|
|
||||||
callable("sendBackCanCmd", controllerHardware.sendBackCanCmd);
|
|
||||||
callable("canTransmitTime", controllerHardware.canTransmitTimeout);
|
|
||||||
callable("canReceiveTimeo", controllerHardware.canReceiveTimeout);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEATURE_GAMETRAK
|
#ifdef FEATURE_GAMETRAK
|
||||||
callable("gametrakXMin", boardcomputerHardware.gametrakXMin);
|
callable("gametrakXMin", boardcomputerHardware.gametrakXMin);
|
||||||
callable("gametrakXMax", boardcomputerHardware.gametrakXMax);
|
callable("gametrakXMax", boardcomputerHardware.gametrakXMax);
|
||||||
|
@@ -12,12 +12,12 @@ espchrono::millis_clock::time_point lastReverseBeepToggle;
|
|||||||
|
|
||||||
float convertToKmh(float val)
|
float convertToKmh(float val)
|
||||||
{
|
{
|
||||||
return val /* / settings.controllerHardware.numMagnetPoles */ / 60.f * settings.controllerHardware.wheelDiameter / 1000.f * 3.14159265359f * 3.6f;
|
return val /* / settings.controllerHardware.numMagnetPoles */ / 60.f * configs.controllerHardware.wheelDiameter.value / 1000.f * 3.14159265359f * 3.6f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float convertFromKmh(float val)
|
float convertFromKmh(float val)
|
||||||
{
|
{
|
||||||
return val /* * settings.controllerHardware.numMagnetPoles */ * 60.f / settings.controllerHardware.wheelDiameter * 1000.f / 3.14159265359f / 3.6f;
|
return val /* * settings.controllerHardware.numMagnetPoles */ * 60.f / configs.controllerHardware.wheelDiameter.value * 1000.f / 3.14159265359f / 3.6f;
|
||||||
}
|
}
|
||||||
|
|
||||||
float convertToInch(float val)
|
float convertToInch(float val)
|
||||||
@@ -192,8 +192,8 @@ void sendCommands()
|
|||||||
#ifdef FEATURE_SERIAL
|
#ifdef FEATURE_SERIAL
|
||||||
void updateSwapFrontBack()
|
void updateSwapFrontBack()
|
||||||
{
|
{
|
||||||
controllers.front.serial = settings.controllerHardware.swapFrontBack ? Serial2 : Serial1;
|
controllers.front.serial = configs.controllerHardware.swapFrontBack.value ? Serial2 : Serial1;
|
||||||
controllers.back.serial = settings.controllerHardware.swapFrontBack ? Serial1 : Serial2;
|
controllers.back.serial = configs.controllerHardware.swapFrontBack.value ? Serial1 : Serial2;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user