-
Notifications
You must be signed in to change notification settings - Fork 3
/
display.hpp
129 lines (99 loc) · 3.75 KB
/
display.hpp
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
// SPDX-FileCopyrightText: 2020-2021 Ivan Ivanov
// SPDX-License-Identifier: GPL-3.0-or-later
#ifndef _DISPLAY_
#define _DISPLAY_
#include <U8g2lib.h>
#include "tsh-watch_menu.h"
#include <TimeLib.h>
#include "utils.h"
#include "stat_records.hpp"
static char *wifi_ap_name = "TshwatchAP";
enum displayActivity_t {
WATCH_ACTICITY = 1 ,
ICON_MENU_MAIN_ACTIVITY,
SETTINGS_ACTIVITY,
GRAPH_BODY_TEMP_ACTIVITY,
GRAPH_STEPS_ACTIVITY,
CONNECT_WIFI_ACTIVITY,
START_WIFI_AP_ACTIVITY,
};
enum displayAsixType_t {
SHOW_INT_TYPE,
SHOW_FLOAT_TYPE,
SHOW_MAX_TYPE
};
class Graph {
float max_v;
float min_v;
String title;
time_t currentDate;
displayAsixType_t asixType;
public:
float graphData[24];
int graphDataLen;
void process();
time_t getDate() { return currentDate; };
void setDate(time_t _date) { currentDate = _date;};
void setDate( int _day, int _month, int _year, int _weekday);
void setData( struct hourStat_t *skim_log, skimrecord_idx_t idxm, displayAsixType_t _asixType);
void setTitle(String _title) { title = _title;};
String getTitle() { return title ;};
float max() {return max_v;};
float min() {return min_v;};
displayAsixType_t getAsixType() {return asixType;};
bool starting;
unsigned int encoderVal = 100;
};
class Bitmap{
public:
int height;
int width;
unsigned char *pic;
void set(unsigned char *pic, int width, int height){
this->pic = pic;
this->width = width;
this->height = height;
}
};
class Display {
private:
const int REPORTING_PERIOD_MS = 1000;
U8G2 _display;
int screenSizeX = 128;
int screenSizeY = 64;
int graphStartX = 0;
int graphStartY = 14;
int graphEndX = screenSizeX - 22;
int graphEndY = screenSizeY - 6;
int countColumnX = 24;
int countColumnY = 3;
displayActivity_t currentActivity;
Bitmap batteryPic;
Bitmap footprintsPic;
Bitmap pressurePic;
Bitmap temperaturePic;
uint32_t tsLastDisplayUpdate = 0;
void showBatteryLevel(uint8_t batLevel);
void showDigitalClock(int16_t x, int16_t y);
void showDate(int16_t x, int16_t y);
void showTemperatureC(int16_t x, int16_t y, float therm, float pulse);
void showSteps(int16_t x, int16_t y, uint16_t steps);
void showPressure(int16_t x, int16_t y, float pressure);
void showGraph(int16_t x, int16_t y);
void showWatchActivity(float therm, float pulse, uint16_t steps, float pressure, uint8_t batLevel);
public:
void init();
void bitmapInitialize();
void update(float therm, float pulse, uint16_t steps, float pressure, uint8_t batLevel, Graph *graph);
void setPowerSave(bool powerSave);
displayActivity_t getCurrentActivity() { return currentActivity; };
void setCurrentActivity(displayActivity_t activity) ;//{ currentActivity = activity; };
void drawCGraph( Graph *graph, boolean Redraw);
void drawAxises(float _min, float _max, int _column_x, int _column_y, int step_x, int step_y, displayAsixType_t asixType) ;
void graphDraw(Graph *graph);
void showSyncTimeMessage(CompletedHandlerFn completedHandler) ;
void showWifiApMessage(CompletedHandlerFn completedHandler) ;
void showWifiPortalMessage(CompletedHandlerFn completedHandler) ;
void showSyncStatDataMessage(CompletedHandlerFn completedHandler);
};
#endif