82 lines
1.8 KiB
C
Raw Permalink Normal View History

2016-03-02 17:30:46 +01:00
/*
* hmi.h
*
* Created on: 02.03.2016
* Author: dehottgw
*/
#ifndef HMI_H_
#define HMI_H_
#include <Adafruit_GFX.h>
2016-03-03 23:19:56 +01:00
// #include <Adafruit_TFTLCD.h>
#include "Adafruit_ILI9341.h"
2016-07-11 21:51:33 +02:00
#include <Adafruit_FT6206.h>
2016-03-03 23:19:56 +01:00
2016-03-02 17:30:46 +01:00
namespace HmiNS {
2016-07-11 21:51:33 +02:00
const static int8_t TFT_CS = 6;
const static int8_t TFT_DC = 9;
const static int8_t TFT_MOSI = 11;
const static int8_t TFT_SCLK = 13;
const static int8_t TFT_RST = -1;
const static int8_t TFT_MISO = 12;
const static int8_t TFT_BACKLIGHT = 5;
2016-03-02 17:30:46 +01:00
const static uint16_t BLACK = 0x0000;
const static uint16_t BLUE = 0x001F;
const static uint16_t RED = 0xF800;
const static uint16_t GREEN = 0x07E0;
const static uint16_t CYAN = 0x07FF;
const static uint16_t MAGENTA = 0xF81F;
const static uint16_t YELLOW = 0xFFE0;
const static uint16_t WHITE = 0xFFFF;
2016-03-04 14:30:30 +01:00
const static uint8_t BUFFERLEN_MESSAGESLOT = 9;
2016-07-10 18:38:53 +02:00
const static uint8_t NUM_OF_MESSAGESLOTS = 10;
2016-07-11 21:51:33 +02:00
const static uint32_t LIGHT_OFF = 79200;
const static uint32_t LIGHT_ON = 25200;
2016-03-02 17:30:46 +01:00
}
struct MessageSlot {
2016-03-04 14:30:30 +01:00
char header[HmiNS::BUFFERLEN_MESSAGESLOT+1];
char body[HmiNS::BUFFERLEN_MESSAGESLOT+1];
2016-07-10 18:38:53 +02:00
bool updateRequired;
2016-03-02 17:30:46 +01:00
uint32_t timestamp;
};
class Hmi {
public:
Hmi();
void begin();
void exec();
2016-03-06 15:45:33 +01:00
Print *tft() { return &m_tft; };
2016-03-04 14:30:30 +01:00
void updateMessage(uint8_t slot, char* header, char* body);
2016-03-03 23:19:56 +01:00
void toggleAlarmState(); // only for debug
2016-07-10 18:38:53 +02:00
void clear();
2016-07-11 21:51:33 +02:00
void setSeconds(uint32_t seconds);
2016-03-02 17:30:46 +01:00
private:
2016-03-03 23:19:56 +01:00
void drawMessages();
Adafruit_ILI9341 m_tft;
2016-07-11 21:51:33 +02:00
Adafruit_FT6206 m_ctp;
int8_t m_backLightPin;
bool m_backLightEnable;
2016-03-02 17:30:46 +01:00
uint16_t m_displayIdentifier;
2016-03-03 23:19:56 +01:00
bool m_alarmMessageAvailable;
2016-07-11 21:51:33 +02:00
uint32_t m_seconds;
uint32_t m_lightOn;
uint32_t m_lightOff;
2016-03-02 17:30:46 +01:00
MessageSlot m_messageSlots[HmiNS::NUM_OF_MESSAGESLOTS];
};
#endif /* HMI_H_ */