-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTft.h
84 lines (64 loc) · 2.37 KB
/
Tft.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef TFT_H
#define TFT_H
#include <linux/fb.h>
#include <cairo/cairo.h>
#include <string>
#include <vector>
#define NR_SCREEN_BUFFERS 4
class EnergyMonitorConfig;
class EnergyData;
class OmnikGetStats;
class PvOutput;
class Tft
{
public:
Tft(const EnergyMonitorConfig& config);
virtual ~Tft();
void displayEnergyData(const EnergyData& energyData, const OmnikGetStats& solarData, PvOutput& pvOutput);
private:
typedef cairo_surface_t* TDisplaySurface;
typedef unsigned char* TDisplaySurfaceMap;
bool initFrameBuffer();
bool initFrameBufferFile(const EnergyMonitorConfig& config);
void initDisplayButtons();
void cleanupFrameBuffer();
void cleanupDisplayButtons();
void displayEnergyTotals(cairo_t* surface, int x, int y, const EnergyData& energyData, const OmnikGetStats& solarData);
void displayCurrentValues(cairo_t* surface, int x, int y, const EnergyData& energyData, const OmnikGetStats& solarData);
void displayEnergySummary(cairo_t* surface, int x, int y, const EnergyData& energyData, const OmnikGetStats& solarData, PvOutput& pvOutput);
void displayStatisticValues(cairo_t* surface, int x, int y, const EnergyData& energyData, const OmnikGetStats& solarData);
double getTodayExtimate() const;
double getYesterdayEstimate() const;
double getMonthEstimate() const;
double getYearEstimate() const;
void clear(cairo_t* surface);
void apply();
void displayPower(bool on);
void displayOn();
void displayOff();
void buttonPressed(int buttonNr);
private:
static void button1Pressed();
static void button2Pressed();
static void button3Pressed();
static void button4Pressed();
static void alarmHandler(int signum);
static std::string getKwhText(double kwh);
static std::string getWText(int w);
static std::string getAText(int a);
static std::string getPercText(double fraction);
private:
std::vector<int> myMonthEstimates;
int myFramebufferDevice;
fb_var_screeninfo myOriginalScreenInfo;
long myScreenSize;
TDisplaySurfaceMap myScreenSurfaceMap;
TDisplaySurfaceMap myScreenBufferMap[NR_SCREEN_BUFFERS];
TDisplaySurface myScreenSurface;
TDisplaySurface myBufferSurface[NR_SCREEN_BUFFERS];
bool myDisplayButtonInitialized;
bool myDisplayOn;
time_t myDisplayEndTime;
int myCurrentDisplayBuffer;
};
#endif /* TFT_H */