Again so many tft fixes
This commit is contained in:
@ -3,6 +3,7 @@ constexpr const char * const TAG = "BatteryGraphDisplay";
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <screenmanager.h>
|
||||
#include <tftcolors.h>
|
||||
|
||||
// local includes
|
||||
#include "battery.h"
|
||||
@ -23,7 +24,7 @@ void BatteryGraphDisplay::initScreen(espgui::TftInterface &tft)
|
||||
drawBatteryCurve();
|
||||
}
|
||||
|
||||
std::string BatteryGraphDisplay::text() const
|
||||
std::string BatteryGraphDisplay::title() const
|
||||
{
|
||||
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
|
||||
{
|
||||
@ -32,10 +33,10 @@ std::string BatteryGraphDisplay::text() const
|
||||
return TEXT_BATTERY_GRAPH;
|
||||
}
|
||||
|
||||
void BatteryGraphDisplay::redraw()
|
||||
void BatteryGraphDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
using namespace espgui;
|
||||
Base::redraw();
|
||||
Base::redraw(TFT);
|
||||
|
||||
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
|
||||
{
|
||||
@ -49,8 +50,8 @@ void BatteryGraphDisplay::redraw()
|
||||
const uint16_t lastXOffset = onePercent * (100 - getBatteryPercentage(m_lastBatVoltage, cellType));
|
||||
|
||||
// clear the old one and draw the new one
|
||||
tft.fillRect(lastXOffset + 2, TOP_OFFSET, onePercent, tft.height() - TOP_OFFSET, TFT_BLACK);
|
||||
tft.fillRect(xOffset + 2, TOP_OFFSET, onePercent, tft.height() - TOP_OFFSET, TFT_WHITE);
|
||||
tft.fillRect(lastXOffset + 2, TOP_OFFSET, onePercent, tft.height() - TOP_OFFSET, espgui::TFT_BLACK);
|
||||
tft.fillRect(xOffset + 2, TOP_OFFSET, onePercent, tft.height() - TOP_OFFSET, espgui::TFT_WHITE);
|
||||
m_lastBatVoltage = *avgVoltage;
|
||||
drawBatteryCurve();
|
||||
}
|
||||
@ -88,7 +89,7 @@ void BatteryGraphDisplay::drawBatteryCurve()
|
||||
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 y2 = float_map(point->maxVoltage / 100.f, min_voltage, max_voltage, max_height, TOP_OFFSET);
|
||||
tft.drawLine(x1, y1, x2, y2, TFT_WHITE);
|
||||
tft.drawLine(x1, y1, x2, y2, espgui::TFT_WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,7 +7,7 @@ class BatteryGraphDisplay : public BobbyDisplayWithTitle {
|
||||
using Base = BobbyDisplayWithTitle;
|
||||
|
||||
public:
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
// 3rdparty lib includes
|
||||
#include <screenmanager.h>
|
||||
#include <tftcolors.h>
|
||||
|
||||
// local includes
|
||||
#include "battery.h"
|
||||
@ -18,15 +19,15 @@ void BatteryInfoDisplay::initScreen(espgui::TftInterface &tft)
|
||||
using namespace espgui;
|
||||
Base::initScreen(tft);
|
||||
|
||||
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(m_offset, m_offset, tft.width() - (m_offset * 2), tft.height() - (m_offset * 2), 10, espgui::TFT_WHITE);
|
||||
tft.drawRoundRect((tft.width() / 2) - (m_offset / 2), m_offset / 2, m_offset, m_offset / 2, 3, espgui::TFT_WHITE);
|
||||
m_lastBarCount = 0;
|
||||
}
|
||||
|
||||
void BatteryInfoDisplay::redraw()
|
||||
void BatteryInfoDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
using namespace espgui;
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
// calculate height of space available for all bars
|
||||
const auto min_x = m_offset + 3; // leave 2 pixels + 1 pixel for border
|
||||
@ -50,7 +51,7 @@ void BatteryInfoDisplay::redraw()
|
||||
for (auto i = 0; i < 10; ++i)
|
||||
{
|
||||
const auto y = bottomY - (i * segment_height) - segment_height;
|
||||
tft.fillRoundRect(min_x, y, width, segment_height - 2, 10, segment_count > i ? TFT_GREEN : TFT_DARKGREY);
|
||||
tft.fillRoundRect(min_x, y, width, segment_height - 2, 10, segment_count > i ? espgui::TFT_GREEN : espgui::TFT_DARKGREY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -42,9 +42,9 @@ void BmsDisplay::initScreen(espgui::TftInterface &tft)
|
||||
m_cycleLabel.start();
|
||||
}
|
||||
|
||||
void BmsDisplay::redraw()
|
||||
void BmsDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
if (bluetoothSerial.hasClient())
|
||||
tft.setTextColor(TFT_GREEN, TFT_BLACK);
|
||||
|
@ -134,7 +134,7 @@ CalibrateVoltageDisplay::CalibrateVoltageDisplay()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_VOLTAGECALIBRATION_RESET>, ResetCalibrationAction>>();
|
||||
}
|
||||
|
||||
std::string CalibrateVoltageDisplay::text() const
|
||||
std::string CalibrateVoltageDisplay::title() const
|
||||
{
|
||||
return TEXT_BATTERY_CALIBRATE;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ class CalibrateVoltageDisplay : public BobbyMenuDisplay
|
||||
public:
|
||||
CalibrateVoltageDisplay();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void back() override;
|
||||
};
|
||||
|
@ -32,13 +32,11 @@ void ConfiscationDisplay::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::initScreen(tft);
|
||||
|
||||
tft.setSwapBytes(true);
|
||||
tft.pushImage(10, 70, bobbyicons::shortcircuit.WIDTH, bobbyicons::shortcircuit.HEIGHT, bobbyicons::shortcircuit.buffer);
|
||||
tft.setSwapBytes(false);
|
||||
|
||||
m_progressBar.start();
|
||||
m_progressBar.start(tft);
|
||||
|
||||
m_label.start();
|
||||
m_label.start(tft);
|
||||
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
tft.setTextFont(2);
|
||||
@ -51,9 +49,9 @@ void ConfiscationDisplay::initScreen(espgui::TftInterface &tft)
|
||||
tft.drawString(fmt::format("der Batterie eingeleitet (ca {:.2f}MJ)", calculateMegaJoules()), 10, y+=lineheight);
|
||||
}
|
||||
|
||||
void ConfiscationDisplay::redraw()
|
||||
void ConfiscationDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
m_progressBar.redraw(m_progress);
|
||||
|
||||
@ -109,7 +107,7 @@ void ConfiscationDisplay::buttonPressed(espgui::Button button)
|
||||
}
|
||||
}
|
||||
|
||||
std::string ConfiscationDisplay::text() const
|
||||
std::string ConfiscationDisplay::title() const
|
||||
{
|
||||
return "Explosions-Modus";
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
|
||||
void buttonPressed(espgui::Button button) override;
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
private:
|
||||
espgui::ProgressBar m_progressBar{10, 210, 200, 10, 0, 500};
|
||||
|
@ -4,6 +4,8 @@
|
||||
#include <randomutils.h>
|
||||
#include <esprandom.h>
|
||||
#include <screenmanager.h>
|
||||
#include <tftinterface.h>
|
||||
#include <tftcolors.h>
|
||||
|
||||
// local includes
|
||||
#include "screens.h"
|
||||
@ -23,16 +25,16 @@ void GameOfLifeDisplay::initScreen(espgui::TftInterface &tft)
|
||||
disableScreenFlip(true);
|
||||
|
||||
tft.setRotation(3);
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.fillScreen(espgui::TFT_BLACK);
|
||||
}
|
||||
|
||||
void GameOfLifeDisplay::redraw()
|
||||
void GameOfLifeDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
if (gen == 0)
|
||||
{
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
tft.fillScreen(espgui::TFT_BLACK);
|
||||
initGrid();
|
||||
}
|
||||
|
||||
@ -71,7 +73,7 @@ void GameOfLifeDisplay::buttonPressed(espgui::Button button)
|
||||
|
||||
void GameOfLifeDisplay::drawGrid()
|
||||
{
|
||||
uint16_t color = TFT_WHITE;
|
||||
uint16_t color = espgui::TFT_WHITE;
|
||||
for (int16_t x = 1; x < GRIDX - 1; x++) {
|
||||
for (int16_t y = 1; y < GRIDY - 1; y++) {
|
||||
if (((*m_grid)[index(x,y)]) != ((*m_newgrid)[index(x,y)])) {
|
||||
|
@ -62,9 +62,9 @@ void GametrakCalibrateDisplay::initScreen(espgui::TftInterface &tft)
|
||||
progressBar.start();
|
||||
}
|
||||
|
||||
void GametrakCalibrateDisplay::redraw()
|
||||
void GametrakCalibrateDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
m_labels[0].redraw(fmt::format("{:.02f}", gametrakX));
|
||||
m_labels[1].redraw(std::to_string(raw_gametrakX));
|
||||
|
@ -48,9 +48,9 @@ void JoystickDebugDisplay::update()
|
||||
m_y = map_analog_stick(m_bremsMitte, m_bremsMin, m_bremsMax, configs.deadband.value(), *raw_brems);
|
||||
}
|
||||
|
||||
void JoystickDebugDisplay::redraw()
|
||||
void JoystickDebugDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
if (m_x && m_y)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ const std::array<uint16_t, 8> tft_colors = {
|
||||
};
|
||||
} // namespace
|
||||
|
||||
std::string LedstripColorsDisplay::text() const
|
||||
std::string LedstripColorsDisplay::title() const
|
||||
{
|
||||
return TEXT_LEDSTRIPCOLORMENU;
|
||||
}
|
||||
@ -57,14 +57,12 @@ void LedstripColorsDisplay::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::initScreen(tft);
|
||||
|
||||
tft.setSwapBytes(true);
|
||||
tft.pushImage(70, 60, bobbyicons::bobbycar.WIDTH, bobbyicons::bobbycar.HEIGHT, bobbyicons::bobbycar.buffer);
|
||||
tft.setSwapBytes(false);
|
||||
}
|
||||
|
||||
void LedstripColorsDisplay::redraw()
|
||||
void LedstripColorsDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
auto y_pos = ((tft.width() - 40) / 8 + 4) + 240;
|
||||
if (last_state != state_select_color)
|
||||
|
@ -15,7 +15,7 @@ class LedstripColorsDisplay : public BobbyDisplayWithTitle
|
||||
using Base = BobbyDisplayWithTitle;
|
||||
|
||||
public:
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
|
||||
|
@ -76,7 +76,7 @@ void Lockscreen::initScreen(espgui::TftInterface &tft)
|
||||
}
|
||||
|
||||
for (auto &label : m_labels)
|
||||
label.start();
|
||||
label.start(tft);
|
||||
|
||||
tft.setTextFont(7);
|
||||
|
||||
|
@ -9,17 +9,17 @@
|
||||
using namespace espgui;
|
||||
|
||||
namespace bobbygui {
|
||||
void MenuDisplayWithTime::start()
|
||||
void MenuDisplayWithTime::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::start();
|
||||
m_label_currentTime.start();
|
||||
Base::initScreen(tft);
|
||||
m_label_currentTime.start(tft);
|
||||
}
|
||||
|
||||
void MenuDisplayWithTime::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw(tft);
|
||||
tft.setTextFont(use_big_font() ? 4 : 2);
|
||||
m_label_currentTime.redraw(fmt::format("&7Time: {}", local_clock_string()));
|
||||
m_label_currentTime.redraw(tft, fontRenderer, fmt::format("&7Time: {}", local_clock_string()));
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -10,7 +10,7 @@ class MenuDisplayWithTime :
|
||||
using Base = BobbyMenuDisplay;
|
||||
|
||||
public:
|
||||
void start() override;
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void redraw(espgui::TftInterface &tft) override;
|
||||
espgui::Label m_label_currentTime{145, 6};
|
||||
|
||||
|
@ -91,7 +91,7 @@ BatteryMenu::BatteryMenu()
|
||||
constructMenuItem<makeComponent<MenuItem, StaticText<TEXT_BACK>, PopScreenAction, StaticMenuItemIcon<&espgui::icons::back>>>();
|
||||
}
|
||||
|
||||
std::string BatteryMenu::text() const
|
||||
std::string BatteryMenu::title() const
|
||||
{
|
||||
return TEXT_BATTERY;
|
||||
}
|
||||
@ -109,9 +109,9 @@ void BatteryMenu::start()
|
||||
m_doubleProgressBarBatPercentage.start();
|
||||
}
|
||||
|
||||
void BatteryMenu::redraw()
|
||||
void BatteryMenu::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
if (const auto avgVoltage = controllers.getAvgVoltage(); avgVoltage)
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ class BatteryMenu : public BobbyMenuDisplay
|
||||
public:
|
||||
BatteryMenu();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void initScreen(espgui::TftInterface &tft) override;
|
||||
void start() override;
|
||||
|
@ -113,7 +113,7 @@ void FeatureFlagsMenu::start()
|
||||
isDirty = false;
|
||||
}
|
||||
|
||||
std::string FeatureFlagsMenu::text() const
|
||||
std::string FeatureFlagsMenu::title() const
|
||||
{
|
||||
return TEXT_FEATUREFLAGS;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ public:
|
||||
FeatureFlagsMenu();
|
||||
void start() override;
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void back() override;
|
||||
};
|
||||
|
@ -124,7 +124,7 @@ MainMenu::MainMenu()
|
||||
//#endif
|
||||
}
|
||||
|
||||
std::string MainMenu::text() const
|
||||
std::string MainMenu::title() const
|
||||
{
|
||||
return TEXT_MAINMENU;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class MainMenu : public bobbygui::MenuDisplayWithTime
|
||||
public:
|
||||
MainMenu();
|
||||
|
||||
std::string text() const override;
|
||||
std::string title() const override;
|
||||
|
||||
void back() override;
|
||||
};
|
||||
|
@ -29,9 +29,9 @@ void MetersDisplay::initScreen(espgui::TftInterface &tft)
|
||||
meter.start();
|
||||
}
|
||||
|
||||
void MetersDisplay::redraw()
|
||||
void MetersDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
m_vuMeter.redraw(avgSpeedKmh);
|
||||
|
||||
|
@ -29,9 +29,9 @@ void PingPongDisplay::initScreen(espgui::TftInterface &tft)
|
||||
midline();
|
||||
}
|
||||
|
||||
void PingPongDisplay::redraw()
|
||||
void PingPongDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
lpaddle();
|
||||
rpaddle();
|
||||
|
@ -66,9 +66,9 @@ void PotisCalibrateDisplay::update()
|
||||
m_brems = std::nullopt;
|
||||
}
|
||||
|
||||
void PotisCalibrateDisplay::redraw()
|
||||
void PotisCalibrateDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
m_labels[0].redraw(m_gas ? fmt::format("{:.02f}", *m_gas) : "?");
|
||||
m_labels[1].redraw(raw_gas ? std::to_string(*raw_gas) : "?");
|
||||
|
@ -22,9 +22,9 @@ void PowerSupplyDisplay::initScreen(espgui::TftInterface &tft)
|
||||
m_currentLabel.start();
|
||||
}
|
||||
|
||||
void PowerSupplyDisplay::redraw()
|
||||
void PowerSupplyDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
m_voltageLabel.redraw(std::to_string(50.4) + 'V');
|
||||
m_currentLabel.redraw(std::to_string(15.1) + 'A');
|
||||
|
@ -42,11 +42,11 @@ void SetupInformationDisplay::update()
|
||||
Base::update();
|
||||
}
|
||||
|
||||
void SetupInformationDisplay::redraw()
|
||||
void SetupInformationDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
m_init_text_progressbar.redraw(espchrono::ago(m_menu_opened_timestamp) / 50ms);
|
||||
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
}
|
||||
|
||||
void SetupInformationDisplay::buttonPressed(espgui::Button button)
|
||||
|
@ -25,11 +25,11 @@ void SpeedInfoDisplay::initScreen(espgui::TftInterface &tft)
|
||||
m_currentPowerLabel.start();
|
||||
}
|
||||
|
||||
void SpeedInfoDisplay::redraw()
|
||||
void SpeedInfoDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
using namespace espgui;
|
||||
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
tft.setTextFont(4);
|
||||
|
@ -33,9 +33,9 @@ void StarfieldDisplay::initScreen(espgui::TftInterface &tft)
|
||||
//tft.fastSetup(); // Prepare plot window range for fast pixel plotting
|
||||
}
|
||||
|
||||
void StarfieldDisplay::redraw()
|
||||
void StarfieldDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
uint8_t spawnDepthVariation = 255;
|
||||
|
||||
|
@ -73,9 +73,9 @@ void StatusDisplay::initScreen(espgui::TftInterface &tft)
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
}
|
||||
|
||||
void StatusDisplay::redraw()
|
||||
void StatusDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
{
|
||||
const auto now = espchrono::millis_clock::now();
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
void UpdateDisplay::initScreen(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::initScreen(espgui::TftInterface &tft);
|
||||
Base::initScreen(tft);
|
||||
|
||||
tft.setTextFont(4);
|
||||
tft.setTextColor(TFT_YELLOW);
|
||||
@ -31,17 +31,17 @@ void UpdateDisplay::initScreen(espgui::TftInterface &tft)
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
|
||||
tft.drawString("Status:", 20, m_statusLabel.y());
|
||||
m_statusLabel.start();
|
||||
m_statusLabel.start(tft);
|
||||
|
||||
tft.drawString("Progress:", 20, m_progressLabel.y());
|
||||
m_progressLabel.start();
|
||||
m_progressLabel.start(tft);
|
||||
|
||||
tft.drawString("Total:", 20, m_totalLabel.y());
|
||||
m_totalLabel.start();
|
||||
m_totalLabel.start(tft);
|
||||
|
||||
m_messageLabel.start();
|
||||
m_messageLabel.start(tft);
|
||||
|
||||
m_progressBar.start();
|
||||
m_progressBar.start(tft);
|
||||
|
||||
if (const esp_app_desc_t *app_desc = esp_ota_get_app_description())
|
||||
{
|
||||
@ -50,12 +50,12 @@ void UpdateDisplay::initScreen(espgui::TftInterface &tft)
|
||||
tft.setTextColor(TFT_WHITE, TFT_BLACK);
|
||||
}
|
||||
|
||||
m_newVersionLabel.start();
|
||||
m_newVersionLabel.start(tft);
|
||||
}
|
||||
|
||||
void UpdateDisplay::redraw()
|
||||
void UpdateDisplay::redraw(espgui::TftInterface &tft)
|
||||
{
|
||||
Base::redraw();
|
||||
Base::redraw(tft);
|
||||
|
||||
if (asyncOta)
|
||||
{
|
||||
|
Reference in New Issue
Block a user