More displays converted to bobby displays
This commit is contained in:
@ -14,6 +14,8 @@
|
|||||||
|
|
||||||
void Lockscreen::start()
|
void Lockscreen::start()
|
||||||
{
|
{
|
||||||
|
Base::start();
|
||||||
|
|
||||||
m_numbers = {0,0,0,0};
|
m_numbers = {0,0,0,0};
|
||||||
m_currentIndex = 0;
|
m_currentIndex = 0;
|
||||||
m_pressed = false;
|
m_pressed = false;
|
||||||
@ -33,6 +35,8 @@ void Lockscreen::start()
|
|||||||
|
|
||||||
void Lockscreen::initScreen()
|
void Lockscreen::initScreen()
|
||||||
{
|
{
|
||||||
|
Base::initScreen();
|
||||||
|
|
||||||
espgui::tft.fillScreen(TFT_BLACK);
|
espgui::tft.fillScreen(TFT_BLACK);
|
||||||
espgui::tft.setTextFont(4);
|
espgui::tft.setTextFont(4);
|
||||||
espgui::tft.setTextColor(TFT_YELLOW);
|
espgui::tft.setTextColor(TFT_YELLOW);
|
||||||
@ -66,12 +70,16 @@ void Lockscreen::initScreen()
|
|||||||
|
|
||||||
void Lockscreen::update()
|
void Lockscreen::update()
|
||||||
{
|
{
|
||||||
|
Base::update();
|
||||||
|
|
||||||
// just in case someone changes that settings somehow
|
// just in case someone changes that settings somehow
|
||||||
profileButtonDisabled = !settings.lockscreen.allowPresetSwitch;
|
profileButtonDisabled = !settings.lockscreen.allowPresetSwitch;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lockscreen::redraw()
|
void Lockscreen::redraw()
|
||||||
{
|
{
|
||||||
|
Base::redraw();
|
||||||
|
|
||||||
if (m_pressed || m_back_pressed)
|
if (m_pressed || m_back_pressed)
|
||||||
{
|
{
|
||||||
drawRect(m_currentIndex, 1, TFT_BLACK);
|
drawRect(m_currentIndex, 1, TFT_BLACK);
|
||||||
@ -151,21 +159,28 @@ void Lockscreen::stop()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lockscreen::confirm()
|
void Lockscreen::buttonPressed(espgui::Button button)
|
||||||
{
|
{
|
||||||
m_pressed = true;
|
Base::buttonPressed(button);
|
||||||
}
|
|
||||||
|
|
||||||
void Lockscreen::back()
|
switch (button)
|
||||||
{
|
{
|
||||||
if (m_currentIndex > 0)
|
using espgui::Button;
|
||||||
m_currentIndex--;
|
case Button::Left:
|
||||||
m_back_pressed = true;
|
if (m_currentIndex > 0)
|
||||||
}
|
m_currentIndex--;
|
||||||
|
m_back_pressed = true;
|
||||||
void Lockscreen::rotate(int offset)
|
break;
|
||||||
{
|
case Button::Right:
|
||||||
m_rotated += offset;
|
m_pressed = true;
|
||||||
|
break;
|
||||||
|
case Button::Up:
|
||||||
|
m_rotated--;
|
||||||
|
break;
|
||||||
|
case Button::Down:
|
||||||
|
m_rotated++;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Lockscreen::drawRect(int index, int offset, uint32_t color) const
|
void Lockscreen::drawRect(int index, int offset, uint32_t color) const
|
||||||
|
@ -3,18 +3,20 @@
|
|||||||
// system includes
|
// system includes
|
||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
|
// 3rdparty lib includes
|
||||||
|
#include <widgets/label.h>
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "display.h"
|
#include "bobbydisplay.h"
|
||||||
#include "widgets/label.h"
|
|
||||||
#include "modes/ignoreinputmode.h"
|
#include "modes/ignoreinputmode.h"
|
||||||
|
|
||||||
#ifdef LOCKSCREEN_PLUGIN
|
#ifdef LOCKSCREEN_PLUGIN
|
||||||
#include "ledstrip.h"
|
#include "ledstrip.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
class Lockscreen : public espgui::Display
|
class Lockscreen : public BobbyDisplay
|
||||||
{
|
{
|
||||||
using Base = espgui::Display;
|
using Base = BobbyDisplay;
|
||||||
|
|
||||||
static constexpr auto boxWidth = 35;
|
static constexpr auto boxWidth = 35;
|
||||||
static constexpr auto boxHeight = 50;
|
static constexpr auto boxHeight = 50;
|
||||||
@ -27,9 +29,7 @@ public:
|
|||||||
void redraw() override;
|
void redraw() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
|
||||||
void confirm() override;
|
void buttonPressed(espgui::Button button) override;
|
||||||
void back() override;
|
|
||||||
void rotate(int offset) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void drawRect(int index, int offset, uint32_t color) const;
|
void drawRect(int index, int offset, uint32_t color) const;
|
||||||
|
@ -15,6 +15,8 @@ using namespace espgui;
|
|||||||
|
|
||||||
void MetersDisplay::initScreen()
|
void MetersDisplay::initScreen()
|
||||||
{
|
{
|
||||||
|
Base::initScreen();
|
||||||
|
|
||||||
tft.fillScreen(TFT_BLACK);
|
tft.fillScreen(TFT_BLACK);
|
||||||
|
|
||||||
m_vuMeter.start();
|
m_vuMeter.start();
|
||||||
@ -30,6 +32,8 @@ void MetersDisplay::initScreen()
|
|||||||
|
|
||||||
void MetersDisplay::redraw()
|
void MetersDisplay::redraw()
|
||||||
{
|
{
|
||||||
|
Base::redraw();
|
||||||
|
|
||||||
m_vuMeter.redraw(avgSpeedKmh);
|
m_vuMeter.redraw(avgSpeedKmh);
|
||||||
|
|
||||||
m_dischargingBar.redraw(sumCurrent<0.f?(-sumCurrent):0.f);
|
m_dischargingBar.redraw(sumCurrent<0.f?(-sumCurrent):0.f);
|
||||||
@ -47,24 +51,26 @@ void MetersDisplay::redraw()
|
|||||||
meters[5].redraw(fixCurrent(controllers.back.feedback.right.dcLink), -10, 10);
|
meters[5].redraw(fixCurrent(controllers.back.feedback.right.dcLink), -10, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MetersDisplay::confirm()
|
void StatusDisplay::buttonPressed(espgui::Button button)
|
||||||
{
|
{
|
||||||
switchScreen<MainMenu>();
|
Base::buttonPressed(button);
|
||||||
}
|
|
||||||
|
|
||||||
void MetersDisplay::back()
|
switch (button)
|
||||||
{
|
{
|
||||||
switchScreen<MainMenu>();
|
using espgui::Button;
|
||||||
}
|
case Button::Left:
|
||||||
|
case Button::Right:
|
||||||
void MetersDisplay::rotate(int offset)
|
switchScreen<MainMenu>();
|
||||||
{
|
break;
|
||||||
if (offset < 0)
|
case Button::Up:
|
||||||
switchScreen<StatusDisplay>();
|
switchScreen<StatusDisplay>();
|
||||||
else if (offset > 0)
|
break;
|
||||||
|
case Button::Down:
|
||||||
#ifdef FEATURE_BMS
|
#ifdef FEATURE_BMS
|
||||||
switchScreen<BmsDisplay>();
|
switchScreen<BmsDisplay>();
|
||||||
#else
|
#else
|
||||||
switchScreen<StatusDisplay>();
|
switchScreen<StatusDisplay>();
|
||||||
#endif
|
#endif
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@
|
|||||||
#include <array>
|
#include <array>
|
||||||
|
|
||||||
// 3rdparty lib includes
|
// 3rdparty lib includes
|
||||||
#include <display.h>
|
|
||||||
#include <actions/switchscreenaction.h>
|
#include <actions/switchscreenaction.h>
|
||||||
#include <widgets/label.h>
|
#include <widgets/label.h>
|
||||||
#include <widgets/reverseprogressbar.h>
|
#include <widgets/reverseprogressbar.h>
|
||||||
@ -12,16 +11,18 @@
|
|||||||
#include <widgets/verticalmeter.h>
|
#include <widgets/verticalmeter.h>
|
||||||
#include <widgets/vumeter.h>
|
#include <widgets/vumeter.h>
|
||||||
|
|
||||||
class MetersDisplay :
|
// local includes
|
||||||
public espgui::Display
|
#include "bobbydisplay.h"
|
||||||
|
|
||||||
|
class MetersDisplay : public BobbyDisplay
|
||||||
{
|
{
|
||||||
|
using Base = BobbyDisplay;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initScreen() override;
|
void initScreen() override;
|
||||||
void redraw() override;
|
void redraw() override;
|
||||||
|
|
||||||
void confirm() override;
|
void buttonPressed(espgui::Button button) override;
|
||||||
void back() override;
|
|
||||||
void rotate(int offset) override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
espgui::VuMeter m_vuMeter;
|
espgui::VuMeter m_vuMeter;
|
||||||
|
@ -20,6 +20,8 @@ PingPongDisplay::PingPongDisplay() :
|
|||||||
|
|
||||||
void PingPongDisplay::initScreen()
|
void PingPongDisplay::initScreen()
|
||||||
{
|
{
|
||||||
|
Base::initScreen();
|
||||||
|
|
||||||
espgui::tft.fillScreen(TFT_BLACK);
|
espgui::tft.fillScreen(TFT_BLACK);
|
||||||
espgui::tft.setRotation(1);
|
espgui::tft.setRotation(1);
|
||||||
|
|
||||||
@ -28,6 +30,8 @@ void PingPongDisplay::initScreen()
|
|||||||
|
|
||||||
void PingPongDisplay::redraw()
|
void PingPongDisplay::redraw()
|
||||||
{
|
{
|
||||||
|
Base::redraw();
|
||||||
|
|
||||||
lpaddle();
|
lpaddle();
|
||||||
rpaddle();
|
rpaddle();
|
||||||
|
|
||||||
@ -38,17 +42,24 @@ void PingPongDisplay::redraw()
|
|||||||
|
|
||||||
void PingPongDisplay::stop()
|
void PingPongDisplay::stop()
|
||||||
{
|
{
|
||||||
|
Base::stop();
|
||||||
|
|
||||||
espgui::tft.setRotation(0);
|
espgui::tft.setRotation(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PingPongDisplay::confirm()
|
void PingPongDisplay::buttonPressed(espgui::Button button)
|
||||||
{
|
{
|
||||||
espgui::switchScreen<DemosMenu>();
|
Base::buttonPressed(button);
|
||||||
}
|
|
||||||
|
|
||||||
void PingPongDisplay::back()
|
switch (button)
|
||||||
{
|
{
|
||||||
espgui::switchScreen<DemosMenu>();
|
using espgui::Button;
|
||||||
|
case Button::Left:
|
||||||
|
case Button::Right:
|
||||||
|
espgui::switchScreen<DemosMenu>();
|
||||||
|
break;
|
||||||
|
default:;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PingPongDisplay::midline()
|
void PingPongDisplay::midline()
|
||||||
|
@ -3,11 +3,13 @@
|
|||||||
// system includes
|
// system includes
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
// 3rdparty lib includes
|
// local includes
|
||||||
#include "display.h"
|
#include "bobbydisplay.h"
|
||||||
|
|
||||||
class PingPongDisplay : public espgui::Display
|
class PingPongDisplay : public BobbyDisplay
|
||||||
{
|
{
|
||||||
|
using Base = BobbyDisplay;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PingPongDisplay();
|
PingPongDisplay();
|
||||||
|
|
||||||
@ -15,8 +17,7 @@ public:
|
|||||||
void redraw() override;
|
void redraw() override;
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
|
||||||
void confirm() override;
|
void buttonPressed(espgui::Button button) override;
|
||||||
void back() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void midline();
|
void midline();
|
||||||
|
@ -14,6 +14,8 @@ using namespace std::chrono_literals;
|
|||||||
|
|
||||||
void PoweroffDisplay::start()
|
void PoweroffDisplay::start()
|
||||||
{
|
{
|
||||||
|
Base::start();
|
||||||
|
|
||||||
m_startTime = espchrono::millis_clock::now();
|
m_startTime = espchrono::millis_clock::now();
|
||||||
|
|
||||||
for (Controller &controller : controllers)
|
for (Controller &controller : controllers)
|
||||||
@ -22,6 +24,8 @@ void PoweroffDisplay::start()
|
|||||||
|
|
||||||
void PoweroffDisplay::initScreen()
|
void PoweroffDisplay::initScreen()
|
||||||
{
|
{
|
||||||
|
Base::initScreen();
|
||||||
|
|
||||||
espgui::tft.fillScreen(TFT_BLACK);
|
espgui::tft.fillScreen(TFT_BLACK);
|
||||||
espgui::tft.setTextColor(TFT_YELLOW);
|
espgui::tft.setTextColor(TFT_YELLOW);
|
||||||
|
|
||||||
@ -37,20 +41,16 @@ void PoweroffDisplay::initScreen()
|
|||||||
|
|
||||||
void PoweroffDisplay::update()
|
void PoweroffDisplay::update()
|
||||||
{
|
{
|
||||||
|
Base::update();
|
||||||
|
|
||||||
if (espchrono::millis_clock::now() - m_startTime >= 1000ms)
|
if (espchrono::millis_clock::now() - m_startTime >= 1000ms)
|
||||||
espgui::switchScreen<MainMenu>();
|
espgui::switchScreen<MainMenu>();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoweroffDisplay::stop()
|
void PoweroffDisplay::stop()
|
||||||
{
|
{
|
||||||
|
Base::stop();
|
||||||
|
|
||||||
for (Controller &controller : controllers)
|
for (Controller &controller : controllers)
|
||||||
controller.command.poweroff = false;
|
controller.command.poweroff = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PoweroffDisplay::confirm()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void PoweroffDisplay::back()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
@ -4,20 +4,18 @@
|
|||||||
#include <espchrono.h>
|
#include <espchrono.h>
|
||||||
|
|
||||||
// local includes
|
// local includes
|
||||||
#include "display.h"
|
#include "bobbydisplay.h"
|
||||||
|
|
||||||
class PoweroffDisplay : public espgui::Display
|
class PoweroffDisplay : public BobbyDisplay
|
||||||
{
|
{
|
||||||
|
using Base = BobbyDisplay;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void start() override;
|
void start() override;
|
||||||
void initScreen() override;
|
void initScreen() override;
|
||||||
void update() override;
|
void update() override;
|
||||||
void redraw() override {}
|
|
||||||
void stop() override;
|
void stop() override;
|
||||||
|
|
||||||
void confirm() override;
|
|
||||||
void back() override;
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
espchrono::millis_clock::time_point m_startTime;
|
espchrono::millis_clock::time_point m_startTime;
|
||||||
};
|
};
|
||||||
|
@ -12,6 +12,8 @@
|
|||||||
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY)
|
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY)
|
||||||
void PowerSupplyDisplay::initScreen()
|
void PowerSupplyDisplay::initScreen()
|
||||||
{
|
{
|
||||||
|
Base::initScreen();
|
||||||
|
|
||||||
espgui::tft.fillScreen(TFT_BLACK);
|
espgui::tft.fillScreen(TFT_BLACK);
|
||||||
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||||
|
|
||||||
@ -25,22 +27,24 @@ void PowerSupplyDisplay::initScreen()
|
|||||||
|
|
||||||
void PowerSupplyDisplay::redraw()
|
void PowerSupplyDisplay::redraw()
|
||||||
{
|
{
|
||||||
|
Base::redraw();
|
||||||
|
|
||||||
m_voltageLabel.redraw(std::to_string(50.4) + 'V');
|
m_voltageLabel.redraw(std::to_string(50.4) + 'V');
|
||||||
m_currentLabel.redraw(std::to_string(15.1) + 'A');
|
m_currentLabel.redraw(std::to_string(15.1) + 'A');
|
||||||
}
|
}
|
||||||
|
|
||||||
void PowerSupplyDisplay::confirm()
|
void PowerSupplyDisplay::buttonPressed(espgui::Button button)
|
||||||
{
|
{
|
||||||
// TODO
|
Base::buttonPressed(button);
|
||||||
}
|
|
||||||
|
|
||||||
void PowerSupplyDisplay::back()
|
switch (button)
|
||||||
{
|
{
|
||||||
espgui::switchScreen<MainMenu>();
|
using espgui::Button;
|
||||||
}
|
case Button::Left:
|
||||||
|
case Button::Right:
|
||||||
void PowerSupplyDisplay::rotate(int offset)
|
espgui::switchScreen<MainMenu>();
|
||||||
{
|
break;
|
||||||
// TODO
|
default:;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -1,22 +1,21 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// 3rdparty lib includes
|
// 3rdparty lib includes
|
||||||
#include "display.h"
|
#include <widgets/label.h>
|
||||||
#include "widgets/label.h"
|
|
||||||
|
// local includes
|
||||||
|
#include "bobbydisplay.h"
|
||||||
|
|
||||||
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY)
|
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY)
|
||||||
class PowerSupplyDisplay : public espgui::Display
|
class PowerSupplyDisplay : public BobbyDisplay
|
||||||
{
|
{
|
||||||
using Base = espgui::Display;
|
using Base = BobbyDisplay;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
void initScreen() override;
|
void initScreen() override;
|
||||||
void redraw() override;
|
void redraw() override;
|
||||||
|
|
||||||
void confirm() override;
|
void buttonPressed(espgui::Button button) override
|
||||||
void back() override;
|
|
||||||
|
|
||||||
void rotate(int offset) override;
|
|
||||||
|
|
||||||
espgui::Label m_voltageLabel{120, 50};
|
espgui::Label m_voltageLabel{120, 50};
|
||||||
espgui::Label m_currentLabel{120, 75};
|
espgui::Label m_currentLabel{120, 75};
|
||||||
|
Reference in New Issue
Block a user