-
Notifications
You must be signed in to change notification settings - Fork 1
/
constants.h
198 lines (173 loc) · 7.46 KB
/
constants.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
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#pragma once // Please format this file with clang before check-in to GitHub
// ------- Identity for splash screen and console --------
#define PROGRAM_TITLE "Griduino"
#define PROGRAM_VERSION "v1.09 beta"
#define PROGRAM_LINE1 "Barry K7BWH"
#define PROGRAM_LINE2 "John KM7O"
#define PROGRAM_COMPILED __DATE__ " " __TIME__
#define PROGRAM_GITHUB "https://github.com/barry-ha/Griduino"
// ------- Select testing features ---------
//#define RUN_UNIT_TESTS // comment out to save boot-up time
//#define FASTBOOT // comment out in production, use to skip some startup screen
//#define USE_SIMULATED_GPS // comment out to use real GPS, or else it simulates driving around (see model_gps.h)
//#define ECHO_GPS // use this to see GPS detailed info on IDE console for debug
//#define SHOW_TOUCH_TARGETS // use this to outline touchscreen sensitive buttons
//#define SHOW_SCREEN_BORDER // use this to outline the screen's displayable area
//#define SHOW_SCREEN_CENTERLINE // use this visual aid to help layout the screen
//#define SHOW_IGNORED_PRESSURE // use this to see barometric pressure readings that are out of range and therefore ignored
// ------- TFT screen definitions ---------
#define gScreenWidth 320 // screen pixels wide
#define gScreenHeight 240 // screen pixels high \
// we use #define here instead of reading it from "tft.width()" because this \
// screen layout is specifically designed for landscape orientation on 3.2" ILI9341
#define gBoxWidth 180 // grid square width as shown on display, pixels
#define gBoxHeight 160 // grid square height as shown on display, pixels
// ------- Physical constants ---------
const float gridWidthDegrees = 2.0; // horiz E-W size of one grid square, degrees
const float gridHeightDegrees = 1.0; // vert N-S size of one grid square, degrees
#define feetPerMeters 3.28084 // altitude conversion
#define mphPerKnots 1.15078 // speed conversion
const double degreesPerRadian = 57.2957795; // conversion factor = (360 degrees)/(2 pi radians)
#define SECS_PER_5MIN ((time_t)(300UL))
#define SECS_PER_15MIN ((time_t)(900UL))
#define DEFAULT_SEALEVEL_PASCALS (101740.0)
#define DEFAULT_SEALEVEL_HPA (1017.40)
// ----- load/save configuration using SDRAM
//#define EXTERNAL_FLASH_USE_QSPI // 2020-02-11 added by BarryH, since it seems to be missing from
// c:\Users\barry\AppData\Local\Arduino15\packages\adafruit\hardware\samd\1.5.7\variants\feather_m4\variant.h
#define CONFIG_FOLDER "/Griduino"
// ----- alias names for SCREEN_ROTATION
enum {
eSCREEN_ROTATE_0 = 1, // 1=landscape
eSCREEN_ROTATE_180 = 3, // 3=landscape 180-degrees
};
// ----- alias names for fGetDataSource()
enum {
eGPSRECEIVER = 1, // use the GPS receiver hardware
eGPSSIMULATOR, // use a GPS simulator
};
// ----- alias names for setFontSize()
enum {
eFONTGIANT = 36,
eFONTBIG = 24,
eFONTSMALL = 12,
eFONTSMALLEST = 9,
eFONTSYSTEM = 0,
eFONTUNSPEC = -1,
};
// ------- NeoPixel brightness ---------
const int MAXBRIGHT = 255; // = 100% brightness = maximum allowed on individual LED
const int BRIGHT = 32; // = tolerably bright indoors
const int HALFBR = 20; // = half of tolerably bright
const int OFF = 0; // = turned off
// ----- Griduino color scheme
// RGB 565 true color: https://chrishewett.com/blog/true-rgb565-colour-picker/
#define BACKGROUND 0x00A // a little darker than ILI9341_NAVY
#define cBACKGROUND 0x00A // 0, 0, 10 = darker than ILI9341_NAVY, but not black
#define cGRIDNAME ILI9341_GREEN //
#define cLABEL ILI9341_GREEN //
#define cDISTANCE ILI9341_YELLOW //
#define cVALUE ILI9341_YELLOW // 255, 255, 0
#define cVALUEFAINT 0xbdc0 // darker than cVALUE
#define cDISABLED 0x7bee // 125, 125, 115 = gray for disabled screen item
#define cHIGHLIGHT ILI9341_WHITE //
#define cBUTTONFILL ILI9341_NAVY //
#define cBUTTONOUTLINE 0x0514 // was ILI9341_CYAN
#define cBREADCRUMB ILI9341_CYAN //
#define cTITLE ILI9341_GREEN //
#define cTEXTCOLOR 0x67FF // rgb(102,255,255) = hsl(180,100,70%)
#define cCYAN ILI9341_CYAN // rgb(0,255,255) = hsl(180,100,50%)
#define cFAINT 0x0555 // rgb(0,168,168) = hsl(180,100,33%) = blue, between CYAN and DARKCYAN
#define cFAINTER 0x04B2 // rgb(0,128,128) = hsl(180,100,29%) = blue, between CYAN and DARKCYAN
#define cBOXDEGREES 0x0410 // rgb(0,128,128) = hsl(180,100,25%) = blue, between CYAN and DARKCYAN
#define cBUTTONLABEL ILI9341_YELLOW //
#define cCOMPASS ILI9341_BLUE // a little darker than cBUTTONOUTLINE
#define cSTATUS 0xFC10 // 255, 128, 128 = lavender
#define cWARN 0xF844 // brighter than ILI9341_RED but not pink
#define cTOUCHTARGET ILI9341_RED // outline touch-sensitive areas
// barometric pressure graph
#define cSCALECOLOR ILI9341_DARKGREEN // pressure graph, I tried yellow but it's too bright
#define cGRAPHCOLOR ILI9341_WHITE // graphed line of baro pressure
#define cDARKPURPLE 0x2809 // debug: 2809 = very dark purple
#define cDARKRED 0x4000 // debug: 4000 = very dark red
#define cDARKBROWN 0x49A0 // debug: 49A0 = dark orange
#define cDARKGREEN 0x01A0 // debug: #0x01A0 = very dark green
// ------------ typedef's
struct Point {
int x, y;
};
struct PointGPS {
public:
double lat, lng;
};
class BaroReading {
public:
float pressure; // in millibars, from BMP388 sensor
time_t time; // in GMT, from realtime clock
};
struct TwoPoints {
int x1, y1;
int x2, y2;
uint16_t color;
};
struct Rect {
Point ul;
Point size;
bool contains(const Point touch) {
if ((ul.x <= touch.x) && (touch.x <= ul.x + size.x) && (ul.y <= touch.y) && (touch.y <= ul.y + size.y)) {
return true;
} else {
return false;
}
}
};
struct Label {
char text[26];
int x, y;
uint16_t color;
};
typedef void (*simpleFunction)();
struct Button {
char text[26];
int x, y;
int w, h;
int radius;
uint16_t color;
simpleFunction function;
};
struct TimeButton {
// TimeButton is like Button, but has a larger specifiable hit target
// This allows very small buttons with a large sensitive area to make it easy to press
char text[26];
int x, y;
int w, h;
Rect hitTarget;
int radius;
uint16_t color;
simpleFunction function;
};
struct FunctionButton {
// FunctionButton is like Button, but has a larger specifiable hit target
// It's also like TimeButton, but specifies the function by enum, rather than pointer to function
// and this allows its usage in classes derived from "class View"
char text[26]; // one line of text, centered
int x, y; // fillRoundRect ul corner
int w, h; // fillRoundRect size
Rect hitTarget; // touch-sensitive area
int radius; // radio button size
uint16_t color; // text color
int functionIndex; // button identifier
};
#include <TimeLib.h> // https://github.com/PaulStoffregen/Time
class Location {
public:
PointGPS loc; // has-a lat/long, degrees
time_t timestamp; // has-a GMT time
void reset() {
loc.lat = loc.lng = 0.0;
timestamp = 0;
}
bool isEmpty() {
return (loc.lat == 0.0 && loc.lng == 0.0);
}
};