forked from portavales/esp32-car-altimeter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscreen_chart.h
67 lines (51 loc) · 1.39 KB
/
screen_chart.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
#ifndef __SCREEN_CHART_H__
#define __SCREEN_CHART_H__
#include <Arduino.h>
#include "utils.h"
#include <TFT_eSPI.h>
// callback that returns a float
typedef float (*CallbackFloat)();
typedef int (*CallbackInt)();
typedef bool (*CallbackBool)();
// How long to show the title of the screen when we change to it
#define SHOW_TITLE_PERIOD 1000 * 3
typedef struct {
String title;
String field_1;
CallbackInt field_1_cb;
CallbackFloat add_to_history_cb;
String field_2;
CallbackInt field_2_cb;
String field_3;
CallbackInt field_3_cb;
String field_4;
CallbackInt field_4_cb;
CallbackInt gps_quality_cb;
CallbackInt sattelites_cb;
CallbackBool gps_altitude_is_updated_cb;
} ScreenChart_config_t;
class ScreenChart{
public:
ScreenChart();
bool begin(TFT_eSprite* screen_p);
void set_config(const ScreenChart_config_t& config);
void showTitle();
void addToHistory();
void draw();
void set_plot_history_period(int period) { // in seconds
//Serial.printf("%s set_plot_history_period: %d\n", _config.title, period);
_save_data_period = 1000 * period;
}
private:
void drawGPS();
void drawNumbers();
void plotHistory();
TFT_eSprite* _screen;
ScreenChart_config_t _config;
float _data_history[SCREEN_WIDTH];
int _data_history_index = 0;
uint32_t _next_data_save_ts = 0;
uint32_t _save_data_period = 1000 * 1;
uint32_t _show_title_ts = 0;
};
#endif