Even more more fixes

This commit is contained in:
2023-08-13 20:26:51 +02:00
parent cca17b7ded
commit f32013f782
71 changed files with 265 additions and 302 deletions

View File

@ -8,15 +8,15 @@
void RebootAction::triggered() void RebootAction::triggered()
{ {
espgui::tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
espgui::tft.setTextColor(TFT_YELLOW); tft.setTextColor(TFT_YELLOW);
espgui::tft.drawString("Reboot", 5, 5, 4); tft.drawString("Reboot", 5, 5, 4);
espgui::tft.fillRect(0, 34, espgui::tft.width(), 3, TFT_WHITE); tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE);
espgui::tft.setTextColor(TFT_WHITE); tft.setTextColor(TFT_WHITE);
espgui::tft.drawString("Rebooting now...", 0, 50, 4); tft.drawString("Rebooting now...", 0, 50, 4);
esp_restart(); esp_restart();
} }

View File

@ -5,7 +5,6 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <actioninterface.h> #include <actioninterface.h>
#include <tftinstance.h>
// local includes // local includes
#include "newsettings.h" #include "newsettings.h"
@ -18,15 +17,15 @@ public:
{ {
if (reboot) if (reboot)
{ {
espgui::tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
espgui::tft.setTextColor(TFT_YELLOW); tft.setTextColor(TFT_YELLOW);
espgui::tft.drawString("Reboot", 5, 5, 4); tft.drawString("Reboot", 5, 5, 4);
espgui::tft.fillRect(0, 34, espgui::tft.width(), 3, TFT_WHITE); tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE);
espgui::tft.setTextColor(TFT_WHITE); tft.setTextColor(TFT_WHITE);
espgui::tft.drawString("Rebooting now...", 0, 50, 4); tft.drawString("Rebooting now...", 0, 50, 4);
configs.reset(); configs.reset();

View File

@ -8,7 +8,6 @@
#include <esp_log.h> #include <esp_log.h>
// 3rdparty lib includes // 3rdparty lib includes
#include <tftinstance.h>
#include <esp32-hal-gpio.h> #include <esp32-hal-gpio.h>
#include <screenmanager.h> #include <screenmanager.h>
#include <changevaluedisplay.h> #include <changevaluedisplay.h>
@ -117,7 +116,7 @@ void handleNormalChar(char c)
{ {
case 'i': case 'i':
case 'I': case 'I':
espgui::tft.init(); tft.init();
break; break;
case 'p': case 'p':
case 'P': case 'P':

View File

@ -3,7 +3,6 @@ constexpr const char * const TAG = "BatteryGraphDisplay";
// 3rdparty lib includes // 3rdparty lib includes
#include <screenmanager.h> #include <screenmanager.h>
#include <tftinstance.h>
// local includes // local includes
#include "battery.h" #include "battery.h"
@ -18,9 +17,9 @@ namespace {
constexpr const uint8_t TOP_OFFSET = 40; constexpr const uint8_t TOP_OFFSET = 40;
} // namespace } // namespace
void BatteryGraphDisplay::initScreen() void BatteryGraphDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
drawBatteryCurve(); drawBatteryCurve();
} }
@ -76,8 +75,8 @@ void BatteryGraphDisplay::buttonPressed(espgui::Button button)
void BatteryGraphDisplay::drawBatteryCurve() void BatteryGraphDisplay::drawBatteryCurve()
{ {
const auto points = count_curve_points(configs.battery.cellType.value()); const auto points = count_curve_points(configs.battery.cellType.value());
const auto max_height = espgui::tft.height() - 1; const auto max_height = tft.height() - 1;
const auto max_width = espgui::tft.width() - 4; const auto max_width = tft.width() - 4;
const uint16_t part = max_width / points; const uint16_t part = max_width / points;
const auto min_voltage = getMinBatCellVoltage(configs.battery.cellType.value()); const auto min_voltage = getMinBatCellVoltage(configs.battery.cellType.value());
const auto max_voltage = getMaxBatCellVoltage(configs.battery.cellType.value()); const auto max_voltage = getMaxBatCellVoltage(configs.battery.cellType.value());
@ -89,7 +88,7 @@ void BatteryGraphDisplay::drawBatteryCurve()
const int y1 = float_map(point->minVoltage / 100.f, min_voltage, max_voltage, max_height, TOP_OFFSET); const int y1 = float_map(point->minVoltage / 100.f, min_voltage, max_voltage, max_height, TOP_OFFSET);
const int x2 = 2 + part * (points - i); const int x2 = 2 + part * (points - i);
const int y2 = float_map(point->maxVoltage / 100.f, min_voltage, max_voltage, max_height, TOP_OFFSET); const int y2 = float_map(point->maxVoltage / 100.f, min_voltage, max_voltage, max_height, TOP_OFFSET);
espgui::tft.drawLine(x1, y1, x2, y2, TFT_WHITE); tft.drawLine(x1, y1, x2, y2, TFT_WHITE);
} }
} }
} }

View File

@ -8,8 +8,8 @@ class BatteryGraphDisplay : public BobbyDisplayWithTitle {
public: public:
std::string text() const override; std::string text() const override;
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -2,7 +2,6 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <screenmanager.h> #include <screenmanager.h>
#include <tftinstance.h>
// local includes // local includes
#include "battery.h" #include "battery.h"
@ -14,10 +13,10 @@
// display with big battery and ten bars (0-100%) // display with big battery and ten bars (0-100%)
void BatteryInfoDisplay::initScreen() void BatteryInfoDisplay::initScreen(espgui::TftInterface &tft)
{ {
using namespace espgui; using namespace espgui;
Base::initScreen(); Base::initScreen(tft);
tft.drawRoundRect(m_offset, m_offset, tft.width() - (m_offset * 2), tft.height() - (m_offset * 2), 10, TFT_WHITE); 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); tft.drawRoundRect((tft.width() / 2) - (m_offset / 2), m_offset / 2, m_offset, m_offset / 2, 3, TFT_WHITE);

View File

@ -8,8 +8,8 @@ class BatteryInfoDisplay : public BobbyDisplay
using Base = BobbyDisplay; using Base = BobbyDisplay;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;
private: private:

View File

@ -5,13 +5,12 @@
#include "displays/speedinfodisplay.h" #include "displays/speedinfodisplay.h"
#include "displays/statusdisplay.h" #include "displays/statusdisplay.h"
#include "screenmanager.h" #include "screenmanager.h"
#include "tftinstance.h"
using namespace espgui; using namespace espgui;
void BmsDisplay::initScreen() void BmsDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);

View File

@ -18,8 +18,8 @@ class BmsDisplay :
using Base = BobbyDisplay; using Base = BobbyDisplay;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -1,7 +1,6 @@
#include "confiscationdisplay.h" #include "confiscationdisplay.h"
// 3rdparty lib includes // 3rdparty lib includes
#include <tftinstance.h>
#include <screenmanager.h> #include <screenmanager.h>
#include <esprandom.h> #include <esprandom.h>
#include <randomutils.h> #include <randomutils.h>
@ -29,27 +28,27 @@ void ConfiscationDisplay::start()
m_nextRestart = espchrono::millis_clock::now() + std::chrono::seconds{cpputils::randomNumber(3, 7, espcpputils::esp_random_device{})}; m_nextRestart = espchrono::millis_clock::now() + std::chrono::seconds{cpputils::randomNumber(3, 7, espcpputils::esp_random_device{})};
} }
void ConfiscationDisplay::initScreen() void ConfiscationDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
espgui::tft.setSwapBytes(true); tft.setSwapBytes(true);
espgui::tft.pushImage(10, 70, bobbyicons::shortcircuit.WIDTH, bobbyicons::shortcircuit.HEIGHT, bobbyicons::shortcircuit.buffer); tft.pushImage(10, 70, bobbyicons::shortcircuit.WIDTH, bobbyicons::shortcircuit.HEIGHT, bobbyicons::shortcircuit.buffer);
espgui::tft.setSwapBytes(false); tft.setSwapBytes(false);
m_progressBar.start(); m_progressBar.start();
m_label.start(); m_label.start();
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
espgui::tft.setTextFont(2); tft.setTextFont(2);
auto y = 235; auto y = 235;
constexpr auto lineheight = 15; constexpr auto lineheight = 15;
espgui::tft.drawString("Bei erneuter, widerrechtlicher", 10, y+=lineheight); tft.drawString("Bei erneuter, widerrechtlicher", 10, y+=lineheight);
espgui::tft.drawString("Beschlagnahmung wird die Selbst-", 10, y+=lineheight); tft.drawString("Beschlagnahmung wird die Selbst-", 10, y+=lineheight);
espgui::tft.drawString("Vernichtung durch Kurzschluss", 10, y+=lineheight); tft.drawString("Vernichtung durch Kurzschluss", 10, y+=lineheight);
espgui::tft.drawString(fmt::format("der Batterie eingeleitet (ca {:.2f}MJ)", calculateMegaJoules()), 10, y+=lineheight); tft.drawString(fmt::format("der Batterie eingeleitet (ca {:.2f}MJ)", calculateMegaJoules()), 10, y+=lineheight);
} }
void ConfiscationDisplay::redraw() void ConfiscationDisplay::redraw()
@ -58,9 +57,9 @@ void ConfiscationDisplay::redraw()
m_progressBar.redraw(m_progress); m_progressBar.redraw(m_progress);
espgui::tft.setTextColor(TFT_YELLOW, TFT_BLACK); tft.setTextColor(TFT_YELLOW, TFT_BLACK);
espgui::tft.setTextFont(2); tft.setTextFont(2);
m_label.redraw([](){ m_label.redraw([](){
if (const auto period = espchrono::millis_clock::now().time_since_epoch() % 6000ms; period < 2000ms) if (const auto period = espchrono::millis_clock::now().time_since_epoch() % 6000ms; period < 2000ms)
return "Halten Sie 10m Abstand."; return "Halten Sie 10m Abstand.";

View File

@ -16,8 +16,8 @@ class ConfiscationDisplay : public BobbyDisplayWithTitle
public: public:
void start() override; void start() override;
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void update() override; void update() override;
void stop() override; void stop() override;

View File

@ -3,7 +3,6 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <randomutils.h> #include <randomutils.h>
#include <esprandom.h> #include <esprandom.h>
#include <tftinstance.h>
#include <screenmanager.h> #include <screenmanager.h>
// local includes // local includes
@ -17,14 +16,14 @@ void GameOfLifeDisplay::start()
m_newgrid = std::make_unique<std::bitset<GRIDX*GRIDY>>(); m_newgrid = std::make_unique<std::bitset<GRIDX*GRIDY>>();
} }
void GameOfLifeDisplay::initScreen() void GameOfLifeDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
disableScreenFlip(true); disableScreenFlip(true);
espgui::tft.setRotation(3); tft.setRotation(3);
espgui::tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
} }
void GameOfLifeDisplay::redraw() void GameOfLifeDisplay::redraw()
@ -33,7 +32,7 @@ void GameOfLifeDisplay::redraw()
if (gen == 0) if (gen == 0)
{ {
espgui::tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
initGrid(); initGrid();
} }
@ -80,7 +79,7 @@ void GameOfLifeDisplay::drawGrid()
color = 0xFFFF; //random(0xFFFF); color = 0xFFFF; //random(0xFFFF);
else else
color = 0; color = 0;
espgui::tft.fillRect(CELLXY * x, CELLXY * y, CELLXY, CELLXY, color); tft.fillRect(CELLXY * x, CELLXY * y, CELLXY, CELLXY, color);
} }
} }
} }

View File

@ -13,8 +13,8 @@ class GameOfLifeDisplay : public BobbyDisplay
public: public:
void start() override; void start() override;
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void stop() override; void stop() override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -21,8 +21,8 @@ class GametrakCalibrateDisplay : public BobbyDisplay, public ConfirmActionInterf
using Base = BobbyDisplay; using Base = BobbyDisplay;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
private: private:
std::array<Label, 6> m_labels {{ std::array<Label, 6> m_labels {{
@ -41,9 +41,9 @@ private:
}}; }};
}; };
void GametrakCalibrateDisplay::initScreen() void GametrakCalibrateDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
tft.setTextFont(4); tft.setTextFont(4);

View File

@ -2,7 +2,6 @@
#include "joystickdebugdisplay.h" #include "joystickdebugdisplay.h"
// 3rdparty lib includes // 3rdparty lib includes
#include <tftinstance.h>
#include <screenmanager.h> #include <screenmanager.h>
// local includes // local includes

View File

@ -8,7 +8,6 @@
#include <cpputils.h> #include <cpputils.h>
#include <menuitem.h> #include <menuitem.h>
#include <actioninterface.h> #include <actioninterface.h>
#include <tftinstance.h>
#include <screenmanager.h> #include <screenmanager.h>
#include <actions/dummyaction.h> #include <actions/dummyaction.h>
@ -54,30 +53,30 @@ std::string LedstripColorsDisplay::text() const
return TEXT_LEDSTRIPCOLORMENU; return TEXT_LEDSTRIPCOLORMENU;
} }
void LedstripColorsDisplay::initScreen() void LedstripColorsDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
espgui::tft.setSwapBytes(true); tft.setSwapBytes(true);
espgui::tft.pushImage(70, 60, bobbyicons::bobbycar.WIDTH, bobbyicons::bobbycar.HEIGHT, bobbyicons::bobbycar.buffer); tft.pushImage(70, 60, bobbyicons::bobbycar.WIDTH, bobbyicons::bobbycar.HEIGHT, bobbyicons::bobbycar.buffer);
espgui::tft.setSwapBytes(false); tft.setSwapBytes(false);
} }
void LedstripColorsDisplay::redraw() void LedstripColorsDisplay::redraw()
{ {
Base::redraw(); Base::redraw();
auto y_pos = ((espgui::tft.width() - 40) / 8 + 4) + 240; auto y_pos = ((tft.width() - 40) / 8 + 4) + 240;
if (last_state != state_select_color) if (last_state != state_select_color)
{ {
espgui::tft.fillRect(0,y_pos - 1, espgui::tft.width(), 20, TFT_BLACK); tft.fillRect(0,y_pos - 1, tft.width(), 20, TFT_BLACK);
last_state = state_select_color; last_state = state_select_color;
} }
espgui::tft.setTextFont(2); tft.setTextFont(2);
espgui::tft.setTextColor(TFT_WHITE); tft.setTextColor(TFT_WHITE);
espgui::tft.drawString(state_select_color ? tft.drawString(state_select_color ?
"Please select a color!" : "Please select a color!" :
"Please select a side!", 50, y_pos); "Please select a side!", 50, y_pos);
@ -103,7 +102,7 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
else else
{ {
state_select_color = false; state_select_color = false;
espgui::tft.fillRect(0, 228, espgui::tft.width(), ((espgui::tft.width() - 40) / 8) + 4, TFT_BLACK); tft.fillRect(0, 228, tft.width(), ((tft.width() - 40) / 8) + 4, TFT_BLACK);
} }
break; break;
@ -119,7 +118,7 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
// Uncomment to close select color menu on color select // Uncomment to close select color menu on color select
/* /*
state_select_color = false; state_select_color = false;
espgui::tft.fillRect(0, 228, espgui::tft.width(), ((espgui::tft.width() - 40) / 8) + 4, TFT_BLACK); tft.fillRect(0, 228, tft.width(), ((tft.width() - 40) / 8) + 4, TFT_BLACK);
*/ */
} }
break; break;
@ -148,7 +147,7 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
} }
else else
{ {
espgui::tft.fillRect(0, 228, espgui::tft.width(), ((espgui::tft.width() - 40) / 8) + 4, TFT_BLACK); tft.fillRect(0, 228, tft.width(), ((tft.width() - 40) / 8) + 4, TFT_BLACK);
clearSides(); clearSides();
drawSide(static_cast<Bobbycar_Side>(selected_side), TFT_GOLD); drawSide(static_cast<Bobbycar_Side>(selected_side), TFT_GOLD);
} }
@ -179,7 +178,7 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
} }
else else
{ {
espgui::tft.fillRect(0, 228, espgui::tft.width(), ((espgui::tft.width() - 40) / 8) + 4, TFT_BLACK); tft.fillRect(0, 228, tft.width(), ((tft.width() - 40) / 8) + 4, TFT_BLACK);
clearSides(); clearSides();
drawSide(static_cast<Bobbycar_Side>(selected_side), TFT_GOLD); drawSide(static_cast<Bobbycar_Side>(selected_side), TFT_GOLD);
} }
@ -190,17 +189,17 @@ void LedstripColorsDisplay::buttonPressed(espgui::Button button)
void LedstripColorsDisplay::drawColors() void LedstripColorsDisplay::drawColors()
{ {
uint16_t width = (espgui::tft.width() - 40); uint16_t width = (tft.width() - 40);
auto cube_width = width / 8; auto cube_width = width / 8;
espgui::tft.fillRect(0, 228, espgui::tft.width(), cube_width + 4, TFT_BLACK); tft.fillRect(0, 228, tft.width(), cube_width + 4, TFT_BLACK);
espgui::tft.fillRect(21, 231, width - 1, cube_width - 1, TFT_WHITE); tft.fillRect(21, 231, width - 1, cube_width - 1, TFT_WHITE);
espgui::tft.fillRect(20 + (selected_color * cube_width - 1), 228, cube_width + 4, cube_width + 4, TFT_YELLOW); tft.fillRect(20 + (selected_color * cube_width - 1), 228, cube_width + 4, cube_width + 4, TFT_YELLOW);
for (int index = 0; index < 8; index++) for (int index = 0; index < 8; index++)
{ {
auto offset = index * (cube_width); auto offset = index * (cube_width);
espgui::tft.fillRect(22 + offset, 232, cube_width - 4, cube_width - 4, tft_colors[index]); tft.fillRect(22 + offset, 232, cube_width - 4, cube_width - 4, tft_colors[index]);
} }
} }
@ -214,7 +213,7 @@ void LedstripColorsDisplay::clearSides()
void LedstripColorsDisplay::drawSide(Bobbycar_Side side, unsigned int color) void LedstripColorsDisplay::drawSide(Bobbycar_Side side, unsigned int color)
{ {
const auto middle = espgui::tft.width() / 2; const auto middle = tft.width() / 2;
const auto width = bobbyicons::bobbycar.WIDTH; const auto width = bobbyicons::bobbycar.WIDTH;
const auto height = bobbyicons::bobbycar.HEIGHT; const auto height = bobbyicons::bobbycar.HEIGHT;
const auto left = middle - (width / 2); const auto left = middle - (width / 2);
@ -224,33 +223,33 @@ void LedstripColorsDisplay::drawSide(Bobbycar_Side side, unsigned int color)
switch (side) { switch (side) {
case Bobbycar_Side::FRONT: case Bobbycar_Side::FRONT:
espgui::tft.fillRect(left, above, width, 5, color); tft.fillRect(left, above, width, 5, color);
break; break;
case Bobbycar_Side::FRONT_LEFT: case Bobbycar_Side::FRONT_LEFT:
espgui::tft.fillRect(left - 10, above + 10, 5, height / 2, color); tft.fillRect(left - 10, above + 10, 5, height / 2, color);
espgui::tft.fillRect(left, above, width / 2, 5, color); tft.fillRect(left, above, width / 2, 5, color);
break; break;
case Bobbycar_Side::LEFT: case Bobbycar_Side::LEFT:
espgui::tft.fillRect(left - 10, above + 10, 5, height, color); tft.fillRect(left - 10, above + 10, 5, height, color);
break; break;
case Bobbycar_Side::BACK_LEFT: case Bobbycar_Side::BACK_LEFT:
espgui::tft.fillRect(left - 10, above + 10 + (height / 2), 5, height / 2, color); tft.fillRect(left - 10, above + 10 + (height / 2), 5, height / 2, color);
espgui::tft.fillRect(left, bellow + 5, width / 2, 5, color); tft.fillRect(left, bellow + 5, width / 2, 5, color);
break; break;
case Bobbycar_Side::BACK: case Bobbycar_Side::BACK:
espgui::tft.fillRect(left, bellow + 5, width, 5, color); tft.fillRect(left, bellow + 5, width, 5, color);
break; break;
case Bobbycar_Side::BACK_RIGHT: case Bobbycar_Side::BACK_RIGHT:
espgui::tft.fillRect(right + 5, above + 10 + (height / 2), 5, height / 2, color); tft.fillRect(right + 5, above + 10 + (height / 2), 5, height / 2, color);
espgui::tft.fillRect(middle, bellow + 5, width / 2, 5, color); tft.fillRect(middle, bellow + 5, width / 2, 5, color);
break; break;
case Bobbycar_Side::RIGHT: case Bobbycar_Side::RIGHT:
espgui::tft.fillRect(right + 5, above + 10, 5, height, color); tft.fillRect(right + 5, above + 10, 5, height, color);
break; break;
case Bobbycar_Side::FRONT_RIGHT: case Bobbycar_Side::FRONT_RIGHT:
espgui::tft.fillRect(right + 5, above + 10, 5, height / 2, color); tft.fillRect(right + 5, above + 10, 5, height / 2, color);
espgui::tft.fillRect(middle, above, width / 2, 5, color); tft.fillRect(middle, above, width / 2, 5, color);
break; break;
} }
// espgui::tft.fillCircle(espgui::tft.width() / 2, 140, 100, TFT_BLACK); // tft.fillCircle(tft.width() / 2, 140, 100, TFT_BLACK);
} }

View File

@ -16,8 +16,8 @@ class LedstripColorsDisplay : public BobbyDisplayWithTitle
public: public:
std::string text() const override; std::string text() const override;
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -4,7 +4,6 @@
#include <algorithm> #include <algorithm>
// 3rdparty lib includes // 3rdparty lib includes
#include <tftinstance.h>
#include <screenmanager.h> #include <screenmanager.h>
// local includes // local includes
@ -57,18 +56,18 @@ void Lockscreen::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(tft); Base::initScreen(tft);
espgui::tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
espgui::tft.setTextFont(4); tft.setTextFont(4);
espgui::tft.setTextColor(TFT_YELLOW); tft.setTextColor(TFT_YELLOW);
espgui::tft.drawString("Lock vehicle", 5, 5); tft.drawString("Lock vehicle", 5, 5);
espgui::tft.fillRect(0, 34, espgui::tft.width(), 3, TFT_WHITE); tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE);
espgui::tft.setTextColor(TFT_WHITE); tft.setTextColor(TFT_WHITE);
espgui::tft.drawString("Enter code to unlock:", 0, 50); tft.drawString("Enter code to unlock:", 0, 50);
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
for(int i = 0; i <= 3; i++) for(int i = 0; i <= 3; i++)
{ {
@ -79,7 +78,7 @@ void Lockscreen::initScreen(espgui::TftInterface &tft)
for (auto &label : m_labels) for (auto &label : m_labels)
label.start(); label.start();
espgui::tft.setTextFont(7); tft.setTextFont(7);
drawRect(m_currentIndex, 1, TFT_YELLOW); drawRect(m_currentIndex, 1, TFT_YELLOW);
drawRect(m_currentIndex, 2, TFT_YELLOW); drawRect(m_currentIndex, 2, TFT_YELLOW);
@ -207,5 +206,5 @@ void Lockscreen::buttonPressed(espgui::Button button)
void Lockscreen::drawRect(int index, int offset, uint32_t color) const void Lockscreen::drawRect(int index, int offset, uint32_t color) const
{ {
espgui::tft.drawRect(m_labels[index].x()-offset, m_labels[index].y()-offset, boxWidth+(offset*2), boxHeight+(offset*2), color); tft.drawRect(m_labels[index].x()-offset, m_labels[index].y()-offset, boxWidth+(offset*2), boxHeight+(offset*2), color);
} }

View File

@ -10,8 +10,6 @@
#include <textwithvaluehelper.h> #include <textwithvaluehelper.h>
#include <fmt/core.h> #include <fmt/core.h>
#include <tftinstance.h>
// Local includes // Local includes
#include "utils.h" #include "utils.h"
#include "icons/settings.h" #include "icons/settings.h"
@ -98,9 +96,9 @@ std::string BatteryMenu::text() const
return TEXT_BATTERY; return TEXT_BATTERY;
} }
void BatteryMenu::initScreen() void BatteryMenu::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
m_batPercentBootLabel.start(); m_batPercentBootLabel.start();
m_batPercentNowLabel.start(); m_batPercentNowLabel.start();
} }

View File

@ -14,9 +14,9 @@ public:
std::string text() const override; std::string text() const override;
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void start() override; void start() override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void back() override; void back() override;
private: private:

View File

@ -141,7 +141,7 @@ DefaultModeSettingsMenu::DefaultModeSettingsMenu()
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
} }
std::string DefaultModeSettingsMenu::text() const std::string DefaultModeSettingsMenu::title() const
{ {
return TEXT_DEFAULTMODESETTIGNS; return TEXT_DEFAULTMODESETTIGNS;
} }

View File

@ -8,7 +8,7 @@ class DefaultModeSettingsMenu : public BobbyMenuDisplay
public: public:
DefaultModeSettingsMenu(); DefaultModeSettingsMenu();
std::string text() const override; std::string title() const override;
void back() override; void back() override;
}; };

View File

@ -54,7 +54,7 @@ LarsmModeSettingsMenu::LarsmModeSettingsMenu()
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
} }
std::string LarsmModeSettingsMenu::text() const std::string LarsmModeSettingsMenu::title() const
{ {
return TEXT_LARSMMODESETTINGS; return TEXT_LARSMMODESETTINGS;
} }

View File

@ -8,7 +8,7 @@ class LarsmModeSettingsMenu : public BobbyMenuDisplay
public: public:
LarsmModeSettingsMenu(); LarsmModeSettingsMenu();
std::string text() const override; std::string title() const override;
void back() override; void back() override;
}; };

View File

@ -4,7 +4,6 @@
#include <actions/pushscreenaction.h> #include <actions/pushscreenaction.h>
#include <actions/popscreenaction.h> #include <actions/popscreenaction.h>
#include <icons/back.h> #include <icons/back.h>
#include <tftinstance.h>
// local includes // local includes
#include "displays/menus/selectmodemenu.h" #include "displays/menus/selectmodemenu.h"

View File

@ -43,7 +43,7 @@ MickModeSettingsMenu::MickModeSettingsMenu()
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
} }
std::string MickModeSettingsMenu::text() const std::string MickModeSettingsMenu::title() const
{ {
return TEXT_MICKMODESETTINGS; return TEXT_MICKMODESETTINGS;
} }

View File

@ -8,7 +8,7 @@ class MickModeSettingsMenu : public BobbyMenuDisplay
public: public:
MickModeSettingsMenu(); MickModeSettingsMenu();
std::string text() const override; std::string title() const override;
void back() override; void back() override;
}; };

View File

@ -44,7 +44,7 @@ MotortestModeSettingsMenu::MotortestModeSettingsMenu()
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
} }
std::string MotortestModeSettingsMenu::text() const std::string MotortestModeSettingsMenu::title() const
{ {
return TEXT_MOTORTESTMODESETTINGS; return TEXT_MOTORTESTMODESETTINGS;
} }

View File

@ -8,7 +8,7 @@ class MotortestModeSettingsMenu : public BobbyMenuDisplay
public: public:
MotortestModeSettingsMenu(); MotortestModeSettingsMenu();
std::string text() const override; std::string title() const override;
void back() override; void back() override;
}; };

View File

@ -34,7 +34,7 @@ RemoteControlModeSettingsMenu::RemoteControlModeSettingsMenu()
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
} }
std::string RemoteControlModeSettingsMenu::text() const std::string RemoteControlModeSettingsMenu::title() const
{ {
return TEXT_REMOTEMODESETTINGS; return TEXT_REMOTEMODESETTINGS;
} }

View File

@ -8,7 +8,7 @@ class RemoteControlModeSettingsMenu : public BobbyMenuDisplay
public: public:
RemoteControlModeSettingsMenu(); RemoteControlModeSettingsMenu();
std::string text() const override; std::string title() const override;
void back() override; void back() override;
}; };

View File

@ -50,7 +50,7 @@ TempomatModeSettingsMenu::TempomatModeSettingsMenu()
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>(); constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
} }
std::string TempomatModeSettingsMenu::text() const std::string TempomatModeSettingsMenu::title() const
{ {
return TEXT_TEMPOMATMODESETTINGS; return TEXT_TEMPOMATMODESETTINGS;
} }

View File

@ -8,7 +8,7 @@ class TempomatModeSettingsMenu : public BobbyMenuDisplay
public: public:
TempomatModeSettingsMenu(); TempomatModeSettingsMenu();
std::string text() const override; std::string title() const override;
void back() override; void back() override;
}; };

View File

@ -1,7 +1,6 @@
#include "metersdisplay.h" #include "metersdisplay.h"
// 3rdparty lib includes // 3rdparty lib includes
#include <tftinstance.h>
#include <fmt/core.h> #include <fmt/core.h>
// local includes // local includes
@ -13,9 +12,9 @@
using namespace espgui; using namespace espgui;
void MetersDisplay::initScreen() void MetersDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);

View File

@ -19,8 +19,8 @@ class MetersDisplay : public BobbyDisplay
using Base = BobbyDisplay; using Base = BobbyDisplay;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -3,7 +3,6 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <randomutils.h> #include <randomutils.h>
#include <esprandom.h> #include <esprandom.h>
#include <tftinstance.h>
#include <screenmanager.h> #include <screenmanager.h>
// local includes // local includes
@ -18,14 +17,14 @@ PingPongDisplay::PingPongDisplay() :
calc_target_y(); calc_target_y();
} }
void PingPongDisplay::initScreen() void PingPongDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
disableScreenFlip(true); disableScreenFlip(true);
espgui::tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
espgui::tft.setRotation(1); tft.setRotation(1);
midline(); midline();
} }
@ -68,29 +67,29 @@ void PingPongDisplay::midline()
// If the ball is not on the line then don't redraw the line // If the ball is not on the line then don't redraw the line
if ((ball_x<dashline_x-ball_w) && (ball_x > dashline_x+dashline_w)) return; if ((ball_x<dashline_x-ball_w) && (ball_x > dashline_x+dashline_w)) return;
espgui::tft.startWrite(); tft.startWrite();
// Quick way to draw a dashed line // Quick way to draw a dashed line
espgui::tft.setAddrWindow(dashline_x, 0, dashline_w, h); tft.setAddrWindow(dashline_x, 0, dashline_w, h);
for (int16_t i = 0; i < dashline_n; i+=2) for (int16_t i = 0; i < dashline_n; i+=2)
{ {
espgui::tft.pushColor(WHITE, dashline_w*dashline_h); // push dash pixels tft.pushColor(WHITE, dashline_w*dashline_h); // push dash pixels
espgui::tft.pushColor(BLACK, dashline_w*dashline_h); // push gap pixels tft.pushColor(BLACK, dashline_w*dashline_h); // push gap pixels
} }
espgui::tft.endWrite(); tft.endWrite();
} }
void PingPongDisplay::lpaddle() void PingPongDisplay::lpaddle()
{ {
if (lpaddle_d == 1) if (lpaddle_d == 1)
{ {
espgui::tft.fillRect(lpaddle_x, lpaddle_y, paddle_w, 1, BLACK); tft.fillRect(lpaddle_x, lpaddle_y, paddle_w, 1, BLACK);
} }
else if (lpaddle_d == -1) else if (lpaddle_d == -1)
{ {
espgui::tft.fillRect(lpaddle_x, lpaddle_y + paddle_h - 1, paddle_w, 1, BLACK); tft.fillRect(lpaddle_x, lpaddle_y + paddle_h - 1, paddle_w, 1, BLACK);
} }
lpaddle_y = lpaddle_y + lpaddle_d; lpaddle_y = lpaddle_y + lpaddle_d;
@ -107,15 +106,15 @@ void PingPongDisplay::lpaddle()
if (lpaddle_y + paddle_h >= h && lpaddle_d == 1) lpaddle_d = 0; if (lpaddle_y + paddle_h >= h && lpaddle_d == 1) lpaddle_d = 0;
else if (lpaddle_y <= 0 && lpaddle_d == -1) lpaddle_d = 0; else if (lpaddle_y <= 0 && lpaddle_d == -1) lpaddle_d = 0;
espgui::tft.fillRect(lpaddle_x, lpaddle_y, paddle_w, paddle_h, WHITE); tft.fillRect(lpaddle_x, lpaddle_y, paddle_w, paddle_h, WHITE);
} }
void PingPongDisplay::rpaddle() void PingPongDisplay::rpaddle()
{ {
if (rpaddle_d == 1) if (rpaddle_d == 1)
espgui::tft.fillRect(rpaddle_x, rpaddle_y, paddle_w, 1, BLACK); tft.fillRect(rpaddle_x, rpaddle_y, paddle_w, 1, BLACK);
else if (rpaddle_d == -1) else if (rpaddle_d == -1)
espgui::tft.fillRect(rpaddle_x, rpaddle_y + paddle_h - 1, paddle_w, 1, BLACK); tft.fillRect(rpaddle_x, rpaddle_y + paddle_h - 1, paddle_w, 1, BLACK);
rpaddle_y = rpaddle_y + rpaddle_d; rpaddle_y = rpaddle_y + rpaddle_d;
@ -133,7 +132,7 @@ void PingPongDisplay::rpaddle()
else if (rpaddle_y <= 0 && rpaddle_d == -1) else if (rpaddle_y <= 0 && rpaddle_d == -1)
rpaddle_d = 0; rpaddle_d = 0;
espgui::tft.fillRect(rpaddle_x, rpaddle_y, paddle_w, paddle_h, WHITE); tft.fillRect(rpaddle_x, rpaddle_y, paddle_w, paddle_h, WHITE);
} }
void PingPongDisplay::calc_target_y() void PingPongDisplay::calc_target_y()
@ -180,8 +179,8 @@ void PingPongDisplay::ball()
} }
//tft.fillRect(oldball_x, oldball_y, ball_w, ball_h, BLACK); //tft.fillRect(oldball_x, oldball_y, ball_w, ball_h, BLACK);
espgui::tft.drawRect(oldball_x, oldball_y, ball_w, ball_h, BLACK); // Less TFT refresh aliasing than line above for large balls tft.drawRect(oldball_x, oldball_y, ball_w, ball_h, BLACK); // Less TFT refresh aliasing than line above for large balls
espgui::tft.fillRect( ball_x, ball_y, ball_w, ball_h, WHITE); tft.fillRect( ball_x, ball_y, ball_w, ball_h, WHITE);
oldball_x = ball_x; oldball_x = ball_x;
oldball_y = ball_y; oldball_y = ball_y;
} }

View File

@ -13,8 +13,8 @@ class PingPongDisplay : public BobbyDisplay
public: public:
PingPongDisplay(); PingPongDisplay();
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void stop() override; void stop() override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -1,8 +1,5 @@
#include "potiscalibratedisplay.h" #include "potiscalibratedisplay.h"
// 3rdparty lib includes
#include <tftinstance.h>
// local includes // local includes
#include "actions/switchscreenaction.h" #include "actions/switchscreenaction.h"
#include "displays/menus/boardcomputerhardwaresettingsmenu.h" #include "displays/menus/boardcomputerhardwaresettingsmenu.h"
@ -35,15 +32,15 @@ void PotisCalibrateDisplay::start()
m_brems = std::nullopt; m_brems = std::nullopt;
} }
void PotisCalibrateDisplay::initScreen() void PotisCalibrateDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
espgui::tft.setTextFont(4); tft.setTextFont(4);
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
espgui::tft.drawString("gas:", 25, 47); tft.drawString("gas:", 25, 47);
espgui::tft.drawString("brems:", 25, 147); tft.drawString("brems:", 25, 147);
for (auto &label : m_labels) for (auto &label : m_labels)
label.start(); label.start();
@ -76,30 +73,30 @@ void PotisCalibrateDisplay::redraw()
m_labels[0].redraw(m_gas ? fmt::format("{:.02f}", *m_gas) : "?"); m_labels[0].redraw(m_gas ? fmt::format("{:.02f}", *m_gas) : "?");
m_labels[1].redraw(raw_gas ? std::to_string(*raw_gas) : "?"); m_labels[1].redraw(raw_gas ? std::to_string(*raw_gas) : "?");
if (m_status == Status::GasMin) if (m_status == Status::GasMin)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK); tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[2].redraw(std::to_string(m_gasMin)); m_labels[2].redraw(std::to_string(m_gasMin));
if (m_status == Status::GasMin) if (m_status == Status::GasMin)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
if (m_status == Status::GasMax) if (m_status == Status::GasMax)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK); tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[3].redraw(std::to_string(m_gasMax)); m_labels[3].redraw(std::to_string(m_gasMax));
if (m_status == Status::GasMax) if (m_status == Status::GasMax)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_progressBars[0].redraw(m_gas ? *m_gas : 0); m_progressBars[0].redraw(m_gas ? *m_gas : 0);
m_labels[4].redraw(m_brems ? fmt::format("{:.02f}", *m_brems) : "?"); m_labels[4].redraw(m_brems ? fmt::format("{:.02f}", *m_brems) : "?");
m_labels[5].redraw(raw_brems ? std::to_string(*raw_brems) : "?"); m_labels[5].redraw(raw_brems ? std::to_string(*raw_brems) : "?");
if (m_status == Status::BremsMin) if (m_status == Status::BremsMin)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK); tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[6].redraw(std::to_string(m_bremsMin)); m_labels[6].redraw(std::to_string(m_bremsMin));
if (m_status == Status::BremsMin) if (m_status == Status::BremsMin)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
if (m_status == Status::BremsMax) if (m_status == Status::BremsMax)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK); tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[7].redraw(std::to_string(m_bremsMax)); m_labels[7].redraw(std::to_string(m_bremsMax));
if (m_status == Status::BremsMax) if (m_status == Status::BremsMax)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_progressBars[1].redraw(m_brems ? *m_brems : 0); m_progressBars[1].redraw(m_brems ? *m_brems : 0);
@ -122,7 +119,7 @@ void PotisCalibrateDisplay::redraw()
{ {
const auto failed = !m_gas || !m_brems || (m_status == Status::Confirm && (*m_gas > 100 || *m_brems > 100)); const auto failed = !m_gas || !m_brems || (m_status == Status::Confirm && (*m_gas > 100 || *m_brems > 100));
const auto color = failed ? TFT_DARKGREY : TFT_WHITE; const auto color = failed ? TFT_DARKGREY : TFT_WHITE;
espgui::tft.setTextColor(color, TFT_BLACK); tft.setTextColor(color, TFT_BLACK);
m_labels[9].redraw([&](){ m_labels[9].redraw([&](){
switch (m_status) switch (m_status)
{ {
@ -140,10 +137,10 @@ void PotisCalibrateDisplay::redraw()
}()); }());
if (m_selectedButton != m_renderedButton && (m_selectedButton == 0 || m_renderedButton == 0)) if (m_selectedButton != m_renderedButton && (m_selectedButton == 0 || m_renderedButton == 0))
espgui::tft.drawRect(3, 275, 100, 27, m_selectedButton == 0 ? color : TFT_BLACK); tft.drawRect(3, 275, 100, 27, m_selectedButton == 0 ? color : TFT_BLACK);
} }
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_labels[10].redraw([&](){ m_labels[10].redraw([&](){
switch (m_status) switch (m_status)
{ {
@ -161,7 +158,7 @@ void PotisCalibrateDisplay::redraw()
}()); }());
if (m_selectedButton != m_renderedButton && (m_selectedButton == 1 || m_renderedButton == 1)) if (m_selectedButton != m_renderedButton && (m_selectedButton == 1 || m_renderedButton == 1))
espgui::tft.drawRect(123, 275, 100, 27, m_selectedButton == 1 ? TFT_WHITE : TFT_BLACK); tft.drawRect(123, 275, 100, 27, m_selectedButton == 1 ? TFT_WHITE : TFT_BLACK);
m_renderedButton = m_selectedButton; m_renderedButton = m_selectedButton;
} }

View File

@ -27,9 +27,9 @@ public:
std::string text() const override; std::string text() const override;
void start() override; void start() override;
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void update() override; void update() override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void stop() override; void stop() override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -1,7 +1,6 @@
#include "poweroffdisplay.h" #include "poweroffdisplay.h"
// 3rdparty lib includes // 3rdparty lib includes
#include <tftinstance.h>
#include <screenmanager.h> #include <screenmanager.h>
// local includes // local includes
@ -20,21 +19,21 @@ void PoweroffDisplay::start()
controller.command.poweroff = true; controller.command.poweroff = true;
} }
void PoweroffDisplay::initScreen() void PoweroffDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
espgui::tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
espgui::tft.setTextColor(TFT_YELLOW); tft.setTextColor(TFT_YELLOW);
espgui::tft.drawString("Poweroff", 5, 5, 4); tft.drawString("Poweroff", 5, 5, 4);
espgui::tft.fillRect(0, 34, espgui::tft.width(), 3, TFT_WHITE); tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE);
espgui::tft.setTextColor(TFT_WHITE); tft.setTextColor(TFT_WHITE);
espgui::tft.drawString("Trying to turn off", 15, 50, 4); tft.drawString("Trying to turn off", 15, 50, 4);
espgui::tft.drawString("both controllers", 25, 75, 4); tft.drawString("both controllers", 25, 75, 4);
espgui::tft.drawString("Please stand still...", 20, 125, 4); tft.drawString("Please stand still...", 20, 125, 4);
} }
void PoweroffDisplay::update() void PoweroffDisplay::update()

View File

@ -12,7 +12,7 @@ class PoweroffDisplay : public BobbyDisplay
public: public:
void start() override; void start() override;
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void update() override; void update() override;
void stop() override; void stop() override;

View File

@ -1,25 +1,24 @@
#include "powersupplydisplay.h" #include "powersupplydisplay.h"
// 3rdparty lib includes // 3rdparty lib includes
#include <tftinstance.h>
#include <screenmanager.h> #include <screenmanager.h>
// local includes // local includes
#include "globals.h" #include "globals.h"
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY) #if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY)
void PowerSupplyDisplay::initScreen() void PowerSupplyDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
espgui::tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
espgui::tft.setTextFont(4); tft.setTextFont(4);
espgui::tft.drawString("Voltage:", 0, m_voltageLabel.y()); tft.drawString("Voltage:", 0, m_voltageLabel.y());
m_voltageLabel.start(); m_voltageLabel.start();
espgui::tft.drawString("Current:", 0, m_currentLabel.y()); tft.drawString("Current:", 0, m_currentLabel.y());
m_currentLabel.start(); m_currentLabel.start();
} }

View File

@ -12,8 +12,8 @@ class PowerSupplyDisplay : public BobbyDisplay
using Base = BobbyDisplay; using Base = BobbyDisplay;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -2,7 +2,6 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <fmt/core.h> #include <fmt/core.h>
#include <tftinstance.h>
// local includes // local includes
#include "globals.h" #include "globals.h"
@ -15,9 +14,9 @@ QrCodeDebugDisplay::QrCodeDebugDisplay()
{ {
} }
void QrCodeDebugDisplay::initScreen() void QrCodeDebugDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
} }
void QrCodeDebugDisplay::buttonPressed(espgui::Button button) void QrCodeDebugDisplay::buttonPressed(espgui::Button button)

View File

@ -14,7 +14,7 @@ class QrCodeDebugDisplay :
public: public:
QrCodeDebugDisplay(); QrCodeDebugDisplay();
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -29,7 +29,7 @@ public:
private: private:
bool m_waitingForResult{false}; bool m_waitingForResult{false};
espgui::Label m_statuslabel{5,(espgui::tft.height() / 2)-espgui::tft.fontHeight(4)}; espgui::Label m_statuslabel{5,(tft.height() / 2)-tft.fontHeight(4)};
std::expected<std::string, std::string> m_result; std::expected<std::string, std::string> m_result;
std::string m_nvs_key; std::string m_nvs_key;

View File

@ -13,9 +13,9 @@ namespace {
constexpr char const askSetupOtherButtonsText[] = "Do you want to setup other\nbuttons?\n(Blinker, Profile Buttons, etc.)\n\nPress LEFT to skip other buttons.\nPress RIGHT to setup buttons."; constexpr char const askSetupOtherButtonsText[] = "Do you want to setup other\nbuttons?\n(Blinker, Profile Buttons, etc.)\n\nPress LEFT to skip other buttons.\nPress RIGHT to setup buttons.";
} // namespace } // namespace
void SetupAskCalibrateOtherButtonsDisplay::initScreen() void SetupAskCalibrateOtherButtonsDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
drawLargeText(askSetupOtherButtonsText); drawLargeText(askSetupOtherButtonsText);
} }

View File

@ -7,7 +7,7 @@ class SetupAskCalibrateOtherButtonsDisplay : public virtual BobbyDisplayWithTitl
{ {
using Base = BobbyDisplayWithTitle; using Base = BobbyDisplayWithTitle;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void start() override; void start() override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -14,9 +14,9 @@ namespace {
constexpr char const askCloudText[] = "Do you want to setup cloud?\nWith this, you will be able\nto send data to graphana,\nremote control things like Buttons\nand NVS and more!\n\nPress LEFT to skip cloud.\nPress RIGHT to setup cloud."; constexpr char const askCloudText[] = "Do you want to setup cloud?\nWith this, you will be able\nto send data to graphana,\nremote control things like Buttons\nand NVS and more!\n\nPress LEFT to skip cloud.\nPress RIGHT to setup cloud.";
} // namespace } // namespace
void SetupAskSetupCloudsDisplay::initScreen() void SetupAskSetupCloudsDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(espgui::TftInterface &tft);
drawLargeText(askCloudText); drawLargeText(askCloudText);
} }

View File

@ -7,7 +7,7 @@ class SetupAskSetupCloudsDisplay : public virtual BobbyDisplayWithTitle
{ {
using Base = BobbyDisplayWithTitle; using Base = BobbyDisplayWithTitle;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void start() override; void start() override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -5,7 +5,6 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <screenmanager.h> #include <screenmanager.h>
#include <tftinstance.h>
// local includes // local includes
#include "bobbyerrorhandler.h" #include "bobbyerrorhandler.h"

View File

@ -3,7 +3,6 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <cpputils.h> #include <cpputils.h>
#include <screenmanager.h> #include <screenmanager.h>
#include <tftinstance.h>
// local includes // local includes
#include "displays/setup/ask_setup_clouds.h" #include "displays/setup/ask_setup_clouds.h"
@ -65,30 +64,30 @@ void SetupCalibratePotisDisplay::redraw(espgui::TftInterface &tft)
m_labels[0].redraw(m_gas ? fmt::format("{:.02f}", *m_gas) : "?"); m_labels[0].redraw(m_gas ? fmt::format("{:.02f}", *m_gas) : "?");
m_labels[1].redraw(raw_gas ? std::to_string(*raw_gas) : "?"); m_labels[1].redraw(raw_gas ? std::to_string(*raw_gas) : "?");
if (m_status == Status::GasMin) if (m_status == Status::GasMin)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK); tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[2].redraw(std::to_string(m_gasMin)); m_labels[2].redraw(std::to_string(m_gasMin));
if (m_status == Status::GasMin) if (m_status == Status::GasMin)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
if (m_status == Status::GasMax) if (m_status == Status::GasMax)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK); tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[3].redraw(std::to_string(m_gasMax)); m_labels[3].redraw(std::to_string(m_gasMax));
if (m_status == Status::GasMax) if (m_status == Status::GasMax)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_progressBars[0].redraw(m_gas ? *m_gas : 0); m_progressBars[0].redraw(m_gas ? *m_gas : 0);
m_labels[4].redraw(m_brems ? fmt::format("{:.02f}", *m_brems) : "?"); m_labels[4].redraw(m_brems ? fmt::format("{:.02f}", *m_brems) : "?");
m_labels[5].redraw(raw_brems ? std::to_string(*raw_brems) : "?"); m_labels[5].redraw(raw_brems ? std::to_string(*raw_brems) : "?");
if (m_status == Status::BremsMin) if (m_status == Status::BremsMin)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK); tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[6].redraw(std::to_string(m_bremsMin)); m_labels[6].redraw(std::to_string(m_bremsMin));
if (m_status == Status::BremsMin) if (m_status == Status::BremsMin)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
if (m_status == Status::BremsMax) if (m_status == Status::BremsMax)
espgui::tft.setTextColor(TFT_RED, TFT_BLACK); tft.setTextColor(TFT_RED, TFT_BLACK);
m_labels[7].redraw(std::to_string(m_bremsMax)); m_labels[7].redraw(std::to_string(m_bremsMax));
if (m_status == Status::BremsMax) if (m_status == Status::BremsMax)
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_progressBars[1].redraw(m_brems ? *m_brems : 0); m_progressBars[1].redraw(m_brems ? *m_brems : 0);
@ -111,7 +110,7 @@ void SetupCalibratePotisDisplay::redraw(espgui::TftInterface &tft)
{ {
const auto failed = !m_gas || !m_brems || (m_status == Status::Confirm && (*m_gas > 100 || *m_brems > 100)); const auto failed = !m_gas || !m_brems || (m_status == Status::Confirm && (*m_gas > 100 || *m_brems > 100));
const auto color = failed ? TFT_DARKGREY : TFT_WHITE; const auto color = failed ? TFT_DARKGREY : TFT_WHITE;
espgui::tft.setTextColor(color, TFT_BLACK); tft.setTextColor(color, TFT_BLACK);
m_labels[9].redraw([&](){ m_labels[9].redraw([&](){
switch (m_status) switch (m_status)
{ {
@ -129,10 +128,10 @@ void SetupCalibratePotisDisplay::redraw(espgui::TftInterface &tft)
}()); }());
if (m_selectedButton != m_renderedButton && (m_selectedButton == 0 || m_renderedButton == 0)) if (m_selectedButton != m_renderedButton && (m_selectedButton == 0 || m_renderedButton == 0))
espgui::tft.drawRect(3, 275, 100, 27, m_selectedButton == 0 ? color : TFT_BLACK); tft.drawRect(3, 275, 100, 27, m_selectedButton == 0 ? color : TFT_BLACK);
} }
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
m_labels[10].redraw([&](){ m_labels[10].redraw([&](){
switch (m_status) switch (m_status)
{ {
@ -150,7 +149,7 @@ void SetupCalibratePotisDisplay::redraw(espgui::TftInterface &tft)
}()); }());
if (m_selectedButton != m_renderedButton && (m_selectedButton == 1 || m_renderedButton == 1)) if (m_selectedButton != m_renderedButton && (m_selectedButton == 1 || m_renderedButton == 1))
espgui::tft.drawRect(123, 275, 100, 27, m_selectedButton == 1 ? TFT_WHITE : TFT_BLACK); tft.drawRect(123, 275, 100, 27, m_selectedButton == 1 ? TFT_WHITE : TFT_BLACK);
m_renderedButton = m_selectedButton; m_renderedButton = m_selectedButton;
} }

View File

@ -16,9 +16,9 @@ namespace {
constexpr char const finalInformationText[] = "Setup is done!\nIf cloud is setup, go to\nhttps://service.bobbycar.cloud/\nand register this bobbycar!\nThis is also used\nto setup udp cloud.\nPress any button to exit."; constexpr char const finalInformationText[] = "Setup is done!\nIf cloud is setup, go to\nhttps://service.bobbycar.cloud/\nand register this bobbycar!\nThis is also used\nto setup udp cloud.\nPress any button to exit.";
} // namespace } // namespace
void SetupFinalInformationDisplay::initScreen() void SetupFinalInformationDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
drawLargeText(finalInformationText); drawLargeText(finalInformationText);
} }

View File

@ -10,7 +10,7 @@ class SetupFinalInformationDisplay : public virtual BobbyDisplayWithTitle
{ {
using Base = BobbyDisplayWithTitle; using Base = BobbyDisplayWithTitle;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void start() override; void start() override;
void stop() override; void stop() override;

View File

@ -14,9 +14,9 @@ namespace {
constexpr char const informationText[] = "Congratulations on your new\nbobbycar! This guide will help\nyou through initial setup,\ncalibrate everything and\nget you ready!"; constexpr char const informationText[] = "Congratulations on your new\nbobbycar! This guide will help\nyou through initial setup,\ncalibrate everything and\nget you ready!";
} // namespace } // namespace
void SetupInformationDisplay::initScreen() void SetupInformationDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
m_init_text_progressbar.start(); m_init_text_progressbar.start();

View File

@ -2,7 +2,6 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <espchrono.h> #include <espchrono.h>
#include <tftinstance.h>
#include <widgets/progressbar.h> #include <widgets/progressbar.h>
// local includes // local includes
@ -12,15 +11,15 @@ class SetupInformationDisplay : public virtual BobbyDisplayWithTitle
{ {
using Base = BobbyDisplayWithTitle; using Base = BobbyDisplayWithTitle;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void start() override; void start() override;
void update() override; void update() override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;
[[nodiscard]] std::string text() const override; [[nodiscard]] std::string text() const override;
private: private:
espchrono::millis_clock::time_point m_menu_opened_timestamp; espchrono::millis_clock::time_point m_menu_opened_timestamp;
espgui::ProgressBar m_init_text_progressbar{10, espgui::tft.height()/2, espgui::tft.width()-20, 30, 0, 100}; espgui::ProgressBar m_init_text_progressbar{10, tft.height()/2, tft.width()-20, 30, 0, 100};
}; };

View File

@ -10,9 +10,9 @@
#include "displays/statusdisplay.h" #include "displays/statusdisplay.h"
#include "drivingstatistics.h" #include "drivingstatistics.h"
void SpeedInfoDisplay::initScreen() void SpeedInfoDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
m_labelSpeed.start(); m_labelSpeed.start();

View File

@ -1,7 +1,6 @@
#pragma once #pragma once
// 3rdparty lib includes // 3rdparty lib includes
#include <tftinstance.h>
#include <widgets/label.h> #include <widgets/label.h>
#include <widgets/progressbar.h> #include <widgets/progressbar.h>
#include <widgets/reverseprogressbar.h> #include <widgets/reverseprogressbar.h>
@ -14,15 +13,15 @@ class SpeedInfoDisplay : public BobbyDisplay
using Base = BobbyDisplay; using Base = BobbyDisplay;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;
private: private:
espgui::Label m_labelSpeed{5, 5}; espgui::Label m_labelSpeed{5, 5};
espgui::ReverseProgressBar m_dischargingBar{10, 110, espgui::tft.width()/2 - 10, 25, 0, 40, TFT_GREEN}; espgui::ReverseProgressBar m_dischargingBar{10, 110, 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}; espgui::ProgressBar m_chargingBar{tft.width()/2, 110, tft.width()/2 - 10, 25, 0, 40, TFT_RED};
#define START_Y 150 #define START_Y 150
espgui::Label m_batteryPercentLabel{5, START_Y}; espgui::Label m_batteryPercentLabel{5, START_Y};

View File

@ -5,7 +5,6 @@
#include <esprandom.h> #include <esprandom.h>
#include <randomutils.h> #include <randomutils.h>
#include <screenmanager.h> #include <screenmanager.h>
#include <tftinstance.h>
// local includes // local includes
#include "screens.h" #include "screens.h"
@ -14,23 +13,23 @@ namespace {
typedef unsigned char byte; typedef unsigned char byte;
} // namespace } // namespace
void SpiroDisplay::initScreen() void SpiroDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
disableScreenFlip(true); disableScreenFlip(true);
espgui::tft.setRotation(3); tft.setRotation(3);
} }
void SpiroDisplay::redraw() void SpiroDisplay::redraw(espgui::TftInterface &tft)
{ {
Base::redraw(); Base::redraw(tft);
for (int j = 0; j < std::max(1, n); j++) for (int j = 0; j < std::max(1, n); j++)
{ {
if (i == 0) if (i == 0)
{ {
espgui::tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
n = cpputils::randomNumber<uint8_t>(2, 23, espcpputils::esp_random_device{}); n = cpputils::randomNumber<uint8_t>(2, 23, espcpputils::esp_random_device{});
r = cpputils::randomNumber<uint8_t>(20, 100, espcpputils::esp_random_device{}); r = cpputils::randomNumber<uint8_t>(20, 100, espcpputils::esp_random_device{});
colour = 0; //rainbow(); colour = 0; //rainbow();
@ -48,7 +47,7 @@ void SpiroDisplay::redraw()
sx = std::sin(((i % 360) - 90) * DEG2RAD); sx = std::sin(((i % 360) - 90) * DEG2RAD);
x1 = sx * r + x0; x1 = sx * r + x0;
yy1 = sy * r + yy0; yy1 = sy * r + yy0;
espgui::tft.drawPixel(x1, yy1, rainbow(cpputils::mapValue<uint16_t>(i%360,0,360,0,127))); //colour); tft.drawPixel(x1, yy1, rainbow(cpputils::mapValue<uint16_t>(i%360,0,360,0,127))); //colour);
} }
if (i == (360 * n)) if (i == (360 * n))
@ -70,7 +69,7 @@ void SpiroDisplay::redraw()
sx = std::sin(((new_i % 360) - 90) * DEG2RAD); sx = std::sin(((new_i % 360) - 90) * DEG2RAD);
x1 = sx * r + x0; x1 = sx * r + x0;
yy1 = sy * r + yy0; yy1 = sy * r + yy0;
espgui::tft.drawPixel(x1, yy1, rainbow(cpputils::mapValue<uint16_t>(new_i%360,0,360,0,127))); //colour); tft.drawPixel(x1, yy1, rainbow(cpputils::mapValue<uint16_t>(new_i%360,0,360,0,127))); //colour);
} }
i++; i++;

View File

@ -11,8 +11,8 @@ class SpiroDisplay : public BobbyDisplay
using Base = BobbyDisplay; using Base = BobbyDisplay;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void stop() override; void stop() override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -3,7 +3,6 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <randomutils.h> #include <randomutils.h>
#include <esprandom.h> #include <esprandom.h>
#include <tftinstance.h>
#include <screenmanager.h> #include <screenmanager.h>
// local includes // local includes
@ -19,14 +18,14 @@ StarfieldDisplay::StarfieldDisplay() :
{ {
} }
void StarfieldDisplay::initScreen() void StarfieldDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(espgui::TftInterface &tft);
disableScreenFlip(true); disableScreenFlip(true);
espgui::tft.fillScreen(TFT_BLACK); tft.fillScreen(TFT_BLACK);
espgui::tft.setRotation(1); tft.setRotation(1);
// fastSetup() must be used immediately before fastPixel() to prepare screen // fastSetup() must be used immediately before fastPixel() to prepare screen
// It must be called after any other graphics drawing function call if fastPixel() // It must be called after any other graphics drawing function call if fastPixel()
@ -54,7 +53,7 @@ void StarfieldDisplay::redraw()
int old_screen_y = ((int)sy[i] - 120) * 256 / sz[i] + 120; int old_screen_y = ((int)sy[i] - 120) * 256 / sz[i] + 120;
// This is a faster pixel drawing function for occassions where many single pixels must be drawn // This is a faster pixel drawing function for occassions where many single pixels must be drawn
espgui::tft.drawPixel(old_screen_x, old_screen_y,TFT_BLACK); tft.drawPixel(old_screen_x, old_screen_y,TFT_BLACK);
sz[i] -= 2; sz[i] -= 2;
if (sz[i] > 1) if (sz[i] > 1)
@ -66,7 +65,7 @@ void StarfieldDisplay::redraw()
{ {
uint8_t r, g, b; uint8_t r, g, b;
r = g = b = 255 - sz[i]; r = g = b = 255 - sz[i];
espgui::tft.drawPixel(screen_x, screen_y, color565(r,g,b)); tft.drawPixel(screen_x, screen_y, color565(r,g,b));
} }
else else
sz[i] = 0; // Out of screen, die. sz[i] = 0; // Out of screen, die.

View File

@ -13,8 +13,8 @@ class StarfieldDisplay : public BobbyDisplay
public: public:
StarfieldDisplay(); StarfieldDisplay();
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void stop() override; void stop() override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -6,7 +6,6 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <espwifistack.h> #include <espwifistack.h>
#include <fmt/core.h> #include <fmt/core.h>
#include <tftinstance.h>
// local includes // local includes
#include "displays/batteryinfodisplay.h" #include "displays/batteryinfodisplay.h"
@ -29,9 +28,9 @@ namespace {
constexpr const char * const TAG = "STATUS"; constexpr const char * const TAG = "STATUS";
} // namespace } // namespace
void StatusDisplay::initScreen() void StatusDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
tft.setTextFont(2); tft.setTextFont(2);
tft.setTextColor(TFT_WHITE); tft.setTextColor(TFT_WHITE);

View File

@ -21,8 +21,8 @@ class StatusDisplay : public BobbyDisplay
using Base = BobbyDisplay; using Base = BobbyDisplay;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -8,7 +8,6 @@
#include <esp_log.h> #include <esp_log.h>
// 3rdparty lib includes // 3rdparty lib includes
#include <tftinstance.h>
#include <screenmanager.h> #include <screenmanager.h>
#include <espasyncota.h> #include <espasyncota.h>
#include <esp_ota_ops.h> #include <esp_ota_ops.h>
@ -18,26 +17,26 @@
#include "ota.h" #include "ota.h"
#include "newsettings.h" #include "newsettings.h"
void UpdateDisplay::initScreen() void UpdateDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(espgui::TftInterface &tft);
espgui::tft.setTextFont(4); tft.setTextFont(4);
espgui::tft.setTextColor(TFT_YELLOW); tft.setTextColor(TFT_YELLOW);
espgui::tft.drawString("Update", 5, 5, 4); tft.drawString("Update", 5, 5, 4);
espgui::tft.fillRect(0, 34, espgui::tft.width(), 3, TFT_WHITE); tft.fillRect(0, 34, tft.width(), 3, TFT_WHITE);
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
espgui::tft.drawString("Status:", 20, m_statusLabel.y()); tft.drawString("Status:", 20, m_statusLabel.y());
m_statusLabel.start(); m_statusLabel.start();
espgui::tft.drawString("Progress:", 20, m_progressLabel.y()); tft.drawString("Progress:", 20, m_progressLabel.y());
m_progressLabel.start(); m_progressLabel.start();
espgui::tft.drawString("Total:", 20, m_totalLabel.y()); tft.drawString("Total:", 20, m_totalLabel.y());
m_totalLabel.start(); m_totalLabel.start();
m_messageLabel.start(); m_messageLabel.start();
@ -46,9 +45,9 @@ void UpdateDisplay::initScreen()
if (const esp_app_desc_t *app_desc = esp_ota_get_app_description()) if (const esp_app_desc_t *app_desc = esp_ota_get_app_description())
{ {
espgui::tft.setTextColor(TFT_ORANGE, TFT_BLACK); tft.setTextColor(TFT_ORANGE, TFT_BLACK);
espgui::tft.drawString(app_desc->version, 20, 250); tft.drawString(app_desc->version, 20, 250);
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
} }
m_newVersionLabel.start(); m_newVersionLabel.start();
@ -77,9 +76,9 @@ void UpdateDisplay::redraw()
if (const auto &appDesc = asyncOta->appDesc()) if (const auto &appDesc = asyncOta->appDesc())
{ {
espgui::tft.setTextColor(TFT_GREEN, TFT_BLACK); tft.setTextColor(TFT_GREEN, TFT_BLACK);
m_newVersionLabel.redraw(appDesc->version); m_newVersionLabel.redraw(appDesc->version);
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
} }
else else
m_newVersionLabel.clear(); m_newVersionLabel.clear();

View File

@ -12,8 +12,8 @@ class UpdateDisplay : public BobbyDisplay
using Base = BobbyDisplay; using Base = BobbyDisplay;
public: public:
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -3,24 +3,23 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <fmt/core.h> #include <fmt/core.h>
#include <screenmanager.h> #include <screenmanager.h>
#include <tftinstance.h>
// local includes // local includes
#include "bobbybuttons.h" #include "bobbybuttons.h"
XYDebugDisplay::XYDebugDisplay() : m_labelCoordinates{5, 5} {} XYDebugDisplay::XYDebugDisplay() : m_labelCoordinates{5, 5} {}
void XYDebugDisplay::initScreen() void XYDebugDisplay::initScreen(espgui::TftInterface &tft)
{ {
Base::initScreen(); Base::initScreen(tft);
m_labelCoordinates.start(); m_labelCoordinates.start(tft);
} }
void XYDebugDisplay::redraw() void XYDebugDisplay::redraw(espgui::TftInterface &tft)
{ {
using namespace espgui; using namespace espgui;
Base::redraw(); Base::redraw(tft);
m_labelCoordinates.redraw(fmt::format("X: {}, Y: {}", m_current_cursor.x, m_current_cursor.y)); 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) if (m_current_cursor.x != m_last_cursor.x || m_current_cursor.y != m_last_cursor.y)
@ -55,7 +54,7 @@ void XYDebugDisplay::buttonPressed(espgui::Button button)
} }
break; break;
case BobbyButton::Right2: case BobbyButton::Right2:
if (m_current_cursor.x < espgui::tft.width() - 1) if (m_current_cursor.x < tft.width() - 1)
{ {
++m_current_cursor.x; ++m_current_cursor.x;
} }
@ -67,7 +66,7 @@ void XYDebugDisplay::buttonPressed(espgui::Button button)
} }
break; break;
case BobbyButton::Down2: case BobbyButton::Down2:
if (m_current_cursor.y < espgui::tft.height() - 1) if (m_current_cursor.y < tft.height() - 1)
{ {
++m_current_cursor.y; ++m_current_cursor.y;
} }

View File

@ -12,8 +12,8 @@ class XYDebugDisplay : public BobbyDisplay
public: public:
XYDebugDisplay(); XYDebugDisplay();
void initScreen() override; void initScreen(espgui::TftInterface &tft) override;
void redraw() override; void redraw(espgui::TftInterface &tft) override;
void buttonPressed(espgui::Button button) override; void buttonPressed(espgui::Button button) override;

View File

@ -1,7 +1,6 @@
#include "screens.h" #include "screens.h"
// 3rdparty lib includes // 3rdparty lib includes
#include <tftinstance.h>
#include <screenmanager.h> #include <screenmanager.h>
// local includes // local includes
@ -25,9 +24,9 @@ void initScreen()
tft.setTextColor(TFT_BLACK, TFT_WHITE); tft.setTextColor(TFT_BLACK, TFT_WHITE);
tft.setTextFont(4); tft.setTextFont(4);
tft.setRotation(configs.boardcomputerHardware.flipScreen.value() ? 2 : 0); tft.setRotation(configs.boardcomputerHardware.flipScreen.value() ? 2 : 0);
espgui::tft.setSwapBytes(true); tft.setSwapBytes(true);
tft.pushImage(0, 40, bobbyicons::logo.WIDTH, bobbyicons::logo.HEIGHT, bobbyicons::logo.buffer); tft.pushImage(0, 40, bobbyicons::logo.WIDTH, bobbyicons::logo.HEIGHT, bobbyicons::logo.buffer);
espgui::tft.setSwapBytes(false); tft.setSwapBytes(false);
tft.drawString("Bobbycar-OS", 32, 200); tft.drawString("Bobbycar-OS", 32, 200);
tft.drawString("booting...", 32, 225); tft.drawString("booting...", 32, 225);
tft.setTextFont(2); tft.setTextFont(2);

View File

@ -3,9 +3,6 @@
// system includes // system includes
#include <utility> #include <utility>
// 3rdparty lib includes
#include <tftinstance.h>
// local includes // local includes
#include "globals.h" #include "globals.h"
#include "newsettings.h" #include "newsettings.h"

View File

@ -3,9 +3,6 @@
// 3rdparty lib includes // 3rdparty lib includes
#include <cpputils.h> #include <cpputils.h>
// local includes
#include "tftinstance.h"
using namespace espgui; using namespace espgui;
namespace bobbygui { namespace bobbygui {