44
44
// ----------------------------------------
45
45
// Locals
46
46
// ----------------------------------------
47
- static CORRECTION_ID_T correctionSourceId; // ID of correction source
48
- static CORRECTION_MASK_T correctionActive; // Bitmap of active correction sources
47
+ static CORRECTION_ID_T correctionSourceId; // ID of correction source
48
+ static CORRECTION_MASK_T correctionActive; // Bitmap of active correction sources
49
49
static uint32_t correctionLastSeenMsec[CORR_NUM]; // Time when correction was last received
50
50
51
51
// ----------------------------------------
@@ -60,20 +60,17 @@ static uint32_t correctionLastSeenMsec[CORR_NUM]; // Time when correction was la
60
60
void correctionSetSourceId (CORRECTION_ID_T id)
61
61
{
62
62
// When the source priority changes, is new prioity the highest
63
- if ((correctionSourceId >= CORR_NUM)
64
- || ((correctionActive & (1 << correctionSourceId)) == 0 )
65
- || (settings.correctionsSourcesPriority [id] < settings.correctionsSourcesPriority [correctionSourceId]))
63
+ if ((correctionSourceId >= CORR_NUM) || ((correctionActive & (1 << correctionSourceId)) == 0 ) ||
64
+ (settings.correctionsSourcesPriority [id] < settings.correctionsSourcesPriority [correctionSourceId]))
66
65
{
67
66
// Display the correction source transition
68
67
if (settings.debugCorrections )
69
68
{
70
69
if ((correctionSourceId <= CORR_NUM) && (correctionActive & (1 << correctionSourceId)))
71
- systemPrintf (" Correction Source: %s --> %s\r\n " ,
72
- correctionsSourceNames[correctionSourceId],
70
+ systemPrintf (" Correction Source: %s --> %s\r\n " , correctionsSourceNames[correctionSourceId],
73
71
correctionsSourceNames[id]);
74
72
else
75
- systemPrintf (" Correction Source: None --> %s\r\n " ,
76
- correctionsSourceNames[id]);
73
+ systemPrintf (" Correction Source: None --> %s\r\n " , correctionsSourceNames[id]);
77
74
}
78
75
79
76
// Set the new correction source
@@ -87,22 +84,23 @@ void correctionSetSourceId(CORRECTION_ID_T id)
87
84
// id: correctionsSource value, ID of the correction source
88
85
// priority: Priority of the correction source
89
86
// ----------------------------------------
90
- void correctionPriorityUpdateSource (CORRECTION_ID_T id,
91
- CORRECTION_ID_T priority)
87
+ void correctionPriorityUpdateSource (CORRECTION_ID_T id, CORRECTION_ID_T priority)
92
88
{
93
89
CORRECTION_MASK_T bitMask;
94
90
95
91
// Validate the id value
96
92
if (id >= CORR_NUM)
97
93
{
98
- systemPrintf (" ERROR: correctionPriorityUpdateSource invalid correction id value %d, valid range (0 - %d)!\r\n " , id, CORR_NUM - 1 );
94
+ systemPrintf (" ERROR: correctionPriorityUpdateSource invalid correction id value %d, valid range (0 - %d)!\r\n " ,
95
+ id, CORR_NUM - 1 );
99
96
return ;
100
97
}
101
98
102
99
// Validate the id value
103
100
if (priority >= CORR_NUM)
104
101
{
105
- systemPrintf (" ERROR: correctionPriorityUpdateSource invalid priority value %d, valid range (0 - %d)!\r\n " , id, CORR_NUM - 1 );
102
+ systemPrintf (" ERROR: correctionPriorityUpdateSource invalid priority value %d, valid range (0 - %d)!\r\n " , id,
103
+ CORR_NUM - 1 );
106
104
return ;
107
105
}
108
106
@@ -128,7 +126,8 @@ void correctionPriorityDecrease(CORRECTION_ID_T oldPriority)
128
126
// Validate the priority value
129
127
if (oldPriority >= CORR_NUM)
130
128
{
131
- systemPrintf (" ERROR: correctionPriorityDecrease invalid correction id value %d, valid range (0 - %d)!\r\n " , id, CORR_NUM - 1 );
129
+ systemPrintf (" ERROR: correctionPriorityDecrease invalid correction id value %d, valid range (0 - %d)!\r\n " , id,
130
+ CORR_NUM - 1 );
132
131
return ;
133
132
}
134
133
@@ -171,16 +170,12 @@ void correctionPriorityDecrease(CORRECTION_ID_T oldPriority)
171
170
if (settings.correctionsSourcesPriority [index] == newPriority)
172
171
{
173
172
if (settings.debugCorrections )
174
- systemPrintf (" %s: %d --> %d\r\n " ,
175
- correctionsSourceNames[index],
176
- settings.correctionsSourcesPriority [index],
177
- oldPriority);
173
+ systemPrintf (" %s: %d --> %d\r\n " , correctionsSourceNames[index],
174
+ settings.correctionsSourcesPriority [index], oldPriority);
178
175
settings.correctionsSourcesPriority [index] = oldPriority;
179
176
}
180
177
if (settings.debugCorrections )
181
- systemPrintf (" %s: %d --> %d\r\n " ,
182
- correctionsSourceNames[id],
183
- settings.correctionsSourcesPriority [id],
178
+ systemPrintf (" %s: %d --> %d\r\n " , correctionsSourceNames[id], settings.correctionsSourcesPriority [id],
184
179
newPriority);
185
180
settings.correctionsSourcesPriority [id] = newPriority;
186
181
@@ -202,7 +197,9 @@ void correctionPriorityIncrease(CORRECTION_ID_T oldPriority)
202
197
// Validate the id value
203
198
if (oldPriority >= CORR_NUM)
204
199
{
205
- systemPrintf (" ERROR: correctionPriorityIncrease invalid correction priority value %d, valid range (0 - %d)!\r\n " , id, CORR_NUM - 1 );
200
+ systemPrintf (
201
+ " ERROR: correctionPriorityIncrease invalid correction priority value %d, valid range (0 - %d)!\r\n " , id,
202
+ CORR_NUM - 1 );
206
203
return ;
207
204
}
208
205
@@ -245,16 +242,12 @@ void correctionPriorityIncrease(CORRECTION_ID_T oldPriority)
245
242
if (settings.correctionsSourcesPriority [index] == newPriority)
246
243
{
247
244
if (settings.debugCorrections )
248
- systemPrintf (" %s: %d --> %d\r\n " ,
249
- correctionsSourceNames[index],
250
- settings.correctionsSourcesPriority [index],
251
- oldPriority);
245
+ systemPrintf (" %s: %d --> %d\r\n " , correctionsSourceNames[index],
246
+ settings.correctionsSourcesPriority [index], oldPriority);
252
247
settings.correctionsSourcesPriority [index] = oldPriority;
253
248
}
254
249
if (settings.debugCorrections )
255
- systemPrintf (" %s: %d --> %d\r\n " ,
256
- correctionsSourceNames[id],
257
- settings.correctionsSourcesPriority [id],
250
+ systemPrintf (" %s: %d --> %d\r\n " , correctionsSourceNames[id], settings.correctionsSourcesPriority [id],
258
251
newPriority);
259
252
settings.correctionsSourcesPriority [id] = newPriority;
260
253
@@ -332,7 +325,7 @@ void menuCorrectionsPriorities()
332
325
void correctionDisplayPriorityTable (bool menu)
333
326
{
334
327
// "a / A) "
335
- const char * blankString = " " ;
328
+ const char *blankString = " " ;
336
329
uint32_t currentMsec;
337
330
CORRECTION_ID_T id;
338
331
char menuString[strlen (blankString) + 1 ];
@@ -375,20 +368,15 @@ void correctionDisplayPriorityTable(bool menu)
375
368
376
369
// Display the priority table
377
370
if ((id < CORR_NUM) && correctionIsSourceActive (id))
378
- systemPrintf (" %s %c %2d active %4d.%03d Sec %s\r\n " ,
379
- menuString,
380
- (correctionSourceId == id) ? ' *' : ' ' ,
381
- settings.correctionsSourcesPriority [id],
382
- seconds, milliseconds,
383
- correctionsSourceNames[id]);
371
+ systemPrintf (" %s %c %2d active %4d.%03d Sec %s\r\n " , menuString,
372
+ (correctionSourceId == id) ? ' *' : ' ' , settings.correctionsSourcesPriority [id], seconds,
373
+ milliseconds, correctionsSourceNames[id]);
384
374
else if (id < CORR_NUM)
385
- systemPrintf (" %s %2d inactive %s\r\n " ,
386
- menuString,
387
- settings.correctionsSourcesPriority [id],
388
- correctionsSourceNames[id]);
375
+ systemPrintf (" %s %2d inactive %s\r\n " , menuString,
376
+ settings.correctionsSourcesPriority [id], correctionsSourceNames[id]);
389
377
else
390
- systemPrintf (" %s %2d inactive %s (%d)\r\n " ,
391
- menu ? blankString : " " , - 1 , " Unknown " , id);
378
+ systemPrintf (" %s %2d inactive %s (%d)\r\n " , menu ? blankString : " " , - 1 , " Unknown " ,
379
+ id);
392
380
}
393
381
}
394
382
@@ -400,12 +388,16 @@ void correctionDisplayPriorityTable(bool menu)
400
388
// Returns the address of a zero terminated constant name string or
401
389
// nullptr when id is invalid
402
390
// ----------------------------------------
403
- const char * correctionGetName (CORRECTION_ID_T id)
391
+ const char *correctionGetName (CORRECTION_ID_T id)
404
392
{
393
+ if (id == CORR_NUM)
394
+ return " None" ;
395
+
405
396
// Validate the id value
406
- if (id >= CORR_NUM)
397
+ if (id > CORR_NUM)
407
398
{
408
- systemPrintf (" ERROR: correctionGetName invalid correction id value %d, valid range (0 - %d)!\r\n " , id, CORR_NUM - 1 );
399
+ systemPrintf (" ERROR: correctionGetName invalid correction id value %d, valid range (0 - %d)!\r\n " , id,
400
+ CORR_NUM - 1 );
409
401
return nullptr ;
410
402
}
411
403
@@ -428,9 +420,9 @@ CORRECTION_ID_T correctionGetSource()
428
420
// Outputs:
429
421
// Returns the correctionsSource ID providing corrections
430
422
// ----------------------------------------
431
- const char * correctionGetSourceName ()
423
+ const char *correctionGetSourceName ()
432
424
{
433
- const char * name;
425
+ const char *name;
434
426
435
427
name = correctionGetName (correctionSourceId);
436
428
if (!name)
@@ -457,7 +449,8 @@ bool correctionIsSourceActive(CORRECTION_ID_T id)
457
449
// Validate the id value
458
450
if (id >= CORR_NUM)
459
451
{
460
- systemPrintf (" ERROR: correctionIsSourceActive invalid correction id value %d, valid range (0 - %d)!\r\n " , id, CORR_NUM - 1 );
452
+ systemPrintf (" ERROR: correctionIsSourceActive invalid correction id value %d, valid range (0 - %d)!\r\n " , id,
453
+ CORR_NUM - 1 );
461
454
return false ;
462
455
}
463
456
@@ -480,8 +473,7 @@ bool correctionIsSourceActive(CORRECTION_ID_T id)
480
473
newPriority = CORR_NUM;
481
474
newSource = CORR_NUM;
482
475
for (index = 0 ; index < CORR_NUM; index++)
483
- if ((correctionActive & (1 << index))
484
- && (settings.correctionsSourcesPriority [index] < newPriority))
476
+ if ((correctionActive & (1 << index)) && (settings.correctionsSourcesPriority [index] < newPriority))
485
477
{
486
478
newPriority = settings.correctionsSourcesPriority [index];
487
479
newSource = index;
@@ -494,12 +486,10 @@ bool correctionIsSourceActive(CORRECTION_ID_T id)
494
486
if (settings.debugCorrections )
495
487
{
496
488
if (newSource < CORR_NUM)
497
- systemPrintf (" Correction Source: %s --> %s\r\n " ,
498
- correctionsSourceNames[id],
489
+ systemPrintf (" Correction Source: %s --> %s\r\n " , correctionsSourceNames[id],
499
490
correctionsSourceNames[newSource]);
500
491
else
501
- systemPrintf (" Correction Source: %s --> None\r\n " ,
502
- correctionsSourceNames[id]);
492
+ systemPrintf (" Correction Source: %s --> None\r\n " , correctionsSourceNames[id]);
503
493
}
504
494
}
505
495
}
@@ -523,7 +513,8 @@ bool correctionLastSeen(CORRECTION_ID_T id)
523
513
// Validate the id value
524
514
if (id >= CORR_NUM)
525
515
{
526
- systemPrintf (" ERROR: correctionLastSeen invalid correction id value %d, valid range (0 - %d)!\r\n " , id, CORR_NUM - 1 );
516
+ systemPrintf (" ERROR: correctionLastSeen invalid correction id value %d, valid range (0 - %d)!\r\n " , id,
517
+ CORR_NUM - 1 );
527
518
return false ;
528
519
}
529
520
@@ -598,6 +589,15 @@ void correctionUpdateSource()
598
589
599
590
for (id = 0 ; id < CORR_NUM; id++)
600
591
correctionPriorityUpdateSource (id, settings.correctionsSourcesPriority [id]);
592
+
593
+ // Display the current correction source
594
+ if (PERIODIC_DISPLAY (PD_CORRECTION_SOURCE) && !inMainMenu)
595
+ {
596
+ PERIODIC_CLEAR (PD_CORRECTION_SOURCE);
597
+ systemPrintf (" Correction Source: %s\r\n " , correctionGetSourceName ());
598
+
599
+ // systemPrintf("%s\r\n", PERIODIC_SETTING(PD_RING_BUFFER_MILLIS) ? "Active" : "Inactive");
600
+ }
601
601
}
602
602
603
603
// ----------------------------------------
0 commit comments