Files
bobbycar-boardcomputer-firm…/main/displays/powersupplydisplay.cpp
T

48 lines
1023 B
C++
Raw Normal View History

2021-11-02 22:47:46 +01:00
#include "powersupplydisplay.h"
// 3rdparty lib includes
#include <tftinstance.h>
#include <screenmanager.h>
// local includes
#include "globals.h"
#if defined(FEATURE_CAN) && defined(FEATURE_POWERSUPPLY)
void PowerSupplyDisplay::initScreen()
{
2021-12-28 02:44:10 +01:00
Base::initScreen();
2021-11-02 22:47:46 +01:00
espgui::tft.fillScreen(TFT_BLACK);
espgui::tft.setTextColor(TFT_WHITE, TFT_BLACK);
espgui::tft.setTextFont(4);
espgui::tft.drawString("Voltage:", 0, m_voltageLabel.y());
m_voltageLabel.start();
espgui::tft.drawString("Current:", 0, m_currentLabel.y());
m_currentLabel.start();
}
void PowerSupplyDisplay::redraw()
{
2021-12-28 02:44:10 +01:00
Base::redraw();
2021-11-02 22:47:46 +01:00
m_voltageLabel.redraw(std::to_string(50.4) + 'V');
m_currentLabel.redraw(std::to_string(15.1) + 'A');
}
2021-12-28 02:44:10 +01:00
void PowerSupplyDisplay::buttonPressed(espgui::Button button)
2021-11-02 22:47:46 +01:00
{
2021-12-28 02:44:10 +01:00
Base::buttonPressed(button);
2021-11-02 22:47:46 +01:00
2021-12-28 02:44:10 +01:00
switch (button)
{
using espgui::Button;
case Button::Left:
case Button::Right:
2022-03-05 22:58:57 +01:00
espgui::popScreen();
2021-12-28 02:44:10 +01:00
break;
default:;
}
2021-11-02 22:47:46 +01:00
}
#endif