Merge pull request #331 from bobbycar-graz/more-displays
This commit is contained in:
Submodule components/esp-gui-lib updated: bb02a6c267...15bdca5645
@ -62,6 +62,7 @@ set(headers
|
||||
debuginputhandler.h
|
||||
debugtexthelpers.h
|
||||
displays/batterygraphdisplay.h
|
||||
displays/batteryinfodisplay.h
|
||||
displays/bmsdisplay.h
|
||||
displays/bobbychangevaluedisplay.h
|
||||
displays/bobbydisplay.h
|
||||
@ -156,10 +157,12 @@ set(headers
|
||||
displays/qrcodedebug.h
|
||||
displays/qrdisplay.h
|
||||
displays/qrimportdisplay.h
|
||||
displays/speedinfodisplay.h
|
||||
displays/spirodisplay.h
|
||||
displays/starfielddisplay.h
|
||||
displays/statusdisplay.h
|
||||
displays/updatedisplay.h
|
||||
displays/xydebugdisplay.h
|
||||
dnsannounce.h
|
||||
dpad.h
|
||||
dpad3wire.h
|
||||
@ -308,6 +311,7 @@ set(sources
|
||||
debuginputhandler.cpp
|
||||
debugtexthelpers.cpp
|
||||
displays/batterygraphdisplay.cpp
|
||||
displays/batteryinfodisplay.cpp
|
||||
displays/bmsdisplay.cpp
|
||||
displays/bobbychangevaluedisplay.cpp
|
||||
displays/bobbydisplay.cpp
|
||||
@ -400,10 +404,12 @@ set(sources
|
||||
displays/qrcodedebug.cpp
|
||||
displays/qrdisplay.cpp
|
||||
displays/qrimportdisplay.cpp
|
||||
displays/speedinfodisplay.cpp
|
||||
displays/spirodisplay.cpp
|
||||
displays/starfielddisplay.cpp
|
||||
displays/statusdisplay.cpp
|
||||
displays/updatedisplay.cpp
|
||||
displays/xydebugdisplay.cpp
|
||||
dnsannounce.cpp
|
||||
dpad.cpp
|
||||
dpad3wire.cpp
|
||||
|
@ -16,7 +16,7 @@ public:
|
||||
void triggered() override
|
||||
{
|
||||
if (auto result = configs.write_config(configs.ledstrip.animationType, type); !result)
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -6,7 +6,7 @@
|
||||
// local includes
|
||||
#include "displays/bobbypopupdisplay.h"
|
||||
|
||||
void BobbyErrorHandler::errorOccured(std::string &&error)
|
||||
void BobbyErrorHandler::errorOccurred(std::string &&error)
|
||||
{
|
||||
auto newDisplay = std::make_unique<BobbyPopupDisplay>(std::move(error), std::move(espgui::currentDisplay));
|
||||
newDisplay->initOverlay();
|
||||
|
@ -5,5 +5,5 @@
|
||||
|
||||
struct BobbyErrorHandler : public virtual espgui::ErrorHandlerInterface
|
||||
{
|
||||
void errorOccured(std::string &&error) override;
|
||||
void errorOccurred(std::string &&error) override;
|
||||
};
|
||||
|
80
main/displays/batteryinfodisplay.cpp
Normal file
80
main/displays/batteryinfodisplay.cpp
Normal file
@ -0,0 +1,80 @@
|
||||
#include "batteryinfodisplay.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <screenmanager.h>
|
||||
#include <tftinstance.h>
|
||||
|
||||
// local includes
|
||||
#include "battery.h"
|
||||
#include "displays/menus/mainmenu.h"
|
||||
#include "displays/metersdisplay.h"
|
||||
#include "displays/speedinfodisplay.h"
|
||||
#include "globals.h"
|
||||
#include "newsettings.h"
|
||||
|
||||
// display with big battery and ten bars (0-100%)
|
||||
|
||||
void BatteryInfoDisplay::initScreen()
|
||||
{
|
||||
using namespace espgui;
|
||||
Base::initScreen();
|
||||
|
||||
tft.drawRoundRect(m_offset, m_offset, tft.width() - (m_offset * 2), tft.height() - (m_offset * 2), 10, TFT_WHITE);
|
||||
tft.drawRoundRect((tft.width() / 2) - (m_offset / 2), m_offset / 2, m_offset, m_offset / 2, 3, TFT_WHITE);
|
||||
m_lastBarCount = 0;
|
||||
}
|
||||
|
||||
void BatteryInfoDisplay::redraw()
|
||||
{
|
||||
using namespace espgui;
|
||||
Base::redraw();
|
||||
|
||||
// calculate height of space available for all bars
|
||||
const auto min_x = m_offset + 3; // leave 2 pixels + 1 pixel for border
|
||||
const auto max_x = tft.width() - m_offset - 3;
|
||||
const auto topY = m_offset + 3;
|
||||
const auto bottomY = tft.height() - m_offset - 3;
|
||||
const auto height = bottomY - topY;
|
||||
const auto width = max_x - min_x;
|
||||
const uint16_t segment_height = (height / 10);
|
||||
|
||||
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
|
||||
{
|
||||
const auto cellType = configs.battery.cellType.value();
|
||||
const uint16_t percentage = getBatteryPercentage(*avgVoltage, cellType);
|
||||
const auto segment_count = std::max(percentage / 10, 1);
|
||||
|
||||
if (segment_count != m_lastBarCount)
|
||||
{
|
||||
m_lastBarCount = segment_count;
|
||||
// draw battery
|
||||
for (auto i = 0; i < 10; ++i)
|
||||
{
|
||||
const auto y = bottomY - (i * segment_height) - segment_height;
|
||||
tft.fillRoundRect(min_x, y, width, segment_height - 2, 10, segment_count > i ? TFT_GREEN : TFT_DARKGREY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// tft.fillRect(0, 0, tft.width(), topY, TFT_CYAN);
|
||||
// tft.fillRect(0, bottomY, tft.width(), tft.height()-bottomY, TFT_YELLOW);
|
||||
}
|
||||
|
||||
void BatteryInfoDisplay::buttonPressed(espgui::Button button)
|
||||
{
|
||||
Base::buttonPressed(button);
|
||||
|
||||
switch (button) {
|
||||
using espgui::Button;
|
||||
case Button::Right:
|
||||
espgui::pushScreen<MainMenu>();
|
||||
break;
|
||||
case Button::Up:
|
||||
espgui::switchScreen<MetersDisplay>();
|
||||
break;
|
||||
case Button::Down:
|
||||
espgui::switchScreen<SpeedInfoDisplay>();
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
18
main/displays/batteryinfodisplay.h
Normal file
18
main/displays/batteryinfodisplay.h
Normal file
@ -0,0 +1,18 @@
|
||||
#pragma once
|
||||
|
||||
// local includes
|
||||
#include "bobbydisplay.h"
|
||||
|
||||
class BatteryInfoDisplay : public BobbyDisplay
|
||||
{
|
||||
using Base = BobbyDisplay;
|
||||
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
private:
|
||||
static constexpr const auto m_offset = 40;
|
||||
uint16_t m_lastBarCount{0};
|
||||
};
|
@ -2,7 +2,7 @@
|
||||
|
||||
#if defined(FEATURE_BLUETOOTH) && defined(FEATURE_BMS)
|
||||
#include "displays/menus/mainmenu.h"
|
||||
#include "displays/metersdisplay.h"
|
||||
#include "displays/speedinfodisplay.h"
|
||||
#include "displays/statusdisplay.h"
|
||||
#include "screenmanager.h"
|
||||
#include "tftinstance.h"
|
||||
@ -102,7 +102,7 @@ void BmsDisplay::buttonPressed(espgui::Button button)
|
||||
{
|
||||
using espgui::Button;
|
||||
case Button::Right: pushScreen<MainMenu>(); break;
|
||||
case Button::Up: switchScreen<MetersDisplay>(); break;
|
||||
case Button::Up: switchScreen<SpeedInfoDisplay>(); break;
|
||||
case Button::Down: switchScreen<StatusDisplay>(); break;
|
||||
default:;
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ void ButtonCalibrateDisplay::update()
|
||||
|
||||
if (auto result = configs.write_config(configs.dpadMappingLeft, m_leftButton); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -66,7 +66,7 @@ void ButtonCalibrateDisplay::update()
|
||||
|
||||
if (auto result = configs.write_config(configs.dpadMappingRight, m_rightButton); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -75,7 +75,7 @@ void ButtonCalibrateDisplay::update()
|
||||
}
|
||||
if (auto result = configs.write_config(configs.dpadMappingUp, m_upButton); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
return;
|
||||
}
|
||||
else
|
||||
@ -84,7 +84,7 @@ void ButtonCalibrateDisplay::update()
|
||||
}
|
||||
if (auto result = configs.write_config(configs.dpadMappingDown, m_downButton); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
@ -182,7 +182,7 @@ public:
|
||||
{
|
||||
const auto result = twai_initiate_recovery();
|
||||
ESP_LOGI(TAG, "twai_initiate_recovery() returned %s", esp_err_to_name(result));
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("twai_initiate_recovery() returned {}", esp_err_to_name(result)));
|
||||
BobbyErrorHandler{}.errorOccurred(fmt::format("twai_initiate_recovery() returned {}", esp_err_to_name(result)));
|
||||
}
|
||||
};
|
||||
|
||||
@ -193,7 +193,7 @@ public:
|
||||
{
|
||||
const auto result = twai_stop();
|
||||
ESP_LOGI(TAG, "twai_stop() returned %s", esp_err_to_name(result));
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("twai_stop() returned {}", esp_err_to_name(result)));
|
||||
BobbyErrorHandler{}.errorOccurred(fmt::format("twai_stop() returned {}", esp_err_to_name(result)));
|
||||
}
|
||||
};
|
||||
|
||||
@ -204,7 +204,7 @@ public:
|
||||
{
|
||||
const auto result = twai_start();
|
||||
ESP_LOGI(TAG, "twai_start() returned %s", esp_err_to_name(result));
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("twai_start() returned {}", esp_err_to_name(result)));
|
||||
BobbyErrorHandler{}.errorOccurred(fmt::format("twai_start() returned {}", esp_err_to_name(result)));
|
||||
}
|
||||
};
|
||||
|
||||
@ -215,7 +215,7 @@ public:
|
||||
{
|
||||
const auto result = twai_driver_uninstall();
|
||||
ESP_LOGI(TAG, "twai_driver_uninstall() returned %s", esp_err_to_name(result));
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("twai_driver_uninstall() returned {}", esp_err_to_name(result)));
|
||||
BobbyErrorHandler{}.errorOccurred(fmt::format("twai_driver_uninstall() returned {}", esp_err_to_name(result)));
|
||||
}
|
||||
};
|
||||
|
||||
@ -230,7 +230,7 @@ public:
|
||||
|
||||
const auto result = twai_driver_install(&g_config, &t_config, &f_config);
|
||||
ESP_LOGI(TAG, "twai_driver_install() returned %s", esp_err_to_name(result));
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("twai_driver_install() returned {}", esp_err_to_name(result)));
|
||||
BobbyErrorHandler{}.errorOccurred(fmt::format("twai_driver_install() returned {}", esp_err_to_name(result)));
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "esptexthelpers.h"
|
||||
#include "accessors/settingsaccessors.h"
|
||||
#include "displays/qrcodedebug.h"
|
||||
#include "displays/xydebugdisplay.h"
|
||||
#include "displays/menus/taskmanagermenu.h"
|
||||
#ifdef FEATURE_CAN
|
||||
#include "displays/menus/candebugmenu.h"
|
||||
@ -38,6 +39,7 @@ constexpr char TEXT_TASKMANAGER[] = "Taskmanager";
|
||||
constexpr char TEXT_CANDEBUG[] = "CAN Debug";
|
||||
#endif
|
||||
constexpr char TEXT_QRCODE_DEBUG[] = "QR Debug";
|
||||
constexpr char TEXT_XY_DEBUG[] = "XY Debug";
|
||||
constexpr char TEXT_BATTERYDEBUG[] = "Bat Debug Menu";
|
||||
constexpr char TEXT_TOGGLECLOUDDEBUG[] = "Cloud Debug";
|
||||
//constexpr char TEXT_FRONTCOMMAND[] = "Front command";
|
||||
@ -67,6 +69,7 @@ DebugMenu::DebugMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CANDEBUG>, PushScreenAction<CanDebugMenu>>>();
|
||||
#endif
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_QRCODE_DEBUG>, PushScreenAction<QrCodeDebugDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_XY_DEBUG>, PushScreenAction<XYDebugDisplay>>>();
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BATTERYDEBUG>, PushScreenAction<BatteryDebugMenu>, StaticMenuItemIcon<&bobbyicons::battery>>>();
|
||||
if (configs.feature.udpcloud.isEnabled.value())
|
||||
{
|
||||
|
@ -101,7 +101,7 @@ class OpenPopupAction : public virtual espgui::ActionInterface
|
||||
public:
|
||||
void triggered() override
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured("Das\nist\nein sehr langer text, der nicht in eine zeile passt");
|
||||
BobbyErrorHandler{}.errorOccurred("Das\nist\nein sehr langer text, der nicht in eine zeile passt");
|
||||
}
|
||||
};
|
||||
} // namespace
|
||||
|
@ -129,84 +129,84 @@ void ExtraButtonCalibrateMenu::rawButtonPressed(uint8_t button)
|
||||
case WaitingUp2:
|
||||
if (auto result = configs.write_config(configs.dpadMappingUp2, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WaitingDown2:
|
||||
if (auto result = configs.write_config(configs.dpadMappingDown2, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WaitingLeft2:
|
||||
if (auto result = configs.write_config(configs.dpadMappingLeft2, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WaitingRight2:
|
||||
if (auto result = configs.write_config(configs.dpadMappingRight2, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WaitingProfile0:
|
||||
if (auto result = configs.write_config(configs.dpadMappingProfile0, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WaitingProfile1:
|
||||
if (auto result = configs.write_config(configs.dpadMappingProfile1, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WaitingProfile2:
|
||||
if (auto result = configs.write_config(configs.dpadMappingProfile2, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WaitingProfile3:
|
||||
if (auto result = configs.write_config(configs.dpadMappingProfile3, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WaitingExtra1:
|
||||
if (auto result = configs.write_config(configs.dpadMappingExtra1, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WaitingExtra2:
|
||||
if (auto result = configs.write_config(configs.dpadMappingExtra2, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WaitingExtra3:
|
||||
if (auto result = configs.write_config(configs.dpadMappingExtra3, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WaitingExtra4:
|
||||
if (auto result = configs.write_config(configs.dpadMappingExtra4, button); !result)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
@ -29,7 +29,7 @@ void exitFeatureFlagsMenu()
|
||||
espgui::popScreen();
|
||||
if (isDirty)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(TEXT_POPUP);
|
||||
BobbyErrorHandler{}.errorOccurred(TEXT_POPUP);
|
||||
}
|
||||
}
|
||||
|
||||
@ -77,7 +77,7 @@ public:
|
||||
void triggered() override
|
||||
{
|
||||
if (auto result = m_flag.isEnabled.write(configs.nvs_handle_user, !m_flag.isEnabled.value()); !result)
|
||||
errorOccured(std::move(result).error());
|
||||
errorOccurred(std::move(result).error());
|
||||
else
|
||||
isDirty = true;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace {
|
||||
public:
|
||||
void triggered() override
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(TEXT_GIT_MESSAGE);
|
||||
BobbyErrorHandler{}.errorOccurred(TEXT_GIT_MESSAGE);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -40,7 +40,7 @@ public:
|
||||
|
||||
if (!settingsPersister.openProfile(m_profileIndex)) // just switch nvs namespace
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("openProfile({}) failed", m_profileIndex));
|
||||
BobbyErrorHandler{}.errorOccurred(fmt::format("openProfile({}) failed", m_profileIndex));
|
||||
return;
|
||||
}
|
||||
saveProfileSettings();
|
||||
@ -60,7 +60,9 @@ public:
|
||||
}
|
||||
else if (m_menu.m_firstIndex != -1 && m_menu.m_firstIndex != m_profileIndex)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("Press CONFIRM to COPY from Profile {} to Profile {}", m_menu.m_firstIndex, m_profileIndex));
|
||||
BobbyErrorHandler{}.errorOccurred(
|
||||
fmt::format("Press CONFIRM to COPY from Profile {} to Profile {}", m_menu.m_firstIndex,
|
||||
m_profileIndex));
|
||||
m_mode = CONFIRM_COPY;
|
||||
}
|
||||
}
|
||||
@ -100,7 +102,9 @@ public:
|
||||
}
|
||||
else if (m_menu.m_firstIndex != -1 && m_menu.m_firstIndex != m_profileIndex)
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("Press CONFIRM to SWAP Profile {} with Profile {}", m_menu.m_firstIndex, m_profileIndex));
|
||||
BobbyErrorHandler{}.errorOccurred(
|
||||
fmt::format("Press CONFIRM to SWAP Profile {} with Profile {}", m_menu.m_firstIndex,
|
||||
m_profileIndex));
|
||||
m_mode = CONFIRM_SWAP;
|
||||
}
|
||||
}
|
||||
@ -125,7 +129,7 @@ public:
|
||||
{
|
||||
m_menu.lock();
|
||||
m_mode = CONFIRM_CLEAR;
|
||||
BobbyErrorHandler{}.errorOccured("Press CONFIRM to reset Profile or BACK to cancel.");
|
||||
BobbyErrorHandler{}.errorOccurred("Press CONFIRM to reset Profile or BACK to cancel.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -128,7 +128,7 @@ void SelectBuildserverBranchMenu::update()
|
||||
check_descriptor_request();
|
||||
if (!request_failed.empty())
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("Error: {}", request_failed));
|
||||
BobbyErrorHandler{}.errorOccurred(fmt::format("Error: {}", request_failed));
|
||||
request_failed = {};
|
||||
}
|
||||
}
|
||||
|
@ -111,7 +111,7 @@ void SelectBuildMenu::update()
|
||||
check_descriptor_request();
|
||||
if (!request_failed.empty())
|
||||
{
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("Error: {}", request_failed));
|
||||
BobbyErrorHandler{}.errorOccurred(fmt::format("Error: {}", request_failed));
|
||||
request_failed = {};
|
||||
}
|
||||
}
|
||||
|
@ -51,7 +51,7 @@ public:
|
||||
void triggered() override
|
||||
{
|
||||
if (auto result = m_config->write(configs.nvs_handle_user, m_value); !result)
|
||||
BobbyErrorHandler{}.errorOccured(std::move(result).error());
|
||||
BobbyErrorHandler{}.errorOccurred(std::move(result).error());
|
||||
}
|
||||
private:
|
||||
const TEnum m_value;
|
||||
|
@ -5,11 +5,11 @@
|
||||
#include <fmt/core.h>
|
||||
|
||||
// local includes
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
#include "displays/batteryinfodisplay.h"
|
||||
#include "displays/menus/mainmenu.h"
|
||||
#include "displays/statusdisplay.h"
|
||||
#include "displays/bmsdisplay.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
|
||||
using namespace espgui;
|
||||
|
||||
@ -58,14 +58,14 @@ void MetersDisplay::buttonPressed(espgui::Button button)
|
||||
switch (button)
|
||||
{
|
||||
using espgui::Button;
|
||||
case Button::Right: pushScreen<MainMenu>(); break;
|
||||
case Button::Up: switchScreen<StatusDisplay>(); break;
|
||||
case Button::Down:
|
||||
#ifdef FEATURE_BMS
|
||||
switchScreen<BmsDisplay>();
|
||||
#else
|
||||
case Button::Right:
|
||||
pushScreen<MainMenu>();
|
||||
break;
|
||||
case Button::Up:
|
||||
switchScreen<StatusDisplay>();
|
||||
#endif
|
||||
break;
|
||||
case Button::Down:
|
||||
switchScreen<BatteryInfoDisplay>();
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
else if (!m_result && !m_result.error().empty())
|
||||
{
|
||||
tft.setTextColor(TFT_RED, TFT_BLACK);
|
||||
BobbyErrorHandler{}.errorOccured(fmt::format("Error: {}", m_result.error()));
|
||||
BobbyErrorHandler{}.errorOccurred(fmt::format("Error: {}", m_result.error()));
|
||||
m_result.error().clear();
|
||||
}
|
||||
else
|
||||
|
96
main/displays/speedinfodisplay.cpp
Normal file
96
main/displays/speedinfodisplay.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
#include "speedinfodisplay.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
#include <screenmanager.h>
|
||||
|
||||
// local includes
|
||||
#include "displays/batteryinfodisplay.h"
|
||||
#include "displays/menus/mainmenu.h"
|
||||
#include "displays/statusdisplay.h"
|
||||
#include "drivingstatistics.h"
|
||||
|
||||
void SpeedInfoDisplay::initScreen()
|
||||
{
|
||||
Base::initScreen();
|
||||
|
||||
m_labelSpeed.start();
|
||||
|
||||
m_dischargingBar.start();
|
||||
m_chargingBar.start();
|
||||
|
||||
m_batteryPercentLabel.start();
|
||||
m_voltageLabel.start();
|
||||
m_distanceLabel.start();
|
||||
m_currentConsumptionLabel.start();
|
||||
}
|
||||
|
||||
void SpeedInfoDisplay::redraw()
|
||||
{
|
||||
using namespace espgui;
|
||||
|
||||
Base::redraw();
|
||||
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
tft.setTextFont(4);
|
||||
|
||||
tft.setTextSize(4);
|
||||
|
||||
m_labelSpeed.redraw(fmt::format(
|
||||
std::abs(avgSpeedKmh) < 10 ? "{:.2f}" :
|
||||
(std::abs(avgSpeedKmh) < 100 ? "{:.1f}" : "{:.0f}"),
|
||||
avgSpeedKmh));
|
||||
|
||||
tft.setTextSize(1);
|
||||
m_batteryPercentLabel.redraw(getBatteryPercentageString());
|
||||
|
||||
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
|
||||
{
|
||||
auto watt = sumCurrent * *avgVoltage;
|
||||
auto wh_per_km = std::abs(avgSpeedKmh) > 0.1 ? watt / std::abs(avgSpeedKmh) : 0;
|
||||
|
||||
m_voltageLabel.redraw(fmt::format("{:.1f} V", avgVoltage.value()));
|
||||
m_currentConsumptionLabel.redraw(fmt::format("{:.1f} Wh/km", wh_per_km));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_voltageLabel.redraw("No voltage");
|
||||
m_currentConsumptionLabel.redraw("No comsumption");
|
||||
}
|
||||
|
||||
m_distanceLabel.redraw(fmt::format(
|
||||
drivingStatistics.meters_driven > 1000 ? "{:.3f} km" :
|
||||
(drivingStatistics.meters_driven > 100 ? "{:.1f} m" : "{:.2f} m"),
|
||||
drivingStatistics.meters_driven > 1000 ?
|
||||
drivingStatistics.meters_driven / 1000 :
|
||||
drivingStatistics.meters_driven));
|
||||
|
||||
tft.setTextSize(1);
|
||||
|
||||
m_dischargingBar.redraw(sumCurrent < 0.f ? (-sumCurrent) : 0.f);
|
||||
m_chargingBar.redraw(sumCurrent > 0.f ? sumCurrent : 0.f);
|
||||
}
|
||||
|
||||
void SpeedInfoDisplay::buttonPressed(espgui::Button button)
|
||||
{
|
||||
Base::buttonPressed(button);
|
||||
|
||||
switch (button)
|
||||
{
|
||||
using espgui::Button;
|
||||
case Button::Right:
|
||||
espgui::pushScreen<MainMenu>();
|
||||
break;
|
||||
case Button::Up:
|
||||
espgui::switchScreen<BatteryInfoDisplay>();
|
||||
break;
|
||||
case Button::Down:
|
||||
#ifdef FEATURE_BMS
|
||||
espgui::switchScreen<BmsDisplay>();
|
||||
#else
|
||||
espgui::switchScreen<StatusDisplay>();
|
||||
#endif
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
32
main/displays/speedinfodisplay.h
Normal file
32
main/displays/speedinfodisplay.h
Normal file
@ -0,0 +1,32 @@
|
||||
#pragma once
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <tftinstance.h>
|
||||
#include <widgets/label.h>
|
||||
#include <widgets/progressbar.h>
|
||||
#include <widgets/reverseprogressbar.h>
|
||||
|
||||
// local includes
|
||||
#include "bobbydisplay.h"
|
||||
|
||||
class SpeedInfoDisplay : public BobbyDisplay
|
||||
{
|
||||
using Base = BobbyDisplay;
|
||||
|
||||
public:
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
private:
|
||||
espgui::Label m_labelSpeed{5, 5};
|
||||
|
||||
espgui::ReverseProgressBar m_dischargingBar{10, 110, espgui::tft.width()/2 - 10, 25, 0, 40, TFT_GREEN};
|
||||
espgui::ProgressBar m_chargingBar{espgui::tft.width()/2, 110, espgui::tft.width()/2 - 10, 25, 0, 40, TFT_RED};
|
||||
|
||||
#define START_Y 150
|
||||
espgui::Label m_batteryPercentLabel{5, START_Y};
|
||||
espgui::Label m_voltageLabel{5, START_Y + 29 * 1};
|
||||
espgui::Label m_distanceLabel{5, START_Y + 29 * 2};
|
||||
espgui::Label m_currentConsumptionLabel{5, START_Y + 29 * 3};
|
||||
};
|
@ -4,23 +4,23 @@
|
||||
#include <esp_log.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
#include <espwifistack.h>
|
||||
#include <fmt/core.h>
|
||||
#include <tftinstance.h>
|
||||
#include <schedulertask.h>
|
||||
|
||||
// local includes
|
||||
#include "displays/menus/mainmenu.h"
|
||||
#include "displays/batteryinfodisplay.h"
|
||||
#include "displays/speedinfodisplay.h"
|
||||
#ifdef FEATURE_BMS
|
||||
#include "displays/bmsdisplay.h"
|
||||
#else
|
||||
#include "displays/metersdisplay.h"
|
||||
#endif
|
||||
#include "displays/menus/mainmenu.h"
|
||||
#include "displays/metersdisplay.h"
|
||||
#include "drivingstatistics.h"
|
||||
#include "udpcloud.h"
|
||||
#include "modes/defaultmode.h"
|
||||
#include "taskmanager.h"
|
||||
#include "newsettings.h"
|
||||
#include "taskmanager.h"
|
||||
#include "udpcloud.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
using namespace espgui;
|
||||
@ -230,14 +230,16 @@ void StatusDisplay::buttonPressed(espgui::Button button)
|
||||
switch (button)
|
||||
{
|
||||
using espgui::Button;
|
||||
case Button::Right: pushScreen<MainMenu>(); break;
|
||||
case Button::Right:
|
||||
pushScreen<MainMenu>();
|
||||
break;
|
||||
case Button::Up:
|
||||
if (simplified)
|
||||
return;
|
||||
#ifdef FEATURE_BMS
|
||||
switchScreen<BmsDisplay>();
|
||||
#else
|
||||
switchScreen<MetersDisplay>();
|
||||
switchScreen<SpeedInfoDisplay>();
|
||||
#endif
|
||||
break;
|
||||
case Button::Down:
|
||||
@ -245,8 +247,7 @@ void StatusDisplay::buttonPressed(espgui::Button button)
|
||||
return;
|
||||
switchScreen<MetersDisplay>();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4,17 +4,17 @@
|
||||
#include <esp_heap_caps.h>
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <espchrono.h>
|
||||
#include <widgets/label.h>
|
||||
#include <widgets/progressbar.h>
|
||||
#include <espchrono.h>
|
||||
|
||||
// local includes
|
||||
#include "bobbydisplay.h"
|
||||
#include "modeinterface.h"
|
||||
#include "globals.h"
|
||||
#include "utils.h"
|
||||
#include "icons/alert.h"
|
||||
#include "battery.h"
|
||||
#include "bobbydisplay.h"
|
||||
#include "globals.h"
|
||||
#include "icons/alert.h"
|
||||
#include "modeinterface.h"
|
||||
#include "utils.h"
|
||||
|
||||
class StatusDisplay : public BobbyDisplay
|
||||
{
|
||||
|
77
main/displays/xydebugdisplay.cpp
Normal file
77
main/displays/xydebugdisplay.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
#include "xydebugdisplay.h"
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <fmt/core.h>
|
||||
#include <screenmanager.h>
|
||||
#include <tftinstance.h>
|
||||
|
||||
// local includes
|
||||
#include "bobbybuttons.h"
|
||||
|
||||
XYDebugDisplay::XYDebugDisplay() : m_labelCoordinates{5, 5} {}
|
||||
|
||||
void XYDebugDisplay::initScreen()
|
||||
{
|
||||
Base::initScreen();
|
||||
m_labelCoordinates.start();
|
||||
}
|
||||
|
||||
void XYDebugDisplay::redraw()
|
||||
{
|
||||
using namespace espgui;
|
||||
|
||||
Base::redraw();
|
||||
m_labelCoordinates.redraw(fmt::format("X: {}, Y: {}", m_current_cursor.x, m_current_cursor.y));
|
||||
|
||||
if (m_current_cursor.x != m_last_cursor.x || m_current_cursor.y != m_last_cursor.y)
|
||||
{
|
||||
tft.fillCircle(m_last_cursor.x, m_last_cursor.y, 2, TFT_BLACK);
|
||||
tft.fillCircle(m_current_cursor.x, m_current_cursor.y, 2, TFT_WHITE);
|
||||
|
||||
m_last_cursor = m_current_cursor;
|
||||
}
|
||||
}
|
||||
|
||||
void XYDebugDisplay::buttonPressed(espgui::Button button)
|
||||
{
|
||||
switch (button)
|
||||
{
|
||||
using espgui::Button;
|
||||
case Button::Left:
|
||||
case Button::Right:
|
||||
case Button::Up:
|
||||
case Button::Down:
|
||||
espgui::popScreen();
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
|
||||
switch (BobbyButton(button))
|
||||
{
|
||||
case BobbyButton::Left2:
|
||||
if (m_current_cursor.x > 0)
|
||||
{
|
||||
--m_current_cursor.x;
|
||||
}
|
||||
break;
|
||||
case BobbyButton::Right2:
|
||||
if (m_current_cursor.x < espgui::tft.width() - 1)
|
||||
{
|
||||
++m_current_cursor.x;
|
||||
}
|
||||
break;
|
||||
case BobbyButton::Up2:
|
||||
if (m_current_cursor.y > 0)
|
||||
{
|
||||
--m_current_cursor.y;
|
||||
}
|
||||
break;
|
||||
case BobbyButton::Down2:
|
||||
if (m_current_cursor.y < espgui::tft.height() - 1)
|
||||
{
|
||||
++m_current_cursor.y;
|
||||
}
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
}
|
29
main/displays/xydebugdisplay.h
Normal file
29
main/displays/xydebugdisplay.h
Normal file
@ -0,0 +1,29 @@
|
||||
#pragma once
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <widgets/label.h>
|
||||
|
||||
// local includes
|
||||
#include "bobbydisplay.h"
|
||||
|
||||
class XYDebugDisplay : public BobbyDisplay
|
||||
{
|
||||
using Base = BobbyDisplay;
|
||||
|
||||
public:
|
||||
XYDebugDisplay();
|
||||
void initScreen() override;
|
||||
void redraw() override;
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
|
||||
private:
|
||||
typedef struct {
|
||||
uint8_t x;
|
||||
uint8_t y;
|
||||
} cursor_pos_t;
|
||||
|
||||
cursor_pos_t m_current_cursor{0, 0};
|
||||
cursor_pos_t m_last_cursor{0, 0};
|
||||
espgui::Label m_labelCoordinates;
|
||||
};
|
Reference in New Issue
Block a user