-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSWRMeter2_DFR_2.jal
executable file
·1260 lines (1151 loc) · 28.8 KB
/
SWRMeter2_DFR_2.jal
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
-- ---------------------------------------------------------------
-- Title:GLCD SWR Meter
--
-- Author: Robert de Kok, Copyright (c) 2014, all rights reserved.
-- ----------------------------------------------------------------
include 18f4550
pragma target clock 8_000_000 -- 20_000_000
--pragma target OSC INTOSC_CLKOUT --hs
pragma target OSC INTOSC_PORTIO --hs RDK
OSCCON_IRCF = 0b_111
UCON_USBEN = 0 ;disable USB
UCFG_UTRDIS = 1 ;disable USB
UCFG = 0b_00001000
pragma target WDT disabled
pragma target LVP disabled
-- GRAPHIC_LCD IO definition ------------------------
var bit GLCD_CS1 is pin_c1 ;omgedraaid tov eigen versie
var bit GLCD_CS2 is pin_c0 ;omgedraaid tov eigen versie
var bit GLCD_RST is pin_c2
var bit GLCD_RW is pin_e2
var bit GLCD_E is pin_e0
var bit GLCD_DI is pin_e1
var bit GLCD_CS1_direction is pin_c0_direction
var bit GLCD_CS2_direction is pin_c1_direction
var bit GLCD_RST_direction is pin_c2_direction
var bit GLCD_RW_direction is pin_e2_direction
var bit GLCD_E_direction is pin_e0_direction
var bit GLCD_DI_direction is pin_e1_direction
var volatile byte GLCD_DATAPRT is portD
var volatile byte GLCD_DATAPRT_DIR is portD_direction
const GLCD_CLIPPING = TRUE
pin_b1_direction = input ;button2
pin_b2_direction = input ;rotary
pin_b3_direction = input ;rotary
pin_c6_direction = output ;led_red
pin_c7_direction = output ;led_green
;pin_b4_direction = output ;led_spare1
;pin_b5_direction = output ;led_spare2
pin_b4_direction = input ;mtr1_l1
pin_b5_direction = input ;mtr1_l2
pin_b0_direction = input ;mtr1_l3
pin_b7_direction = output;mtr1_vo
pin_a4_direction = input ;mtr2_l1
pin_a5_direction = input ;mtr2_l2
pin_a6_direction = input ;mtr2_l3
pin_b6_direction = output;mtr2_vo
alias led_green is pin_C7
alias led_red is pin_C6
;alias led_spare1 is pin_b4
;alias led_spare2 is pin_b5
alias rotary_dir is pin_b2
alias mtr1_l1 is pin_b4
alias mtr1_l2 is pin_b5
alias mtr1_l3 is pin_b0
alias mtr1_vo is pin_b6
alias mtr2_l1 is pin_a4
alias mtr2_l2 is pin_a5
alias mtr2_l3 is pin_a6
alias mtr2_vo is pin_b7
const byte msg1[] = "SWR Meter * By PA2RDK"
const byte msg2[] = " WWW.PI4RAZ.NL"
const byte msg3[] = " Copyright PA2RDK (c)"
const byte msg4[] = " Version 2.2"
const byte fwdstr[] = "FWD"
const byte refstr[] = "REF ="
const byte swrstr[] = "SWR ="
const byte peakst[] = "PEAK="
const byte watstr[] = "W "
const byte watXstr[] = "0W "
const byte sw2str[] = "1:"
const byte empstr[] = " "
const byte pntstr[] = "."
const byte starstr[] = "*"
const byte forwart[] = "FWD"
const byte reverse[] = "REF"
const byte maxswr[] = "HIGH "
const byte swr1[] = "1="
const byte swr2[] = "2="
const byte power1[] = "SWR1 Power "
const byte power2[] = "SWR2 Power "
const byte mpr[] = "Multiplier "
const byte volt[] = "5 Volt "
const byte voltOn[] = "On "
const byte voltOff[] = "Off"
const byte isHF[] = "HF "
const byte is4M[] = "4M "
const byte isVHF[] = "VHF"
const byte isUHF[] = "UHF"
const byte isSHF[] = "SHF"
const byte isFree[] = "Free"
const byte isNC[] = "N/C"
const byte toLeft = 64
const byte SWRLOOKUP[] = {12,13,14,15,16,16,17,18,19,19,20,21,21,22,
23,23,24,25,25,26,27,28,28,29,30,31,32,32,
33,34,35,36,37,38,39,40,41,42,43,44,46,47,
48,49,51,52,54,55,57,58,60,62,64,65,67,69,
72,74,76,79,81,84,87,90,93,97,99}
const byte PWRLOOKUP[] = {0,0,0,0,1,1,1,1,2,2,2,3,3,4,5,5,6,6,7,8,9,10,11,12,13,14,15,16,17,
18,19,20,22,23,25,26,27,29,30,32,34,35,37,39,41,42,44,46,48,50,52,
54,56,58,61,63,65,67,70,72,74,77,79,82,85,87,90,92,95,98,101,104,
107,110,113,116,119,122,125,128,131,134,138,141,145,148,151,155,
158,162,166,169,173,177,181,184,188,192,196,200,204,208,212,216}
enable_digital_io() -- all pins digital I/O
include delay
include math
include print
include glcd_5x7_font -- font to be used
include glcd_8x12_font -- font to be used
include glcd_6x8_font -- font to be used
include glcd_font -- common font stuff
include glcd_ks0108 -- glcd device dependent library
include glcd_common -- device independent glcd library
include pic_data_eeprom
;include SWRMeterHelpers
glcd_font_use(FONT_6X8) -- activate font
glcd_init() -- initialize display
led_green = 1
led_red = 0
;led_spare1 = 0
;led_spare2 = 0
var word i = 0
var sword dy = 0
var byte mtrMode = 1
var byte menuNo = 1
var bit auto1_vo = 0
var bit auto2_vo = 0
var bit red_on = 0
procedure DrawDemo() is
glcd_pen_color = GLCD_BLACK -- pixel color
glcd_clear_screen()
for 2 loop
for ((GLCD_X_PIXELS / 2) - 1) using i loop -- line animation
glcd_line(i * 2, 0, GLCD_X_PIXELS - i * 2 - 1, GLCD_Y_PIXELS - 1)
delay_1ms(3)
end loop
for (GLCD_Y_PIXELS - 1) using i loop
glcd_line(GLCD_X_PIXELS - 1, i, 0, GLCD_Y_PIXELS - i)
delay_1ms(3)
end loop
glcd_pen_color = GLCD_WHITE -- 'erase' first pattern
end loop
delay_100ms(2)
glcd_pen_color = GLCD_BLACK -- pixel color
glcd_clear_screen()
end procedure
DrawDemo()
glcd_char_goto(0,10)
print_string(glcd, msg1)
glcd_char_goto(0,20)
print_string(glcd, msg2)
glcd_char_goto(2,35)
print_string(glcd, msg3)
glcd_char_goto(2,50)
print_string(glcd, msg4)
delay_100ms(20)
glcd_clear_screen()
const bit ADC_HIGH_RESOLUTION = high
const byte ADC_NCHANNEL = 1
const byte ADC_NVREF = ADC_NO_EXT_VREF
include adc
adc_init()
var dword w1measure = 0
var dword w2measure = 0
var dword w3measure = 0
var dword w4measure = 0
var dword w5measure = 0
var dword w6measure = 0
var dword w7measure = 0
var dword o1measure = 0
var dword o2measure = 0
var dword o3measure = 0
var dword o4measure = 0
var dword o5measure = 0
var dword o6measure = 0
var dword o7measure = 0
var dword w1T1measure = 0
var dword w2T1measure = 0
var dword w4T1measure = 0
var dword w5T1measure = 0
var dword w6T1measure = 0
var dword w7T1measure = 0
var dword w1T2measure = 0
var dword w2T2measure = 0
var dword w4T2measure = 0
var dword w5T2measure = 0
var dword w6T2measure = 0
var dword w7T2measure = 0
var byte pmcount1 = 0
var byte pmcount2 = 0
var byte xpos = 0
var byte ypos = 0
var byte swr = 0
var byte swrl = 0
var byte swrh = 0
var byte lpcount = 0
var byte mtrUp = 0
var byte mpr_hf = 100
var byte mpr_4m = 100
var byte mpr_vhf = 100
var byte mpr_uhf = 100
var byte mpr_shf = 100
var byte mpr_free = 100
var bit mpv_hf = 0
var bit mpv_4m = 0
var bit mpv_vhf = 0
var bit mpv_uhf = 0
var bit mpv_shf = 0
var bit mpv_free = 0
var byte mtype1 = 0
var byte mtype2 = 0
if data_eeprom(0)!=255 then
mpr_hf = data_eeprom(0)
mpr_4m = data_eeprom(1)
mpr_vhf = data_eeprom(2)
mpr_uhf = data_eeprom(3)
mpr_shf = data_eeprom(4)
mpr_free = data_eeprom(5)
mpv_HF = data_eeprom(6)
mpv_4m = data_eeprom(7)
mpv_vhf = data_eeprom(8)
mpv_uhf = data_eeprom(9)
mpv_shf = data_eeprom(10)
mpv_free = data_eeprom(11)
end if
procedure RecalcXY(word in Value) is
if Value>990 then
Value = 990
end if
xpos = (dword(SINLOOKUP[(990-Value)/11]))/5
ypos = (dword(SINLOOKUP[(Value)/11]))/5
end procedure
procedure RecalcSwr(word in a, word in b) is
if b>a then
swr=255
else
if a>0 then
if (b*100)/a >66 then
swr = 255
else
swr = SWRLOOKUP[(b*100)/a]
if (b*100)/a <1 then
swr = 11
end if
end if
else
swr = 10
end if
end if
if b==0 then
swr = 10
end if
if swr>50 then
red_on = 1
end if
swrh = swr/10
swrl = swr-((swr/10)*10)
end procedure
procedure WriteSWR(bit in isTwee) is
if isTwee==0 then
RecalcSwr(PWRLOOKUP[w1measure/10],PWRLOOKUP[w2measure/10])
else
RecalcSwr(PWRLOOKUP[w4measure/10],PWRLOOKUP[w5measure/10])
end if
if swr==255 then
print_string(glcd,maxswr)
else
print_string(glcd,sw2str)
print_word_dec(glcd, swrh)
print_string(glcd,pntstr)
print_word_dec(glcd, swrl)
end if
end procedure
procedure SetMtrType() is
If mtr1_l3==0 Then
If mtr1_l2==0 then
if mtr1_l1==0 Then
mtype1 = 0 -- HF
Else
mtype1 = 1 -- 4M
end if
Else
if mtr1_l1==0 then
mtype1 = 2 -- VHF
Else
mtype1 = 3 -- UHF
End If
end if
Else
If mtr1_l2==0 then
if mtr1_l1==0 Then
mtype1 = 4 -- SHF
Else
mtype1 = 5 -- Free
End If
Else
if mtr1_l1==0 Then
mtype1 = 6 -- NC
Else
mtype1 = 6 -- NC
End If
end if
End If
If mtr2_l3==0 Then
if mtr2_l2==0 then
if mtr2_l1==0 then
mtype2 = 0 -- HF
Else
mtype2 = 1 -- 4M
End If
Else
if mtr2_l2==0 then
if mtr2_l1==0 Then
mtype2 = 2 -- VHF
Else
mtype2 = 3 -- UHF
End If
End If
End If
Else
if mtr2_l2==0 then
if mtr2_l1==0 Then
mtype2 = 4 -- SHF
Else
mtype2 = 5 -- Free
End If
Else
if mtr2_l1==0 Then
mtype2 = 6 -- NC
Else
mtype2 = 6 -- NC
End If
end if
End If
end procedure
procedure WriteMtrType(bit in isTwee) is
if isTwee==0 then
if (mtype1==0) then
print_string(glcd,isHF)
end if
if (mtype1==1) then
print_string(glcd,is4M)
end if
if (mtype1==2) then
print_string(glcd,isVHF)
end if
if (mtype1==3) then
print_string(glcd,isUHF)
end if
if (mtype1==4) then
print_string(glcd,isSHF)
end if
if (mtype1==5) then
print_string(glcd,isFree)
end if
if (mtype1==6) then
print_string(glcd,isNC)
end if
else
if (mtype2==0) then
print_string(glcd,isHF)
end if
if (mtype2==1) then
print_string(glcd,is4M)
end if
if (mtype2==2) then
print_string(glcd,isVHF)
end if
if (mtype2==3) then
print_string(glcd,isUHF)
end if
if (mtype2==4) then
print_string(glcd,isSHF)
end if
if (mtype2==5) then
print_string(glcd,isFree)
end if
if (mtype2==6) then
print_string(glcd,isNC)
end if
end if
end procedure
procedure DrawMeter(byte in b) is
glcd_pen_color = GLCD_BLACK
glcd_box(0+b,0,63+b,63)
glcd_box(0+b,52,63+b,63)
glcd_box(0+b,49,3+b,52)
glcd_box(60+b,49,63+b,52)
glcd_pen_color = GLCD_WHITE
glcd_box(1+b,53,62+b,62)
glcd_pen_color = GLCD_BLACK
glcd_char_goto(2+b,54)
;print_string(glcd,forwart)
if b==0 then
WriteMtrType(0)
else
WriteMtrType(1)
end if
glcd_char_goto(43+b,54)
print_string(glcd,reverse)
glcd_circle(31+b,57, 3)
glcd_line(30+b,55,32+b,59)
glcd_char_goto(2+b, 2)
if b==0 then
print_string(glcd,swr1)
WriteSWR(0)
else
print_string(glcd,swr2)
WriteSWR(1)
end if
end procedure
procedure PrintWattSign(bit in isTwee, byte in i) is
if isTwee==0 then
if (auto1_vo == 1) & (i>0) then
print_string(glcd,watXstr)
else
print_string(glcd,watstr)
end if
else
if (auto2_vo == 1) & (i>0) then
print_string(glcd,watXstr)
else
print_string(glcd,watstr)
end if
end if
end procedure
procedure WriteValues(byte in b, bit in isTwee) is
glcd_char_goto(2+b, 5)
;print_string(glcd,fwdstr)
WriteMtrType(isTwee)
if isTwee==0 then
print_string(glcd,swr1)
else
print_string(glcd,swr2)
end if
if isTwee==0 then
i = PWRLOOKUP[w1measure/10]
else
i = PWRLOOKUP[w4measure/10]
end if
print_word_dec(glcd, i)
PrintWattSign(isTwee,i)
if i<10 then
print_string(glcd,empstr)
end if
glcd_char_goto(2+b, 20)
print_string(glcd,refstr)
if isTwee==0 then
i = PWRLOOKUP[w2measure/10]
else
i = PWRLOOKUP[w5measure/10]
end if
print_word_dec(glcd, i)
PrintWattSign(isTwee,i)
if i<10 then
print_string(glcd,empstr)
end if
glcd_char_goto(2+b, 35)
print_string(glcd,peakst)
if isTwee==0 then
i = PWRLOOKUP[w3measure/10]
else
i = PWRLOOKUP[w6measure/10]
end if
print_word_dec(glcd, i)
PrintWattSign(isTwee,i)
if i<10 then
print_string(glcd,empstr)
end if
glcd_char_goto(2+b, 50)
print_string(glcd,swrstr)
WriteSWR(isTwee)
end procedure
procedure WriteMenu() is
glcd_char_goto(2, 0)
if mtype1==0 then
print_string(glcd,isHF)
end if
if mtype1==1 then
print_string(glcd,is4M)
end if
if mtype1==2 then
print_string(glcd,isVHF)
end if
if mtype1==3 then
print_string(glcd,isUHF)
end if
if mtype1==4 then
print_string(glcd,isSHF)
end if
if mtype1==5 then
print_string(glcd,isFree)
end if
if mtype1==6 then
print_string(glcd,isNC)
end if
print_string(glcd,empstr)
print_string(glcd,power1)
i = PWRLOOKUP[w1measure/10]
print_word_dec(glcd, i)
print_string(glcd,watstr)
if i<10 then
print_string(glcd,empstr)
end if
glcd_char_goto(2, 10)
if mtype2==0 then
print_string(glcd,isHF)
end if
if mtype2==1 then
print_string(glcd,is4M)
end if
if mtype2==2 then
print_string(glcd,isVHF)
end if
if mtype2==3 then
print_string(glcd,isUHF)
end if
if mtype2==4 then
print_string(glcd,isSHF)
end if
if mtype2==5 then
print_string(glcd,isFree)
end if
if mtype2==6 then
print_string(glcd,isNC)
end if
print_string(glcd,empstr)
print_string(glcd,power2)
i = PWRLOOKUP[w4measure/10]
print_word_dec(glcd, i)
print_string(glcd,watstr)
if i<10 then
print_string(glcd,empstr)
end if
if menuNo<3 then
glcd_char_goto(2, 25)
print_string(glcd,empstr)
print_string(glcd,isHF)
glcd_char_goto(2, 35)
if menuNo==1 then
print_string(glcd,starstr)
else
print_string(glcd,empstr)
end if
print_string(glcd,mpr)
print_word_dec(glcd, mpr_hf)
if mpr_hf<10 then
print_string(glcd,empstr)
end if
glcd_char_goto(2, 45)
if menuNo==2 then
print_string(glcd,starstr)
else
print_string(glcd,empstr)
end if
print_string(glcd,volt)
if mpv_hf==1 then
print_string(glcd,voltOn)
else
print_string(glcd,voltOff)
end if
end if
if (menuNo==3)|(menuNo==4) then
glcd_char_goto(2, 25)
print_string(glcd,empstr)
print_string(glcd,is4M)
glcd_char_goto(2, 35)
if menuNo==3 then
print_string(glcd,starstr)
else
print_string(glcd,empstr)
end if
print_string(glcd,mpr)
print_word_dec(glcd, mpr_4m)
if mpr_4m<10 then
print_string(glcd,empstr)
end if
glcd_char_goto(2, 45)
if menuNo==4 then
print_string(glcd,starstr)
else
print_string(glcd,empstr)
end if
print_string(glcd,volt)
if mpv_4m==1 then
print_string(glcd,voltOn)
else
print_string(glcd,voltOff)
end if
end if
if (menuNo==5)|(menuNo==6) then
glcd_char_goto(2, 25)
print_string(glcd,empstr)
print_string(glcd,isVHF)
glcd_char_goto(2, 35)
if menuNo==5 then
print_string(glcd,starstr)
else
print_string(glcd,empstr)
end if
print_string(glcd,mpr)
print_word_dec(glcd, mpr_vhf)
if mpr_vhf<10 then
print_string(glcd,empstr)
end if
glcd_char_goto(2, 45)
if menuNo==6 then
print_string(glcd,starstr)
else
print_string(glcd,empstr)
end if
print_string(glcd,volt)
if mpv_vhf==1 then
print_string(glcd,voltOn)
else
print_string(glcd,voltOff)
end if
end if
if (menuNo==7) | (menuNo==8) then
glcd_char_goto(2, 25)
print_string(glcd,empstr)
print_string(glcd,isUHF)
glcd_char_goto(2, 35)
if menuNo==7 then
print_string(glcd,starstr)
else
print_string(glcd,empstr)
end if
print_string(glcd,mpr)
print_word_dec(glcd, mpr_uhf)
if mpr_uhf<10 then
print_string(glcd,empstr)
end if
glcd_char_goto(2, 45)
if menuNo==8 then
print_string(glcd,starstr)
else
print_string(glcd,empstr)
end if
print_string(glcd,volt)
if mpv_uhf==1 then
print_string(glcd,voltOn)
else
print_string(glcd,voltOff)
end if
end if
if (menuNo==9) | (menuNo==10) then --SHF
glcd_char_goto(2, 25)
print_string(glcd,empstr)
print_string(glcd,isSHF)
glcd_char_goto(2, 35)
if menuNo==9 then
print_string(glcd,starstr)
else
print_string(glcd,empstr)
end if
print_string(glcd,mpr)
print_word_dec(glcd, mpr_shf)
if mpr_shf<10 then
print_string(glcd,empstr)
end if
glcd_char_goto(2, 45)
if menuNo==10 then
print_string(glcd,starstr)
else
print_string(glcd,empstr)
end if
print_string(glcd,volt)
if mpv_shf==1 then
print_string(glcd,voltOn)
else
print_string(glcd,voltOff)
end if -- end SHF
end if
; if (menuNo==11) | (menuNo==12) then -- start Free
; glcd_char_goto(2, 25)
; print_string(glcd,empstr)
; print_string(glcd,isFree)
; glcd_char_goto(2, 35)
; if menuNo==11 then
; print_string(glcd,starstr)
; else
; print_string(glcd,empstr)
; end if
; print_string(glcd,mpr)
; print_word_dec(glcd, mpr_free)
; if mpr_free<10 then
; print_string(glcd,empstr)
; end if
;
; glcd_char_goto(2, 45)
; if menuNo==12 then
; print_string(glcd,starstr)
; else
; print_string(glcd,empstr)
; end if
; print_string(glcd,volt)
; if mpv_free==1 then
; print_string(glcd,voltOn)
; else
; print_string(glcd,voltOff)
; end if
; end if end Free
end procedure
procedure MyInt is pragma interrupt
if INTCON_INT0IF then
INTCON_INT0IF = off
end if
if INTCON3_INT1IF then
if (mtrUp==0) then
mtrUp = 1
end if
INTCON3_INT1IF = off
end if
if INTCON3_INT2IF then
if (mtrUp==0) then
if (rotary_dir == 0) then
mtrUp = 2
else
mtrUp = 3
end if
end if
INTCON3_INT2IF = off
end if
end procedure
procedure MeasureADC() is
w1T1measure = adc_read(0)
w2T1measure = adc_read(1)
w4T1measure = adc_read(2)
w5T1measure = adc_read(3)
w6T1measure = adc_read(4)
w7T1measure = adc_read(5)
if w1T1measure > w1T2measure then
w1T2measure = w1T1measure
end if
if w2T1measure > w2T2measure then
w2T2measure = w2T1measure
end if
if w4T1measure > w4T2measure then
w4T2measure = w4T1measure
end if
if w5T1measure > w5T2measure then
w5T2measure = w5T1measure
end if
if w6T1measure > w6T2measure then
w6T2measure = w6T1measure
end if
if w7T1measure > w7T2measure then
w7T2measure = w7T1measure
end if
end procedure
procedure HandleMenu() is
if (mtrUp==1) then
if mtrMode <7 then
mtrMode =7
else
menuNo = menuNo + 1
if (menuNo == 11) then
data_eeprom_write(0,mpr_hf)
data_eeprom_write(1,mpr_4m)
data_eeprom_write(2,mpr_vhf)
data_eeprom_write(3,mpr_uhf)
data_eeprom_write(4,mpr_shf)
; data_eeprom_write(10,mpr_free) --*********************
data_eeprom_write(5,mpv_hf)
data_eeprom_write(6,mpv_4m)
data_eeprom_write(7,mpv_vhf)
data_eeprom_write(8,mpv_uhf)
data_eeprom_write(9,mpv_shf)
; data_eeprom_write(11,mpv_free) --*********************
mtrMode = 1
menuNo = 1
end if
end if
mtrUp=0
glcd_clear_screen()
end if
if (mtrUp==2) then
if (mtrMode==7) then
if menuNo==1 then
mpr_hf = mpr_hf + 1
end if
if menuNo==2 then
mpv_hf = mpv_hf + 1
end if
if menuNo==3 then
mpr_4m = mpr_4m + 1
end if
if menuNo==4 then
mpv_4m = mpv_4m + 1
end if
if menuNo==5 then
mpr_vhf = mpr_vhf + 1
end if
if menuNo==6 then
mpv_vhf = mpv_vhf + 1
end if
if menuNo==7 then
mpr_uhf = mpr_uhf + 1
end if
if menuNo==8 then
mpv_uhf = mpv_uhf + 1
end if
if menuNo==9 then
mpr_shf = mpr_shf + 1
end if
if menuNo==10 then
mpv_shf = mpv_shf + 1
end if
; if menuNo==11 then --*********************
; mpv_free = mpr_free + 1
; end if
; if menuNo==12 then
; mpv_free = mpv_free + 1
; end if
else
mtrMode = mtrMode + 1
if mtrMode ==7 then
mtrMode =1
end if
end if
mtrUp=0
glcd_clear_screen()
end if
if (mtrUp==3) then
if (mtrMode==7) then
if menuNo==1 then
mpr_hf = mpr_hf - 1
end if
if menuNo==2 then
mpv_hf = mpv_hf - 1
end if
if menuNo==3 then
mpr_4m = mpr_4m - 1
end if
if menuNo==4 then
mpv_4m = mpv_4m - 1
end if
if menuNo==5 then
mpr_vhf = mpr_vhf - 1
end if
if menuNo==6 then
mpv_vhf = mpv_vhf - 1
end if
if menuNo==7 then
mpr_uhf = mpr_uhf - 1
end if
if menuNo==8 then
mpv_uhf = mpv_uhf - 1
end if
if menuNo==9 then
mpr_shf = mpr_shf - 1
end if
if menuNo==10 then
mpv_shf = mpv_shf - 1
end if
; if menuNo==11 then --*********************
; mpv_shf = mpr_free - 1
; end if
; if menuNo==12 then
; mpv_shf = mpv_free - 1
; end if
else
mtrMode = mtrMode - 1
if mtrMode ==0 then
mtrMode =6
end if
end if
mtrUp=0
glcd_clear_screen()
end if
end procedure
procedure MainLoop is
SetMtrType()
MeasureADC()
if mtrUP>0 then
HandleMenu()
end if
MeasureADC()
-- mtrMode
-- 1 M1 M2
-- 2 T1 T2
-- 3 M1 T1
-- 4 M1 T2
-- 5 T1 M2
-- 6 T2 M2
if red_on == 1 then
led_red = !led_red
led_green = 0
else
led_green = !led_green
led_red = 0
end if
MeasureADC()
red_on = 0
if (mtrMode ==1) | (mtrMode ==3) | (mtrMode ==4) then
DrawMeter(0)
end if
MeasureADC()
if (mtrMode ==1) | (mtrMode ==5) | (mtrMode ==6) then
DrawMeter(toLeft)
end if
MeasureADC()
w1measure = w1T2measure
w2measure = w2T2measure
w4measure = w4T2measure
w5measure = w5T2measure
w6measure = w6T2measure
w7measure = w7T2measure
w1T1measure = 0
w2T1measure = 0
w4T1measure = 0
w5T1measure = 0
w6T1measure = 0
w7T1measure = 0
w1T2measure = 0
w2T2measure = 0
w4T2measure = 0
w5T2measure = 0
w6T2measure = 0
w7T2measure = 0