ready so far
This commit is contained in:
42
hmi.cpp
42
hmi.cpp
@ -12,7 +12,6 @@ using namespace HmiNS;
|
||||
|
||||
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)
|
||||
{
|
||||
|
||||
@ -20,6 +19,7 @@ Hmi::Hmi() : m_tft(6, 9, 11, 13, -1, 12), // m_tft(LCD_CS, LCD_CD, LCD_WR, LCD_R
|
||||
memset(m_messageSlots[i].header, 0, BUFFERLEN_MESSAGESLOT);
|
||||
memset(m_messageSlots[i].body, 0, BUFFERLEN_MESSAGESLOT);
|
||||
m_messageSlots[i].timestamp = 0;
|
||||
m_messageSlots[i].updateRequired = false;
|
||||
}
|
||||
|
||||
}
|
||||
@ -28,55 +28,33 @@ void Hmi::begin() {
|
||||
m_tft.begin();
|
||||
m_tft.setRotation(1);
|
||||
m_tft.setTextSize(2);
|
||||
m_tft.fillScreen(BLACK);
|
||||
}
|
||||
|
||||
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::clear() {
|
||||
m_tft.fillScreen(BLACK);
|
||||
}
|
||||
|
||||
void Hmi::updateMessage(uint8_t slot, char* header, char* body) {
|
||||
uint8_t index = slot - 1; // slots start at 1, the index starts at 0
|
||||
if (index < NUM_OF_MESSAGESLOTS) {
|
||||
strncpy(m_messageSlots[index].header, header, BUFFERLEN_MESSAGESLOT);
|
||||
strncpy(m_messageSlots[index].body, body, BUFFERLEN_MESSAGESLOT);
|
||||
m_messageSlots[index].timestamp = millis();
|
||||
m_messageDrawUpdateRequired = true;
|
||||
m_messageSlots[index].updateRequired = true;
|
||||
}
|
||||
}
|
||||
|
||||
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++) {
|
||||
for (uint8_t i = 0; i < NUM_OF_MESSAGESLOTS; i++) {
|
||||
if (m_messageSlots[i].updateRequired) {
|
||||
m_messageSlots[i].updateRequired = false;
|
||||
m_tft.setCursor(0, 5+i*22);
|
||||
m_tft.fillRect(0, 5+i*22, 320, 22, BLACK);
|
||||
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 << " ";
|
||||
}
|
||||
|
Reference in New Issue
Block a user