Mick config & fixes (#260)
This commit is contained in:
@ -41,13 +41,13 @@ set(BOBBYCAR_BUILDFLAGS
|
||||
-DDEFAULT_FIELDWEAKMAX=7
|
||||
-DDEFAULT_FIELDADVMAX=40
|
||||
-DFEATURE_WEBSERVER
|
||||
# -DFEATURE_OTA
|
||||
# -DFEATURE_DPAD_5WIRESW
|
||||
# -DPINS_DPAD_5WIRESW_OUT=4
|
||||
# -DPINS_DPAD_5WIRESW_IN1=5
|
||||
# -DPINS_DPAD_5WIRESW_IN2=27
|
||||
# -DPINS_DPAD_5WIRESW_IN3=18
|
||||
# -DPINS_DPAD_5WIRESW_IN4=19
|
||||
-DFEATURE_OTA
|
||||
-DFEATURE_DPAD_5WIRESW_2OUT
|
||||
-DPINS_DPAD_5WIRESW_OUT1=5
|
||||
-DPINS_DPAD_5WIRESW_OUT2=19
|
||||
-DPINS_DPAD_5WIRESW_IN1=4
|
||||
-DPINS_DPAD_5WIRESW_IN2=18
|
||||
-DPINS_DPAD_5WIRESW_IN3=27
|
||||
-DFEATURE_BLE
|
||||
# -DFEATURE_BLUETOOTH
|
||||
# -DFEATURE_BMS
|
||||
@ -70,6 +70,7 @@ set(BOBBYCAR_BUILDFLAGS
|
||||
-DLEDSTRIP_ANIMATION_DEFAULT=0
|
||||
-DOLD_NVS
|
||||
-DFEATURE_DNS_NS
|
||||
-DFEATURE_IS_MIR_EGAL_OB_DER_WEBSERVER_KORREKT_ARBEITET
|
||||
)
|
||||
|
||||
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ignore/lockscreen_plugin.cmake")
|
||||
|
Binary file not shown.
@ -113,6 +113,7 @@ struct BremsMinAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<in
|
||||
struct BremsMaxAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.bremsMax; } };
|
||||
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW) || defined(FEATURE_DPAD_5WIRESW) || defined(FEATURE_DPAD_5WIRESW_2OUT) || defined (FEATURE_DPAD_6WIRESW)
|
||||
struct DPadDebounceAccessor : public NewSettingsAccessor<uint8_t> { ConfigWrapper<uint8_t> &getConfig() const override { return configs.dpadDebounce; } };
|
||||
struct ButtonDelayAccessor : public NewSettingsAccessor<uint16_t> { ConfigWrapper<uint16_t> &getConfig() const override { return configs.buttonReadDelay; } };
|
||||
#endif
|
||||
#ifdef FEATURE_GAMETRAK
|
||||
struct GametrakXMinAccessor : public NewSettingsAccessor<int16_t> { ConfigWrapper<int16_t> &getConfig() const override { return configs.boardcomputerHardware.gametrakXMin; } };
|
||||
|
@ -331,10 +331,14 @@ void sendCanCommands()
|
||||
|
||||
using namespace bobbycar::protocol::can;
|
||||
|
||||
#ifdef HAS_SIMPLIFIED
|
||||
SIMPLIFIED_PWM
|
||||
#else
|
||||
if (front) send(MotorController<false, false>::Command::InpTgt, front->command.left.pwm);
|
||||
if (front) send(MotorController<false, true>::Command::InpTgt, front->command.right.pwm);
|
||||
if (back) send(MotorController<true, false>::Command::InpTgt, back->command.left.pwm);
|
||||
if (back) send(MotorController<true, true>::Command::InpTgt, back->command.right.pwm);
|
||||
#endif
|
||||
|
||||
uint16_t buttonLeds{};
|
||||
if (const auto index = settingsPersister.currentlyOpenProfileIndex())
|
||||
|
@ -40,6 +40,7 @@ constexpr char TEXT_GASMAX[] = "gasMax";
|
||||
constexpr char TEXT_BREMSMIN[] = "bremsMin";
|
||||
constexpr char TEXT_BREMSMAX[] = "bremsMax";
|
||||
constexpr char TEXT_DPADDEBOUNCE[] = "dpadDebounce";
|
||||
constexpr char TEXT_BUTTONDELAY[] = "button read delay";
|
||||
constexpr char TEXT_GAMETRAKCALIBRATE[] = "Gametrak calibrate";
|
||||
constexpr char TEXT_SETGAMETRAKXMIN[] = "Set gametrakXMin";
|
||||
constexpr char TEXT_SETGAMETRAKXMAX[] = "Set gametrakXMax";
|
||||
@ -116,6 +117,13 @@ using DPadDebounceChangeScreen = espgui::makeComponent<
|
||||
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
|
||||
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>
|
||||
>;
|
||||
using ButtonDelayChangeScreen = espgui::makeComponent<
|
||||
BobbyChangeValueDisplay<uint16_t>,
|
||||
espgui::StaticText<TEXT_BUTTONDELAY>,
|
||||
ButtonDelayAccessor,
|
||||
espgui::ConfirmActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>,
|
||||
espgui::BackActionInterface<espgui::SwitchScreenAction<BoardcomputerHardwareSettingsMenu>>
|
||||
>;
|
||||
#endif
|
||||
|
||||
#ifdef FEATURE_GAMETRAK
|
||||
@ -198,6 +206,7 @@ BoardcomputerHardwareSettingsMenu::BoardcomputerHardwareSettingsMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BREMSMAX, BremsMaxAccessor>, SwitchScreenAction<BremsMaxChangeScreen>>>();
|
||||
#if defined(FEATURE_DPAD) || defined(FEATURE_DPAD_3WIRESW) || defined(FEATURE_DPAD_5WIRESW) || defined(FEATURE_DPAD_5WIRESW_2OUT) || defined (FEATURE_DPAD_6WIRESW)
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_DPADDEBOUNCE, DPadDebounceAccessor>, SwitchScreenAction<DPadDebounceChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BUTTONDELAY, ButtonDelayAccessor>, SwitchScreenAction<ButtonDelayChangeScreen>>>();
|
||||
#endif
|
||||
#ifdef FEATURE_GAMETRAK
|
||||
constructMenuItem<makeComponent<MenuItem, EmptyText, DummyAction>,
|
||||
|
@ -42,6 +42,7 @@ class UptimeText : public virtual espgui::TextInterface
|
||||
public:
|
||||
std::string text() const override
|
||||
{
|
||||
using namespace std::chrono_literals;
|
||||
const auto uptime = espchrono::millis_clock::now().time_since_epoch();
|
||||
auto converted = date::make_time(uptime);
|
||||
auto msecs = uptime
|
||||
@ -52,7 +53,7 @@ public:
|
||||
converted.hours().count(),
|
||||
converted.minutes().count(),
|
||||
converted.seconds().count(),
|
||||
msecs.count());
|
||||
msecs / 1ms);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "taskmanager.h"
|
||||
|
||||
using namespace espgui;
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
namespace {
|
||||
constexpr char TEXT_TASKMANAGER[] = "Taskmanager";
|
||||
@ -25,7 +26,7 @@ public:
|
||||
std::string text() const override
|
||||
{
|
||||
const std::string_view name{m_task.name()};
|
||||
return fmt::format("{}{}&f &2{} &1{}ms", name.size() > 6 ? "&s" : "", name, m_task.callCount(), m_task.maxElapsed().count());
|
||||
return fmt::format("{}{}&f &2{} &1{}ms", name.size() > 6 ? "&s" : "", name, m_task.callCount(), m_task.maxElapsed() / 1ms);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -52,7 +52,11 @@ std::array<bool, 12> Helper<OUT1, OUT2, IN1, IN2, IN3>::read()
|
||||
pinMode(IN2, INPUT_PULLUP);
|
||||
pinMode(IN3, INPUT_PULLUP);
|
||||
|
||||
vPortYield();
|
||||
if (configs.buttonReadDelay.value != 0) {
|
||||
delayMicroseconds(configs.buttonReadDelay.value);
|
||||
} else {
|
||||
vPortYield();
|
||||
}
|
||||
|
||||
result[0] = digitalRead(IN1)==LOW;
|
||||
result[1] = digitalRead(IN2)==LOW;
|
||||
@ -64,7 +68,11 @@ std::array<bool, 12> Helper<OUT1, OUT2, IN1, IN2, IN3>::read()
|
||||
pinMode(IN2, INPUT_PULLDOWN);
|
||||
pinMode(IN3, INPUT_PULLDOWN);
|
||||
|
||||
vPortYield();
|
||||
if (configs.buttonReadDelay.value != 0) {
|
||||
delayMicroseconds(configs.buttonReadDelay.value);
|
||||
} else {
|
||||
vPortYield();
|
||||
}
|
||||
|
||||
result[3] = digitalRead(IN1);
|
||||
result[4] = digitalRead(IN2);
|
||||
@ -79,7 +87,11 @@ std::array<bool, 12> Helper<OUT1, OUT2, IN1, IN2, IN3>::read()
|
||||
pinMode(IN2, INPUT_PULLUP);
|
||||
pinMode(IN3, INPUT_PULLUP);
|
||||
|
||||
vPortYield();
|
||||
if (configs.buttonReadDelay.value != 0) {
|
||||
delayMicroseconds(configs.buttonReadDelay.value);
|
||||
} else {
|
||||
vPortYield();
|
||||
}
|
||||
|
||||
result[6] = digitalRead(IN1)==LOW;
|
||||
result[7] = digitalRead(IN2)==LOW;
|
||||
@ -91,7 +103,11 @@ std::array<bool, 12> Helper<OUT1, OUT2, IN1, IN2, IN3>::read()
|
||||
pinMode(IN2, INPUT_PULLDOWN);
|
||||
pinMode(IN3, INPUT_PULLDOWN);
|
||||
|
||||
vPortYield();
|
||||
if (configs.buttonReadDelay.value != 0) {
|
||||
delayMicroseconds(configs.buttonReadDelay.value);
|
||||
} else {
|
||||
vPortYield();
|
||||
}
|
||||
|
||||
result[9] = digitalRead(IN1);
|
||||
result[10] = digitalRead(IN2);
|
||||
|
@ -53,7 +53,11 @@ std::array<bool, 10> Helper<OUT, IN1, IN2, IN3, IN4, IN5>::read()
|
||||
pinMode(IN4, INPUT_PULLUP);
|
||||
pinMode(IN5, INPUT_PULLUP);
|
||||
|
||||
vPortYield();
|
||||
if (configs.buttonReadDelay.value != 0) {
|
||||
delayMicroseconds(configs.buttonReadDelay.value);
|
||||
} else {
|
||||
vPortYield();
|
||||
}
|
||||
|
||||
result[0] = digitalRead(IN1)==LOW;
|
||||
result[1] = digitalRead(IN2)==LOW;
|
||||
@ -69,7 +73,11 @@ std::array<bool, 10> Helper<OUT, IN1, IN2, IN3, IN4, IN5>::read()
|
||||
pinMode(IN4, INPUT_PULLDOWN);
|
||||
pinMode(IN5, INPUT_PULLDOWN);
|
||||
|
||||
vPortYield();
|
||||
if (configs.buttonReadDelay.value != 0) {
|
||||
delayMicroseconds(configs.buttonReadDelay.value);
|
||||
} else {
|
||||
vPortYield();
|
||||
}
|
||||
|
||||
result[4] = digitalRead(IN1);
|
||||
result[5] = digitalRead(IN2);
|
||||
|
@ -21,7 +21,7 @@ float getAvgWhPerKm()
|
||||
|
||||
float getAvgKmh()
|
||||
{
|
||||
return (drivingStatistics.meters_driven / 1000.) / ((drivingStatistics.currentDrivingTime / 1ms) / 1000 / 60 / 60); // (meter / 1000) / (ms / 1000 / 60 / 60)
|
||||
return (drivingStatistics.meters_driven / 1000.f) / ((drivingStatistics.currentDrivingTime / 1ms) / 1000.f / 60.f / 60.f); // (meter / 1000) / (ms / 1000 / 60 / 60)
|
||||
}
|
||||
|
||||
float getEstimatedKmLeft()
|
||||
@ -72,53 +72,51 @@ void initStatistics()
|
||||
|
||||
void calculateStatistics()
|
||||
{
|
||||
EVERY_N_MILLIS( 10 ) {
|
||||
static bool saveTotal = false;
|
||||
static bool saveTotal = false;
|
||||
|
||||
if ((configs.savedStatistics.totalCentimeters.value / 100.f) > drivingStatistics.totalMeters)
|
||||
if ((configs.savedStatistics.totalCentimeters.value / 100.f) > drivingStatistics.totalMeters)
|
||||
{
|
||||
drivingStatistics.totalMeters = configs.savedStatistics.totalCentimeters.value / 100.f;
|
||||
drivingStatistics.last_cm_written = configs.savedStatistics.totalCentimeters.value;
|
||||
}
|
||||
|
||||
static auto last_km_calculation = espchrono::millis_clock::now();
|
||||
const auto duration = espchrono::ago(last_km_calculation);
|
||||
last_km_calculation = espchrono::millis_clock::now();
|
||||
|
||||
const float meters_driven_now = (abs(avgSpeedKmh) / 3.6) * ((duration / 1ms) / 1000.);
|
||||
drivingStatistics.meters_driven += meters_driven_now;
|
||||
drivingStatistics.totalMeters += meters_driven_now; // Udate meters driven
|
||||
|
||||
if (abs(avgSpeedKmh) > 1)
|
||||
{
|
||||
if (!saveTotal && abs(avgSpeedKmh) > 5)
|
||||
{
|
||||
drivingStatistics.totalMeters = configs.savedStatistics.totalCentimeters.value / 100.f;
|
||||
drivingStatistics.last_cm_written = configs.savedStatistics.totalCentimeters.value;
|
||||
saveTotal = true;
|
||||
}
|
||||
drivingStatistics.currentDrivingTime += duration;
|
||||
|
||||
static auto last_km_calculation = espchrono::millis_clock::now();
|
||||
const auto duration = espchrono::ago(last_km_calculation);
|
||||
last_km_calculation = espchrono::millis_clock::now();
|
||||
|
||||
const float meters_driven_now = (abs(avgSpeedKmh) / 3.6) * ((duration / 1ms) / 1000.);
|
||||
drivingStatistics.meters_driven += meters_driven_now;
|
||||
drivingStatistics.totalMeters += meters_driven_now; // Udate meters driven
|
||||
|
||||
if (abs(avgSpeedKmh) > 1)
|
||||
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
|
||||
{
|
||||
if (!saveTotal && abs(avgSpeedKmh) > 5)
|
||||
{
|
||||
saveTotal = true;
|
||||
}
|
||||
drivingStatistics.currentDrivingTime += duration;
|
||||
|
||||
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
|
||||
{
|
||||
auto watt = sumCurrent * *avgVoltage;
|
||||
const float ws_driven_now = watt * ((duration / 1ms) / 1000.);
|
||||
drivingStatistics.wh_used += ws_driven_now / 3600; // Wh
|
||||
drivingStatistics.batteryWhEstimate -= ws_driven_now / 3600;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
drivingStatistics.wh_used += (13 * ((duration / 1ms) / 1000.)) / 3600; // Wh
|
||||
drivingStatistics.batteryWhEstimate = getRemainingWattHours();
|
||||
}
|
||||
|
||||
if ((drivingStatistics.totalMeters > ((drivingStatistics.last_cm_written / 100.f) + 100)) || (saveTotal && abs(avgSpeedKmh) < 0.5))
|
||||
{
|
||||
if (saveTotal)
|
||||
{
|
||||
saveTotal = false;
|
||||
}
|
||||
drivingStatistics.last_cm_written = drivingStatistics.totalMeters * 100; // Save total Meters
|
||||
configs.write_config(configs.savedStatistics.totalCentimeters, drivingStatistics.last_cm_written);
|
||||
auto watt = sumCurrent * *avgVoltage;
|
||||
const float ws_driven_now = watt * ((duration / 1ms) / 1000.);
|
||||
drivingStatistics.wh_used += ws_driven_now / 3600; // Wh
|
||||
drivingStatistics.batteryWhEstimate -= ws_driven_now / 3600;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
drivingStatistics.wh_used += (13 * ((duration / 1ms) / 1000.)) / 3600; // Wh
|
||||
drivingStatistics.batteryWhEstimate = getRemainingWattHours();
|
||||
}
|
||||
|
||||
if ((drivingStatistics.totalMeters > ((drivingStatistics.last_cm_written / 100.f) + 100)) || (saveTotal && abs(avgSpeedKmh) < 0.5))
|
||||
{
|
||||
if (saveTotal)
|
||||
{
|
||||
saveTotal = false;
|
||||
}
|
||||
drivingStatistics.last_cm_written = drivingStatistics.totalMeters * 100; // Save total Meters
|
||||
configs.write_config(configs.savedStatistics.totalCentimeters, drivingStatistics.last_cm_written);
|
||||
}
|
||||
}
|
||||
|
@ -138,6 +138,7 @@ public:
|
||||
ConfigWrapper<uint16_t> deadband {20, DoReset, MinMaxValue<uint16_t, 0, 4095>,"deadband" };
|
||||
|
||||
ConfigWrapper<uint8_t> dpadDebounce {25, DoReset, {}, "dpadDebounce" };
|
||||
ConfigWrapper<uint16_t> buttonReadDelay {1, DoReset, {}, "buttonDelay" };
|
||||
|
||||
ConfigWrapper<uint8_t> dpadMappingLeft {INPUT_MAPPING_NONE, DoReset, {}, "dpadMapLeft" };
|
||||
ConfigWrapper<uint8_t> dpadMappingRight {INPUT_MAPPING_NONE, DoReset, {}, "dpadMapRight" };
|
||||
@ -432,6 +433,7 @@ public:
|
||||
x(deadband) \
|
||||
\
|
||||
x(dpadDebounce) \
|
||||
x(buttonReadDelay) \
|
||||
\
|
||||
x(dpadMappingLeft) \
|
||||
x(dpadMappingRight) \
|
||||
|
Reference in New Issue
Block a user