From eb82f9d9939d3d1c25b73c77e7ef029e43c6cce2 Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Thu, 30 Sep 2021 13:48:16 +0200 Subject: [PATCH 1/7] feedc0de config updated --- config_feedc0de.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config_feedc0de.cmake b/config_feedc0de.cmake index 5075ca9..0fde4a7 100644 --- a/config_feedc0de.cmake +++ b/config_feedc0de.cmake @@ -35,10 +35,10 @@ set(BOBBYCAR_BUILDFLAGS -DPINS_MOSFET0=4 -DPINS_MOSFET1=5 -DPINS_MOSFET2=25 - -DDEFAULT_IMOTMAX=35 - -DDEFAULT_IDCMAX=37 + -DDEFAULT_IMOTMAX=40 + -DDEFAULT_IDCMAX=42 -DDEFAULT_NMOTMAX=2000 - -DDEFAULT_FIELDWEAKMAX=7 + -DDEFAULT_FIELDWEAKMAX=17 -DDEFAULT_FIELDADVMAX=40 -DDEVICE_PREFIX=bobbyquad -DAP_PASSWORD=Passwort_123 @@ -60,7 +60,7 @@ set(BOBBYCAR_BUILDFLAGS -DDPAD_5WIRESW_PROFILE3=4 # -DDPAD_5WIRESW_DEBUG -DDEFAULT_GASMIN=40 - -DDEFAULT_GASMAX=850 + -DDEFAULT_GASMAX=770 -DDEFAULT_BREMSMIN=80 -DDEFAULT_BREMSMAX=1100 -DFEATURE_BLE From f7c0b18cc4e88bf996d975973b9535d9dec78b0c Mon Sep 17 00:00:00 2001 From: 0xFEEDC0DE64 Date: Thu, 30 Sep 2021 13:48:49 +0200 Subject: [PATCH 2/7] bmsdisplay removed string concats --- main/displays/bmsdisplay.h | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/main/displays/bmsdisplay.h b/main/displays/bmsdisplay.h index 103f464..4897b1b 100644 --- a/main/displays/bmsdisplay.h +++ b/main/displays/bmsdisplay.h @@ -1,7 +1,7 @@ #pragma once -// Arduino includes -#include +// 3rdparty lib includes +#include // local includes #include "display.h" @@ -95,11 +95,11 @@ void BmsDisplay::redraw() if (bluetoothSerial.hasClient()) { - m_voltageLabel.redraw(std::to_string(bms::voltage) + 'V'); - m_capacityLabel.redraw(std::to_string(int(bms::capacity)) + "mAh"); - m_socLabel.redraw(std::to_string(bms::soc) + '%'); - m_powerLabel.redraw(std::to_string(bms::power) + 'W'); - m_currentLabel.redraw(std::to_string(bms::current) + 'A'); + m_voltageLabel.redraw(fmt::format("{:.02f}V", bms::voltage)); + m_capacityLabel.redraw(fmt::format("{:.02f} mAh", bms::capacity)); + m_socLabel.redraw(fmt::format("{:.02f}%", bms::soc)); + m_powerLabel.redraw(fmt::format("{:.02f}W", bms::power)); + m_currentLabel.redraw(fmt::format("{:.02f}A", bms::current)); } else { @@ -110,18 +110,18 @@ void BmsDisplay::redraw() m_currentLabel.clear(); } - m_speedLabel.redraw(std::to_string(avgSpeedKmh) + "kmh"); + m_speedLabel.redraw(fmt::format("{:.02f}kmh", avgSpeedKmh)); if (bluetoothSerial.hasClient()) - m_powerPerSpeedLabel.redraw(std::to_string(avgSpeedKmh < 1 ? 0 : bms::power / avgSpeedKmh) + "W/kmh"); + m_powerPerSpeedLabel.redraw(fmt::format("{:.02f}W/kmh", avgSpeedKmh < 1 ? 0 : bms::power / avgSpeedKmh)); else m_powerPerSpeedLabel.clear(); for (int i = 0; i < 12; i++) - m_battLabels[i].redraw(std::to_string(bms::batt[i])); + m_battLabels[i].redraw(fmt::format("{:.02f}", bms::batt[i])); if (bluetoothSerial.hasClient()) - m_cycleLabel.redraw(std::to_string(bms::cycle) + "AH"); + m_cycleLabel.redraw(fmt::format("{:.02f}AH", bms::cycle)); else m_cycleLabel.clear(); } From 0529c85151d54deb85e0db8442d1e861b771aba2 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Thu, 30 Sep 2021 14:08:38 +0200 Subject: [PATCH 3/7] Improved animation selection --- main/CMakeLists.txt | 3 ++ main/actions/ledstripanimationactions.h | 35 ++++++++++++++++++ main/displays/menus/ledstripmenu.h | 5 ++- .../menus/ledstripselectanimationmenu.h | 37 +++++++++++++++++++ main/ledstripdefines.h | 0 main/texts.h | 7 ++++ 6 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 main/actions/ledstripanimationactions.h create mode 100644 main/displays/menus/ledstripselectanimationmenu.h create mode 100644 main/ledstripdefines.h diff --git a/main/CMakeLists.txt b/main/CMakeLists.txt index cf41118..cdbff58 100644 --- a/main/CMakeLists.txt +++ b/main/CMakeLists.txt @@ -13,6 +13,7 @@ set(headers actions/bmsturnonchargeaction.h actions/bmsturnondischargeaction.h actions/erasenvsaction.h + actions/ledstripanimationactions.h actions/loadsettingsaction.h actions/modesettingsaction.h actions/multiaction.h @@ -55,6 +56,7 @@ set(headers displays/menus/invertmenu.h displays/menus/larsmmodesettingsmenu.h displays/menus/ledstripmenu.h + displays/menus/ledstripselectanimationmenu.h displays/menus/modessettingsmenu.h displays/menus/mosfetsmenu.h displays/menus/motorstatedebugmenu.h @@ -111,6 +113,7 @@ set(headers icons/update.h icons/wifi.h ledstrip.h + ledstripdefines.h modes/defaultmode.h modes/gametrakmode.h modes/ignoreinputmode.h diff --git a/main/actions/ledstripanimationactions.h b/main/actions/ledstripanimationactions.h new file mode 100644 index 0000000..3f7b4e6 --- /dev/null +++ b/main/actions/ledstripanimationactions.h @@ -0,0 +1,35 @@ +#pragma once + +#include "actioninterface.h" +#include "utils.h" +#include "globals.h" +#include "ledstrip.h" +#include "ledstripdefines.h" + +using namespace espgui; + +namespace { +class LedstripAnimationDefaultRainbowAction : public virtual ActionInterface +{ +public: + void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_DEFAULTRAINBOW; } +}; + +class LedstripAnimationBlinkLeftAction : public virtual ActionInterface +{ +public: + void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_BLINKLEFT; } +}; + +class LedstripAnimationBlinkRightAction : public virtual ActionInterface +{ +public: + void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_BLINKRIGHT; } +}; + +class LedstripAnimationBlinkBothAction : public virtual ActionInterface +{ +public: + void triggered() override { blinkAnimation = LEDSTRIP_ANIMATION_BLINKBOTH; } +}; +} diff --git a/main/displays/menus/ledstripmenu.h b/main/displays/menus/ledstripmenu.h index b56fb9a..9ac55eb 100644 --- a/main/displays/menus/ledstripmenu.h +++ b/main/displays/menus/ledstripmenu.h @@ -5,6 +5,7 @@ #include "menuitem.h" #include "actions/toggleboolaction.h" #include "actions/switchscreenaction.h" +#include "ledstripselectanimationmenu.h" #include "texts.h" #include "icons/back.h" #include "checkboxicon.h" @@ -25,6 +26,7 @@ using namespace espgui; namespace { #ifdef FEATURE_LEDSTRIP class LedstripMenu; +class LedstripSelectAnimationMenu; struct BlinkAnimationAccessor : public RefAccessor { int16_t &getRef() const override { return blinkAnimation; } }; @@ -78,7 +80,8 @@ public: { constructMenuItem, ToggleBoolAction, CheckboxIcon, EnableLedAnimationAccessor>>(); constructMenuItem, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>(); - constructMenuItem, SwitchScreenAction>>(); + constructMenuItem, SwitchScreenAction>>(); +// constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction>>(); constructMenuItem, SwitchScreenAction>>(); diff --git a/main/displays/menus/ledstripselectanimationmenu.h b/main/displays/menus/ledstripselectanimationmenu.h new file mode 100644 index 0000000..1548ed0 --- /dev/null +++ b/main/displays/menus/ledstripselectanimationmenu.h @@ -0,0 +1,37 @@ +#pragma once + +// Local includes +#include "menudisplay.h" +#include "utils.h" +#include "menuitem.h" +#include "ledstrip.h" +#include "ledstripselectanimationmenu.h" +#include "icons/back.h" +#include "texts.h" +#include "actions/dummyaction.h" +#include "actions/ledstripanimationactions.h" +#include "actions/switchscreenaction.h" + +using namespace espgui; + +namespace { + class LedstripMenu; +} + +namespace { + class LedstripSelectAnimationMenu : + public MenuDisplay, + public StaticText, + public BackActionInterface> + { + public: + LedstripSelectAnimationMenu() + { + constructMenuItem, LedstripAnimationDefaultRainbowAction>>(); + constructMenuItem, LedstripAnimationBlinkLeftAction>>(); + constructMenuItem, LedstripAnimationBlinkRightAction>>(); + constructMenuItem, LedstripAnimationBlinkBothAction>>(); + constructMenuItem, SwitchScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); + } + }; +} // Namespace diff --git a/main/ledstripdefines.h b/main/ledstripdefines.h new file mode 100644 index 0000000..e69de29 diff --git a/main/texts.h b/main/texts.h index 262c8df..c459f20 100644 --- a/main/texts.h +++ b/main/texts.h @@ -249,6 +249,13 @@ constexpr char TEXT_SMALLOFFSET[] = "Small Offset"; constexpr char TEXT_BIGOFFSET[] = "Big Offset"; //constexpr char TEXT_BACK[] = "Back"; +//LedstripSelectAnimationMenu +constexpr char TEXT_SELECTANIMATION[] = "Select Animation"; +constexpr char TEXT_ANIMATION_DEFAULTRAINBOW[] = "Default Rainbow"; +constexpr char TEXT_ANIMATION_BLINKLEFT[] = "Blink Left"; +constexpr char TEXT_ANIMATION_BLINKRIGHT[] = "Blink Right"; +constexpr char TEXT_ANIMATION_BLINKBOTH[] = "Blink Both"; + //LockscreenSettingsMenu constexpr char TEXT_LOCKSCREENSETTINGS[] = "Lockscreen Settings"; constexpr char TEXT_ALLOWPRESETSWITCH[] = "Allow preset switch"; From fb120aa7f8201fc2f00d22905c52f8f82390a847 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Thu, 30 Sep 2021 14:09:05 +0200 Subject: [PATCH 4/7] Added defines for code quality --- main/ledstrip.h | 9 +++++---- main/ledstripdefines.h | 10 ++++++++++ 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/main/ledstrip.h b/main/ledstrip.h index 4951ce0..37880ac 100644 --- a/main/ledstrip.h +++ b/main/ledstrip.h @@ -8,12 +8,13 @@ #include "globals.h" #include "cpputils.h" #include "espchrono.h" +#include "ledstripdefines.h" namespace { std::vector leds; uint8_t gHue = 0; -int16_t blinkAnimation = 0; +int16_t blinkAnimation = LEDSTRIP_ANIMATION_DEFAULT; void showDefaultLedstrip(); @@ -28,7 +29,7 @@ void updateLedStrip() { EVERY_N_MILLISECONDS( 20 ) { gHue++; } - if (cpputils::is_in(blinkAnimation, 1, 2, 3)) + if (cpputils::is_in(blinkAnimation, LEDSTRIP_ANIMATION_BLINKLEFT, LEDSTRIP_ANIMATION_BLINKRIGHT, LEDSTRIP_ANIMATION_BLINKBOTH)) { std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0}); @@ -37,9 +38,9 @@ void updateLedStrip() auto color = CRGB{255, 255, 0}; const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset); - if (blinkAnimation != 2) + if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKRIGHT) std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color); - if (blinkAnimation != 1) + if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKLEFT) std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color); } } diff --git a/main/ledstripdefines.h b/main/ledstripdefines.h index e69de29..88be16e 100644 --- a/main/ledstripdefines.h +++ b/main/ledstripdefines.h @@ -0,0 +1,10 @@ +#pragma once +/* + * This file contains a few defines, so you don't have to remember which ledstrip animation is which number + */ +#define LEDSTRIP_ANIMATION_DEFAULTRAINBOW 0 +#define LEDSTRIP_ANIMATION_BLINKLEFT 1 +#define LEDSTRIP_ANIMATION_BLINKRIGHT 2 +#define LEDSTRIP_ANIMATION_BLINKBOTH 3 + +#define LEDSTRIP_ANIMATION_DEFAULT LEDSTRIP_ANIMATION_DEFAULTRAINBOW From 99f4d916d3f6a217b13d9a955712b6a85a7f03d1 Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Thu, 30 Sep 2021 14:17:46 +0200 Subject: [PATCH 5/7] Switched left and right --- main/ledstripdefines.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/ledstripdefines.h b/main/ledstripdefines.h index 88be16e..a8f418f 100644 --- a/main/ledstripdefines.h +++ b/main/ledstripdefines.h @@ -3,8 +3,8 @@ * This file contains a few defines, so you don't have to remember which ledstrip animation is which number */ #define LEDSTRIP_ANIMATION_DEFAULTRAINBOW 0 -#define LEDSTRIP_ANIMATION_BLINKLEFT 1 -#define LEDSTRIP_ANIMATION_BLINKRIGHT 2 +#define LEDSTRIP_ANIMATION_BLINKLEFT 2 +#define LEDSTRIP_ANIMATION_BLINKRIGHT 1 #define LEDSTRIP_ANIMATION_BLINKBOTH 3 #define LEDSTRIP_ANIMATION_DEFAULT LEDSTRIP_ANIMATION_DEFAULTRAINBOW From 0b0e49cf93db4e735d9e7033d326fcb8fa381ecb Mon Sep 17 00:00:00 2001 From: CommanderRedYT Date: Thu, 30 Sep 2021 14:22:44 +0200 Subject: [PATCH 6/7] Fixed / revert 'Switched left and right' --- main/ledstrip.h | 4 ++-- main/ledstripdefines.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/main/ledstrip.h b/main/ledstrip.h index 37880ac..29d6278 100644 --- a/main/ledstrip.h +++ b/main/ledstrip.h @@ -38,9 +38,9 @@ void updateLedStrip() auto color = CRGB{255, 255, 0}; const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset); - if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKRIGHT) - std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color); if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKLEFT) + std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color); + if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKRIGHT) std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color); } } diff --git a/main/ledstripdefines.h b/main/ledstripdefines.h index a8f418f..88be16e 100644 --- a/main/ledstripdefines.h +++ b/main/ledstripdefines.h @@ -3,8 +3,8 @@ * This file contains a few defines, so you don't have to remember which ledstrip animation is which number */ #define LEDSTRIP_ANIMATION_DEFAULTRAINBOW 0 -#define LEDSTRIP_ANIMATION_BLINKLEFT 2 -#define LEDSTRIP_ANIMATION_BLINKRIGHT 1 +#define LEDSTRIP_ANIMATION_BLINKLEFT 1 +#define LEDSTRIP_ANIMATION_BLINKRIGHT 2 #define LEDSTRIP_ANIMATION_BLINKBOTH 3 #define LEDSTRIP_ANIMATION_DEFAULT LEDSTRIP_ANIMATION_DEFAULTRAINBOW From 4613dc7259c6a54eb9f4ad03c4b4825436f5e391 Mon Sep 17 00:00:00 2001 From: Peter Poetzi Date: Thu, 30 Sep 2021 00:24:36 +0200 Subject: [PATCH 7/7] peters config --- config_peter.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config_peter.cmake b/config_peter.cmake index 776f6c6..0618d86 100644 --- a/config_peter.cmake +++ b/config_peter.cmake @@ -81,12 +81,12 @@ set(BOBBYCAR_BUILDFLAGS # -DDEFAULT_GAMETRAKDISTMIN=0 # -DDEFAULT_GAMETRAKDISTMAX=4095 # -DFEATURE_POWERSUPPLY - # -DFEATURE_CLOUD + -DFEATURE_CLOUD -DFEATURE_LEDBACKLIGHT -DPINS_LEDBACKLIGHT=23 -DLEDBACKLIGHT_INVERTED - # -DFEATURE_GARAGE - # -DFEATURE_NTP + -DFEATURE_GARAGE + -DFEATURE_NTP -DFEATURE_WIRELESS_CONFIG -DFEATURE_LEDSTRIP -DPINS_LEDSTRIP=33