diff --git a/config_feedc0de.cmake b/config_feedc0de.cmake index afaa1e8..974fdf9 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 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..00b80ea --- /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_DEFAULT; } +}; + +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/buttons.h b/main/buttons.h index 78b00b5..50eae28 100644 --- a/main/buttons.h +++ b/main/buttons.h @@ -8,6 +8,7 @@ // local includes #include "settingsutils.h" +#include "ledstripdefines.h" #ifdef FEATURE_LEDSTRIP #include "ledstrip.h" @@ -142,11 +143,11 @@ public: if(!pressed)return; #ifdef FEATURE_LEDSTRIP - if(blinkAnimation == 0){ //transition from off to left - blinkAnimation = 2; + if(blinkAnimation == LEDSTRIP_ANIMATION_DEFAULT){ //transition from off to left + blinkAnimation = LEDSTRIP_ANIMATION_BLINKLEFT; } - else if(blinkAnimation == 1){ // transition to warning - blinkAnimation = 3; + else if(blinkAnimation == LEDSTRIP_ANIMATION_BLINKRIGHT){ // transition to warning + blinkAnimation = LEDSTRIP_ANIMATION_BLINKBOTH; } else{ // transition to off blinkAnimation = 0; @@ -157,11 +158,11 @@ public: static void blinkRightButton(bool pressed){ if(!pressed)return; #ifdef FEATURE_LEDSTRIP - if(blinkAnimation == 0){ //transition from off to right - blinkAnimation = 1; + if(blinkAnimation == LEDSTRIP_ANIMATION_DEFAULT){ //transition from off to right + blinkAnimation = LEDSTRIP_ANIMATION_BLINKRIGHT; } - else if(blinkAnimation == 2){ // transition to warning - blinkAnimation = 3; + else if(blinkAnimation == LEDSTRIP_ANIMATION_BLINKLEFT){ // transition to warning + blinkAnimation = LEDSTRIP_ANIMATION_BLINKBOTH; } else{ // transition to off blinkAnimation = 0; 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(); } diff --git a/main/displays/menus/ledstripmenu.h b/main/displays/menus/ledstripmenu.h index 23e0ace..49d9886 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; } }; @@ -86,7 +88,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/ledstrip.h b/main/ledstrip.h index 3cbc83a..c59e6ae 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}); @@ -43,9 +44,9 @@ void updateLedStrip() } #endif - if (blinkAnimation != 2) + if (blinkAnimation != LEDSTRIP_ANIMATION_BLINKLEFT) std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color); - if (blinkAnimation != 1) + 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 new file mode 100644 index 0000000..36e368d --- /dev/null +++ b/main/ledstripdefines.h @@ -0,0 +1,8 @@ +#pragma once +/* + * This file contains a few defines, so you don't have to remember which ledstrip animation is which number + */ +#define LEDSTRIP_ANIMATION_DEFAULT 0 +#define LEDSTRIP_ANIMATION_BLINKLEFT 1 +#define LEDSTRIP_ANIMATION_BLINKRIGHT 2 +#define LEDSTRIP_ANIMATION_BLINKBOTH 3 diff --git a/main/texts.h b/main/texts.h index a2aab9b..155b7db 100644 --- a/main/texts.h +++ b/main/texts.h @@ -250,6 +250,13 @@ constexpr char TEXT_BIGOFFSET[] = "Big Offset"; constexpr char TEXT_LEDSTRIP_MILLIAMP[] = "Ledstrip 0.1A"; //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";