-
Notifications
You must be signed in to change notification settings - Fork 0
/
soarMap.c
1333 lines (1202 loc) · 51.4 KB
/
soarMap.c
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
#include <PalmOS.h>
#include "soarMap.h"
#include "soarUMap.h"
#include "soaring.h"
#include "soarForm.h"
#include "soarUtil.h"
#include "soarMem.h"
#include "soarDB.h"
#include "soarTask.h"
#include "soarSUA.h"
#include "soarWind.h"
#include "soarWLst.h"
#include "soarSTF.h"
#include "soarMath.h"
#include "soarTer.h"
#include "soarWay.h"
//#define PRINT_FPS // Used to show drawing speed
Boolean updatemap = false;
double truecse;
// screen size & scale
double curmapscale = 20.0;
double actualmapscale = 20.0;
double savmapscale = 20.0;
double xdist, ydistul, ydistll;
double ulRng, llRng;
double xratio, yratio, bigratio;
double mapmaxlat, mapmaxlon;
double mapminlat, mapminlon;
Int16 TextOff = 0;
Boolean firsttime = true;
// map modes
UInt8 mapmode = CRUISE;
Boolean draw_log = false;
Boolean draw_task = false;
Boolean IsMap = false;
// externals
extern IndexedColorType indexGreen, indexRed, indexSector, indexBlack, indexTask;
extern double bigratio;
extern Int16 activetskway;
extern Int16 selectedTaskWayIdx;
extern Int16 selectedFltindex;
extern Int16 profilemaxalt;
extern Int16 profileminalt;
extern WindProfileType *windprofile;
extern double profilestep;
extern Boolean recv_data;
extern double MCCurVal;
extern Boolean taskonhold;
extern Boolean reachedwayppoint;
extern Int32 SUAdrawclasses;
extern TaskData *edittsk;
extern double MCMult;
extern Char timeinfo[15];
extern double calcstfhwind;
extern Boolean taskpreview;
// external variables for terrain
extern Boolean terrainpresent;
extern Boolean terrainvalid;
extern Boolean offterrain;
extern Boolean tskoffterrain;
extern Boolean crash;
extern double crashalt;
extern double crashlat;
extern double crashlon;
extern Boolean crash1;
extern double crashalt1;
extern double crashlat1;
extern double crashlon1;
extern Boolean wptcrash;
extern double wptcrashalt;
extern double wptcrashlat;
extern double wptcrashlon;
extern double *wptterheights;
extern Int32 numwptter;
extern Int32 prevnumwptter;
extern double prevterbear;
extern Boolean tskcrash;
extern double tskcrashalt;
extern double tskcrashlat;
extern double tskcrashlon;
extern double *tskterheights;
extern Int32 numtskter;
extern Int32 prevnumtskter;
// functions
void UpdateMap2(Boolean cleanup, double gliderLat, double gliderLon, double mapscale, Boolean ismap, TaskData *tsk, Boolean gliderpos)
{
static double scale;
double poirange, poibearing;
double WaySTF;
double startalt;
Char tempchar[20];
Int16 plotX, plotY;
static WinHandle winH, activeWinH;
UInt16 errW;
MemHandle output_hand;
MemPtr output_ptr;
RectangleType rectP;
Boolean plotgood;
Boolean leftturn;
Char text[30];
double tmpstf, tmpalt;
double maxdist;
double tmpdbl=0.0;
double fgatpdist=0.0, fgatpbear=0.0;
double fgatpalt1=0.0;
double fgatpalt2=0.0;
double firstaltloss;
double secondaltloss;
Int8 fieldadj;
double boldline = 1.0;
Int16 TOff;
FlightData *fltdata;
LoggerData *logdata;
UInt32 recindex;
double pointlat, pointlon;
Int16 prevplotX = -1, prevplotY = -1;
Boolean prevplotgood = false;
Boolean firstpoint;
Int8 i, lftprec;
Char fgotchar[10];
Int16 WfgplotX, WfgplotY;
Int16 TfgplotX, TfgplotY;
double refRng, refBrg;
Int16 posX, posY;
double ld;
double temprng, tempbrg;
Boolean centerglider;
#ifdef PRINT_FPS
UInt32 t=0;
UInt32 old_t=0;
Int32 fps;
#endif
// HostTraceOutputTL(appErrorClass, "Updatemap - Begin");
IsMap = ismap;
startalt = data.input.inusealt;
// Calculate the altitude required for the current distance to the waypoint
if (data.config.inrngcalc) {
// HostTraceOutputTL(appErrorClass, "Using Accurate Calculations");
CalcSTFSpdAlt2(0, 1.0, RecipCse(data.input.wnddir), &tmpstf, &tmpalt);
} else {
// HostTraceOutputTL(appErrorClass, "Using Less Accurate Calculations");
CalcSTFSpdAlt2(0, 1.0, data.input.magnetic_track.value, &tmpstf, &tmpalt);
}
// HostTraceOutputTL(appErrorClass, "tmpalt1=|%s|", DblToStr(tmpalt, 1));
maxdist = (startalt-data.config.safealt) / tmpalt;
// HostTraceOutputTL(appErrorClass, "maxdist=|%s|", DblToStr(maxdist, 1));
if (device.HiDensityScrPresent) {
WinSetCoordinateSystem(device.HiDensityScrPresent);
}
if (cleanup) {
if (winH) {
WinDeleteWindow(winH, true);
}
return;
}
if (device.DIACapable ) {
TextOff = 46*SCREEN.SRES;
} else {
TextOff = 0;
}
#ifdef PRINT_FPS
old_t = TimGetTicks();
#endif
if (firsttime) {
if (device.DIACapable) {
// This is large enough to cover the entire screen on an iQue
// When the screen copying is down down further, it copies different amounts depending
// on whether this is the normal map or the waypoint sector screen
winH = WinCreateOffscreenWindow(SCREEN.WIDTH, SCREEN.HEIGHT+TextOff+40, nativeFormat, &errW);
} else {
winH = WinCreateOffscreenWindow(SCREEN.WIDTH, SCREEN.HEIGHT, nativeFormat, &errW);
}
DrawGlider(data.input.curmaporient, SCREEN.GLIDERX, SCREEN.GLIDERY);
switch (data.config.lftunits) {
case STATUTE:
// fpm
MCMult = 100;
break;
case NAUTICAL:
// kts
MCMult = 1;
break;
case METRIC:
// m/s
MCMult = 0.5;
break;
default:
break;
}
firsttime = false;
}
/* Set Drawing Window to Offscreen Window */
activeWinH = WinSetDrawWindow(winH);
WinEraseWindow();
if (scale != mapscale && mapscale > 0.0) {
scale = mapscale;
/* Find Range to both corners of the screen */
// HostTraceOutputTL(appErrorClass, "scale =|%s|", DblToStr(scale, 2));
// HostTraceOutputTL(appErrorClass, "X =|%s|", DblToStr(SCREEN.GLIDERX, 2));
// HostTraceOutputTL(appErrorClass, "Y =|%s|", DblToStr(SCREEN.GLIDERY, 2));
xdist = PixelToDist(scale, (double)SCREEN.GLIDERX);
ydistul = PixelToDist(scale, (double)SCREEN.GLIDERY);
ydistll = PixelToDist(scale, (double)(SCREEN.HEIGHT - SCREEN.GLIDERY));
// HostTraceOutputTL(appErrorClass, "X dis=|%s|", DblToStr(xdist, 2));
// HostTraceOutputTL(appErrorClass, "YU dis=|%s|", DblToStr(ydistul, 2));
// HostTraceOutputTL(appErrorClass, "YL dis=|%s|", DblToStr(ydistll, 2));
ulRng = XYDistToRng(xdist, ydistul);
llRng = XYDistToRng(xdist, ydistll);
// HostTraceOutputTL(appErrorClass, "ulRng =|%s|", DblToStr(ulRng, 2));
// HostTraceOutputTL(appErrorClass, "llRng =|%s|", DblToStr(llRng, 2));
xratio = (double)SCREEN.GLIDERX / (scale * ((double)SCREEN.GLIDERX / (double)SCREEN.WIDTH));
yratio = (double)SCREEN.GLIDERY / (scale * ((double)SCREEN.GLIDERY / (double)SCREEN.HEIGHT));
// used to avoid Int16 overflow in calcplotvalues
if (xratio > yratio) {
bigratio = xratio;
} else {
bigratio = yratio;
}
}
// force orientation to North Up for flight log display
// and set task data to task in flight log
if (draw_log) {
if (!draw_task) {
data.input.curmaporient = NORTHUP;
// get flight record
AllocMem((void *)&fltdata, sizeof(FlightData));
OpenDBQueryRecord(flight_db, selectedFltindex, &output_hand, &output_ptr);
MemMove(fltdata,output_ptr,sizeof(FlightData));
MemHandleUnlock(output_hand);
tsk = &fltdata->flttask;
} else if (!taskpreview) {
data.input.curmaporient = NORTHUP;
} else if (data.input.curmaporient == COURSEUP) data.input.curmaporient = TRACKUP;
}
// find true course
if (data.input.curmaporient == TRACKUP) {
truecse = data.input.true_track.value;
} else if ((data.input.curmaporient == COURSEUP) && (data.input.bearing_to_destination.valid==VALID)) {
truecse = nice_brg(data.input.bearing_to_destination.value - data.input.deviation.value);
} else {
truecse = nice_brg(-data.input.deviation.value);
}
// glider position towards bottom of screen
centerglider = false;
SCREEN.GLIDERY = 100*SCREEN.SRES;
// select to center glider on screen or not
if (ismap && !draw_log && ((mapmode == THERMAL) || (data.input.curmaporient != TRACKUP))) {
// if (ismap && !draw_log && (mapmode == THERMAL)) {
// move glider to center of screen
if (!device.DIACapable || data.config.btmlabels) {
SCREEN.GLIDERY = (device.DIACapable?80:(70+(data.config.btmlabels?0:10)))*SCREEN.SRES;
centerglider = true;
}
}
// initialise max/min lat/lon
mapmaxlat = -90.0;
mapminlat = 90.0;
mapmaxlon = -180.0;
mapminlon = 180.0;
// find lat/lon of corners of screen
poirange = PixelToDist(scale, SCREEN.TOPCORNER * SCREEN.SRES);
poibearing = SCREEN.TOPANGLE;
// top right
RangeBearingToLatLonLinearInterp(gliderLat, gliderLon, poirange, nice_brg(truecse+poibearing), &pointlat, &pointlon);
if (pointlat > mapmaxlat) mapmaxlat = pointlat;
if (pointlat < mapminlat) mapminlat = pointlat;
if (pointlon > mapmaxlon) mapmaxlon = pointlon;
if (pointlon < mapminlon) mapminlon = pointlon;
// top left
RangeBearingToLatLonLinearInterp(gliderLat, gliderLon, poirange, nice_brg(truecse-poibearing), &pointlat, &pointlon);
if (pointlat > mapmaxlat) mapmaxlat = pointlat;
if (pointlat < mapminlat) mapminlat = pointlat;
if (pointlon > mapmaxlon) mapmaxlon = pointlon;
if (pointlon < mapminlon) mapminlon = pointlon;
// check for bottom labels and DIA capable Palm
if (!draw_log && ismap && data.config.btmlabels && !centerglider) {
poirange = PixelToDist(scale, SCREEN.BOTTOMCORNERLBL * SCREEN.SRES);
poibearing = SCREEN.BOTTOMANGLELBL;
} else {
poirange = PixelToDist(scale, SCREEN.BOTTOMCORNER * SCREEN.SRES);
poibearing = SCREEN.BOTTOMANGLE;
}
// bottom right
RangeBearingToLatLonLinearInterp(gliderLat, gliderLon, poirange, nice_brg(truecse+poibearing), &pointlat, &pointlon);
if (pointlat > mapmaxlat) mapmaxlat = pointlat;
if (pointlat < mapminlat) mapminlat = pointlat;
if (pointlon > mapmaxlon) mapmaxlon = pointlon;
if (pointlon < mapminlon) mapminlon = pointlon;
// bottom left
RangeBearingToLatLonLinearInterp(gliderLat, gliderLon, poirange, nice_brg(truecse-poibearing), &pointlat, &pointlon);
if (pointlat > mapmaxlat) mapmaxlat = pointlat;
if (pointlat < mapminlat) mapminlat = pointlat;
if (pointlon > mapmaxlon) mapmaxlon = pointlon;
if (pointlon < mapminlon) mapminlon = pointlon;
// HostTraceOutputTL(appErrorClass, "Max Lat %s", DblToStr(mapmaxlat,2));
// HostTraceOutputTL(appErrorClass, "Min Lat %s", DblToStr(mapminlat,2));
// HostTraceOutputTL(appErrorClass, "Max Lon %s", DblToStr(mapmaxlon,2));
// HostTraceOutputTL(appErrorClass, "Min Lon %s", DblToStr(mapminlon,2));
// Draw the two range circles if active
if (!draw_log && ismap && (data.config.mapcircrad1 > 0.0)) {
// Draw the first map range circle
WinDrawCircle(SCREEN.GLIDERX, SCREEN.GLIDERY, (Int32)(data.config.mapcircrad1*xratio), DASHED);
}
if (!draw_log && ismap && (data.config.mapcircrad2 > 0.0)) {
// Draw the second map range circle
WinDrawCircle(SCREEN.GLIDERX, SCREEN.GLIDERY, (Int32)(data.config.mapcircrad2*xratio), DASHED);
}
// Draw Terrain Coverage Box
firstpoint = true;
if (data.input.showterbox) {
for (i=0; i<5; i++) {
if (i == 4 ) {
// Gotta do this to draw the last line back to the
// original point
GetTerrainBounds(&pointlat, &pointlon, 0);
} else {
GetTerrainBounds(&pointlat, &pointlon, i);
}
plotgood = CalcPlotValues(gliderLat, gliderLon, pointlat, pointlon, xratio, yratio,
&plotX, &plotY, &poirange, &poibearing, FORCEACTUAL, data.input.curmaporient, false);
// lines
if (firstpoint) {
firstpoint = false;
} else if (plotgood && prevplotgood) {
WinDrawClippedLine(prevplotX, prevplotY, plotX, plotY, SOLID);
}
prevplotX = plotX;
prevplotY = plotY;
prevplotgood = plotgood;
}
}
// Draw SUA Data
if (data.config.suaactivetypes && SUAdrawclasses && ((ismap && ((mapmode == CRUISE) || data.config.keepSUA)) || (!ismap && data.config.keepSUA))) {
DrawSUA(gliderLat, gliderLon, xratio, yratio, ulRng);
}
// Draw Waypoints
if (data.config.wayonoff && ((mapmode == CRUISE) || (device.romVersion >= SYS_VER_50))) {
draw_waypoints(gliderLat, gliderLon, mapscale, maxdist, gliderpos);
}
// Draw max and min points for area waypoints
if (!ismap && (tsk->waypttypes[selectedTaskWayIdx] & AREA)) {
// plot min point
// CalcAreaMin(tsk, selectedTaskWayIdx, &minlat, &minlon, true);
plotgood = CalcPlotValues(gliderLat, gliderLon, data.input.areaminlat, data.input.areaminlon, xratio, yratio,
&plotX, &plotY, &poirange, &poibearing, NOFORCE, data.input.curmaporient, false);
if (plotgood) DrawPOI(plotX, plotY, "Min", (SCREEN.SRES*3), 3, false, false, TURN, false, mapscale, false, false, false);
// plot max point
// CalcAreaMax(tsk, selectedTaskWayIdx, &maxlat, &maxlon, true);
plotgood = CalcPlotValues(gliderLat, gliderLon, data.input.areamaxlat, data.input.areamaxlon, xratio, yratio,
&plotX, &plotY, &poirange, &poibearing, NOFORCE, data.input.curmaporient, false);
if (plotgood) DrawPOI(plotX, plotY, "Max", (SCREEN.SRES*3), 3, false, false, TURN, false, mapscale, false, false, false);
}
// Draw the track trail
if (!draw_log && ismap && (data.config.trktrail)) {
DrawTrkTrail(gliderLat, gliderLon, xratio, yratio, ulRng);
}
// Draw Final Glide Over Terrain info
if (!draw_log && ismap) {
// plot terrain crashes
// predicted landing point
if (crash1) {
// predicted (crash) landing point
plotgood = CalcPlotValues(gliderLat, gliderLon, crashlat1, crashlon1, xratio, yratio,
&WfgplotX, &WfgplotY, &poirange, &poibearing, NOFORCE, data.input.curmaporient, false);
if (plotgood) {
// HostTraceOutputTL(appErrorClass, "Plotting 1st Terrain Crash");
StrCopy(fgotchar, " ");
DrawPOI(WfgplotX, WfgplotY, fgotchar, (SCREEN.SRES*3), 0, false, true, CRASH, true, mapscale, false, false, false);
}
}
// inusewaypt
if (wptcrash) {
// HostTraceOutputTL(appErrorClass, "Plot Inusewaypt Terrain Crash");
// worst crash point
plotgood = CalcPlotValues(gliderLat, gliderLon, wptcrashlat, wptcrashlon, xratio, yratio,
&WfgplotX, &WfgplotY, &poirange, &poibearing, NOFORCE, data.input.curmaporient, false);
if (plotgood) {
// HostTraceOutputTL(appErrorClass, "Plotting Worst Waypoint Terrain Crash %s", print_altitude(wptcrashalt));
StrCopy(fgotchar, print_altitude(wptcrashalt));
DrawPOI(WfgplotX, WfgplotY, fgotchar, (SCREEN.SRES*3), StrLen(fgotchar), false, true, TERRAIN, true, mapscale, false, false, false);
}
}
// task
if (tskcrash) {
// HostTraceOutputTL(appErrorClass, "Plot Task Terrain Crash");
// worst taskcrash point
plotgood = CalcPlotValues(gliderLat, gliderLon, tskcrashlat, tskcrashlon, xratio, yratio,
&TfgplotX, &TfgplotY, &poirange, &poibearing, NOFORCE, data.input.curmaporient, false);
if (plotgood) {
// HostTraceOutputTL(appErrorClass, "Plotting Worst Task Terrain Crash %s", print_altitude(tskcrashalt));
StrCopy(fgotchar, print_altitude(tskcrashalt));
DrawPOI(TfgplotX, TfgplotY, fgotchar, (SCREEN.SRES*3), StrLen(fgotchar), false, true, TERRAIN, true, mapscale, false, false, false);
}
}
}
// Draw the active task
if (data.config.taskonoff || !ismap) {
if (!draw_task) {
DrawTask(gliderLat, gliderLon, xratio, yratio, ulRng, maxdist, startalt, tsk, scale, ismap);
} else {
DrawTask(gliderLat, gliderLon, xratio, yratio, ulRng, maxdist, startalt, edittsk, scale, ismap);
}
}
// Draw the waypoint line on moving map screen
// Placed here so that I can blank the bottom of the screen
// where the text goes.
if (!draw_log) {
if(ismap && (data.input.bearing_to_destination.valid==VALID)) {
// CalcPlotValues returns bearing in magnetic
plotgood = CalcPlotValues(gliderLat, gliderLon, data.input.destination_lat, data.input.destination_lon, xratio, yratio,
&plotX, &plotY, &poirange, &poibearing, FORCEACTUAL, data.input.curmaporient, true);
if (!taskonhold && (activetskway >= 0)) {
// take task waypoint if task active
plotgood = CalcPlotValues(gliderLat, gliderLon, data.task.targetlats[activetskway], data.task.targetlons[activetskway], xratio, yratio,
&posX, &posY, &temprng, &tempbrg, FORCEACTUAL, data.input.curmaporient, true);
} else {
// inuseWaypoint position
posX = plotX;
posY = plotY;
}
// This is for determining if the selected waypoint gets drawn in Bold/Green or
// Regular/Red.
// HostTraceOutputTL(appErrorClass, "wayline-poirange=|%s|", DblToStr(poirange, 1));
// HostTraceOutputTL(appErrorClass, "wayline-maxdist=|%s|", DblToStr(maxdist, 1));
// using firstaltloss here to be used in the FGA calculations later
CalcSTFSpdAlt2(MCCurVal, poirange, poibearing, &WaySTF, &firstaltloss);
data.input.destination_aalt = ConvertAltType(data.input.destination_elev, startalt, true, REQALT, firstaltloss);
// HostTraceOutputTL(appErrorClass, "wayline-WaySTF=|%s|", DblToStr(WaySTF, 1));
// HostTraceOutputTL(appErrorClass, "wayline-firstaltloss=|%s|", DblToStr(firstaltloss, 1));
// HostTraceOutputTL(appErrorClass, "wayline-data.input.destination_aalt=|%s|", DblToStr(data.input.destination_aalt, 1));
// HostTraceOutputTL(appErrorClass, "wayline-startalt=|%s|", DblToStr(startalt, 1));
// draw destination symbol and name
if ((data.input.destination_type & AREA) == 0) {
if (data.input.destination_aalt <= startalt) {
DrawPOI(posX, posY, data.input.destination_name, (SCREEN.SRES*3), data.config.waymaxlen, true, true, data.input.destination_type, true, mapscale,
(data.input.destination_type & AIRPORT), (data.input.destination_type & AIRLAND), (data.input.destination_aalt+data.config.safealt > startalt));
} else {
DrawPOI(posX, posY, data.input.destination_name, (SCREEN.SRES*3), data.config.waymaxlen, false, true, data.input.destination_type, true, mapscale, false, false, false);
}
}
// If this is just a single selected waypoint, draw a circle around it
// at the same radius as the circle radius for a task turnpoint
if ((tsk->numwaypts <= 0) || (taskonhold) || (!data.config.taskonoff)) {
// set to colour for sectors
if (device.colorCapable) {
WinSetForeColor(indexSector);
}
// check for bold line
if (device.HiDensityScrPresent && data.config.BoldSector) {
WinSetCoordinateSystem(kCoordinatesStandard);
boldline = SCREEN.SRES;
}
//Check the truncating here and do some rounding instead
WinDrawCircle(plotX/boldline, plotY/boldline, (Int32)(data.config.turncircrad*xratio)/boldline, SOLID);
// reset colour to black and normal lines
if (device.colorCapable) {
WinSetForeColor(indexBlack);
}
if (device.HiDensityScrPresent) {
WinSetCoordinateSystem(device.HiDensityScrPresent);
boldline = 1.0;
}
}
// Draw the In Use Waypoint direction
RctSetRectangle (&rectP, WIDTH_MIN, HEIGHT_MIN, (SCREEN.SRES*25), (SCREEN.SRES*14));
WinEraseRectangle(&rectP, 0);
FntSetFont(largeBoldFont);
StrCopy(tempchar, print_direction2(poibearing));
StrCat(tempchar, "°");
WinDrawChars(tempchar, StrLen(tempchar), WIDTH_MIN+(SCREEN.SRES*1), HEIGHT_MIN);
// Draw the In Use Waypoint distance
RctSetRectangle (&rectP, SCREEN.WIDTH-(SCREEN.SRES*22), HEIGHT_MIN, (SCREEN.SRES*22), (SCREEN.SRES*14));
WinEraseRectangle(&rectP, 0);
if ((poirange*data.input.disconst) < 10.0) {
StrCopy(tempchar, print_distance2(poirange, 2));
} else if ((poirange*data.input.disconst) < 100.0) {
StrCopy(tempchar, print_distance2(poirange, 1));
} else if ((poirange*data.input.disconst) < 1000.0) {
StrCopy(tempchar, print_distance2(poirange, 0));
} else {
StrCopy(tempchar, "999");
}
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH-(SCREEN.SRES*21), HEIGHT_MIN);
// Draw the turn direction arrows
tmpdbl = data.input.magnetic_track.value - poibearing;
if (tmpdbl < 0.0) {
tmpdbl = 360.0 + tmpdbl;
}
if (tmpdbl < 180.0) {
leftturn = true;
} else {
leftturn = false;
tmpdbl = 360.0 - tmpdbl;
}
FntSetFont(symbol11Font);
if (tmpdbl > 10.0) {
if (leftturn) {
WinDrawChars("\002\002", 2, WIDTH_MIN+(SCREEN.SRES*1), HEIGHT_MIN+(SCREEN.SRES*13));
} else {
WinDrawChars("\003\003", 2, WIDTH_MIN+(SCREEN.SRES*1), HEIGHT_MIN+(SCREEN.SRES*13));
}
} else if (tmpdbl > 5.0) {
if (leftturn) {
WinDrawChars("\002", 1, WIDTH_MIN+(SCREEN.SRES*5), HEIGHT_MIN+(SCREEN.SRES*13));
} else {
WinDrawChars("\003", 1, WIDTH_MIN+(SCREEN.SRES*5), HEIGHT_MIN+(SCREEN.SRES*13));
}
}
FntSetFont(stdFont);
} else {
// Draw the manual distance
poirange = data.input.distance_to_destination.value;
FntSetFont(largeBoldFont);
RctSetRectangle (&rectP, SCREEN.WIDTH-(SCREEN.SRES*22), HEIGHT_MIN, (SCREEN.SRES*22), (SCREEN.SRES*14));
WinEraseRectangle(&rectP, 0);
if ((poirange*data.input.disconst) < 10.0) {
StrCopy(tempchar, print_distance2(poirange, 2));
} else if ((poirange*data.input.disconst) < 100.0) {
StrCopy(tempchar, print_distance2(poirange, 1));
} else if ((poirange*data.input.disconst) < 1000.0) {
StrCopy(tempchar, print_distance2(poirange, 0));
} else {
StrCopy(tempchar, "999");
}
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH-(SCREEN.SRES*21), HEIGHT_MIN);
FntSetFont(stdFont);
}
}
// Draw the next waypoint point bearing and distance if valid and meets criteria
if (!draw_log && ismap && (((data.config.shownextwpt == NEXTALL) || ((data.config.shownextwpt == NEXTCTL) && data.input.isctlpt)) && (data.input.nextwpt_dist >= 0.0))) {
FntSetFont(stdFont);
// bearing
StrCopy(tempchar, print_direction2(data.input.nextwpt_bear));
StrCat(tempchar, "°");
WinDrawChars(tempchar, StrLen(tempchar), WIDTH_MIN+(SCREEN.SRES*25), HEIGHT_MIN+(SCREEN.SRES*3));
// label
if (StrLen(data.input.nextwpt_text) == 3) { // only show for Max, Min and Ctl
WinDrawChars(data.input.nextwpt_text, StrLen(data.input.nextwpt_text), SCREEN.WIDTH-(SCREEN.SRES*18), HEIGHT_MIN+(SCREEN.SRES*12));
}
// distance
if ((data.input.nextwpt_dist*data.input.disconst) < 10.0) {
StrCopy(tempchar, print_distance2(data.input.nextwpt_dist, 2));
} else if ((data.input.nextwpt_dist*data.input.disconst) < 100.0) {
StrCopy(tempchar, print_distance2(data.input.nextwpt_dist, 1));
} else if ((data.input.nextwpt_dist*data.input.disconst) < 1000.0) {
StrCopy(tempchar, print_distance2(data.input.nextwpt_dist, 0));
} else {
StrCopy(tempchar, "999");
}
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH-(SCREEN.SRES*40), HEIGHT_MIN+(SCREEN.SRES*3));
FntSetFont(largeBoldFont);
}
// Draw the line to the inuse waypoint and name
if (!draw_log && (data.config.wayline) && (data.input.bearing_to_destination.valid==VALID)) {
DrawWayLine(plotX, plotY, gliderLat, gliderLon, xratio, yratio, ismap);
}
// Draw the reference point or current waypoint name on map screen
StrCopy(tempchar,"");
if (!draw_log && ismap) {
if ((data.input.refwpttype != REFNONE) && (data.input.refLat != INVALID_LAT_LON) && (data.input.refLon != INVALID_LAT_LON)) {
// display range and bearing from/to ref point
LatLonToRangeBearing(data.input.gpslatdbl, data.input.gpslngdbl, data.input.refLat, data.input.refLon, &refRng, &refBrg);
refBrg = nice_brg(refBrg + data.input.deviation.value);
StrCopy(tempchar, " ");
if (data.config.RefWptRadial) {
refBrg = RecipCse(refBrg);
StrCat(tempchar, print_direction2(refBrg));
StrCat(tempchar, "R");
} else {
StrCat(tempchar, print_direction2(refBrg));
StrCat(tempchar, "°");
}
if (pround(refRng*data.input.disconst,0) > 999.0) {
StrCat(tempchar, "999");
} else {
StrCat(tempchar, print_distance2(refRng,0));
}
StrCopy(tempchar, Right(tempchar,7));
} else {
// display current waypoint name
if ((StrLen(data.input.destination_name) == 0) || (StrCompare(data.input.destination_name, ",") == 0)) {
StrCopy(tempchar, "Not Selected");
} else {
StrCopy(tempchar, " ");
StrCat(tempchar, data.input.destination_name);
StrCat(tempchar, " ");
}
}
}
FntSetFont(stdFont);
if (StrLen(tempchar) > 0) {
if (!device.DIACapable) {
if (data.config.btmlabels) {
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH/2-FntCharsWidth(tempchar,StrLen(tempchar))/2, SCREEN.HEIGHT-(SCREEN.SRES*32));
} else {
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH/2-FntCharsWidth(tempchar,StrLen(tempchar))/2, SCREEN.HEIGHT-(SCREEN.SRES*10));
}
} else {
if (data.config.btmlabels) {
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH/2-FntCharsWidth(tempchar,StrLen(tempchar))/2, SCREEN.HEIGHT-(SCREEN.SRES*10));
} else {
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH/2-FntCharsWidth(tempchar,StrLen(tempchar))/2, SCREEN.HEIGHT+(SCREEN.SRES*36));
}
}
}
FntSetFont(largeBoldFont);
// Draw Wind Data
if (!draw_log && data.config.windarrow && ismap) {
DrawWind(SCREEN.GLIDERX, SCREEN.GLIDERY, xratio, yratio, scale);
}
// Draw thermal strength with height profile
if (!draw_log && data.config.thermalprofile && ismap && (mapmode == THERMAL)) {
DrawThermalProfile();
}
// if required show time to go to start opens, TOT info or temp waypoint
if (StrLen(timeinfo) > 0) {
StrCopy(timeinfo, trim(timeinfo, ' ', true));
WinDrawChars(timeinfo, StrLen(timeinfo), SCREEN.SRES*80-FntCharsWidth(timeinfo,StrLen(timeinfo))/2, 0);
}
/* Draw Bottom Labels */
// poirange and poibear must not change from above
if (!draw_log && ismap && (data.config.btmlabels)) {
// If drawing the bottom labels or the FG labels
// clears the area where the text goes
if (device.DIACapable) {
RctSetRectangle (&rectP, WIDTH_MIN+(SCREEN.SRES), SCREEN.HEIGHT-(SCREEN.SRES*45)+TextOff,SCREEN.WIDTH, SCREEN.SRES*45);
} else {
RctSetRectangle (&rectP, WIDTH_MIN+(SCREEN.SRES), SCREEN.HEIGHT-(SCREEN.SRES*22)+TextOff,SCREEN.WIDTH, SCREEN.SRES*22);
}
WinEraseRectangle(&rectP, 0);
// Clear the area for the MC (cruise) or TLft (thermal) value
if ((mapmode == THERMAL) && !device.DIACapable && (data.config.mapRHfield != MAPTLFT)) {
tmpdbl = pround(data.input.thavglift*data.input.lftconst, data.input.lftprec+1);
} else {
tmpdbl = pround(data.input.basemc*data.input.lftconst, data.input.lftprec+1);
}
StrCopy(tempchar, DblToStr(tmpdbl, data.input.lftprec));
fieldadj = 19;
if (StrLen(tempchar) > 3) {
fieldadj = fieldadj + 6;
}
if (!device.DIACapable) {
RctSetRectangle (&rectP, WIDTH_MIN, SCREEN.HEIGHT-(SCREEN.SRES*44)+TextOff, (SCREEN.SRES*fieldadj), (SCREEN.SRES*22));
WinEraseRectangle(&rectP, 0);
}
if ((mapmode == THERMAL) && !device.DIACapable && (data.config.mapRHfield != MAPTLFT)) {
StrCopy(text, "Tlft");
} else {
StrCopy(text, "MC: ");
}
FntSetFont(largeBoldFont);
WinDrawChars(tempchar, StrLen(tempchar), WIDTH_MIN+(SCREEN.SRES*1), SCREEN.HEIGHT-(SCREEN.SRES*35)+TextOff);
FntSetFont(stdFont);
WinDrawChars(text, StrLen(text), WIDTH_MIN+(SCREEN.SRES*1), SCREEN.HEIGHT-(SCREEN.SRES*44)+TextOff);
// calculate STF and arrival attide
if (data.input.destination_valid) {
CalcSTFSpdAlt2(MCCurVal, data.inuseWaypoint.distance, data.inuseWaypoint.bearing, &WaySTF, &tmpalt);
} else {
CalcSTFSpdAlt2(MCCurVal, data.input.distance_to_destination.value, data.input.magnetic_track.value, &WaySTF, &firstaltloss);
data.inuseWaypoint.elevation = 0.0;
data.input.destination_aalt = ConvertAltType(data.inuseWaypoint.elevation, startalt, true, REQALT, firstaltloss);;
}
// speed to fly or required ground speed value
FntSetFont(stdFont);
if (data.config.showrgs) {
StrCopy(text, "RGS");
WaySTF = WaySTF - calcstfhwind;
} else {
StrCopy(text, "STF");
}
WinDrawChars(text, StrLen(text), WIDTH_MIN+(SCREEN.SRES*46), SCREEN.HEIGHT-(SCREEN.SRES*22)+TextOff);
FntSetFont(largeBoldFont);
StrCopy(text, print_horizontal_speed2(WaySTF, 0));
WinDrawChars(text, StrLen(text), WIDTH_MIN+(SCREEN.SRES*46), SCREEN.HEIGHT-(SCREEN.SRES*13)+TextOff);
FntSetFont(stdFont);
// Veritcal Line to the left of the STF value
WinDrawLine(WIDTH_MIN+(SCREEN.SRES*44), SCREEN.HEIGHT-(SCREEN.SRES*22)+TextOff,
WIDTH_MIN+(SCREEN.SRES*44), SCREEN.HEIGHT+TextOff);
// Draw Vertical Line to the left of the Altitude
WinDrawLine(WIDTH_MIN+(SCREEN.SRES*65), SCREEN.HEIGHT-(SCREEN.SRES*22)+TextOff,
WIDTH_MIN+(SCREEN.SRES*65), SCREEN.HEIGHT+TextOff);
if (device.DIACapable) {
// Veritcal Line to the right of the MC value
WinDrawLine(WIDTH_MIN+(SCREEN.SRES*23), SCREEN.HEIGHT-(SCREEN.SRES*46)+TextOff,
WIDTH_MIN+(SCREEN.SRES*23), SCREEN.HEIGHT-(SCREEN.SRES*22)+TextOff);
// Veritcal Line to the left of the FGA value
WinDrawLine(WIDTH_MIN+(SCREEN.SRES*44), SCREEN.HEIGHT-(SCREEN.SRES*46)+TextOff,
WIDTH_MIN+(SCREEN.SRES*44), SCREEN.HEIGHT-(SCREEN.SRES*22)+TextOff);
// Setting the placment values for the above/below glideslope arrows
plotX = WIDTH_MIN+(SCREEN.SRES*24);
plotY = SCREEN.HEIGHT-(SCREEN.SRES*44)+TextOff;
} else {
// Setting the placment values for the above/below glideslope arrows
plotX = SCREEN.WIDTH-(SCREEN.SRES*20);
plotY = SCREEN.HEIGHT-(SCREEN.SRES*44)+TextOff;
}
// Clear the area for the D.Alt arrows or average LD or FGA
if (!device.DIACapable) {
RctSetRectangle (&rectP, SCREEN.WIDTH-(SCREEN.SRES*20), SCREEN.HEIGHT-(SCREEN.SRES*44)+TextOff, (SCREEN.SRES*20), (SCREEN.SRES*22));
WinEraseRectangle(&rectP, 0);
}
// Draw the average LD
FntSetFont(largeBoldFont);
if (device.DIACapable || (data.config.mapRHfield == MAPGLIDE)) {
if ((data.input.distdone != 0.0) && (data.input.avglift != 0.0)) {
ld = -data.input.distdone*2*60 / data.input.avglift; // assuming 30 sec average
lftprec = 0;
if (ld < -99) ld = -99;
if (ld > 199) ld = 199;
if ((ld > 0) && (ld < 10)) lftprec = 1;
StrCopy(tempchar, DblToStr(ld, lftprec));
WinDrawChars(tempchar, StrLen(tempchar), plotX+(SCREEN.SRES*2), plotY+(SCREEN.SRES*9));
} else {
WinDrawChars("XX", 2, plotX+(SCREEN.SRES*2), plotY+(SCREEN.SRES*9));
}
}
// Draw the D.ALT Arrows
FntSetFont(symbolFont);
if (device.DIACapable || (data.config.mapRHfield == MAPGLIDE)) {
tmpdbl = ConvertAltType(data.inuseWaypoint.elevation, startalt, true, ARVALT, firstaltloss);
if (tmpdbl > (2.0*data.config.safealt)) {
WinDrawChars("\005\005", 2, plotX, plotY);
} else if (tmpdbl >= data.config.safealt && tmpdbl <= (2.0*data.config.safealt)) {
WinDrawChars("\005", 1, plotX, plotY);
} else if (tmpdbl < data.config.safealt && tmpdbl >= 0.0) {
WinDrawChars("\006", 1, plotX, plotY);
} else if (tmpdbl < 0.0) {
WinDrawChars("\006\006", 2, plotX, plotY);
}
}
// Have to save this to fgatpalt1 since data.input.destination_aalt could change below
fgatpalt1 = data.input.destination_aalt;
// Only need to call this if in mode other than REQALT since it is calculated above.
if (data.config.alttype != REQALT) {
data.input.destination_aalt = ConvertAltType(data.inuseWaypoint.elevation, startalt, true, data.config.alttype, firstaltloss);
}
// convert the displayed altitudes taking into account the terrain clearance
tmpalt = data.input.destination_aalt;
// HostTraceOutputTL(appErrorClass, "In Use Alt %s", DblToStr(tmpalt*ALTMETCONST,0));
// HostTraceOutputTL(appErrorClass, "Wpt Crash Alt %s", DblToStr(wptcrashalt*ALTMETCONST,0));
switch (data.config.alttype) {
case REQALT:
StrCopy(text, "RAlt");
if (wptcrash && !offterrain) {
tmpalt = startalt - wptcrashalt;
}
break;
case ARVALT:
StrCopy(text, "AAlt");
if (wptcrash && !offterrain) {
// if crash is more than safety height, adjust AAlt figure
if (wptcrashalt + data.config.safealt < 0) {
tmpalt = wptcrashalt + data.config.safealt;
}
}
break;
case DLTALT:
StrCopy(text, "DAlt");
if (wptcrash && !offterrain) {
tmpalt = wptcrashalt;
}
break;
default:
break;
}
// display the altitude
FntSetFont(stdFont);
WinDrawChars(text, StrLen(text), WIDTH_MIN+(SCREEN.SRES*67), SCREEN.HEIGHT-(SCREEN.SRES*22)+TextOff);
FntSetFont(largeBoldFont);
if (tmpalt >= 99999.5) {
StrCopy(text, "99999");
} else if (tmpalt <= -99999.5) {
StrCopy(text, "-99999");
} else {
StrCopy(text, print_altitude(tmpalt));
}
WinDrawChars(text, StrLen(text), WIDTH_MIN+(SCREEN.SRES*67), SCREEN.HEIGHT-(SCREEN.SRES*13)+TextOff);
FntSetFont(stdFont);
if (data.input.destination_valid) {
if (device.DIACapable || (data.config.mapRHfield == MAPFGA)) {
// Find the STF altitude from current waypoint to:
// The Finish Point if a task is active or
// The HOME waypoint if no task is active
if (tsk->numwaypts > 0) {
// get FGA altitude
fgatpalt2 = data.input.FGAdispalt;
} else {
// HostTraceOutputTL(appErrorClass, "Inside GOTO Waypoint FGA Case");
// Setting fgatpalt2 to fgatpalt1 to cover the case where
// the current waypoint/turnpoint is the HOME/Finish waypoint/turnpoint
tskcrash = false;
if (data.config.alttype == REQALT) {
fgatpalt2 = fgatpalt1;
} else {
fgatpalt2 = ConvertAltType(data.input.destination_elev, startalt, true, data.config.alttype, firstaltloss);
}
if (data.input.destination_lat != data.input.homeLat || data.input.destination_lon != data.input.homeLon) {
LatLonToRangeBearing(data.input.destination_lat, data.input.destination_lon, data.input.homeLat, data.input.homeLon, &fgatpdist, &fgatpbear);
// Convert to Magnetic
fgatpbear = nice_brg(fgatpbear + data.input.deviation.value);
// CalcSTFSpdAlt expects the first parameter to be in knots
CalcSTFSpdAlt2(MCCurVal, fgatpdist, fgatpbear, &WaySTF, &secondaltloss);
fgatpalt2 = ConvertAltType(data.input.homeElev, startalt, true, REQALT, (firstaltloss+secondaltloss));
if (data.config.alttype != REQALT) {
fgatpalt2 = ConvertAltType(data.input.homeElev, startalt, true, data.config.alttype, (firstaltloss+secondaltloss));
}
}
}
tmpalt = fgatpalt2;
// display the result
if (tmpalt >= 99999.5) {
StrCopy(text, "99999");
} else if (tmpalt <= -99999.5) {
StrCopy(text, "-99999");
} else {
StrCopy(text, print_altitude(tmpalt));
}
FntSetFont(stdFont);
if (device.DIACapable) {
WinDrawChars("FGA:", 4, WIDTH_MIN+(SCREEN.SRES*46), SCREEN.HEIGHT-(SCREEN.SRES*44)+TextOff);
FntSetFont(largeBoldFont);
WinDrawChars(text, StrLen(text), WIDTH_MIN+(SCREEN.SRES*46), SCREEN.HEIGHT-(SCREEN.SRES*35)+TextOff);
// Draw Vertical Line to the left of the Altitude
// Drawn here to fix problem where the line isn't getting drawn all the way to
// the top because the FGA value is masking it off.
WinDrawLine(WIDTH_MIN+(SCREEN.SRES*65), SCREEN.HEIGHT-(SCREEN.SRES*22)+TextOff,
WIDTH_MIN+(SCREEN.SRES*65), SCREEN.HEIGHT+TextOff);
} else if (data.config.mapRHfield == MAPFGA) {
WinDrawChars("FGA:", 4, SCREEN.WIDTH-(SCREEN.SRES*17), SCREEN.HEIGHT-(SCREEN.SRES*44)+TextOff);
FntSetFont(largeBoldFont);
WinDrawChars(text, StrLen(text), plotX+(SCREEN.SRES*(15-StrLen(text)*5)), plotY+(SCREEN.SRES*9));
}
}
}
// display course and speed
FntSetFont(stdFont);
StrCopy(tempchar, "Cse");
WinDrawChars(tempchar, StrLen(tempchar), WIDTH_MIN, SCREEN.HEIGHT-(SCREEN.SRES*22)+TextOff);
StrCopy(tempchar, "Spd");
WinDrawChars(tempchar, StrLen(tempchar), WIDTH_MIN+(SCREEN.SRES*25), SCREEN.HEIGHT-(SCREEN.SRES*22)+TextOff);
FntSetFont(largeBoldFont);
StrCopy(tempchar, print_direction(data.input.magnetic_track));
// StrCat(tempchar, "°");
WinDrawChars(tempchar, StrLen(tempchar), WIDTH_MIN, SCREEN.HEIGHT-(SCREEN.SRES*13)+TextOff);
StrCopy(tempchar, print_horizontal_speed(data.input.ground_speed));
WinDrawChars(tempchar, StrLen(tempchar), WIDTH_MIN+(SCREEN.SRES*25), SCREEN.HEIGHT-(SCREEN.SRES*13)+TextOff);
if (data.config.altreftype == AGL) {
if (terrainvalid) {
StrCopy(tempchar, print_altitude(data.input.inusealt-data.input.terelev));
} else {
StrCopy(tempchar, "N/A");
}
} else if (data.config.altreftype == QFE) {
StrCopy(tempchar, print_altitude(data.input.inusealt-data.config.qfealt));
} else if (data.config.altreftype == PALT) {
// FL always in ft
StrCopy(tempchar, DblToStr(pround(data.logger.pressalt,0),0));
} else {
StrCopy(tempchar, print_altitude(data.input.inusealt));
}
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH-(SCREEN.SRES*55), SCREEN.HEIGHT-(SCREEN.SRES*13)+TextOff);
// Placed this here to make the Q plot correctly
FntSetFont(stdFont);
switch ( data.config.altreftype ) {
case MSL:
StrCopy(tempchar, "MSL:");
StrCat(tempchar,data.input.alttext);
break;
case QFE:
StrCopy(tempchar, "QFE:");
StrCat(tempchar,data.input.alttext);
break;
case AGL:
StrCopy(tempchar, "AGL:");
StrCat(tempchar,data.input.alttext);
break;
case PALT:
// FL always in ft
StrCopy(tempchar, " FL:ft");
break;
default:
break;
}
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH-(SCREEN.SRES*55), SCREEN.HEIGHT-(SCREEN.SRES*22)+TextOff);
FntSetFont(largeBoldFont);
if (device.DIACapable) {
// This is for the Current Lift Value
lftprec = data.input.lftprec;
if ((data.input.lftprec == 2) && (data.input.curlift < 0.0)) lftprec = 1;
StrCopy(tempchar, DblToStr(pround(data.input.curlift*data.input.lftconst, lftprec), lftprec));
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH-(SCREEN.SRES*78), SCREEN.HEIGHT-(SCREEN.SRES*35)+TextOff);
// This is for the Average Lift Value
StrCopy(tempchar, DblToStr(pround(data.input.avglift*data.input.lftconst, data.input.lftprec), data.input.lftprec));
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH-(SCREEN.SRES*55), SCREEN.HEIGHT-(SCREEN.SRES*35)+TextOff);
// This is for the Thermal Average Lift Value
lftprec = data.input.lftprec;
if ((data.input.lftprec == 2) && (data.input.thavglift < 0)) lftprec = 1;
StrCopy(tempchar, DblToStr(pround(data.input.thavglift*data.input.lftconst, lftprec), lftprec));
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH-(SCREEN.SRES*23), SCREEN.HEIGHT-(SCREEN.SRES*35)+TextOff);
FntSetFont(stdFont);
StrCopy(tempchar, "Lft");
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH-(SCREEN.SRES*78), SCREEN.HEIGHT-(SCREEN.SRES*44)+TextOff);
StrCopy(tempchar, "Avg");
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH-(SCREEN.SRES*55), SCREEN.HEIGHT-(SCREEN.SRES*44)+TextOff);
StrCopy(tempchar, "Tlft");
WinDrawChars(tempchar, StrLen(tempchar), SCREEN.WIDTH-(SCREEN.SRES*23), SCREEN.HEIGHT-(SCREEN.SRES*44)+TextOff);