BIG ledstrip update

This commit is contained in:
2021-09-10 21:13:34 +02:00
parent d3ed93ef5f
commit 71675f68b3
24 changed files with 199 additions and 76 deletions

View File

@ -86,5 +86,5 @@ set(BOBBYCAR_BUILDFLAGS
# -DFEATURE_WIRELESS_CONFIG # -DFEATURE_WIRELESS_CONFIG
-DFEATURE_LEDSTRIP -DFEATURE_LEDSTRIP
-DPINS_LEDSTRIP=26 -DPINS_LEDSTRIP=26
-DLEDSTRIP_LENGTH=95 -DLEDSTRIP_LENGTH=200
) )

View File

@ -144,6 +144,11 @@ struct LarsmModeModeAccessor : public RefAccessorSaveSettings<LarsmModeMode> { L
struct LarsmModeIterationsAccessor : public RefAccessorSaveSettings<uint8_t> { uint8_t &getRef() const override { return settings.larsmMode.iterations; } }; struct LarsmModeIterationsAccessor : public RefAccessorSaveSettings<uint8_t> { uint8_t &getRef() const override { return settings.larsmMode.iterations; } };
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
struct EnableLedAnimationAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableLedAnimation; } };
struct EnableBrakeLightsAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableBrakeLights; } }; struct EnableBrakeLightsAccessor : public RefAccessorSaveSettings<bool> { bool &getRef() const override { return settings.ledstrip.enableBrakeLights; } };
struct LedsCountAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.ledsCount; } };
struct CenterOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.centerOffset; } };
struct SmallOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.smallOffset; } };
struct BigOffsetAccessor : public RefAccessorSaveSettings<int16_t> { int16_t &getRef() const override { return settings.ledstrip.bigOffset; } };
#endif #endif
} }

View File

@ -29,7 +29,7 @@ void initCloud()
if (!cloudClient) if (!cloudClient)
return; return;
if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED)
return; return;
startCloud(); startCloud();
@ -54,7 +54,7 @@ void handleCloud()
if (espchrono::ago(lastStartTry) < 10s) if (espchrono::ago(lastStartTry) < 10s)
return; return;
if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() != wifi_stack::WiFiStaStatus::CONNECTED)
return; return;
startCloud(); startCloud();
@ -66,7 +66,7 @@ void handleCloud()
return; return;
std::string rssi = "null"; std::string rssi = "null";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const auto &result = wifi_stack::get_sta_ap_info(); result) if (const auto &result = wifi_stack::get_sta_ap_info(); result)
rssi = std::to_string(result->rssi); rssi = std::to_string(result->rssi);

View File

@ -1,8 +1,14 @@
#pragma once #pragma once
// system includes
#include <bitset> #include <bitset>
#include <memory> #include <memory>
// 3rdparty lib includes
#include <randomutils.h>
#include <esprandom.h>
// local includes
#include "display.h" #include "display.h"
#include "actions/switchscreenaction.h" #include "actions/switchscreenaction.h"
@ -132,7 +138,7 @@ void GameOfLifeDisplay::initGrid()
(*m_grid)[index(x,y)] = 0; (*m_grid)[index(x,y)] = 0;
else else
{ {
if (random(3) == 1) if (cpputils::randomNumber<uint8_t>(4, espcpputils::esp_random_device{}) == 1)
(*m_grid)[index(x,y)] = 1; (*m_grid)[index(x,y)] = 1;
else else
(*m_grid)[index(x,y)] = 0; (*m_grid)[index(x,y)] = 0;

View File

@ -7,6 +7,8 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <espchrono.h> #include <espchrono.h>
#include <fmt/core.h> #include <fmt/core.h>
#include <randomutils.h>
#include <esprandom.h>
// local includes // local includes
#include "menudisplay.h" #include "menudisplay.h"
@ -36,8 +38,8 @@ public:
const auto now = espchrono::millis_clock::now(); const auto now = espchrono::millis_clock::now();
if (!m_nextUpdate || now >= *m_nextUpdate) if (!m_nextUpdate || now >= *m_nextUpdate)
{ {
m_title = fmt::format("Dynamic text: {}", random(0, 100)); m_title = fmt::format("Dynamic text: {}", cpputils::randomNumber<uint8_t>(100, espcpputils::esp_random_device{}));
m_nextUpdate = now + std::chrono::milliseconds{random(0, 1000)}; m_nextUpdate = now + std::chrono::milliseconds{cpputils::randomNumber<long>(100, 1000, espcpputils::esp_random_device{})};
} }
return m_title; return m_title;
@ -57,8 +59,8 @@ public:
if (!m_nextUpdate || now >= *m_nextUpdate) if (!m_nextUpdate || now >= *m_nextUpdate)
{ {
const auto count = std::size(default_4bit_palette); const auto count = std::size(default_4bit_palette);
m_color = default_4bit_palette[random(0, count)]; m_color = default_4bit_palette[cpputils::randomNumber<uint32_t>(count-1, espcpputils::esp_random_device{})];
m_nextUpdate = now + std::chrono::milliseconds{random(0, 1000)}; m_nextUpdate = now + std::chrono::milliseconds{cpputils::randomNumber<long>(100, 1000, espcpputils::esp_random_device{})};
} }
return m_color; return m_color;
@ -77,8 +79,9 @@ public:
const auto now = espchrono::millis_clock::now(); const auto now = espchrono::millis_clock::now();
if (!m_nextUpdate || now >= *m_nextUpdate) if (!m_nextUpdate || now >= *m_nextUpdate)
{ {
m_font = random(1, 5); constexpr const int fonts[] = { 2, 4 };
m_nextUpdate = now + std::chrono::milliseconds{random(0, 1000)}; m_font = fonts[cpputils::randomNumber<uint32_t>(std::size(fonts)-1, espcpputils::esp_random_device{})];
m_nextUpdate = now + std::chrono::milliseconds{cpputils::randomNumber<long>(100, 1000, espcpputils::esp_random_device{})};
} }
return m_font; return m_font;
@ -101,7 +104,7 @@ public:
m_icon = nullptr; m_icon = nullptr;
else else
m_icon = &icons::lock; m_icon = &icons::lock;
m_nextUpdate = now + std::chrono::milliseconds{random(0, 1000)}; m_nextUpdate = now + std::chrono::milliseconds{cpputils::randomNumber<long>(100, 1000, espcpputils::esp_random_device{})};
} }
return m_icon; return m_icon;

View File

@ -13,6 +13,7 @@
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
#include "ledstrip.h" #include "ledstrip.h"
#endif #endif
#include "changevaluedisplay.h"
// forward declares // forward declares
namespace { namespace {
@ -23,7 +24,49 @@ using namespace espgui;
namespace { namespace {
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
struct EnableLedAnimationAccessor : public RefAccessor<bool> { bool &getRef() const override { return enableLedAnimation; } }; class LedstripMenu;
struct BlinkAnimationAccessor : public RefAccessor<int16_t> { int16_t &getRef() const override { return blinkAnimation; } };
using BlinkAnimationChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_BLINKANIMATION>,
BlinkAnimationAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using LedsCountChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_LEDSCOUNT>,
LedsCountAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using CenterOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_CENTEROFFSET>,
CenterOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using SmallOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_SMALLOFFSET>,
SmallOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
using BigOffsetChangeScreen = makeComponent<
ChangeValueDisplay<int16_t>,
StaticText<TEXT_BIGOFFSET>,
BigOffsetAccessor,
BackActionInterface<SwitchScreenAction<LedstripMenu>>,
SwitchScreenAction<LedstripMenu>
>;
class LedstripMenu : class LedstripMenu :
public MenuDisplay, public MenuDisplay,
@ -35,6 +78,11 @@ public:
{ {
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDANIMATION>, ToggleBoolAction, CheckboxIcon, EnableLedAnimationAccessor>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_LEDANIMATION>, ToggleBoolAction, CheckboxIcon, EnableLedAnimationAccessor>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BRAKELIGHTS>, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BRAKELIGHTS>, ToggleBoolAction, CheckboxIcon, EnableBrakeLightsAccessor>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BLINKANIMATION, LedsCountAccessor>, 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>>>();
constructMenuItem<makeComponent<MenuItem, TextWithValueHelper<TEXT_BIGOFFSET, BigOffsetAccessor>, SwitchScreenAction<BigOffsetChangeScreen>>>();
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, SwitchScreenAction<MainMenu>, StaticMenuItemIcon<&espgui::icons::back>>>();
} }
}; };

View File

@ -1,7 +1,13 @@
#pragma once #pragma once
// system includes
#include <cstdint> #include <cstdint>
// 3rdparty lib includes
#include <randomutils.h>
#include <esprandom.h>
// local includes
#include "display.h" #include "display.h"
#include "actions/switchscreenaction.h" #include "actions/switchscreenaction.h"
@ -74,8 +80,8 @@ private:
}; };
PingPongDisplay::PingPongDisplay() : PingPongDisplay::PingPongDisplay() :
lpaddle_y(random(0, h - paddle_h)), lpaddle_y(cpputils::randomNumber<uint8_t>(0, h - paddle_h, espcpputils::esp_random_device{})),
rpaddle_y(random(0, h - paddle_h)), rpaddle_y(cpputils::randomNumber<uint8_t>(0, h - paddle_h, espcpputils::esp_random_device{})),
// ball is placed on the center of the left paddle // ball is placed on the center of the left paddle
ball_y(lpaddle_y + (paddle_h / 2)) ball_y(lpaddle_y + (paddle_h / 2))
{ {
@ -207,11 +213,11 @@ void PingPongDisplay::ball()
if (ball_dx == -1 && ball_x == paddle_w && ball_y + ball_h >= lpaddle_y && ball_y <= lpaddle_y + paddle_h) { if (ball_dx == -1 && ball_x == paddle_w && ball_y + ball_h >= lpaddle_y && ball_y <= lpaddle_y + paddle_h) {
ball_dx = ball_dx * -1; ball_dx = ball_dx * -1;
dly = random(5); // change speed of ball after paddle contact dly = cpputils::randomNumber<uint8_t>(5, espcpputils::esp_random_device{}); // change speed of ball after paddle contact
calc_target_y(); calc_target_y();
} else if (ball_dx == 1 && ball_x + ball_w == w - paddle_w && ball_y + ball_h >= rpaddle_y && ball_y <= rpaddle_y + paddle_h) { } else if (ball_dx == 1 && ball_x + ball_w == w - paddle_w && ball_y + ball_h >= rpaddle_y && ball_y <= rpaddle_y + paddle_h) {
ball_dx = ball_dx * -1; ball_dx = ball_dx * -1;
dly = random(5); // change speed of ball after paddle contact dly = cpputils::randomNumber<uint8_t>(5, espcpputils::esp_random_device{}); // change speed of ball after paddle contact
calc_target_y(); calc_target_y();
} else if ((ball_dx == 1 && ball_x >= w) || (ball_dx == -1 && ball_x + ball_w < 0)) { } else if ((ball_dx == 1 && ball_x >= w) || (ball_dx == -1 && ball_x + ball_w < 0)) {
dly = 5; dly = 5;

View File

@ -1,7 +1,13 @@
#pragma once #pragma once
// system includes
#include <cstdint> #include <cstdint>
// 3rdparty lib includes
#include <randomutils.h>
#include <esprandom.h>
// local includes
#include "display.h" #include "display.h"
#include "actions/switchscreenaction.h" #include "actions/switchscreenaction.h"
@ -42,8 +48,8 @@ void SpiroDisplay::redraw()
if (i == 0) if (i == 0)
{ {
tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
n = random(2, 23); n = cpputils::randomNumber<uint8_t>(2, 23, espcpputils::esp_random_device{});
r = random(20, 100); r = cpputils::randomNumber<uint8_t>(20, 100, espcpputils::esp_random_device{});
colour = 0; //rainbow(); colour = 0; //rainbow();
} }
@ -64,7 +70,7 @@ void SpiroDisplay::redraw()
if (i == (360 * n)) if (i == (360 * n))
{ {
r = random(20, 100);//r = r / random(2,4); r = cpputils::randomNumber<uint8_t>(20, 100, espcpputils::esp_random_device{});//r = r / random(2,4);
} }
if (i >= (360 * n)) if (i >= (360 * n))

View File

@ -1,9 +1,13 @@
#pragma once #pragma once
// system includes
#include <cstdint> #include <cstdint>
#include <Arduino.h> // 3rdparty lib includes
#include <randomutils.h>
#include <esprandom.h>
// local includes
#include "display.h" #include "display.h"
#include "actions/switchscreenaction.h" #include "actions/switchscreenaction.h"
#include "globals.h" #include "globals.h"
@ -36,10 +40,10 @@ private:
}; };
StarfieldDisplay::StarfieldDisplay() : StarfieldDisplay::StarfieldDisplay() :
za(random(256)), za(cpputils::randomNumber<uint8_t>(256, espcpputils::esp_random_device{})),
zb(random(256)), zb(cpputils::randomNumber<uint8_t>(256, espcpputils::esp_random_device{})),
zc(random(256)), zc(cpputils::randomNumber<uint8_t>(256, espcpputils::esp_random_device{})),
zx(random(256)) zx(cpputils::randomNumber<uint8_t>(256, espcpputils::esp_random_device{}))
{ {
} }

View File

@ -167,7 +167,7 @@ void StatusDisplay::redraw()
tft.setTextFont(2); tft.setTextFont(2);
const auto staStatus = wifi_stack::get_sta_status(); const auto staStatus = wifi_stack::get_sta_status();
if (staStatus == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (staStatus == wifi_stack::WiFiStaStatus::CONNECTED)
{ {
if (const auto result = wifi_stack::get_sta_ap_info(); result) if (const auto result = wifi_stack::get_sta_ap_info(); result)
{ {
@ -191,7 +191,7 @@ showStaStatus:
m_labelLimit0.redraw(fmt::format("{}A", controllers.front.command.left.iMotMax)); m_labelLimit0.redraw(fmt::format("{}A", controllers.front.command.left.iMotMax));
if (staStatus == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (staStatus == wifi_stack::WiFiStaStatus::CONNECTED)
{ {
if (const auto result = wifi_stack::get_ip_info(TCPIP_ADAPTER_IF_STA); result) if (const auto result = wifi_stack::get_ip_info(TCPIP_ADAPTER_IF_STA); result)
m_labelIpAddress.redraw(wifi_stack::toString(result->ip)); m_labelIpAddress.redraw(wifi_stack::toString(result->ip));

View File

@ -6,18 +6,21 @@
// local includes // local includes
#include "globals.h" #include "globals.h"
#include "cpputils.h"
#include "espchrono.h"
namespace { namespace {
bool enableLedAnimation{false}; std::vector<CRGB> leds;
std::array<CRGB, LEDSTRIP_LENGTH> leds;
uint8_t gHue = 0; uint8_t gHue = 0;
int16_t blinkAnimation = 0;
void showDefaultLedstrip(); void showDefaultLedstrip();
void initLedStrip() void initLedStrip()
{ {
FastLED.addLeds<NEOPIXEL, PINS_LEDSTRIP>(std::begin(leds), leds.size()) leds.resize(settings.ledstrip.ledsCount);
FastLED.addLeds<NEOPIXEL, PINS_LEDSTRIP>(&*std::begin(leds), leds.size())
.setCorrection(TypicalSMD5050); .setCorrection(TypicalSMD5050);
} }
@ -25,47 +28,63 @@ void updateLedStrip()
{ {
EVERY_N_MILLISECONDS( 20 ) { gHue++; } EVERY_N_MILLISECONDS( 20 ) { gHue++; }
if (settings.ledstrip.enableBrakeLights) if (cpputils::is_in(blinkAnimation, 1, 2, 3))
{ {
float avgPwm{}; std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
for (const Controller &controller : controllers)
if (espchrono::millis_clock::now().time_since_epoch() % 750ms < 375ms)
{ {
avgPwm += auto color = CRGB{255, 255, 0};
controller.command.left.pwm * (controller.invertLeft ? -1 : 1) + const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
controller.command.right.pwm * (controller.invertRight ? -1 : 1);
if (blinkAnimation != 2)
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
if (blinkAnimation != 1)
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
} }
avgPwm /= 4; }
else
if (avgPwm < -1.f) {
if (settings.ledstrip.enableBrakeLights)
{ {
auto color = avgSpeedKmh < -0.1f ? CRGB{255, 255, 255} : CRGB{255, 0, 0}; float avgPwm{};
constexpr auto kleinerOffset = 4; for (const Controller &controller : controllers)
constexpr auto grosserOffset = 10; {
avgPwm +=
controller.command.left.pwm * (controller.invertLeft ? -1 : 1) +
controller.command.right.pwm * (controller.invertRight ? -1 : 1);
}
avgPwm /= 4;
const auto center = std::begin(leds) + (leds.size() / 2) + 1; if (avgPwm < -1.f)
{
auto color = avgSpeedKmh < -0.1f ? CRGB{255, 255, 255} : CRGB{255, 0, 0};
std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0}); const auto center = (std::begin(leds) + (leds.size() / 2) + settings.ledstrip.centerOffset);
std::fill(center - grosserOffset, center - kleinerOffset, color);
std::fill(center + kleinerOffset, center + grosserOffset, color); std::fill(std::begin(leds), std::end(leds), CRGB{0, 0, 0});
std::fill(center - settings.ledstrip.bigOffset, center - settings.ledstrip.smallOffset, color);
std::fill(center + settings.ledstrip.smallOffset, center + settings.ledstrip.bigOffset, color);
}
else
{
showDefaultLedstrip();
}
} }
else else
{ {
showDefaultLedstrip(); showDefaultLedstrip();
} }
} }
else
{
showDefaultLedstrip();
}
FastLED.show(); FastLED.show();
} }
void showDefaultLedstrip() void showDefaultLedstrip()
{ {
if (enableLedAnimation) if (settings.ledstrip.enableLedAnimation)
{ {
fadeToBlackBy(std::begin(leds), leds.size(), 20); fadeToBlackBy(&*std::begin(leds), leds.size(), 20);
uint8_t dothue = 0; uint8_t dothue = 0;
for (int i = 0; i < 8; i++) for (int i = 0; i < 8; i++)

View File

@ -215,7 +215,12 @@ constexpr Settings::LarsmMode defaultLarsmMode {
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
constexpr Settings::Ledstrip defaultLedstrip { constexpr Settings::Ledstrip defaultLedstrip {
.enableBrakeLights = true .enableLedAnimation = true,
.enableBrakeLights = true,
.ledsCount = LEDSTRIP_LENGTH,
.centerOffset = 1,
.smallOffset = 4,
.bigOffset = 10
}; };
#endif #endif

View File

@ -149,7 +149,12 @@ struct Settings
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
struct Ledstrip { struct Ledstrip {
bool enableLedAnimation;
bool enableBrakeLights; bool enableBrakeLights;
int16_t ledsCount;
int16_t centerOffset;
int16_t smallOffset;
int16_t bigOffset;
} ledstrip; } ledstrip;
#endif #endif
@ -236,7 +241,12 @@ void Settings::executeForEveryCommonSetting(T &&callable)
#endif #endif
#ifdef FEATURE_LEDSTRIP #ifdef FEATURE_LEDSTRIP
callable("enableLedAnimat", ledstrip.enableLedAnimation);
callable("enableBrakeLigh", ledstrip.enableBrakeLights); callable("enableBrakeLigh", ledstrip.enableBrakeLights);
callable("ledsCount", ledstrip.ledsCount);
callable("centerOffset", ledstrip.centerOffset);
callable("smallOffset", ledstrip.smallOffset);
callable("bigOffset", ledstrip.bigOffset);
#endif #endif
} }

View File

@ -45,7 +45,7 @@ void pushStats()
statistics::bmsCurrent.push_back(bms::current); statistics::bmsCurrent.push_back(bms::current);
statistics::bmsPower.push_back(bms::power); statistics::bmsPower.push_back(bms::power);
#endif #endif
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
{ {
if (const auto &result = wifi_stack::get_sta_ap_info(); result) if (const auto &result = wifi_stack::get_sta_ap_info(); result)
statistics::rssi.push_back(result->rssi); statistics::rssi.push_back(result->rssi);

View File

@ -236,6 +236,11 @@ constexpr char TEXT_SETITERATIONS[] = "Set iterations";
constexpr char TEXT_LEDSTRIP[] = "Ledstrip"; constexpr char TEXT_LEDSTRIP[] = "Ledstrip";
constexpr char TEXT_LEDANIMATION[] = "LED Animation"; constexpr char TEXT_LEDANIMATION[] = "LED Animation";
constexpr char TEXT_BRAKELIGHTS[] = "Brake Lights"; constexpr char TEXT_BRAKELIGHTS[] = "Brake Lights";
constexpr char TEXT_BLINKANIMATION[] = "Blink animation";
constexpr char TEXT_LEDSCOUNT[] = "LEDs Count";
constexpr char TEXT_CENTEROFFSET[] = "Center Offset";
constexpr char TEXT_SMALLOFFSET[] = "Small Offset";
constexpr char TEXT_BIGOFFSET[] = "Big Offset";
//constexpr char TEXT_BACK[] = "Back"; //constexpr char TEXT_BACK[] = "Back";
//ModesSettingsMenu //ModesSettingsMenu

View File

@ -13,9 +13,9 @@ namespace {
wifi_stack::config wifi_create_config() wifi_stack::config wifi_create_config()
{ {
return wifi_stack::config { return wifi_stack::config {
.wifiEnabled = settings.wifiSettings.wifiEnabled,
.hostname = deviceName, .hostname = deviceName,
.sta = { .sta = {
.enabled = settings.wifiSettings.wifiEnabled,
.wifis = std::array<wifi_stack::wifi_entry, 10> { .wifis = std::array<wifi_stack::wifi_entry, 10> {
wifi_stack::wifi_entry { .ssid = stringSettings.wifis[0].ssid, .key = stringSettings.wifis[0].key }, wifi_stack::wifi_entry { .ssid = stringSettings.wifis[0].ssid, .key = stringSettings.wifis[0].key },
wifi_stack::wifi_entry { .ssid = stringSettings.wifis[1].ssid, .key = stringSettings.wifis[1].key }, wifi_stack::wifi_entry { .ssid = stringSettings.wifis[1].ssid, .key = stringSettings.wifis[1].key },

View File

@ -45,7 +45,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "SSID: "; std::string text = "SSID: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const auto &result = wifi_stack::get_sta_ap_info(); result) if (const auto &result = wifi_stack::get_sta_ap_info(); result)
text += std::string_view{reinterpret_cast<const char*>(result->ssid)}; text += std::string_view{reinterpret_cast<const char*>(result->ssid)};
return text; return text;
@ -57,7 +57,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "BSSID: "; std::string text = "BSSID: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const auto &result = wifi_stack::get_sta_ap_info(); result) if (const auto &result = wifi_stack::get_sta_ap_info(); result)
text += wifi_stack::toString(wifi_stack::mac_t{result->bssid}); text += wifi_stack::toString(wifi_stack::mac_t{result->bssid});
return text; return text;
@ -69,7 +69,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "RSSI: "; std::string text = "RSSI: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const auto &result = wifi_stack::get_sta_ap_info(); result) if (const auto &result = wifi_stack::get_sta_ap_info(); result)
text += fmt::format("{}dB", result->rssi); text += fmt::format("{}dB", result->rssi);
return text; return text;
@ -81,7 +81,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "encryptionType: "; std::string text = "encryptionType: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const auto &result = wifi_stack::get_sta_ap_info(); result) if (const auto &result = wifi_stack::get_sta_ap_info(); result)
text += wifi_stack::toString(result->authmode); text += wifi_stack::toString(result->authmode);
return text; return text;
@ -93,7 +93,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "pairwiseCipher: "; std::string text = "pairwiseCipher: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const auto &result = wifi_stack::get_sta_ap_info(); result) if (const auto &result = wifi_stack::get_sta_ap_info(); result)
text += wifi_stack::toString(result->pairwise_cipher); text += wifi_stack::toString(result->pairwise_cipher);
return text; return text;
@ -105,7 +105,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "groupCipher: "; std::string text = "groupCipher: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const auto &result = wifi_stack::get_sta_ap_info(); result) if (const auto &result = wifi_stack::get_sta_ap_info(); result)
text += wifi_stack::toString(result->group_cipher); text += wifi_stack::toString(result->group_cipher);
return text; return text;
@ -117,7 +117,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "ip: "; std::string text = "ip: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const auto result = wifi_stack::get_ip_info(TCPIP_ADAPTER_IF_STA); result) if (const auto result = wifi_stack::get_ip_info(TCPIP_ADAPTER_IF_STA); result)
text += wifi_stack::toString(result->ip); text += wifi_stack::toString(result->ip);
return text; return text;
@ -129,7 +129,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "netmask: "; std::string text = "netmask: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const auto result = wifi_stack::get_ip_info(TCPIP_ADAPTER_IF_STA); result) if (const auto result = wifi_stack::get_ip_info(TCPIP_ADAPTER_IF_STA); result)
text += wifi_stack::toString(result->netmask); text += wifi_stack::toString(result->netmask);
return text; return text;
@ -141,7 +141,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "gateway: "; std::string text = "gateway: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const auto result = wifi_stack::get_ip_info(TCPIP_ADAPTER_IF_STA); result) if (const auto result = wifi_stack::get_ip_info(TCPIP_ADAPTER_IF_STA); result)
text += wifi_stack::toString(result->gw); text += wifi_stack::toString(result->gw);
return text; return text;
@ -153,7 +153,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "ipv6: "; std::string text = "ipv6: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
{ {
esp_ip6_addr_t addr; esp_ip6_addr_t addr;
if (const auto result = esp_netif_get_ip6_linklocal(wifi_stack::esp_netifs[ESP_IF_WIFI_STA], &addr); result == ESP_OK) if (const auto result = esp_netif_get_ip6_linklocal(wifi_stack::esp_netifs[ESP_IF_WIFI_STA], &addr); result == ESP_OK)
@ -168,7 +168,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "ipv6: "; std::string text = "ipv6: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
{ {
esp_ip6_addr_t addr; esp_ip6_addr_t addr;
if (const auto result = esp_netif_get_ip6_global(wifi_stack::esp_netifs[ESP_IF_WIFI_STA], &addr); result == ESP_OK) if (const auto result = esp_netif_get_ip6_global(wifi_stack::esp_netifs[ESP_IF_WIFI_STA], &addr); result == ESP_OK)
@ -183,7 +183,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "dns0: "; std::string text = "dns0: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const ip_addr_t *dns_ip = dns_getserver(0)) if (const ip_addr_t *dns_ip = dns_getserver(0))
text += wifi_stack::toString(*dns_ip); text += wifi_stack::toString(*dns_ip);
return text; return text;
@ -195,7 +195,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "dns1: "; std::string text = "dns1: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const ip_addr_t *dns_ip = dns_getserver(1)) if (const ip_addr_t *dns_ip = dns_getserver(1))
text += wifi_stack::toString(*dns_ip); text += wifi_stack::toString(*dns_ip);
return text; return text;
@ -207,7 +207,7 @@ public:
std::string text() const override std::string text() const override
{ {
std::string text = "dns2: "; std::string text = "dns2: ";
if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::WL_CONNECTED) if (wifi_stack::get_sta_status() == wifi_stack::WiFiStaStatus::CONNECTED)
if (const ip_addr_t *dns_ip = dns_getserver(2)) if (const ip_addr_t *dns_ip = dns_getserver(2))
text += wifi_stack::toString(*dns_ip); text += wifi_stack::toString(*dns_ip);
return text; return text;

View File

@ -162,6 +162,12 @@ CONFIG_ARDUINO_SELECTIVE_SPI=y
CONFIG_ARDUINO_SELECTIVE_Wire=y CONFIG_ARDUINO_SELECTIVE_Wire=y
# end of Arduino Configuration # end of Arduino Configuration
#
# ESP Gui settings
#
CONFIG_ESPGUI_MENUDISPLAY_ROWS=10
# end of ESP Gui settings
# #
# Simple Async HTTP Request # Simple Async HTTP Request
# #