light off mechanics
This commit is contained in:
45
hmi.cpp
45
hmi.cpp
@ -10,9 +10,15 @@
|
||||
|
||||
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),
|
||||
Hmi::Hmi() : m_tft(TFT_CS, TFT_DC, TFT_MOSI, TFT_SCLK, TFT_RST, TFT_MISO), // m_tft(LCD_CS, LCD_CD, LCD_WR, LCD_RD, LCD_RESET),
|
||||
m_ctp(),
|
||||
m_backLightPin(TFT_BACKLIGHT),
|
||||
m_backLightEnable(true),
|
||||
m_displayIdentifier(0),
|
||||
m_alarmMessageAvailable(false)
|
||||
m_alarmMessageAvailable(false),
|
||||
m_seconds(0),
|
||||
m_lightOn(LIGHT_ON),
|
||||
m_lightOff(LIGHT_OFF)
|
||||
{
|
||||
|
||||
for (uint8_t i = 0; i < NUM_OF_MESSAGESLOTS; i++) {
|
||||
@ -25,15 +31,25 @@ Hmi::Hmi() : m_tft(6, 9, 11, 13, -1, 12), // m_tft(LCD_CS, LCD_CD, LCD_WR, LCD_R
|
||||
}
|
||||
|
||||
void Hmi::begin() {
|
||||
pinMode(5, OUTPUT);
|
||||
digitalWrite(5, HIGH);
|
||||
|
||||
m_tft.begin();
|
||||
m_tft.setRotation(1);
|
||||
m_tft.setTextSize(2);
|
||||
m_tft.fillScreen(BLACK);
|
||||
|
||||
if (! m_ctp.begin(40)) { // pass in 'sensitivity' coefficient
|
||||
Serial.println("Couldn't start FT6206 touchscreen controller");
|
||||
while (1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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) {
|
||||
@ -73,6 +89,31 @@ void Hmi::drawMessages() {
|
||||
}
|
||||
}
|
||||
|
||||
void Hmi::setSeconds(uint32_t seconds) {
|
||||
m_seconds = seconds;
|
||||
}
|
||||
|
||||
void Hmi::exec() {
|
||||
drawMessages();
|
||||
|
||||
static uint32_t oldSeconds = 0;
|
||||
if (m_seconds != oldSeconds) {
|
||||
oldSeconds = m_seconds;
|
||||
Serial << "LIGHT_OFF: " << m_lightOff << endl;
|
||||
Serial << "LIGHT_ON: " << m_lightOn << endl;
|
||||
Serial << "enable: " << m_backLightEnable << endl;
|
||||
Serial << "Seconds: " << m_seconds << endl;
|
||||
}
|
||||
|
||||
if (((m_seconds > m_lightOff) || (m_seconds < m_lightOn)) && !m_ctp.touched() && m_backLightEnable) {
|
||||
m_backLightEnable = false;
|
||||
digitalWrite(m_backLightPin, LOW);
|
||||
Serial << "lights off" << endl;
|
||||
}
|
||||
|
||||
if ((((m_seconds < m_lightOff) && (m_seconds > m_lightOn)) || m_ctp.touched()) && !m_backLightEnable) {
|
||||
m_backLightEnable = true;
|
||||
digitalWrite(m_backLightPin, HIGH);
|
||||
Serial << "lights on" << endl;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user