Merge pull request #62 from bobbycar-graz/48-fullRedraw-fix

Fixed fullRedraw for StatusDisplay and MenuDisplay
This commit is contained in:
2020-06-07 01:22:44 +02:00
committed by GitHub
2 changed files with 16 additions and 18 deletions

View File

@ -48,8 +48,6 @@ private:
void redraw(const Controller &controller); void redraw(const Controller &controller);
private: private:
void drawWarning();
class MotorStatus class MotorStatus
{ {
public: public:
@ -72,7 +70,8 @@ private:
const int m_y; const int m_y;
bool m_lastFeedbackValid{}; bool m_initialRedraw;
bool m_lastFeedbackValid;
Label m_labelLeftPwm; Label m_labelLeftPwm;
Label m_labelRightPwm; Label m_labelRightPwm;
@ -184,7 +183,7 @@ void StatusDisplay::BoardStatus::start()
tft.drawString("pwm:", 0, m_y); tft.drawString("pwm:", 0, m_y);
m_labelLeftPwm.start(); m_labelLeftPwm.start();
m_labelRightPwm.start(); m_labelRightPwm.start();
drawWarning(); m_initialRedraw = true;
} }
void StatusDisplay::BoardStatus::redraw(const Controller &controller) void StatusDisplay::BoardStatus::redraw(const Controller &controller)
@ -194,7 +193,7 @@ void StatusDisplay::BoardStatus::redraw(const Controller &controller)
m_labelLeftPwm.redraw(String{controller.command.left.pwm}); m_labelLeftPwm.redraw(String{controller.command.left.pwm});
m_labelRightPwm.redraw(String{controller.command.right.pwm}); m_labelRightPwm.redraw(String{controller.command.right.pwm});
if (controller.feedbackValid != m_lastFeedbackValid) if (controller.feedbackValid != m_lastFeedbackValid || m_initialRedraw)
{ {
tft.fillRect(0, m_y+25, tft.width(), 75, TFT_BLACK); tft.fillRect(0, m_y+25, tft.width(), 75, TFT_BLACK);
@ -214,9 +213,18 @@ void StatusDisplay::BoardStatus::redraw(const Controller &controller)
tft.setTextColor(TFT_WHITE, TFT_BLACK); tft.setTextColor(TFT_WHITE, TFT_BLACK);
} }
else else
drawWarning(); {
tft.setTextColor(TFT_RED);
tft.drawString("No data!", 60, m_y+50, 4);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setSwapBytes(!settings.boardcomputerHardware.swapScreenBytes);
tft.pushImage(10, m_y+40, icons::alert.WIDTH, icons::alert.HEIGHT, icons::alert.buffer);
tft.setSwapBytes(settings.boardcomputerHardware.swapScreenBytes);
}
m_lastFeedbackValid = controller.feedbackValid; m_lastFeedbackValid = controller.feedbackValid;
m_initialRedraw = false;
} }
if (controller.feedbackValid) if (controller.feedbackValid)
@ -228,17 +236,6 @@ void StatusDisplay::BoardStatus::redraw(const Controller &controller)
} }
} }
void StatusDisplay::BoardStatus::drawWarning()
{
tft.setTextColor(TFT_RED);
tft.drawString("No data!", 60, m_y+50, 4);
tft.setTextColor(TFT_WHITE, TFT_BLACK);
tft.setSwapBytes(!settings.boardcomputerHardware.swapScreenBytes);
tft.pushImage(10, m_y+40, icons::alert.WIDTH, icons::alert.HEIGHT, icons::alert.buffer);
tft.setSwapBytes(settings.boardcomputerHardware.swapScreenBytes);
}
void StatusDisplay::BoardStatus::MotorStatus::start() void StatusDisplay::BoardStatus::MotorStatus::start()
{ {
m_labelError.start(); m_labelError.start();

View File

@ -73,7 +73,6 @@ void MenuDisplay::start()
{ {
m_selectedIndex = 0; m_selectedIndex = 0;
m_scrollOffset = 0; m_scrollOffset = 0;
m_highlightedIndex = -1;
m_rotateOffset = 0; m_rotateOffset = 0;
m_pressed = false; m_pressed = false;
@ -94,6 +93,8 @@ void MenuDisplay::initScreen()
}); });
m_icons.fill(nullptr); m_icons.fill(nullptr);
m_highlightedIndex = -1;
} }
void MenuDisplay::update() void MenuDisplay::update()