merge led defines
This commit is contained in:
@ -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
|
||||
|
@ -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
|
||||
|
35
main/actions/ledstripanimationactions.h
Normal file
35
main/actions/ledstripanimationactions.h
Normal file
@ -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; }
|
||||
};
|
||||
}
|
@ -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;
|
||||
|
@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
// Arduino includes
|
||||
#include <Arduino.h>
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
|
||||
// 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();
|
||||
}
|
||||
|
@ -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> { int16_t &getRef() const override { return blinkAnimation; } };
|
||||
|
||||
@ -86,7 +88,8 @@ public:
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDANIMATION>, ToggleBoolAction, CheckboxIcon, EnableLedAnimationAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BRAKELIGHTS>, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BLINKANIMATION, BlinkAnimationAccessor>, SwitchScreenAction<BlinkAnimationChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_SELECTANIMATION>, SwitchScreenAction<LedstripSelectAnimationMenu>>>();
|
||||
// constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BLINKANIMATION, BlinkAnimationAccessor>, SwitchScreenAction<BlinkAnimationChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_LEDSCOUNT, LedsCountAccessor>, SwitchScreenAction<LedsCountChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_CENTEROFFSET, CenterOffsetAccessor>, SwitchScreenAction<CenterOffsetChangeScreen>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_SMALLOFFSET, SmallOffsetAccessor>, SwitchScreenAction<SmallOffsetChangeScreen>>>();
|
||||
|
37
main/displays/menus/ledstripselectanimationmenu.h
Normal file
37
main/displays/menus/ledstripselectanimationmenu.h
Normal file
@ -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<TEXT_SELECTANIMATION>,
|
||||
public BackActionInterface<SwitchScreenAction<LedstripMenu>>
|
||||
{
|
||||
public:
|
||||
LedstripSelectAnimationMenu()
|
||||
{
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_DEFAULTRAINBOW>, LedstripAnimationDefaultRainbowAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKLEFT>, LedstripAnimationBlinkLeftAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKRIGHT>, LedstripAnimationBlinkRightAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_ANIMATION_BLINKBOTH>, LedstripAnimationBlinkBothAction>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<LedstripMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
};
|
||||
} // Namespace
|
@ -8,12 +8,13 @@
|
||||
#include "globals.h"
|
||||
#include "cpputils.h"
|
||||
#include "espchrono.h"
|
||||
#include "ledstripdefines.h"
|
||||
|
||||
namespace {
|
||||
std::vector<CRGB> 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);
|
||||
}
|
||||
}
|
||||
|
8
main/ledstripdefines.h
Normal file
8
main/ledstripdefines.h
Normal file
@ -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
|
@ -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";
|
||||
|
Reference in New Issue
Block a user