-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.lua
3730 lines (2758 loc) · 155 KB
/
main.lua
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
-- License https://www.gnu.org/licenses/gpl-3.0.en.html
-- OpenTX/EdgeTX Lua script
-- TELEMETRY
-- File Locations On The Transmitter's SD Card
-- This script file /SCRIPTS/WIDGETS/
-- Sound files /SCRIPTS/WIDGETS/TxBatTele/sounds/
-- Works On EdgeTX Companion Version: 2.10
-- Works With Sensor: FrSky FAS40S, FCS-150A, FAS100, FLVS Voltage Sensors
--
-- Author: Derelict
-- Date: 2024 June 27
-------------------------------------------------------------------------------------------------------------------------------------------------
local Title = "Flight Telemetry and Battery Monitor"
-------------------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
-- CONFIGURATION(S)
---------------------------------------------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------------------------
-- Switch State Voice Announcements (Settings/Variable) will/can be placed into a model definition later down below
----------------------------------------------------------------------------------------------------------------------
-- - first parameter is the switch name, what follows can be up to 3 voice announcements
-- - they have to be present on the sd card (default edgetx NOT in the widget folder)
-- - tested with 3-position switches currently
-- - if only one value is specified, the most "far" position of the switch will trigger the voice
-- - if two values are specified on a 3-position switch ... the announcements will be triggerd "up" and "down" but not middle
-- - just test it out ;-)
local SwitchAnnounceTable = {
{"sf","disarm","armed"},
{"sh","safeon"},
{"se","fm-nrm","fm-1","fm-2"}
}
----------------------------------------------------------------------------------------------------------------------
-- Bottom Sensors
----------------------------------------------------------------------------------------------------------------------
-- - You can define as "much" of Sensors as you like ... but please be aware ... if the screen bottom has been reached they will be ommited
-- - You can optionaly specify a condition to be evaluated to change the color ... for instance if a temperature has been to high change color to RED
-- - The less sensors you specify the more space you have per line (they will be distributed accross three lines maximum currently)
-- - these are only variable definitions and will be placed "into" the model down below ... you can choose any name for the variable for different scenarios and/or models and/or sensors per model
-- - do not change defaultAdlSensors ... because it is choosen as the default for the default model below ... unless ... of course ... you know what you are doing ;-)
-- - sensorname is the radio sensor name ... displayname can freely be choosen (but depending on number of sensors is more or less limited to 4 Chars maximum)
local defaultAdlSensors = {
--- first line
{ sensorName = "RPM+" , displayName = "RPM+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
{ sensorName = "RPM-" , displayName = "RPM-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "< 1200" , condColor = RED },
{ sensorName = "RxBt+" , displayName = "BEC+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "V" , cond = ">9" , condColor = RED },
{ sensorName = "RxBt-" , displayName = "BEC-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "V" , cond = "<6" , condColor = RED },
--- second line
{ sensorName = "RSSI+" , displayName = "RSI+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
{ sensorName = "RSSI-" , displayName = "RSI-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
{ sensorName = "Fuel+" , displayName = "HLD " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
{ sensorName = "Fuel-" , displayName = "TRS " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
--- third line
{ sensorName = "Tmp1+" , displayName = "TF+ " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">50" , condColor = RED },
{ sensorName = "Tmp1-" , displayName = "TF- " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">50" , condColor = RED },
{ sensorName = "Tmp2+" , displayName = "ET+ " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">50" , condColor = RED },
{ sensorName = "Tmp2-" , displayName = "ET- " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">50" , condColor = RED }
}
local sensg580 = { -- this is a real definition to my own model -- can be deleted together with the model below
--- first line
{ sensorName = "Erpm+" , displayName = "RPM+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
{ sensorName = "Erpm-" , displayName = "RPM-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "< 1500" , condColor = RED },
{ sensorName = "VBEC+" , displayName = "BEC+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "V" , cond = ">10" , condColor = RED },
{ sensorName = "VBEC-" , displayName = "BEC-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "V" , cond = "<7" , condColor = RED },
--- second line
{ sensorName = "FLss+" , displayName = "FLS " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = ">1" , condColor = RED },
{ sensorName = "FdeA+" , displayName = "FDE " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = ">1" , condColor = RED },
{ sensorName = "Hold+" , displayName = "HLD " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = ">1" , condColor = RED },
{ sensorName = "TRSS-" , displayName = "TRS " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
--- third line
{ sensorName = "TFET+" , displayName = "TF+ " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED },
{ sensorName = "TFET-" , displayName = "TF- " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED },
{ sensorName = "RB1T+" , displayName = "ET+ " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED },
{ sensorName = "RB1T-" , displayName = "ET- " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED }
}
local sensSimulator = { -- this is what i use for testing and development -- can be deleted together with the model below
--- first line
{ sensorName = "RPM+" , displayName = "RPM+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
{ sensorName = "RPM-" , displayName = "RPM-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "< 1500" , condColor = RED },
{ sensorName = "VFAS+" , displayName = "BAT+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "V" , cond = ">40" , condColor = RED },
{ sensorName = "VFAS-" , displayName = "BAT-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "V" , cond = "<7" , condColor = RED },
--- second line
{ sensorName = "Curr" , displayName = "CURR" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "A" , cond = "" , condColor = RED },
{ sensorName = "RSSI+" , displayName = "RSI+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
{ sensorName = "RSSI-" , displayName = "RSI-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
{ sensorName = "RPM-" , displayName = "RPM-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
--- third line
{ sensorName = "Tmp1+" , displayName = "TF+ " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED },
{ sensorName = "Tmp1-" , displayName = "TF- " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED },
{ sensorName = "Tmp2+" , displayName = "ET+ " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED },
{ sensorName = "Tmp2-" , displayName = "ET- " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED }
}
local senhwspek = { -- this is a real definition to my own model -- can be deleted together with the model below
--- first line
{ sensorName = "Erpm+" , displayName = "RPM+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
{ sensorName = "Erpm-" , displayName = "RPM-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "< 1500" , condColor = RED },
{ sensorName = "VBEC+" , displayName = "BEC+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "V" , cond = ">10" , condColor = RED },
{ sensorName = "VBEC-" , displayName = "BEC-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "V" , cond = "<7" , condColor = RED },
--- second line
{ sensorName = "FLss+" , displayName = "FLS " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = ">1" , condColor = RED },
{ sensorName = "FdeA+" , displayName = "FDE " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = ">1" , condColor = RED },
{ sensorName = "Hold+" , displayName = "HLD " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = ">1" , condColor = RED },
{ sensorName = "TRSS-" , displayName = "TRS " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
--- third line
{ sensorName = "TFET+" , displayName = "TF+ " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED },
{ sensorName = "TFET-" , displayName = "TF- " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED },
{ sensorName = "RB1T+" , displayName = "ET+ " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED },
{ sensorName = "RB1T-" , displayName = "ET- " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED }
}
local senhwelrs = { -- this is a real definition to my own model -- can be deleted together with the model below
--- first line
{ sensorName = "hspd+" , displayName = "RPM+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
{ sensorName = "hspd-" , displayName = "RPM-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "< 1500" , condColor = RED },
{ sensorName = "bec+" , displayName = "BEC+" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "V" , cond = ">10" , condColor = RED },
{ sensorName = "bec-" , displayName = "BEC-" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "V" , cond = "<7" , condColor = RED },
--- second line
{ sensorName = "1RSS-" , displayName = "1RS " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = ">1" , condColor = RED },
{ sensorName = "2RSS-" , displayName = "2RS " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = ">1" , condColor = RED },
{ sensorName = "RQly-" , displayName = "RQL " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = ">1" , condColor = RED },
{ sensorName = "RSNR-" , displayName = "SNR " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = "" , condColor = RED },
--- third line
{ sensorName = "esct+" , displayName = "ESC+ " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED },
{ sensorName = "esct-" , displayName = "ESC- " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED },
{ sensorName = "hspd" , displayName = "RPM" , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "" , cond = ">45" , condColor = GREEN },
--{ sensorName = "RB1T-" , displayName = "ET- " , prefix = "[" , suffix = "]" , displayNameColor = COLOR_THEME_SECONDARY2, prefixColor = BLUE, valueColor = GREEN , suffixColor = BLUE, unit = "°C" , cond = ">45" , condColor = RED }
}
----------------------------------------------------------------------------------------------------------------------
-- Battery / Powersource Definition
----------------------------------------------------------------------------------------------------------------------
-- - dischargeCurve : Well ... discharge Curve in steps of 2.5 ... can be nil ... in that case a linear curve will be created during runtime (based on lowVoltage and highVoltage)
-- - graceperiod : time in seconds that has to pass until a change of value is "valid" ... this has been implemented to not get voice announcements for short fluctuations in values
-- - criticalThreshold : Threshhold in Percent for the Battery/Powersource to be in a critical state (Percentage left measured by voltage currently)
-- - warningThreshold : Threshhold in Percent for the Battery/Powersource to be in a warning state (Percentage left measured by voltage currently)
-- - notFullCriticalThreshold : Threshhold in Percent for the Battery/Powersource to be in a critical state of not being full
-- - notFullWarningThreshold : Threshhold in Percent for the Battery/Powersource to be in a warning state of not being full
-- - announceNotFullCriticalMode : ONLY USED FOR PREFLIGHT CHECK -- this can be an integer ( which then announces the Battery NOT FULL Critical Threshold (above) state on a fixed interval ) or change ( only announce ONCE on a CHANGE ) or disable ( DO NOT Care and announce at all )
-- - announceNotFullWarningMode : ONLY USED FOR PREFLIGHT CHECK -- this can be an integer ( which then announces the Battery NOT FULL Warning Threshold (above) state on a fixed interval ) or change ( only announce ONCE on a CHANGE ) or disable ( DO NOT Care and announce at all )
-- - announceNormalMode : For Battery/Power Percentage left states: this can be an integer ( which then announces the NORMAL state (not warning and not critical) on a fixed interval ) or change ( only announce ONCE on a CHANGE ) or disable ( DO NOT Care and announce at all )
-- - announceWarningMode : For Battery/Power Percentage left states: this can be an integer ( which then announces the WARNING Threshold (above) on a fixed interval ) or change ( only announce ONCE on a CHANGE ) or disable ( DO NOT Care and announce at all )
-- - announceCriticalMode : For Battery/Power Percentage left states: this can be an integer ( which then announces the CRITICAL Threshold (above) on a fixed interval ) or change ( only announce ONCE on a CHANGE ) or disable ( DO NOT Care and announce at all )
-- - cellDeltaVoltage : Cell delta voltage "allowance" before getting alerted (see isNotABattery !!)
-- - highVoltage : Battery/Power Source maximum/normal high Voltage per Cell (see isNotABattery !!)
-- - lowVoltage : Battery/Power Source maximum low Voltage per Cell (see isNotABattery !!)
-- NOTE:
-- - there is not such a thing as "lowvoltage" if only using a bec ... if you loose your bec you will recognize it before we can announce anything ... so lets set this to anything below what is "normal" ... like 5
-- - isNotABattery : true or false .. here you specify if the Battery/Powersource is a real battery ( that has Cells ) or not ... DO NOT CHANGE TO FALSE if there is a real Battery involved !!!
-- NOTE:
-- - A buffer is not a battery and values for high and low voltage represent real voltages and will be devided by 2 by the script to get a theoretical cell value -- todo improve change in the future
-- - Just see comments and examples below
local powerSources = {
lipo = { -- normal lipo Battery
dischargeCurve = {
{4.20, 100}, {4.17, 97.5}, {4.15, 95}, {4.13, 92.5},
{4.11, 90}, {4.10, 87.5}, {4.08, 85}, {4.05, 82.5},
{4.02, 80}, {4.00, 77.5}, {3.98, 75}, {3.97, 72.5},
{3.95, 70}, {3.93, 67.5}, {3.91, 65}, {3.89, 62.5},
{3.87, 60}, {3.86, 57.5}, {3.85, 55}, {3.85, 52.5},
{3.84, 50}, {3.83, 47.5}, {3.82, 45}, {3.81, 42.5},
{3.80, 40}, {3.80, 37.5}, {3.79, 35}, {3.78, 32.5},
{3.77, 30}, {3.76, 27.5}, {3.75, 25}, {3.74, 22.5},
{3.73, 20}, {3.72, 17.5}, {3.71, 15}, {3.70, 12.5},
{3.69, 10}, {3.67, 7.5}, {3.61, 5}, {3.49, 2.5},
{3.27, 0}
},
-- dischargeCurveHighLoad = {
-- {4.10, 100}, {4.07, 97.5}, {4.05, 95}, {4.03, 92.5},
-- {4.00, 90}, {3.99, 87.5}, {3.97, 85}, {3.94, 82.5},
-- {3.91, 80}, {3.89, 77.5}, {3.87, 75}, {3.86, 72.5},
-- {3.84, 70}, {3.82, 67.5}, {3.80, 65}, {3.78, 62.5},
-- {3.76, 60}, {3.75, 57.5}, {3.74, 55}, {3.73, 52.5},
-- {3.72, 50}, {3.71, 47.5}, {3.70, 45}, {3.69, 42.5},
-- {3.68, 40}, {3.67, 37.5}, {3.66, 35}, {3.65, 32.5},
-- {3.64, 30}, {3.63, 27.5}, {3.62, 25}, {3.61, 22.5},
-- {3.60, 20}, {3.59, 17.5}, {3.58, 15}, {3.57, 12.5},
-- {3.56, 10}, {3.54, 7.5}, {3.48, 5}, {3.36, 2.5},
-- {3.15, 0}
-- },
dischargeCurveHighLoad = {
{4.08, 100}, {4.05, 97.5}, {4.03, 95}, {4.01, 92.5},
{3.99, 90}, {3.97, 87.5}, {3.95, 85}, {3.92, 82.5},
{3.90, 80}, {3.88, 77.5}, {3.86, 75}, {3.85, 72.5},
{3.83, 70}, {3.81, 67.5}, {3.79, 65}, {3.77, 62.5},
{3.75, 60}, {3.74, 57.5}, {3.73, 55}, {3.72, 52.5},
{3.71, 50}, {3.70, 47.5}, {3.69, 45}, {3.68, 42.5},
{3.67, 40}, {3.66, 37.5}, {3.64, 35}, {3.63, 32.5},
{3.62, 30}, {3.61, 27.5}, {3.60, 25}, {3.59, 22.5},
{3.58, 20}, {3.57, 17.5}, {3.56, 15}, {3.55, 12.5},
{3.54, 10}, {3.52, 7.5}, {3.48, 5}, {3.36, 2.5},
{3.15, 0}
},
typeName = "LiPo",
name = "Battery", -- will be used as suffix to the source name (see below), has to be present as wav or voice announce wont work
graceperiod = 4, -- grace period for fluctuations
-- criticalThreshold = 15, -- Critical threshold in percentage
-- warningThreshold = 20, -- Warning threshold in percentage
--
-- notFullCriticalThreshold = 96, -- Not full critical threshold in percentage
-- notFullWarningThreshold = 98, -- Not full warning threshold in percentage
--
-- announceNotFullCriticalMode = 10, -- change, disable or integer intervall
-- announceNotFullWarningMode = 10, -- change, disable or integer intervall
--
-- announceNormalMode = 20, -- change, disable or integer intervall
-- announceWarningMode = "change", -- change, disable or integer intervall
-- announceCriticalMode = "change", -- change, disable or integer intervall
notFullAlertModes = {
normal = { mode = "disable" } , -- do NOT announce anything under normal conditions
warning = { mode = 10 , threshold = 94 } , -- announce on intervals, threshold for warning, steps = amount of change required for announcement
critical = { mode = 10 , threshold = 92 } , -- announce on intervals, threshold for critical, steps = amount of change required for announcement
},
alertModes = {
normal = { mode = "change" , steps = 10 } , -- announce on changes, steps = amount of change required for announcement during normal condition
warning = { mode = "change" , threshold = 20 , steps = 5 } , -- announce on changes, threshold for warning, steps = amount of change required for announcement
critical = { mode = "change" , threshold = 15 , steps = 2.5 } , -- announce on changes, threshold for critical, steps = amount of change required for announcement
},
highVoltage = 4.20, -- High voltage
lowVoltage = 3.27, -- Low voltage
cellDeltaVoltage = 0.1, -- Cell delta voltage
isNotABattery = false -- DO NOT CHANGE for any Battery !!!
},
buffer = { -- Buffer Pack (condensator)
dischargeCurve = nil, -- This will be dynamically calculated based on voltage range
dischargeCurveHighLoad = nil,
typeName = "Buffer Pack",
name = "Buffer", -- will be used as suffix to the source name (see below), has to be present as wav or voice announce wont work
graceperiod = 4, -- grace period for fluctuations
--criticalThreshold = 96, -- Critical threshold in percentage
--warningThreshold = 97, -- Warning threshold in percentage
--
--notFullCriticalThreshold = 98, -- Not full critical threshold in percentage
--notFullWarningThreshold = 99, -- Not full warning threshold in percentage
--announceNotFullCriticalMode = 10, -- change, disable or integer intervall
--announceNotFullWarningMode = 10, -- change, disable or integer intervall
--
--announceNormalMode = "disable", -- change, disable or integer intervall
--announceWarningMode = "change", -- change, disable or integer intervall
--announceCriticalMode = "change", -- change, disable or integer intervall highVoltage = nil, -- High voltage -- will be set to rxReferenceVoltage from the model once it's loaded ... you can override it here ... but it's better to "calculate"/set it to the rxReferenceVoltage -- todo
notFullAlertModes = {
normal = { mode = "disable" } , -- do NOT announce anything under normal conditions
warning = { mode = 10 , threshold = 99 } , -- announce on intervals, threshold for warning, steps = amount of change required for announcement
critical = { mode = 10 , threshold = 98 } , -- announce on intervals, threshold for critical, steps = amount of change required for announcement
},
alertModes = {
normal = { mode = "disable" } , -- announce on changes, steps = amount of change required for announcement during normal condition
warning = { mode = "change" , threshold = 97 , steps = 5 } , -- announce on changes, threshold for warning, steps = amount of change required for announcement
critical = { mode = "change" , threshold = 87 , steps = 2.5 } , -- announce on changes, threshold for critical, steps = amount of change required for announcement
},
highVoltage = nil, -- if nil will use model rxReferenceVoltage
lowVoltage = 6, -- Low voltage -- where your buffer pack shuts off completely ... all hope is lost after this ;-) .. please note... in the case of buffer packs ... we will device this value by 2 in order to get a theoretical 2s per cell value for the alerts and percentage left -- todo
cellDeltaVoltage = nil, -- Cell delta voltage -- irrelevant for buffer or bec
isNotABattery = true -- buffer is not a battery and values for high and low voltage represent real voltages and will be devided by 2 by the script to get a theoretical cell value
},
beconly = { -- BEC only Definition
dischargeCurve = nil, -- This will be dynamically calculated based on voltage range
dischargeCurveHighLoad = nil,
typeName = "BEC only",
name = "Power", -- will be used as suffix to the source name (see below), has to be present as wav or voice announce wont work
graceperiod = 4, -- grace period for fluctuations
-- criticalThreshold = 96, -- Critical threshold in percentage
-- warningThreshold = 97, -- Warning threshold in percentage
-- notFullCriticalThreshold = 98, -- Not full critical threshold in percentage
-- notFullWarningThreshold = 99, -- Not full warning threshold in percentage
-- announceNotFullCriticalMode = 10, -- change, disable or integer intervall
-- announceNotFullWarningMode = 10, -- change, disable or integer intervall
--announceNormalMode = "disable", -- change, disable or integer intervall
--announceWarningMode = "change", -- change, disable or integer intervall
--announceCriticalMode = "change", -- change, disable or integer intervall highVoltage = nil, -- High voltage -- will be set to rxReferenceVoltage from the model once it's loaded ... you can override it here ... but it's better to "calculate"/set it to the rxReferenceVoltage -- todo
notFullAlertModes = {
normal = { mode = "disable" } , -- do NOT announce anything under normal conditions
warning = { mode = 10 , threshold = 99 } , -- announce on intervals, threshold for warning, steps = amount of change required for announcement
critical = { mode = 10 , threshold = 98 } , -- announce on intervals, threshold for critical, steps = amount of change required for announcement
},
alertModes = {
normal = { mode = "disable" } , -- announce on changes, steps = amount of change required for announcement during normal condition
warning = { mode = "change" , threshold = 97 , steps = 5 } , -- announce on changes, threshold for warning, steps = amount of change required for announcement
critical = { mode = "change" , threshold = 87 , steps = 2.5 } , -- announce on changes, threshold for critical, steps = amount of change required for announcement
},
highVoltage = nil, -- if nil will use model rxReferenceVoltage
lowVoltage = 5, -- Low voltage -- there is not such a thing as "lowvoltage" if only using a bec ... if you loose your bec you will recognize it before we can announce anything ... so lets set this to anything below what is "normal" ... like 5
cellDeltaVoltage = nil, -- Cell delta voltage -- irrelevant for buffer or bec
isNotABattery = true -- BEC is not a battery and values for high and low voltage represent real voltages and will be devided by 2 by the script to get a theoretical cell value
},
}
----------------------------------------------------------------------------------------------------------------------
-- Model Definitions ... where it all sticks together ;-)
----------------------------------------------------------------------------------------------------------------------
local modelTable = {
{
modelNameMatch = "DEFAULT",
modelName = "DEFAULT",
modelImage = "goblin.png",
modelWav = "sg630",
rxReferenceVoltage = 8.2,
resetSwitch = "TELE",
AdlSensors = defaultAdlSensors,
telemetrysettlement = 5, -- how long to let telemetry and sensors to settle before taking values for real
doScreenshot = true, -- Take a Screenshot after a reset (see resetSwitch above)
screenshotLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Special Function Screenshot. See github page on how to implement this.
loggingLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Special Function SD Logs. See github page on how to implement this.
resetTeleLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Reset - Telemetry. See github page on how to implement this.
-- Switches have to be lowercase ... Sensors are Case Sensitive ... Condition for a 3 position switch -1024, 0 and 1024
-- See Example(s) below. ActivityTrigger (normally your Arm Switch) will currently only be used to dismiss the preflight status screen
activityTrigger = { source = "RPM", condition = ">50" },
--loggingTrigger = { source = "sd", condition = "=0" },
loggingTrigger = { source = "RPM", condition = ">50" },
flightDetection = { source = "RPM", condition = ">1000" },
resetTrigger = { source = "TELE", condition = "=0" },
flightCountGV = 1, -- Global Variable (Number as displayed, like GV1) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
flighttimeHoursGV = 2, -- Global Variable (Number as displayed, like GV2) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
flighttimeMinutesGV = 3, -- Global Variable (Number as displayed, like GV3) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
gvFm = 0, -- flightmode for storing Global Variables above, change as needed if GV's are occupied above
activeFlightDetTime = 5, -- todo ... choose a better name for this ... as it is currently only used for buffer pack "ignore" after this seconds of flight
doHaptic = true,
doWarnTone = true,
switchAnnounces = SwitchAnnounceTable,
BattPackSelectorSwitch = nil, -- !!! NOT IMPLEMENTED YET !!!
powerSources = {
{
displayName = "Main", -- single words have to be present as wav or voice announce wont work
VoltageSensor = { sensorName = "Cels" },
CurrentSensor = { sensorName = "Curr" },
MahSensor = { sensorName = "mah" },
type = powerSources.lipo,
CellCount = 8,
capacities = { 500, 1000, 1500, 2000, 2500, 3000 } -- not used as of now
},
{
displayName = "Receiver", -- single words have to be present as wav or voice announce wont work
VoltageSensor = { sensorName = "RxBt" },
CurrentSensor = { sensorName = "Curr" },
MahSensor = { sensorName = "mah" },
type = powerSources.buffer,
CellCount = 2,
capacities = { 500, 1000, 1500, 2000, 2500, 3000 } -- not used as of now
}
}
},
{
modelNameMatch = "580t", -- this is currently my REAL testing model
modelName = "SAB RAW 580",
modelImage = "580.png",
modelWav = "sr580",
rxReferenceVoltage = 7.96,
resetSwitch = "TELE",
AdlSensors = sensg580,
telemetrysettlement = 8, -- how long to let telemetry and sensors to settle before taking values for real
doScreenshot = true, -- Take a Screenshot after a reset (see resetSwitch above)
screenshotLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Special Function Screenshot. See github page on how to implement this.
loggingLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Special Function SD Logs. See github page on how to implement this.
resetTeleLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Reset - Telemetry. See github page on how to implement this.
-- Switches have to be lowercase ... Sensors are Case Sensitive ... Condition for a 3 position switch -1024, 0 and 1024
-- See Example(s) below. ActivityTrigger (normally your Arm Switch) will currently only be used to dismiss the preflight status screen
activityTrigger = { source = "RPM", condition = ">50" },
--loggingTrigger = { source = "sd", condition = "=0" },
loggingTrigger = { source = "RPM", condition = ">50" },
flightDetection = { source = "RPM", condition = ">1000" },
resetTrigger = { source = "TELE", condition = "=0" },
flightCountGV = 1, -- Global Variable (Number as displayed, like GV1) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
flighttimeHoursGV = 2, -- Global Variable (Number as displayed, like GV2) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
flighttimeMinutesGV = 3, -- Global Variable (Number as displayed, like GV3) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
gvFm = 0, -- flightmode for storing Global Variables above, change as needed if GV's are occupied above
activeFlightDetTime = 5, -- todo ... choose a better name for this ... as it is currently only used for buffer pack "ignore" after this seconds of flight
doHaptic = true,
doWarnTone = true,
switchAnnounces = SwitchAnnounceTable,
BattPackSelectorSwitch = nil, -- !!! NOT IMPLEMENTED YET !!!
powerSources = {
{
displayName = "Main", -- single words have to be present as wav or voice announce wont work
VoltageSensor = { sensorName = "RB1V" },
CurrentSensor = { sensorName = "RB1A" },
MahSensor = { sensorName = "RB1C" },
type = powerSources.lipo,
CellCount = 12,
capacities = { 500, 1000, 1500, 2000, 2500, 3000 } -- not used as of now
},
{
displayName = "Receiver", -- single words have to be present as wav or voice announce wont work
VoltageSensor = { sensorName = "RB2V" },
CurrentSensor = { sensorName = "" },
MahSensor = { sensorName = "" },
type = powerSources.buffer,
CellCount = 2,
capacities = { 500, 1000, 1500, 2000, 2500, 3000 } -- not used as of now
}
}
},
{
modelNameMatch = "heli", -- this is the simulator for dev/tests actually
modelName = "SAB Goblin 630",
modelImage = "goblin.png",
modelWav = "sg630",
rxReferenceVoltage = 8.19,
resetSwitch = "TELE",
AdlSensors = sensSimulator,
telemetrysettlement = 5, -- how long to let telemetry and sensors to settle before taking values for real
doScreenshot = true, -- Take a Screenshot after a reset (see resetSwitch above)
screenshotLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Special Function Screenshot. See github page on how to implement this.
loggingLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Special Function SD Logs. See github page on how to implement this.
resetTeleLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Reset - Telemetry. See github page on how to implement this.
-- Switches have to be lowercase ... Sensors are Case Sensitive ... Condition for a 3 position switch -1024, 0 and 1024
-- See Example(s) below. ActivityTrigger (normally your Arm Switch) will currently only be used to dismiss the preflight status screen
activityTrigger = { source = "RPM", condition = ">50" },
--loggingTrigger = { source = "sd", condition = "=0" },
loggingTrigger = { source = "RPM", condition = ">50" },
flightDetection = { source = "RPM", condition = ">1000" },
--resetTrigger = { source = "TELE" },
resetTrigger = { source = "VFAS", condition = "<1" },
flightCountGV = 1, -- Global Variable (Number as displayed, like GV1) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
flighttimeHoursGV = 2, -- Global Variable (Number as displayed, like GV2) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
flighttimeMinutesGV = 3, -- Global Variable (Number as displayed, like GV3) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
gvFm = 0, -- flightmode for storing Global Variables above, change as needed if GV's are occupied above
activeFlightDetTime = 5, -- todo ... choose a better name for this ... as it is currently only used for buffer pack "ignore" after this seconds of flight
doHaptic = true,
doWarnTone = true,
switchAnnounces = SwitchAnnounceTable,
BattPackSelectorSwitch = nil , -- !!! NOT IMPLEMENTED YET !!!
battCapacity = 4500,
powerSources = {
{
displayName = "Main", -- single words have to be present as wav or voice announce wont work
--VoltageSensor = { sensorName = "Cels" },
VoltageSensor = { sensorName = "VFAS" },
CurrentSensor = { sensorName = "Curr" },
MahSensor = { sensorName = "mah" },
type = powerSources.lipo,
CellCount = 12,
capacities = { 500, 1000, 1500, 2000, 2500, 3000 } -- not used as of now
},
{
displayName = "Receiver", -- single words have to be present as wav or voice announce wont work
VoltageSensor = { sensorName = "RxBt" },
CurrentSensor = { sensorName = "Curr" },
MahSensor = { sensorName = "mah" },
type = powerSources.buffer,
CellCount = 2,
capacities = { 500, 1000, 1500, 2000, 2500, 3000 } -- not used as of now
}
}
},
{
modelNameMatch = "goblin", -- this is the simulator for dev/tests actually
modelName = "SAB Goblin 630",
modelImage = "goblin.png",
modelWav = "sg630",
rxReferenceVoltage = 8.01,
resetSwitch = "TELE",
AdlSensors = senhwelrs,
telemetrysettlement = 10, -- how long to let telemetry and sensors to settle before taking values for real
doScreenshot = true, -- Take a Screenshot after a reset (see resetSwitch above)
screenshotLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Special Function Screenshot. See github page on how to implement this.
loggingLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Special Function SD Logs. See github page on how to implement this.
resetTeleLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Reset - Telemetry. See github page on how to implement this.
-- Switches have to be lowercase ... Sensors are Case Sensitive ... Condition for a 3 position switch -1024, 0 and 1024
-- See Example(s) below. ActivityTrigger (normally your Arm Switch) will currently only be used to dismiss the preflight status screen
activityTrigger = { source = "hspd", condition = ">50" },
--loggingTrigger = { source = "sd", condition = "=0" },
loggingTrigger = { source = "hspd", condition = ">50" },
flightDetection = { source = "hspd", condition = ">1000" },
resetTrigger = { source = "TELE", condition = "=0" },
flightCountGV = 1, -- Global Variable (Number as displayed, like GV1) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
flighttimeHoursGV = 2, -- Global Variable (Number as displayed, like GV2) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
flighttimeMinutesGV = 3, -- Global Variable (Number as displayed, like GV3) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
gvFm = 0, -- flightmode for storing Global Variables above, change as needed if GV's are occupied above
activeFlightDetTime = 5, -- todo ... choose a better name for this ... as it is currently only used for buffer pack "ignore" after this seconds of flight
doHaptic = true,
doWarnTone = true,
switchAnnounces = SwitchAnnounceTable,
BattPackSelectorSwitch = nil , -- !!! NOT IMPLEMENTED YET !!!
powerSources = {
{
displayName = "Main", -- single words have to be present as wav or voice announce wont work
--VoltageSensor = { sensorName = "Cels" },
VoltageSensor = { sensorName = "RxBt" },
CurrentSensor = { sensorName = "Curr" },
MahSensor = { sensorName = "Capa" },
type = powerSources.lipo,
CellCount = 12,
capacities = { 500, 1000, 1500, 2000, 2500, 3000 } -- not used as of now
},
{
displayName = "Receiver", -- single words have to be present as wav or voice announce wont work
VoltageSensor = { sensorName = "bec" },
CurrentSensor = { sensorName = "" },
MahSensor = { sensorName = "" },
type = powerSources.buffer,
CellCount = 2,
capacities = { 500, 1000, 1500, 2000, 2500, 3000 } -- not used as of now
}
}
},
-- 8.14 8.15
{
modelNameMatch = "tb60", -- this is the simulator for dev/tests actually
modelName = "TB60",
modelImage = "trex600.png",
modelWav = "t600",
rxReferenceVoltage = 8.14,
resetSwitch = "TELE",
AdlSensors = senhwspek,
telemetrysettlement = 10, -- how long to let telemetry and sensors to settle before taking values for real
doScreenshot = true, -- Take a Screenshot after a reset (see resetSwitch above)
screenshotLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Special Function Screenshot. See github page on how to implement this.
loggingLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Special Function SD Logs. See github page on how to implement this.
resetTeleLS = "create", -- use "create" in order for the script to create everything for you ... creation will start at LS/SF 65 counting down as needed ... if Number, it has to be a Sticky LS (0=L01) LS has to be used for Reset - Telemetry. See github page on how to implement this.
-- Switches have to be lowercase ... Sensors are Case Sensitive ... Condition for a 3 position switch -1024, 0 and 1024
-- See Example(s) below. ActivityTrigger (normally your Arm Switch) will currently only be used to dismiss the preflight status screen
activityTrigger = { source = "Erpm", condition = ">50" },
--loggingTrigger = { source = "sd", condition = "=0" },
loggingTrigger = { source = "Erpm", condition = ">50" },
flightDetection = { source = "Erpm", condition = ">1000" },
resetTrigger = { source = "TELE", condition = "=0" },
flightCountGV = 1, -- Global Variable (Number as displayed, like GV1) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
flighttimeHoursGV = 2, -- Global Variable (Number as displayed, like GV2) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
flighttimeMinutesGV = 3, -- Global Variable (Number as displayed, like GV3) to store the value, make sure it is not used for something else. Set to nil to disable. Please Note: only a flight time longer as one (1) minute will make this count !
gvFm = 0, -- flightmode for storing Global Variables above, change as needed if GV's are occupied above
activeFlightDetTime = 5, -- todo ... choose a better name for this ... as it is currently only used for buffer pack "ignore" after this seconds of flight
doHaptic = true,
doWarnTone = true,
switchAnnounces = SwitchAnnounceTable,
BattPackSelectorSwitch = nil , -- !!! NOT IMPLEMENTED YET !!!
powerSources = {
{
displayName = "Main", -- single words have to be present as wav or voice announce wont work
--VoltageSensor = { sensorName = "Cels" },
VoltageSensor = { sensorName = "RB1V" },
CurrentSensor = { sensorName = "RB1A" },
MahSensor = { sensorName = "RB1C" },
type = powerSources.lipo,
CellCount = 12,
capacities = { 500, 1000, 1500, 2000, 2500, 3000 } -- not used as of now
},
{
displayName = "Receiver", -- single words have to be present as wav or voice announce wont work
VoltageSensor = { sensorName = "RB2V" },
CurrentSensor = { sensorName = "" },
MahSensor = { sensorName = "" },
type = powerSources.buffer,
CellCount = 2,
capacities = { 500, 1000, 1500, 2000, 2500, 3000 } -- not used as of now
}
}
}
}
----------------------------------------------------------------------------------------------------------------------
-- Battery Capacity Change Switches - !!! NOT IMPLEMENTED YET !!!
----------------------------------------------------------------------------------------------------------------------
local BattPackSelectorSwitch = {
main = {
{ switchName = '6POS1', value = 1 },
{ switchName = '6POS2', value = 2 },
{ switchName = '6POS3', value = 3 },
{ switchName = '6POS4', value = 4 },
{ switchName = '6POS5', value = 5 },
{ switchName = '6POS6', value = 6 }
},
receiver = {
{ switchName = '6POS1', value = 1 },
{ switchName = '6POS2', value = 2 },
{ switchName = '6POS3', value = 3 },
{ switchName = '6POS4', value = 4 },
{ switchName = '6POS5', value = 5 },
{ switchName = '6POS6', value = 6 }
}
}
---------------------------------------------------------------------------------------------------------------------------------------
-- INTERNAL VARIABLES -- to NOT Change unless needed and you know what you are doing
---------------------------------------------------------------------------------------------------------------------------------------
local DEBUG_ENABLED = true
local verbosity = 3 --todo verbosity levels
-- State management for reset if needed and screenshot
local resetInitiated = false
local screenshotTriggered = false
local loggingState = false
local activityState = false
local flightState = false
local activeFlightState = false
local resetState = false
local prevFlightTime = 0
idstatusTele = getSwitchIndex("TELE") -- Telemetry Status -- ID: 244
local telegrace = 0
local properties = {
"CurVolt", "LatestVolt", "LowestVolt", "HighestVolt",
"CurPercRem", "LatestPercRem", "CurAmp", "LatestAmp",
"LowestAmp", "HighestAmp", "CellsDetectedCurrent",
"cellMissing", "cellInconsistent"
}
local sensornamedefs = {
"VoltageSensor", "CurrentSensor", "MahSensor"
}
pfStatus = {
text = "unknown", -- This can be "ok", "warning", "error", or "unknown"
color = GREY -- Default color for unknown status
}
FirstModelInit = false
local modelAlreadyLoaded = false
local priorizeSwitchAnnouncements = true
local ShowPostFlightSummary = true --todo
local ShowPreFlightStatus = true -- todo
local ActiveFlightIndicator = "choose switch" -- todo ... use arm switch or maybe there is a good tele sensor for this
local statusTable = {}
-- to support future functions like taking screenshot and logging on/off
local ver, radio, maj, minor, rev, osname = getVersion()
if DEBUG_ENABLED then
print ( "version: " .. ver )
if radio then print ( "version radio: " .. radio ) end
if maj then print ( "version maj: " .. maj ) end
if minor then print ( "version minor: " .. minor ) end
if rev then print ( "version rev: " .. rev ) end
if osname then print ( "version osname: " .. osname) end
end
local AutomaticResetOnResetSwitchToggle = 4 -- 5 seconds for TELE Trigger .... maybe 1 second for switch trigger
-- local AutomaticResetOnNextChange = true
local isPreFlightStage = true
local TriggerTimers = {}
local announcementConfig = {
-- Telemetry configuration
telemetry = {
normal = { mode = "disable", gracePeriod = 1 }, -- Mode to disable telemetry in normal state
warning = { mode = 10, threshold = false }, -- Mode to change telemetry in warning state
critical = { mode = "disable", threshold = "undef" } -- Mode to disable telemetry in critical state
},
-- Battery Missing Cell configuration
BatteryMissingCell = {
normal = { mode = "disable", gracePeriod = 1 }, -- Mode to disable in normal state
warning = { mode = 10, threshold = -1 }, -- Mode to change in warning state after threshold
critical = { mode = 10, threshold = -2 } -- Mode to change in critical state after threshold
},
-- Cell Delta configuration
CellDelta = {
normal = { mode = "disable", gracePeriod = 3 }, -- Mode to disable in normal state
warning = { mode = 10, threshold = "undef" }, -- Mode to change in warning state after threshold
critical = { mode = 10, threshold = true } -- Mode to change in critical state after threshold
}
}
local announcementConfigDefault = {
normal = {
mode = "change", -- "disable", "change", or an interval in seconds
gracePeriod = 4 -- Default grace period in seconds
},
warning = {
threshold = 80, -- Default threshold for warning level
mode = "change" -- "disable", "change", or an interval in seconds
},
critical = {
threshold = 50, -- Default threshold for critical level
mode = "change" -- "disable", "change", or an interval in seconds
}
}
-- local unitNames = {
-- [0] = "", -- Raw unit (no unit)
-- [1] = "V", -- Volts
-- [2] = "A", -- Amps
-- [3] = "mA", -- Milliamps
-- [4] = "kts", -- Knots
-- [5] = "m/s", -- Meters per Second
-- [6] = "ft/s", -- Feet per Second
-- [7] = "km/h", -- Kilometers per Hour
-- [8] = "mph", -- Miles per Hour
-- [9] = "m", -- Meters
-- [10] = "ft", -- Feet
-- [11] = "°C", -- Degrees Celsius
-- [12] = "°F", -- Degrees Fahrenheit
-- [13] = "%", -- Percent
-- [14] = "mAh", -- Milliamp Hour
-- [15] = "W", -- Watts
-- [16] = "mW", -- Milliwatts
-- [17] = "dB", -- dB
-- [18] = "rpm", -- RPM
-- [19] = "G", -- G
-- [20] = "°", -- Degrees
-- [21] = "rad", -- Radians
-- [22] = "ml", -- Milliliters
-- [23] = "floz", -- Fluid Ounces
-- [24] = "ml/min", -- Ml per minute
-- [35] = "h", -- Hours
-- [36] = "min", -- Minutes
-- [37] = "s", -- Seconds
-- [38] = "V", -- Virtual unit for Cells
--
-- }
-- todo -- really needed ?
local CapacityReservePercent = 0 -- set to zero to disable
local soundDirPath = "/WIDGETS/TxBatTele/sounds/" -- where you put the sound files
-- todo
-- Do not change the next line
local GV = {[1] = 0, [2] = 1, [3] = 2,[4] = 3,[5] = 4,[6] = 5, [7] = 6, [8] = 7, [9] = 8}
local WriteGVBatRemmAh = true -- set to false to turn off write
local WriteGVBatRemPer = true
-- If writes are false then the corresponding GV below will not be used and these
-- lines can be ignored.
local GVBatRemmAh = GV[8] -- Write remaining mAh, 2345 mAh will be writen as 23, floor(2345/100)
local GVBatRemPer = GV[9] -- Write remaining percentage, 76.7% will be writen as 76, floor(76)
local CanCallInitFuncAgain = false -- updated in bg_func
local VoltageHistory = {} -- updated in bg_func
-- Display
local x, y, fontSize, yColumn2
local xAlign = 0
local BlinkWhenZero = 0 -- updated in run_func
local Color = BLUE
local BGColor = BLACK
local soundQueue = {}
local currentState = "idle"
local waitUntil = 0
local timer = {
startTime = 0,
accumulatedTime = 0,
running = false
}
---------------------------------------------------------------------------------------------------------------------------------------
-- FUNCTIONS
---------------------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------------------------
-- CF FUNCTIONS
---------------------------------------------------------------------------------------------------------------------------------------
--
-- variables for demo
--
-- local lastActive = 0 -- for demo: toggles SD Logs on/off every 5s
-- local interval = 500
-- local enable = 0
--
-- internal variables for SF SD Logs enable/disable function
--
local nSF = 64 -- 64 SFs to consider
local function init_sf(trigger,type) -- initializes the SF SD Logs enable/disable function
local createSF = false
local index = nil
for i = nSF-1, 0, -1 do
local sf = model.getCustomFunction(i) -- get SF at index i
print("SFDEBG: Getting CF:" .. i )
if sf ~= nil then
if sf.func == type then -- check if SF is SF SD Logs
--SDlogsTable = cf -- copy entry
index = i -- memorize index
createSF = false -- no need to create SF
print("SFDEBG: EXISTING SF FOUND:" .. i )
break -- exit search loop
end
if index == nil and -- search for first free index
sf.switch == 0 then
index = i -- memorize index
createSF = true -- need to create the SF
print("SFDEBG: Setting Create to true. index: " .. index )
end
end
end
if createSF == true then
local switchname = string.format("L%02d", tonumber(index+1))
SF_Table = {
["switch"] = getSwitchIndex(switchname), -- trigger permanently ON
["func"] = type, -- SD Logs
["active"] = 1 -- disabled
}
if type == FUNC_LOGS then
SF_Table.value = 10
end
if type == FUNC_RESET then
SF_Table.value = 4
end
print("SFDEBG: Creating SF:" .. switchname)
model.setCustomFunction(index, SF_Table)
end
end
local function init_ls(internalidx, isonoff ) -- initializes the SF SD Logs enable/disable function
local createLS = false
local index = nil
local duration = 10 + internalidx
local delay = internalidx
if isonoff then
duration = 0
end
--for i = 0, nSF-1 do -- go through all LSs
for i = nSF-1, 0, -1 do
print("LSDEBG: Getting LS:" .. i )
local ls = model.getLogicalSwitch(i) -- get SF at index i
if ls ~= nil then
print("LSDEBG: NOT NIL:" .. i )
print("LSDEBG: FUNC:" .. ls.func )
if ls.func == LS_FUNC_STICKY and ls.duration == duration and ls.delay == delay then -- check if SF is SF SD Logs
--SF_RESET_Table = cf -- copy entry
index = i -- memorize index
--thisModel.resetTeleLS = index
createLS = false -- no need to create SF