Add new confiscation mode screen
This commit is contained in:
BIN
icons/shortcircuit.png
Normal file
BIN
icons/shortcircuit.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 27 KiB |
@ -69,6 +69,7 @@ set(headers
|
|||||||
displays/bobbysplitgraphdisplay.h
|
displays/bobbysplitgraphdisplay.h
|
||||||
displays/buttoncalibratedisplay.h
|
displays/buttoncalibratedisplay.h
|
||||||
displays/calibratevoltagedisplay.h
|
displays/calibratevoltagedisplay.h
|
||||||
|
displays/confiscationdisplay.h
|
||||||
displays/gameoflifedisplay.h
|
displays/gameoflifedisplay.h
|
||||||
displays/gametrakcalibratedisplay.h
|
displays/gametrakcalibratedisplay.h
|
||||||
displays/joystickdebugdisplay.h
|
displays/joystickdebugdisplay.h
|
||||||
@ -185,6 +186,7 @@ set(headers
|
|||||||
icons/presets.h
|
icons/presets.h
|
||||||
icons/reboot.h
|
icons/reboot.h
|
||||||
icons/scan.h
|
icons/scan.h
|
||||||
|
icons/shortcircuit.h
|
||||||
icons/settings.h
|
icons/settings.h
|
||||||
icons/statistics.h
|
icons/statistics.h
|
||||||
icons/time.h
|
icons/time.h
|
||||||
@ -302,6 +304,7 @@ set(sources
|
|||||||
displays/bobbysplitgraphdisplay.cpp
|
displays/bobbysplitgraphdisplay.cpp
|
||||||
displays/buttoncalibratedisplay.cpp
|
displays/buttoncalibratedisplay.cpp
|
||||||
displays/calibratevoltagedisplay.cpp
|
displays/calibratevoltagedisplay.cpp
|
||||||
|
displays/confiscationdisplay.cpp
|
||||||
displays/gameoflifedisplay.cpp
|
displays/gameoflifedisplay.cpp
|
||||||
displays/gametrakcalibratedisplay.cpp
|
displays/gametrakcalibratedisplay.cpp
|
||||||
displays/joystickdebugdisplay.cpp
|
displays/joystickdebugdisplay.cpp
|
||||||
@ -416,6 +419,7 @@ set(sources
|
|||||||
icons/presets.cpp
|
icons/presets.cpp
|
||||||
icons/reboot.cpp
|
icons/reboot.cpp
|
||||||
icons/scan.cpp
|
icons/scan.cpp
|
||||||
|
icons/shortcircuit.cpp
|
||||||
icons/settings.cpp
|
icons/settings.cpp
|
||||||
icons/statistics.cpp
|
icons/statistics.cpp
|
||||||
icons/time.cpp
|
icons/time.cpp
|
||||||
|
117
main/displays/confiscationdisplay.cpp
Normal file
117
main/displays/confiscationdisplay.cpp
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
#include "confiscationdisplay.h"
|
||||||
|
|
||||||
|
// 3rdparty lib includes
|
||||||
|
#include <tftinstance.h>
|
||||||
|
#include <screenmanager.h>
|
||||||
|
#include <actions/switchscreenaction.h>
|
||||||
|
#include <esprandom.h>
|
||||||
|
#include <randomutils.h>
|
||||||
|
|
||||||
|
// local includes
|
||||||
|
#include "globals.h"
|
||||||
|
#include "displays/menus/mainmenu.h"
|
||||||
|
#include "icons/shortcircuit.h"
|
||||||
|
|
||||||
|
using namespace std::chrono_literals;
|
||||||
|
|
||||||
|
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY)
|
||||||
|
void ConfiscationDisplay::start()
|
||||||
|
{
|
||||||
|
Base::start();
|
||||||
|
|
||||||
|
m_oldMode = currentMode;
|
||||||
|
currentMode = &m_mode;
|
||||||
|
|
||||||
|
m_progress = 500;
|
||||||
|
|
||||||
|
m_nextRestart = espchrono::millis_clock::now() + std::chrono::seconds{cpputils::randomNumber(3, 7, espcpputils::esp_random_device{})};
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfiscationDisplay::initScreen()
|
||||||
|
{
|
||||||
|
Base::initScreen();
|
||||||
|
|
||||||
|
espgui::tft.setSwapBytes(true);
|
||||||
|
espgui::tft.pushImage(10, 70, bobbyicons::shortcircuit.WIDTH, bobbyicons::shortcircuit.HEIGHT, bobbyicons::shortcircuit.buffer);
|
||||||
|
espgui::tft.setSwapBytes(false);
|
||||||
|
|
||||||
|
m_progressBar.start();
|
||||||
|
|
||||||
|
m_label.start();
|
||||||
|
|
||||||
|
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
espgui::tft.setTextFont(2);
|
||||||
|
|
||||||
|
auto y = 235;
|
||||||
|
constexpr auto lineheight = 15;
|
||||||
|
espgui::tft.drawString("Bei erneuter, widerrechtlicher", 10, y+=lineheight);
|
||||||
|
espgui::tft.drawString("Beschlagnahmung wird die Selbst-", 10, y+=lineheight);
|
||||||
|
espgui::tft.drawString("Vernichtung durch Kurzschluss", 10, y+=lineheight);
|
||||||
|
espgui::tft.drawString("der Batterie eingeleitet (ca 4.31MJ)", 10, y+=lineheight);
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfiscationDisplay::redraw()
|
||||||
|
{
|
||||||
|
Base::redraw();
|
||||||
|
|
||||||
|
m_progressBar.redraw(m_progress);
|
||||||
|
|
||||||
|
espgui::tft.setTextColor(TFT_YELLOW, TFT_BLACK);
|
||||||
|
|
||||||
|
espgui::tft.setTextFont(2);
|
||||||
|
m_label.redraw([](){
|
||||||
|
if (const auto period = espchrono::millis_clock::now().time_since_epoch() % 6000ms; period < 2000ms)
|
||||||
|
return "Halten Sie 10m Abstand.";
|
||||||
|
else if (period < 4000ms)
|
||||||
|
return "Bewegen Sie kein Rad.";
|
||||||
|
else
|
||||||
|
return "Die Lenkung nicht drehen.";
|
||||||
|
}());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfiscationDisplay::update()
|
||||||
|
{
|
||||||
|
if (espchrono::millis_clock::now() > m_nextRestart)
|
||||||
|
{
|
||||||
|
m_progress = 500;
|
||||||
|
const auto timeout = cpputils::randomNumber(3, 7, espcpputils::esp_random_device{});
|
||||||
|
ESP_LOGI("BOBBY", "agian in %i", timeout);
|
||||||
|
m_nextRestart = espchrono::millis_clock::now() + std::chrono::seconds{timeout};
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_progress--;
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfiscationDisplay::stop()
|
||||||
|
{
|
||||||
|
Base::stop();
|
||||||
|
|
||||||
|
if (currentMode == &m_mode)
|
||||||
|
{
|
||||||
|
// to avoid crash after deconstruction
|
||||||
|
m_mode.stop();
|
||||||
|
lastMode = nullptr;
|
||||||
|
|
||||||
|
currentMode = m_oldMode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void ConfiscationDisplay::buttonPressed(espgui::Button button)
|
||||||
|
{
|
||||||
|
Base::buttonPressed(button);
|
||||||
|
|
||||||
|
switch (button)
|
||||||
|
{
|
||||||
|
using espgui::Button;
|
||||||
|
case Button::Left:
|
||||||
|
espgui::switchScreen<MainMenu>();
|
||||||
|
break;
|
||||||
|
default:;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string ConfiscationDisplay::text() const
|
||||||
|
{
|
||||||
|
return "Explosions-Modus";
|
||||||
|
}
|
||||||
|
#endif
|
39
main/displays/confiscationdisplay.h
Normal file
39
main/displays/confiscationdisplay.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
// 3rdparty lib includes
|
||||||
|
#include <widgets/label.h>
|
||||||
|
#include <widgets/progressbar.h>
|
||||||
|
#include <espchrono.h>
|
||||||
|
|
||||||
|
// local includes
|
||||||
|
#include "bobbydisplaywithtitle.h"
|
||||||
|
#include "modes/ignoreinputmode.h"
|
||||||
|
|
||||||
|
class ConfiscationDisplay : public BobbyDisplayWithTitle
|
||||||
|
{
|
||||||
|
using Base = BobbyDisplayWithTitle;
|
||||||
|
|
||||||
|
public:
|
||||||
|
void start() override;
|
||||||
|
|
||||||
|
void initScreen() override;
|
||||||
|
void redraw() override;
|
||||||
|
void update() override;
|
||||||
|
void stop() override;
|
||||||
|
|
||||||
|
void buttonPressed(espgui::Button button) override;
|
||||||
|
|
||||||
|
std::string text() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
espgui::ProgressBar m_progressBar{10, 210, 200, 10, 0, 500};
|
||||||
|
|
||||||
|
espgui::Label m_label{10, 225};
|
||||||
|
|
||||||
|
int m_progress;
|
||||||
|
|
||||||
|
espchrono::millis_clock::time_point m_nextRestart;
|
||||||
|
|
||||||
|
ModeInterface *m_oldMode;
|
||||||
|
IgnoreInputMode m_mode{0, bobbycar::protocol::ControlType::FieldOrientedControl, bobbycar::protocol::ControlMode::Speed};
|
||||||
|
};
|
@ -25,6 +25,7 @@
|
|||||||
#include "displays/menus/otamenu.h"
|
#include "displays/menus/otamenu.h"
|
||||||
#include "displays/poweroffdisplay.h"
|
#include "displays/poweroffdisplay.h"
|
||||||
#include "displays/menus/statisticsmenu.h"
|
#include "displays/menus/statisticsmenu.h"
|
||||||
|
#include "displays/confiscationdisplay.h"
|
||||||
#include "actions/rebootaction.h"
|
#include "actions/rebootaction.h"
|
||||||
#include "displays/menus/debugmenu.h"
|
#include "displays/menus/debugmenu.h"
|
||||||
#include "icons/battery.h"
|
#include "icons/battery.h"
|
||||||
@ -72,6 +73,7 @@ constexpr char TEXT_REBOOT[] = "Reboot";
|
|||||||
constexpr char TEXT_DEBUG[] = "Debug";
|
constexpr char TEXT_DEBUG[] = "Debug";
|
||||||
constexpr char TEXT_BATTERY[] = "Battery";
|
constexpr char TEXT_BATTERY[] = "Battery";
|
||||||
constexpr char TEXT_BATTERYDEBUG[] = "Bat Debug Menu";
|
constexpr char TEXT_BATTERYDEBUG[] = "Bat Debug Menu";
|
||||||
|
constexpr char TEXT_CONFISCATIONMODE[] = "Confiscation Mode";
|
||||||
constexpr char TEXT_TOGGLECLOUDDEBUG[] = "Cloud Debug";
|
constexpr char TEXT_TOGGLECLOUDDEBUG[] = "Cloud Debug";
|
||||||
constexpr char TEXT_MANAGEPROFILESMENU[] = "Manage Profiles";
|
constexpr char TEXT_MANAGEPROFILESMENU[] = "Manage Profiles";
|
||||||
|
|
||||||
@ -115,6 +117,7 @@ MainMenu::MainMenu()
|
|||||||
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MANAGEPROFILESMENU>,SwitchScreenAction<ManageProfilesMenu>, StaticMenuItemIcon<&bobbyicons::presets>>>(); }
|
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_MANAGEPROFILESMENU>,SwitchScreenAction<ManageProfilesMenu>, StaticMenuItemIcon<&bobbyicons::presets>>>(); }
|
||||||
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEBUG>, SwitchScreenAction<DebugMenu>>>(); }
|
if (SHOWITEM) { constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_DEBUG>, SwitchScreenAction<DebugMenu>>>(); }
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POWEROFF>, SwitchScreenAction<PoweroffDisplay>, StaticMenuItemIcon<&bobbyicons::poweroff>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_POWEROFF>, SwitchScreenAction<PoweroffDisplay>, StaticMenuItemIcon<&bobbyicons::poweroff>>>();
|
||||||
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_CONFISCATIONMODE>, SwitchScreenAction<ConfiscationDisplay>>>();
|
||||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REBOOT>, RebootAction, StaticMenuItemIcon<&bobbyicons::reboot>>>();
|
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_REBOOT>, RebootAction, StaticMenuItemIcon<&bobbyicons::reboot>>>();
|
||||||
//#ifdef MAINMENU_PLUGIN
|
//#ifdef MAINMENU_PLUGIN
|
||||||
// GMEN1
|
// GMEN1
|
||||||
|
1889
main/icons/shortcircuit.cpp
Normal file
1889
main/icons/shortcircuit.cpp
Normal file
File diff suppressed because it is too large
Load Diff
7
main/icons/shortcircuit.h
Normal file
7
main/icons/shortcircuit.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "icon.h"
|
||||||
|
|
||||||
|
namespace bobbyicons {
|
||||||
|
extern const espgui::Icon<220, 137> shortcircuit;
|
||||||
|
} // namespace bobbyicons
|
Reference in New Issue
Block a user