70 lines
1.4 KiB
C++
70 lines
1.4 KiB
C++
/*
|
|
* LCD.h
|
|
*
|
|
* Created on: 15.06.2014
|
|
* Author: matzman
|
|
*/
|
|
|
|
#ifndef LCD_H_
|
|
#define LCD_H_
|
|
|
|
#include "TfCPPsimple.h"
|
|
#include "lcdpages/MainPage.h"
|
|
#include <mutex>
|
|
|
|
|
|
using namespace tfcppsimple;
|
|
|
|
namespace growcontrol {
|
|
|
|
class GrowControl;
|
|
struct GCSensorsInfo;
|
|
|
|
class LCD : public TfLCD20x4Listener, public TfDeviceStateListener {
|
|
private:
|
|
static log4cpp::Category& logger;
|
|
|
|
TfLCD20x4Bricklet* lcdBricklet = nullptr;
|
|
|
|
std::mutex lcdMutex;
|
|
char lcdBuffer[4][21];
|
|
bool lineFlags[4] = {false, false, false, false};
|
|
int lcdLightCountdown = 0;
|
|
int lcdLightMaxCountdown = 30;
|
|
bool lcdLightCountdownFlag = false;
|
|
LCDPage* activePage = nullptr;
|
|
|
|
GrowControl& controller;
|
|
MainPage pageRoot;
|
|
|
|
public:
|
|
LCD(GrowControl& controller);
|
|
virtual ~LCD();
|
|
|
|
void setTfObject(TfLCD20x4Bricklet& lcd);
|
|
|
|
void buttonStateCallback(TfLCD20x4Bricklet& lcd, uint8_t button, bool state);
|
|
void stateChangeCallback(TfDevice& device, TfDeviceState oldstate, TfDeviceState newstate);
|
|
|
|
void writeLine(int line, std::string txt);
|
|
int writeLCDBuffer();
|
|
void clearDisplay();
|
|
|
|
void setActivePage(LCDPage& page, bool reset = false);
|
|
void startLightCountdown();
|
|
void stopLightCountdown();
|
|
void resetLightCountdown();
|
|
void setLight(bool light);
|
|
|
|
GrowControl& getGrowControl() { return controller; }
|
|
|
|
void controlMainLoopCallback(GCSensorsInfo& sensors);
|
|
|
|
bool isLCDConnected();
|
|
|
|
};
|
|
|
|
} /* namespace growcontrol */
|
|
|
|
#endif /* LCD_H_ */
|