-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathsdlSpeedometer.h
More file actions
227 lines (204 loc) · 5.54 KB
/
sdlSpeedometer.h
File metadata and controls
227 lines (204 loc) · 5.54 KB
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
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
#ifndef SPEEDOMETER_H
#define SPEEDOMETER_H
#include <sqlite3.h>
#ifdef HAS_SMBUS_H
#include <i2c/smbus.h>
#endif
#include <alsa/asoundlib.h>
// Dendent on project https://github.com/ehedman/flowSensor
//#define DIGIFLOW
// Volume slider
#define SWINDOW_WIDTH 20
#define SWINDOW_HEIGHT 300
#define SLIDER_WIDTH 20
#define SLIDER_HEIGHT 300
#define RIGHT_MARGIN 20
// Power plot
#define PWINDOW_W 700
#define PWINDOW_H 250
#define PHISTORY 250
#define SCALE_WINDOW 50
// Depth plot
#define DWINDOW_W 800
#define DWINDOW_H 480
#define DHISTORY 300
// Video
#define VIDEO_BUFFERS 4
#define AUDIO_BUFFER_FRAMES 1024
#define FRAME_SIZE 1024
// See: BerryIMU/compass_tutorial03_calibration
// Defaults if db fails
#define dmagXmax 2029
#define dmagYmax 1297
#define dmagZmax 579
#define dmagXmin -324
#define dmagYmin -1066
#define dmagZmin -1338
#define ddeclval 0.13
#define RFB_TOUCH 1
#define NMBUFF 2048
typedef struct {
int magXmax;
int magYmax;
int magZmax;
int magXmin;
int magYmin;
int magZmin;
float declval;
int coffset;
float roffset;
float depthw;
} calibration;
typedef struct {
volatile int runSer;
volatile int runi2c;
volatile int runNet;
volatile int runVnc;
volatile int runWrn;
volatile int runTyd;
pid_t wayvncPid;
int numThreads;
short port;
char server[100];
int useWm;
SDL_Surface* vncPixelBuffer;
float scale;
char ssize[50];
int window_w;
int window_h;
int vncClients;
int vncPort;
int doFokusCheck;
char tty[40];
int baud;
int i2cFile;
sqlite3 *conn;
int netStat;
int muted;
int subTaskPID;
int cursor;
int ttydPID;
snd_mixer_t *mixer;
snd_mixer_elem_t *elem;
long snd_minv, snd_maxv;
int snd_useMixer;
int snd_showMixer;
char snd_card[60];
char snd_card_name[256];
char cam_url[200];
char vid_device[60];
SDL_mutex* nm_mutex;
} configuration;
enum sdlPages {
COGPAGE = 1,
SOGPAGE,
DPTPAGE,
WNDPAGE,
GPSPAGE,
PWRPAGE,
VIDPAGE,
CALPAGE,
TSKPAGE,
WTRPAGE
};
typedef struct {
SDL_Window *window;
SDL_Renderer *renderer;
char *fontPath;
char *subAppsCmd[VIDPAGE][VIDPAGE];
char *subAppsIco[VIDPAGE][VIDPAGE];
int nextPage;
int curPage;
int plotMode;
SDL_Texture* textFieldArr[60];
SDL_Surface* formattedSurf;
SDL_mutex* vnc_mutex;
int textFieldArrIndx;
Uint32 last_reset_time;
configuration *conf;
} sdl2_app;
typedef struct {
int run;
float latitude;
float longitude;
float declination;
char progress[200];
int i2cFile;
} calRunner;
typedef struct {
volatile int run;
int mute;
int astat;
char snd_card[60];
char snd_card_dev[60];
} audRunner;
typedef struct {
float depthw;
float draftw;
float lowvoltw;
float highcurrw;
} warnings;
extern int i2cinit(int bus);
extern float i2cReadHdm(int file, calibration *calib);
extern float i2cReadRoll(int file, int dt, calibration *calib);
extern void i2creadMAG(int m[], int file);
typedef struct {
// Dynamic data from NMEA server
float rmc; // RMC (Speed Over Ground) in knots
char time[20]; // UTC Time
char date[20]; // Date
int rmc_tm_set; // time isset ?
time_t rmc_ts; // RMC Timestamp
time_t rmc_nme_ts; // Got RMC
float roll; // Vessel roll (non NMEA)
time_t roll_i2cts; // Roll timestamp
float stw; // Speed of vessel relative to the water (Knots)
time_t stw_ts; // STW Timestamp
float dbt; // Depth in meters
time_t dbt_ts; // DBT Timestamp
float mtw; // Water temperature
time_t mtw_ts; // Water temperature Timestamp
float hdm; // Heading
time_t hdm_ts; // HDM Timestamp (nmea)
float rsa; // Rudder angle
time_t rsa_ts; // Rudder angle Timestamp
time_t hdm_i2cts; // HDM Timestamp (i2c)
time_t xdr_ts; // Wessel roll Timestamp
float vwra; // Relative wind angle (0-180)
float vwta; // True wind angle
time_t vwr_ts; // Wind data Timestamp
time_t vwt_ts; // True wind data Timestamp
int vwrd; // Right or Left Heading
float vwrs; // Relative wind speed knots
float vwts; // True wind speed
char gll[40]; // Position Latitude
time_t gll_ts; // Position Timestamp
char glo[40]; // Position Longitude
char glns[2]; // North (N) or South (S)
char glne[2]; // East (E) or West (W)
time_t net_ts; // Data valid from network
// Sensors $P type messages
float volt; // Sensor Volt
char volt_bank[20]; // Batery sensor bank #
time_t volt_ts; // Volt Timestamp
float curr; // Sensor Current
char curr_bank[20]; // Current sensor bank #
time_t curr_ts; // Current Timestamp
float temp; // Sensor Temp
char temp_loc[20]; // Sensor location i.e, indoor ...
time_t temp_ts; // Temp Timestamp
float kWhp; // Kilowatt hour - charged
float kWhn; // Kilowatt hour - consumed
time_t startTime; // Server's starttime
// Misc
float declination; // from NOAA
#ifdef DIGIFLOW
time_t fdate; // Filter date
float tvol; // Total consumed volume
float gvol; // Grand total consumed volume
float tank; // Tank Volume
int tds; // TDS value
float ttemp; // Water temp
#endif
} collected_nmea;
#endif /* SPEEDOMETER_H */