message displaying works
This commit is contained in:
17
hmi.cpp
17
hmi.cpp
@ -25,14 +25,8 @@ Hmi::Hmi() : m_tft(6, 9, 11, 13, -1, 12), // m_tft(LCD_CS, LCD_CD, LCD_WR, LCD_R
|
||||
}
|
||||
|
||||
void Hmi::begin() {
|
||||
// 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::updateMessage() {
|
||||
@ -47,6 +41,15 @@ void Hmi::updateMessage() {
|
||||
strcpy(m_messageSlots[5].body, "123456789");
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
void Hmi::toggleAlarmState() {
|
||||
m_alarmMessageAvailable = ! m_alarmMessageAvailable;
|
||||
@ -79,7 +82,7 @@ void Hmi::drawMessages() {
|
||||
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++) {
|
||||
for (uint8_t spaces = 0; spaces < (BUFFERLEN_MESSAGESLOT - strlen(m_messageSlots[i].header)); spaces++) {
|
||||
m_tft << " ";
|
||||
}
|
||||
m_tft << " : " << m_messageSlots[i].body;
|
||||
|
Reference in New Issue
Block a user