display changed and mqtt stuff added
This commit is contained in:
77
hmi.cpp
77
hmi.cpp
@ -6,11 +6,15 @@
|
||||
*/
|
||||
|
||||
#include "hmi.h"
|
||||
#include <Streaming.h>
|
||||
|
||||
using namespace HmiNS;
|
||||
|
||||
Hmi::Hmi() : m_tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET),
|
||||
m_displayIdentifier(0) {
|
||||
Hmi::Hmi() : m_tft(6, 9, 11, 13, -1, 12), // m_tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET),
|
||||
m_displayIdentifier(0),
|
||||
m_messageDrawUpdateRequired(true),
|
||||
m_alarmMessageAvailable(false)
|
||||
{
|
||||
|
||||
for (uint8_t i = 0; i < NUM_OF_MESSAGESLOTS; i++) {
|
||||
memset(m_messageSlots[i].header, 0, BUFFERLEN_MESSAGESLOT);
|
||||
@ -21,13 +25,72 @@ Hmi::Hmi() : m_tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET),
|
||||
}
|
||||
|
||||
void Hmi::begin() {
|
||||
m_tft.reset();
|
||||
m_displayIdentifier = m_tft.readID();
|
||||
m_tft.begin(m_displayIdentifier);
|
||||
// m_tft.reset();
|
||||
// m_displayIdentifier = m_tft.readID();
|
||||
// Serial << "display id: " << m_displayIdentifier << endl;
|
||||
// m_tft.begin(m_displayIdentifier);
|
||||
m_tft.begin();
|
||||
Serial << "tft begin done" << endl;
|
||||
m_tft.setRotation(1);
|
||||
|
||||
}
|
||||
|
||||
void Hmi::exec() {
|
||||
|
||||
void Hmi::updateMessage() {
|
||||
m_messageDrawUpdateRequired = true;
|
||||
strcpy(m_messageSlots[0].header, "abc");
|
||||
strcpy(m_messageSlots[0].body, "123");
|
||||
strcpy(m_messageSlots[1].header, "abcdefghi");
|
||||
strcpy(m_messageSlots[1].body, "123456789");
|
||||
strcpy(m_messageSlots[2].header, "abcdefghi");
|
||||
strcpy(m_messageSlots[2].body, "123456789");
|
||||
strcpy(m_messageSlots[5].header, "abcdefghi");
|
||||
strcpy(m_messageSlots[5].body, "123456789");
|
||||
}
|
||||
|
||||
|
||||
void Hmi::toggleAlarmState() {
|
||||
m_alarmMessageAvailable = ! m_alarmMessageAvailable;
|
||||
m_messageDrawUpdateRequired = true;
|
||||
}
|
||||
|
||||
void Hmi::drawMessages() {
|
||||
if (m_messageDrawUpdateRequired) {
|
||||
m_messageDrawUpdateRequired = false;
|
||||
m_tft.setTextSize(2);
|
||||
m_tft.setCursor(0,0);
|
||||
if (m_alarmMessageAvailable) {
|
||||
m_tft.fillScreen(RED);
|
||||
// m_tft.invertDisplay(false);
|
||||
} else {
|
||||
m_tft.fillScreen(GREEN);
|
||||
// m_tft.invertDisplay(true);
|
||||
}
|
||||
m_tft << endl;
|
||||
for (uint8_t i = 0; i < NUM_OF_MESSAGESLOTS; i++) {
|
||||
uint8_t l = i + 1;
|
||||
if (i % 2 == 0) {
|
||||
m_tft.setTextColor(WHITE);
|
||||
} else {
|
||||
m_tft.setTextColor(YELLOW);
|
||||
}
|
||||
if (l < 10) { // prefix numbers with only one digit with a leading 0
|
||||
m_tft << " ";
|
||||
}
|
||||
m_tft << l << ": ";
|
||||
if (strlen(m_messageSlots[i].header) > 0) {
|
||||
m_tft << m_messageSlots[i].header;
|
||||
for (uint8_t spaces = 0; spaces < (BUFFERLEN_MESSAGESLOT - 1 - strlen(m_messageSlots[i].header)); spaces++) {
|
||||
m_tft << " ";
|
||||
}
|
||||
m_tft << " : " << m_messageSlots[i].body;
|
||||
m_tft << endl;
|
||||
} else {
|
||||
m_tft << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Hmi::exec() {
|
||||
drawMessages();
|
||||
}
|
||||
|
Reference in New Issue
Block a user