-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathHamClock.h
1564 lines (1182 loc) · 46.9 KB
/
HamClock.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
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
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* HamClock glue
*/
#ifndef _HAMCLOCK_H
#define _HAMCLOCK_H
// handy build categories
#if defined(ESP8266)
#define _IS_ESP8266
#else
#define _IS_UNIX
#endif
#if defined(__linux__)
#define _IS_LINUX
#endif
#if defined(__FreeBSD__)
#define _IS_FREEBSD
#endif
// TODO: any better way to detect linux on RPi?
#if defined(__arm__) && defined(_IS_LINUX)
#if __has_include(<bcm_host.h>)
#define _IS_LINUX_RPI
#endif
#endif
#if defined(_IS_ESP8266)
#define _IIC_ESP
#elif defined(__has_include)
#if defined(_IS_FREEBSD) && __has_include(<dev/iicbus/iic.h>) && __has_include("/dev/iic0")
#define _IIC_FREEBSD
#elif defined(_IS_LINUX) && (__has_include(<linux/i2c-dev.h>) || __has_include("linux/i2c-dev.h"))
#define _IIC_LINUX
#endif
#endif
#if defined(_IS_ESP8266)
#define _GPIO_ESP
#elif defined(__has_include)
#if defined(_IS_FREEBSD) && __has_include(<libgpio.h>) && __has_include("/dev/gpioc0")
#define _GPIO_FREEBSD
#elif defined(_IS_LINUX) && __has_include(<bcm_host.h>)
#define _GPIO_LINUX
#endif
#endif
// whether we seem to support discreet IO
#if defined(_GPIO_ESP) || defined(_GPIO_FREEBSD) || defined(_GPIO_LINUX)
#define _SUPPORT_GPIO
#endif
// whether we can support a temp sensor
#if defined(_IIC_ESP) || defined(_IIC_FREEBSD) || defined(_IIC_LINUX)
#define _SUPPORT_ENVSENSOR
#endif
// Flip screen only on ESP
#if defined(_IS_ESP8266)
#define _SUPPORT_FLIP
#endif
// kx3 on any system with GPIO
#if defined(_SUPPORT_GPIO)
#define _SUPPORT_KX3
#endif
// phot only supported on ESP and then only if phot is detected
#if defined(_IS_ESP8266)
#define _SUPPORT_PHOT
#endif
// full res app, map, moon and running man sizes
#if defined(_CLOCK_1600x960)
#define HC_MAP_W (660*2)
#define HC_MAP_H (330*2)
#define HC_MOON_W (148*2)
#define HC_MOON_H (148*2)
#define HC_RUNNER_W (13*2)
#define HC_RUNNER_H (20*2)
#define BUILD_W 1600
#define BUILD_H 960
#elif defined(_CLOCK_2400x1440)
#define HC_MAP_W (660*3)
#define HC_MAP_H (330*3)
#define HC_MOON_W (148*3)
#define HC_MOON_H (148*3)
#define HC_RUNNER_W (13*3)
#define HC_RUNNER_H (20*3)
#define BUILD_W 2400
#define BUILD_H 1440
#elif defined(_CLOCK_3200x1920)
#define HC_MAP_W (660*4)
#define HC_MAP_H (330*4)
#define HC_MOON_W (148*4)
#define HC_MOON_H (148*4)
#define HC_RUNNER_W (13*4)
#define HC_RUNNER_H (20*4)
#define BUILD_W 3200
#define BUILD_H 1920
#else // original size
#define HC_MAP_W 660
#define HC_MAP_H 330
#define HC_MOON_W 148
#define HC_MOON_H 148
#define HC_RUNNER_W 13
#define HC_RUNNER_H 20
#define BUILD_W 800
#define BUILD_H 480
#endif
// canonical map size
#define EARTH_H 330
#define EARTH_XH 1
#define EARTH_W 660
#define EARTH_XW 1
// UNIX-like modules
#include <stdio.h>
#include <stdint.h>
#include <stdarg.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#if defined(_IS_UNIX)
#include <signal.h>
#endif // _IS_UNIX
// see Adafruit_RA8875.h
#define USE_ADAFRUIT_GFX_FONTS
// community modules
#include <TimeLib.h>
#include <ESP8266WiFi.h>
#include <IPAddress.h>
#include <WiFiClient.h>
#include <WiFiServer.h>
#include <WiFiUdp.h>
#include <LittleFS.h>
#include "Adafruit_RA8875_R.h"
// HamClock modules
#include "calibrate.h"
#include "version.h"
#include "P13.h"
// GPIO.h for unix systems only
#if defined(_SUPPORT_GPIO) && defined(_IS_UNIX)
#include "GPIO.h"
// Raspberry Pi GPIO definitions, not header pins
#define SW_RED_GPIO 13 // header 33
#define SW_GRN_GPIO 19 // header 35
#define SW_COUNTDOWN_GPIO 26 // header 37
#define SW_ALARMOUT_GPIO 06 // header 31
#define SW_ALARMOFF_GPIO 05 // header 29
#define Elecraft_GPIO 14 // header 8
#define SATALARM_GPIO 20 // header 38
#define ONAIR_GPIO 21 // header 40
#endif
// handy nelements in array
// N.B. call with real array, not a pointer
#define NARRAY(a) (sizeof(a)/sizeof(a[0]))
// float versions
#define M_PIF 3.14159265F
#define M_PI_2F (M_PIF/2)
#define deg2rad(d) ((M_PIF/180)*(d))
#define rad2deg(d) ((180/M_PIF)*(d))
// time to leave new DX path up, millis()
#define DXPATH_LINGER 20000
// tcp ports
#define HTTPPORT 80
#define SERVERPORT 8080
// default menu timeout, millis
#define MENU_TO 20000
// maidenhead character arrey length, including EOS
#define MAID_CHARLEN 7
/* handy malloc wrapper that frees automatically when leaves scope
*/
class StackMalloc
{
public:
StackMalloc (size_t nbytes) {
// printf ("SM: new %lu\n", nbytes);
mem = (char *) malloc (nbytes);
siz = nbytes;
}
StackMalloc (const char *string) {
// printf ("SM: new %s\n", string);
mem = (char *) strdup (string);
siz = strlen(string) + 1;
}
~StackMalloc (void) {
// printf ("SM: free(%d)\n", siz);
free (mem);
}
size_t getSize(void) {
return (siz);
}
char *getMem(void) {
return (mem);
}
private:
char *mem;
size_t siz;
};
/* plot choices and pane locations
*/
typedef enum {
PLOT_CH_BC,
PLOT_CH_DEWX,
PLOT_CH_DXCLUSTER,
PLOT_CH_DXWX,
PLOT_CH_FLUX,
PLOT_CH_KP,
PLOT_CH_MOON,
PLOT_CH_NOAASWX,
PLOT_CH_SSN,
PLOT_CH_XRAY,
PLOT_CH_GIMBAL,
PLOT_CH_TEMPERATURE,
PLOT_CH_PRESSURE,
PLOT_CH_HUMIDITY,
PLOT_CH_DEWPOINT,
PLOT_CH_SDO_1,
PLOT_CH_SDO_2,
PLOT_CH_SDO_3,
PLOT_CH_SDO_4,
PLOT_CH_SOLWIND,
PLOT_CH_DRAP,
PLOT_CH_COUNTDOWN,
PLOT_CH_STEREO_A,
PLOT_CH_N
} PlotChoice;
// reuse count also handy flag for not found
#define PLOT_CH_NONE PLOT_CH_N
typedef enum {
PANE_1,
PANE_2,
PANE_3,
PANE_N
} PlotPane;
// reuse count also handy flag for not found
#define PANE_NONE PANE_N
#define N_NOAASW_C 3 // n categories : R, S and G
#define N_NOAASW_V 4 // values per cat : current and 3 days predictions
typedef struct {
char cat[N_NOAASW_C];
int val[N_NOAASW_C][N_NOAASW_V];
} NOAASpaceWx;
typedef struct {
float value; // from pane update
time_t age; // secs old
} SPWxValue;
extern const char *svr_host; // backend server name
extern int svr_port; // web server port
// screen coordinates, upper left at [0,0]
typedef struct {
uint16_t x, y;
} SCoord;
// screen coords of box ul and size
typedef struct {
uint16_t x, y, w, h;
} SBox;
// screen center, radius
typedef struct {
SCoord s;
uint16_t r;
} SCircle;
// timezone info
typedef struct {
SBox box;
uint16_t color;
int32_t tz_secs;
} TZInfo;
// callsign info
typedef struct {
char *call; // malloced callsign
uint16_t fg_color; // fg color
uint16_t bg_color; // bg color unless ..
uint8_t bg_rainbow; // .. bg rainbow?
SBox box; // size and location
} CallsignInfo;
extern CallsignInfo cs_info;
// map lat, lng, + radians N and E
typedef struct {
float lat, lng; // radians north, east
float lat_d, lng_d; // degrees +N +E
} LatLong;
#define LIFE_LED 0
#define DE_INFO_ROWS 3 // n text rows in DE pane -- not counting top row
#define DX_INFO_ROWS 5 // n text rows in DX pane
extern Adafruit_RA8875_R tft; // compat layer
extern TZInfo de_tz, dx_tz; // time zone info
extern SBox NCDXF_b; // NCDXF box
extern SBox brightness_b; // brightness controls
#define PLOTBOX_W 160 // common plot box width
#define PLOTBOX_H 148 // common plot box height, ends just above map border
extern SBox sensor_b;
extern SBox clock_b; // main time
extern SCircle satpass_c; // satellite pass horizon
extern SBox rss_bnr_b; // rss banner button
extern uint8_t rss_on; // rss on/off
extern uint8_t night_on; // show night portion of map on/off
extern uint8_t names_on; // show place names when roving
extern SBox desrss_b, dxsrss_b; // sun rise/set display
extern uint8_t desrss, dxsrss; // sun rise/set chpice
enum {
DXSRSS_INAGO, // display time from now
DXSRSS_ATAT, // display local time
DXSRSS_PREFIX, // must be last
DXSRSS_N,
};
// Antenna heading lines
extern int16_t antenna_heading; // Heading the antenna is pointing, in degrees.
extern int16_t antenna_width; // Beam width of the antenna, in degrees.
// show NCDXF beacons or up to one of several brightness controls in brightness_b
extern uint8_t brb_mode;
typedef enum {
BRB_SHOW_BEACONS, // NCDXF beacons
BRB_SHOW_ONOFF, // on/off/idle times
BRB_SHOW_PHOT, // brightness and phot controls
BRB_SHOW_BR, // just brightness control
BRB_SHOW_NOTHING, // blank region
} BRB_MODE;
extern uint8_t azm_on; // whether azimuthal else mercator projection
extern SBox dx_info_b; // dx info pane
extern SBox satname_b; // satellite name pick
extern SBox de_info_b; // de info pane
extern SBox map_b; // main map
extern SBox view_btn_b; // map view menu button
extern SBox view_pick_b; // map view pick box
extern SBox dx_maid_b; // dx maidenhead pick
extern SBox de_maid_b; // de maidenhead pick
extern SBox lkscrn_b; // screen lock icon button
extern SBox drap_b; // DRAP scale
#define VIEWBTN_W 40 // map View button width
#define VIEWBTN_H 13 // map View button height
#define VIEWMENU_W 85 // map View menu width
#define MOUSELOC_H 62 // height of mouse loc box
extern const SBox skip_b; // common "Skip" button
extern bool skip_skip; // whether to skip skipping
extern bool init_iploc; // init DE using our IP location
extern const char *init_locip; // init DE from given IP
// size and location of maidenhead labels
#define MH_TR_H 9 // top row background height
#define MH_TR_DX 2 // top row char cell x indent
#define MH_TR_DY 1 // top row char cell y down
#define MH_RC_W 8 // right columns background width
#define MH_RC_DX 1 // right column char cell x indent
#define MH_RC_DY 5 // right column char cell y down
// ESP mechanism to save lots of RAM by storing what appear to be RAM strings in FLASH
#if defined (_IS_ESP8266)
#define _FX(x) _FX_helper (F(x))
extern const char *_FX_helper(const __FlashStringHelper *flash_string);
#else
#define _FX(x) x
#endif
#define RSS_BG_COLOR RGB565(0,40,80) // RSS banner background color
#define RSS_FG_COLOR RA8875_WHITE // RSS banner text color
extern char *stack_start; // used to estimate stack usage
// map grid options
enum {
MAPGRID_OFF,
MAPGRID_TROPICS,
MAPGRID_LATLNG,
MAPGRID_MAID,
MAPGRID_N
};
extern uint8_t mapgrid_choice;
#define MAX_PREF_LEN 4 // maximumm prefix length
// touch screen actions
typedef enum {
TT_NONE, // no touch event
TT_TAP, // brief touch event
TT_HOLD, // at least TOUCH_HOLDT
} TouchType;
typedef struct {
char city[32];
float temperature_c;
float humidity_percent;
float wind_speed_mps;
char wind_dir_name[4];
char clouds[32];
char conditions[32];
char attribution[32];
} WXInfo;
#define N_WXINFO_FIELDS 8
/*********************************************************************************************
*
* ESPHamClock.ino
*
*/
extern bool newVersionIsAvailable (char *nv, uint16_t nvl);
extern bool askOTAupdate(char *ver);
extern void drawDXTime(void);
extern void drawDXMarker(bool force);
extern void drawAllSymbols(bool erase_too);
extern void drawTZ(const TZInfo &tzi);
extern bool inBox (const SCoord &s, const SBox &b);
extern bool inCircle (const SCoord &s, const SCircle &c);
extern void tftMsg (bool verbose, uint32_t dwell_ms, const char *fmt, ...);
extern void reboot(void);
extern void printFreeHeap (const __FlashStringHelper *label);
extern void getWorstMem (int *heap, int *stack);
extern void resetWatchdog(void);
extern void wdDelay(int ms);
extern bool timesUp (uint32_t *prev, uint32_t dt);
extern void setDXPathInvalid(void);
extern bool overMap (const SCoord &s);
extern bool overAnySymbol (const SCoord &s);
extern bool overRSS (const SCoord &s);
extern bool overRSS (const SBox &b);
extern void newDE (LatLong &ll, const char *grid);
extern void newDX (LatLong &ll, const char *grid, const char *override_prefix);
extern void drawDXPath(void);
extern void drawHeadingPath();
extern void getTextBounds (const char str[], uint16_t *wp, uint16_t *hp);
extern uint16_t getTextWidth (const char str[]);
extern void normalizeLL (LatLong &ll);
extern bool screenIsLocked(void);
extern void fatalError (const char *fmt, ...);
extern time_t getUptime (uint16_t *days, uint8_t *hrs, uint8_t *mins, uint8_t *secs);
extern void eraseScreen(void);
extern void setMapTagBox (const char *tag, const SCoord &c, uint16_t r, SBox &box);
extern void drawMapTag (const char *tag, SBox &box);
extern void setDXPrefixOverride (char p[MAX_PREF_LEN]);
extern bool getDXPrefix (char p[MAX_PREF_LEN+1]);
extern void call2Prefix (const char *call, char prefix[MAX_PREF_LEN]);
extern void setOnAir (bool on);
extern void drawCallsign (bool all);
extern void logState (void);
extern bool DRAPScaleIsUp(void);
extern const char *hc_version;
/*********************************************************************************************
*
* OTAupdate.cpp
*
*/
extern bool newVersionIsAvailable (char *nv, uint16_t nvl);
extern bool askOTAupdate(char *ver);
extern void doOTAupdate(const char *ver);
/*********************************************************************************************
*
* askNewPos.cpp
*
*/
extern bool askNewPos (const SBox &b, LatLong &ll, char grid[MAID_CHARLEN]);
/*********************************************************************************************
*
* astro.cpp
*
*/
typedef struct {
float az, el; // topocentric, rads
float ra, dec; // geocentric EOD, rads
float gha; // geocentric rads
float dist; // geocentric km
float vel; // topocentric m/s
float phase; // rad angle from new
} AstroCir;
extern AstroCir lunar_cir, solar_cir;
extern void getLunarCir (time_t t0, const LatLong &ll, AstroCir &cir);
extern void getSolarCir (time_t t0, const LatLong &ll, AstroCir &cir);
extern void getSolarRS (const time_t t0, const LatLong &ll, time_t *riset, time_t *sett);
extern void getLunarRS (const time_t t0, const LatLong &ll, time_t *riset, time_t *sett);
#define SECSPERDAY (3600*24L) // seconds per day
#define MINSPERDAY (24*60) // minutes per day
#define DAYSPERWEEK 7 // days per week
/*********************************************************************************************
*
* brightness.cpp
*
*/
extern void drawBrightness (void);
extern void initBrightness (void);
extern void setupBrightness (void);
extern void followBrightness (void);
extern void changeBrightness (SCoord &s);
extern bool brightnessOn(void);
extern void brightnessOff(void);
extern bool checkBeaconTouch (SCoord &s);
extern bool setDisplayOnOffTimes (int dow, uint16_t on, uint16_t off, int &idle);
extern bool getDisplayOnOffTimes (int dow, uint16_t &on, uint16_t &off);
extern bool getDisplayInfo (uint16_t &percent, uint16_t &idle_min, uint16_t &idle_left_sec);
extern void setFullBrightness(void);
extern bool brControlOk(void);
extern bool brOnOffOk(void);
extern bool found_phot;
/*********************************************************************************************
*
* cities.cpp
*
*/
extern void readCities(void);
extern const char *getNearestCity (const LatLong &ll, LatLong &city_ll);
/*********************************************************************************************
*
* clocks.cpp
*
*/
enum {
DETIME_INFO,
DETIME_ANALOG,
DETIME_CAL,
DETIME_ANALOG_DTTM,
DETIME_N,
};
extern uint8_t de_time_fmt;
extern void initTime(void);
extern time_t nowWO(void);
extern void updateClocks(bool all);
extern bool clockTimeOk(void);
extern void changeTime (time_t t);
extern bool checkClockTouch (SCoord &s, TouchType tt);
extern bool checkTZTouch (const SCoord &s, TZInfo &tzi, const LatLong &ll);
extern void enableSyncProvider(void);
extern void drawDESunRiseSetInfo(void);
extern void drawCalendar(bool force);
extern void hideClocks(void);
extern void showClocks(void);
extern void drawDXSunRiseSetInfo(void);
extern int DEWeekday(void);
extern int32_t utcOffset(void);
extern const char *gpsd_server, *ntp_server;
/*********************************************************************************************
*
* color.cpp
*
*/
// convert 8-bit each (R,G,B) to 5R : 6G : 5G
// would expect this to be in graphics lib but can't find it...
#define RGB565(R,G,B) ((((uint16_t)(R) & 0xF8) << 8) | (((uint16_t)(G) & 0xFC) << 3) | ((uint16_t)(B) >> 3))
// extract 8-bit colors from uint16_t RGB565 color in range 0-255
#define RGB565_R(c) (((c) & 0xF800) >> 8)
#define RGB565_G(c) (((c) & 0x07E0) >> 3)
#define RGB565_B(c) (((c) & 0x001F) << 3)
#define GRAY RGB565(140,140,140)
#define BRGRAY RGB565(200,200,200)
#define DYELLOW RGB565(255,212,112)
extern void hsvtorgb(uint8_t *r, uint8_t *g, uint8_t *b, uint8_t h, uint8_t s, uint8_t v);
extern void rgbtohsv(uint8_t *h, uint8_t *s, uint8_t *v, uint8_t r, uint8_t g, uint8_t b);
/*********************************************************************************************
*
* dxcluster.cpp
*
*/
#define MAX_SPOTCALL_LEN 12
typedef struct {
char call[MAX_SPOTCALL_LEN]; // call
float freq; // kHz
char grid[MAID_CHARLEN]; // used only with WSJT-X
uint16_t uts; // UT spotted
LatLong ll; // lat, long
SBox map_b; // map label
} DXClusterSpot;
extern bool updateDXCluster(const SBox &box);
extern void closeDXCluster(void);
extern bool checkDXClusterTouch (const SCoord &s, const SBox &box);
extern bool getDXClusterSpots (DXClusterSpot **spp, uint8_t *nspotsp);
extern bool overAnyDXClusterSpots(const SCoord &s);
extern void drawDXClusterSpotsOnMap (void);
extern void updateDXClusterSpotScreenLocations(void);
extern bool isDXClusterConnected(void);
extern bool sendDXClusterDELLGrid(void);
/*********************************************************************************************
*
* earthmap.cpp
*
*/
#define DX_R 8 // dx marker radius (erases better if even)
#define DX_COLOR RA8875_GREEN
extern SCircle dx_c;
extern LatLong dx_ll;
extern uint16_t map_x0, map_y0;
extern uint16_t map_w, map_h;
extern bool mapmenu_pending; // draw map menu at next opportunity
extern uint8_t show_km; // show prop path distance in km, else miles
extern uint8_t show_lp; // show prop long path, else short path
#define ERAD_M 3959.0F // earth radius, miles
#define DE_R 8 // radius of DE marker (erases better if even)
#define DEAP_R 8 // radius of DE antipodal marker (erases better if even)
#define DE_COLOR RGB565(255,125,0) // orange
extern SCircle de_c;
extern LatLong de_ll;
extern float sdelat, cdelat;
extern SCircle deap_c;
extern LatLong deap_ll;
extern LatLong sun_ss_ll;
extern LatLong moon_ss_ll;
#define SUN_R 9 // radius of sun marker
extern float sslng, sslat, csslat, ssslat;
extern SCircle sun_c;
#define MOON_R 9 // radius of moon marker
#define MOON_COLOR RGB565(150,150,150)
extern SCircle moon_c;
extern uint32_t max_wd_dt;
extern uint8_t flash_crc_ok;
extern void drawMoreEarth (void);
extern void eraseDEMarker (void);
extern void eraseDEAPMarker (void);
extern void drawDEMarker (bool force);
extern void drawDEAPMarker (void);
extern void drawDEInfo (void);
extern void drawDETime (bool center);
extern void drawDXTime (void);
extern void initEarthMap (void);
extern void antipode (LatLong &to, const LatLong &from);
extern void drawMapCoord (const SCoord &s);
extern void drawMapCoord (uint16_t x, uint16_t y);
extern void drawSun (void);
extern void drawMoon (void);
extern void drawDXInfo (void);
extern void ll2s (const LatLong &ll, SCoord &s, uint8_t edge);
extern void ll2s (float lat, float lng, SCoord &s, uint8_t edge);
extern bool s2ll (uint16_t x, uint16_t y, LatLong &ll);
extern bool s2ll (const SCoord &s, LatLong &ll);
extern void solveSphere (float A, float b, float cc, float sc, float *cap, float *Bp);
extern bool checkDistTouch (const SCoord &s);
extern bool checkPathDirTouch (const SCoord &s);
extern void propDEDXPath (bool long_path, LatLong &ll, float *distp, float *bearp);
extern bool waiting4DXPath(void);
extern void eraseSCircle (const SCircle &c);
extern void eraseRSSBox (void);
extern void drawMapMenu(void);
extern bool segmentSpanOk (SCoord &s0, SCoord &s1);
extern void roundLatLong (LatLong &ll);
extern void initScreen(void);
extern bool checkOnAir(void);
extern float lngDiff (float dlng);
/*********************************************************************************************
*
* BME280.cpp
*
*/
// measurement queues
#define N_BME_READINGS 100 // n measurements stored for each sensor
typedef struct {
float t[N_BME_READINGS]; // circular queue of temperature values as per useMetricUnits()
float p[N_BME_READINGS]; // circular queue of pressure values as per useMetricUnits()
float h[N_BME_READINGS]; // circular queue of humidity values
time_t u[N_BME_READINGS]; // circular queue of UNIX sensor read times, 0 if no data
uint8_t q_head; // index of next q entries to use
uint8_t i2c; // i2c addr
} BMEData;
enum {
BME_76, // index for sensor at 0x76
BME_77, // index for sensor at 0x77
MAX_N_BME // max sensors connected
};
extern void initBME280 (void);
extern void readBME280 (void);
extern void drawBME280Panes(void);
extern void drawOneBME280Pane (const SBox &box, PlotChoice ch);
extern bool newBME280data (PlotChoice ch);
extern const BMEData *getBMEData (int i);
extern int getNBMEConnected (void);
extern float dewPoint (float T, float RH);
/*********************************************************************************************
*
* earthsat.cpp
*
*/
extern void updateSatPath(void);
extern void drawSatPathAndFoot(void);
extern void updateSatPass(void);
extern bool querySatSelection(void);
extern void strncpySubChar (char to_str[], const char from_str[], char to_char, char from_char, int maxlen);
extern bool checkSatMapTouch (const SCoord &s);
extern bool checkSatNameTouch (const SCoord &s);
extern void displaySatInfo(void);
extern void setSatObserver (float lat, float lng);
extern void drawSatPointsOnRow (uint16_t r);
extern void drawSatNameOnRow(uint16_t y);
extern bool dx_info_for_sat;
extern bool setSatFromName (const char *new_name);
extern bool setSatFromTLE (const char *name, const char *t1, const char *t2);
extern bool initSatSelection(void);
extern bool getSatAzElNow (char *name, float *azp, float *elp, float *rangep, float *ratep,
float *razp, float *sazp, float *rdtp, float *sdtp);
extern bool isNewPass(void);
extern bool isSatMoon(void);
extern const char **getAllSatNames(void);
extern int nextSatRSEvents (time_t **rises, time_t **sets);
extern void showNextSatEvents (void);
#define SAT_NOAZ (-999) // error flag
#define SAT_MIN_EL 0.0F // rise elevation
#define TLE_LINEL 70 // including EOS
/*********************************************************************************************
*
* gimbal.cpp
*
*/
extern void initGimbalGUI(const SBox &box);
extern bool haveGimbal(void);
extern void updateGimbal (void);
extern bool checkGimbalTouch (const SCoord &s, const SBox &box);
extern void stopGimbalNow(void);
extern void closeGimbal(void);
extern bool getGimbalWrapAz (float *azp);
/*********************************************************************************************
*
* gpsd.cpp
*
*/
extern bool getGPSDLatLong(LatLong *llp);
extern time_t getGPSDUTC(const char **server);
/*********************************************************************************************
*
* setup.cpp
*
*/
extern void clockSetup(void);
extern const char *getWiFiSSID(void);
extern const char *getWiFiPW(void);
extern const char *getCallsign(void);
extern const char *getDXClusterHost(void);
extern int getDXClusterPort(void);
extern bool useMetricUnits(void);
extern bool useGeoIP(void);
extern bool useGPSD(void);
extern bool mapDXClusterSpots(void);
extern bool plotSpotCallsigns(void);
extern bool rotateScreen(void);
extern float getBMETempCorr(int i);
extern float getBMEPresCorr(int i);
extern const char *getGPSDHost(void);
extern bool useLocalNTPHost(void);
extern bool GPIOOk(void);
extern const char *getLocalNTPHost(void);
extern bool useDXCluster(void);
extern uint32_t getKX3Baud(void);
extern void drawStringInBox (const char str[], const SBox &b, bool inverted, uint16_t color);
extern bool logUsageOk(void);
extern uint16_t getSatPathColor(void);
extern uint16_t getSatFootColor(void);
extern uint16_t getShortPathColor(void);
extern uint16_t getLongPathColor(void);
extern uint16_t getAntennaHeadingColor(void);
extern uint16_t getAntennaBackColor(void);
extern uint8_t getBrMax(void);
extern uint8_t getBrMin(void);
extern bool getX11FullScreen(void);
extern bool latSpecIsValid (const char *lng_spec, float &lng);
extern bool lngSpecIsValid (const char *lng_spec, float &lng);
extern bool getDemoMode(void);
extern void setDemoMode(bool on);
extern uint16_t getGridColor(void);
extern int16_t getCenterLng(void);
extern void setCenterLng(int16_t);
/*********************************************************************************************
*
* magdecl.cpp
*
*/
extern int magdecl (float l, float L, float e, float y, float *mdp);
/*********************************************************************************************
*
* mapmanage.cpp
*
*/
typedef enum {
PROP_MAP_80M,
PROP_MAP_40M,
PROP_MAP_30M,
PROP_MAP_20M,
PROP_MAP_17M,
PROP_MAP_15M,
PROP_MAP_12M,
PROP_MAP_10M,
PROP_MAP_N
} PropMapSetting;
#define PROP_MAP_OFF PROP_MAP_N // handy alias meaning none active
extern PropMapSetting prop_map;
// N.B. must be in same order as map_files[]
typedef enum {
CM_COUNTRIES,
CM_TERRAIN,
CM_DRAP,
CM_N
} CoreMaps;
#define CM_NONE CM_N // handy alias meaning none active
extern CoreMaps core_map; // current map, if any