-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple_menu.asm
2931 lines (2779 loc) · 75.1 KB
/
simple_menu.asm
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
;------------------------------------------------------------------------------
; Î÷åíü ïðèìèòèâíàÿ ðåàëèçàöèÿ ìåíþ
; Äëÿ êàæäîãî ýêðàíà åñòü ñâîé îáðàáîò÷èê ñîáûòèé è íàáîð ïîäïðîãðàìì îáðàáîòêè ýòèõ ñòáûòèé
;
;
; (C) 2019-2020 Vitaliy Zinoviev
; https://github.com/nf-zvv/IVC_Tracer_v2
;
; History
; =======
;
;------------------------------------------------------------------------------
;------------------------------------------------------------------------------
; Çàãëóøêà
;------------------------------------------------------------------------------
void:
ret
;==============================================================================
;
; #
; # #### #### # ####
; # # # # # # # #
; # # # # # #
; # # # # ### # #
; # # # # # # # #
; ####### #### #### # ####
;
;==============================================================================
;------------------------------------------------------------------------------
; Îáðàáîò÷èê ñîáûòèé
;
;
;------------------------------------------------------------------------------
MENU_EVENT_HANDLER:
lds r16,Flags
sbrs r16,enc_left_spin
rjmp menu_event_handler_enc_right_spin
; ñðàáîòàëî ñîáûòèå enc_left_spin
; ñáðîñèì ôëàã
andi r16,~(1 << enc_left_spin)
sts Flags,r16
; âûáèðàåì äåéñòâèå â çàâèñèìîñòè îò òåêóùåãî ýêðàíà
lds r16,screen_ID
; Ãëàâíûé ýêðàí
cpi r16,MAIN_SCREEN_ID
breq main_scr_left_spin_action
; Ýêðàí êàëèáðîâêè
cpi r16,CALIBRATION_SCREEN_ID
breq calib_scr_left_spin_action
; Ýêðàí àâòîìàòè÷åñêîãî ñíÿòèÿ ÂÀÕ
cpi r16,IVC_TRACE_SCREEN_ID
breq ivc_trace_scr_left_spin_action
; Íåêîððåêòíîå çíà÷åíèå screen_ID
rjmp menu_event_handler_enc_right_spin
main_scr_left_spin_action:
rcall main_scr_encoder_left
rjmp menu_event_handler_enc_right_spin
calib_scr_left_spin_action:
rcall calib_scr_encoder_left
rjmp menu_event_handler_enc_right_spin
ivc_trace_scr_left_spin_action:
rcall ivc_trace_scr_encoder_left
;rjmp menu_event_handler_enc_right_spin
;------------------------------------------------------------------------------
menu_event_handler_enc_right_spin:
lds r16,Flags
sbrs r16,enc_right_spin
rjmp menu_event_handler_btn_press
; ñðàáîòàëî ñîáûòèå enc_right_spin
; ñáðîñèì ôëàã
andi r16,~(1 << enc_right_spin)
sts Flags,r16
; âûáèðàåì äåéñòâèå â çàâèñèìîñòè îò òåêóùåãî ýêðàíà
lds r16,screen_ID
; Ãëàâíûé ýêðàí
cpi r16,MAIN_SCREEN_ID
breq main_scr_right_spin_action
; Ýêðàí êàëèáðîâêè
cpi r16,CALIBRATION_SCREEN_ID
breq calib_scr_right_spin_action
; Ýêðàí àâòîìàòè÷åñêîãî ñíÿòèÿ ÂÀÕ
cpi r16,IVC_TRACE_SCREEN_ID
breq ivc_trace_scr_right_spin_action
; Íåêîððåêòíîå çíà÷åíèå screen_ID
rjmp menu_event_handler_btn_press
main_scr_right_spin_action:
rcall main_scr_encoder_right
rjmp menu_event_handler_btn_press
calib_scr_right_spin_action:
rcall calib_scr_encoder_right
rjmp menu_event_handler_btn_press
ivc_trace_scr_right_spin_action:
rcall ivc_trace_scr_encoder_right
;rjmp menu_event_handler_btn_press
;------------------------------------------------------------------------------
menu_event_handler_btn_press:
lds r16,Flags
sbrs r16,btn_press
rjmp menu_event_handler_btn_long_press
; ñðàáîòàëî ñîáûòèå btn_press
; ñáðîñèì ôëàã
andi r16,~(1 << btn_press)
sts Flags,r16
; âûáèðàåì äåéñòâèå â çàâèñèìîñòè îò òåêóùåãî ýêðàíà
lds r16,screen_ID
; Ãëàâíûé ýêðàí
cpi r16,MAIN_SCREEN_ID
breq main_scr_btn_press_action
; Ýêðàí êàëèáðîâêè
cpi r16,CALIBRATION_SCREEN_ID
breq calib_scr_btn_press_action
; Ýêðàí àâòîìàòè÷åñêîãî ñíÿòèÿ ÂÀÕ
cpi r16,IVC_TRACE_SCREEN_ID
breq ivc_trace_scr_btn_press_action
; Íåêîððåêòíîå çíà÷åíèå screen_ID
rjmp menu_event_handler_btn_long_press
main_scr_btn_press_action:
rcall main_scr_btn_press
rjmp menu_event_handler_btn_long_press
calib_scr_btn_press_action:
rcall calib_scr_btn_press
rjmp menu_event_handler_btn_long_press
ivc_trace_scr_btn_press_action:
rcall ivc_trace_scr_btn_press
;rjmp menu_event_handler_btn_long_press
;------------------------------------------------------------------------------
menu_event_handler_btn_long_press:
lds r16,Flags
sbrs r16,btn_long_press
rjmp menu_event_handler_update
; ñðàáîòàëî ñîáûòèå btn_long_press
; ñáðîñèì ôëàã
andi r16,~(1 << btn_long_press)
sts Flags,r16
; âûáèðàåì äåéñòâèå â çàâèñèìîñòè îò òåêóùåãî ýêðàíà
lds r16,screen_ID
; Ãëàâíûé ýêðàí
cpi r16,MAIN_SCREEN_ID
breq main_scr_btn_long_press_action
; Ýêðàí êàëèáðîâêè
cpi r16,CALIBRATION_SCREEN_ID
breq calib_scr_btn_long_press_action
; Ýêðàí àâòîìàòè÷åñêîãî ñíÿòèÿ ÂÀÕ
cpi r16,IVC_TRACE_SCREEN_ID
breq ivc_trace_scr_btn_long_press_action
; Íåêîððåêòíîå çíà÷åíèå screen_ID
rjmp menu_event_handler_update
main_scr_btn_long_press_action:
rcall void
rjmp menu_event_handler_update
calib_scr_btn_long_press_action:
rcall void
rjmp menu_event_handler_update
ivc_trace_scr_btn_long_press_action:
rcall void
;rjmp menu_event_handler_update
;------------------------------------------------------------------------------
menu_event_handler_update:
lds r16,Flags
sbrs r16,update
rjmp menu_event_handler_change_screen
; ñðàáîòàëî ñîáûòèå update
; ñáðîñèì ôëàã
andi r16,~(1 << update)
sts Flags,r16
; âûáèðàåì äåéñòâèå â çàâèñèìîñòè îò òåêóùåãî ýêðàíà
lds r16,screen_ID
; Ãëàâíûé ýêðàí
cpi r16,MAIN_SCREEN_ID
breq main_scr_update_action
; Ýêðàí êàëèáðîâêè
cpi r16,CALIBRATION_SCREEN_ID
breq calib_scr_update_action
; Ýêðàí àâòîìàòè÷åñêîãî ñíÿòèÿ ÂÀÕ
cpi r16,IVC_TRACE_SCREEN_ID
breq ivc_trace_scr_update_action
; Íåêîððåêòíîå çíà÷åíèå screen_ID
rjmp menu_event_handler_change_screen
main_scr_update_action:
rcall main_scr_update
rjmp menu_event_handler_change_screen
calib_scr_update_action:
rcall calib_scr_update
rjmp menu_event_handler_change_screen
ivc_trace_scr_update_action:
rcall void
;rjmp menu_event_handler_change_screen
;------------------------------------------------------------------------------
menu_event_handler_change_screen:
lds r16,Flags
sbrs r16,change_screen
rjmp menu_event_handler_uart_rx_parse
; ñðàáîòàëî ñîáûòèå change_screen
; ñáðîñèì ôëàã
andi r16,~(1 << change_screen)
sts Flags,r16
; âûáèðàåì äåéñòâèå â çàâèñèìîñòè îò òåêóùåãî ýêðàíà
lds r16,screen_ID
; Ãëàâíûé ýêðàí
cpi r16,MAIN_SCREEN_ID
breq main_scr_change_screen_action
; Ýêðàí êàëèáðîâêè
cpi r16,CALIBRATION_SCREEN_ID
breq calib_scr_change_screen_action
; Ýêðàí àâòîìàòè÷åñêîãî ñíÿòèÿ ÂÀÕ
cpi r16,IVC_TRACE_SCREEN_ID
breq ivc_trace_scr_change_screen_action
; Íåêîððåêòíîå çíà÷åíèå screen_ID
rjmp menu_event_handler_uart_rx_parse
main_scr_change_screen_action:
rcall MAIN_SCREEN
rjmp menu_event_handler_uart_rx_parse
calib_scr_change_screen_action:
rcall CALIBRATION_SCREEN
rjmp menu_event_handler_uart_rx_parse
ivc_trace_scr_change_screen_action:
rcall IVC_TRACE_SCREEN
;rjmp menu_event_handler_uart_rx_parse
;------------------------------------------------------------------------------
menu_event_handler_uart_rx_parse:
lds r16,UART_Flags
sbrs r16,UART_STR_RCV
rjmp menu_event_handler_end
; ñðàáîòàëî ñîáûòèå uart_rx_parse
; ñáðîñèì ôëàã
;andi r16,~(1 << UART_STR_RCV)
;sts UART_Flags,r16
; Ñáðîñ ôëàãà âûïîëíÿåòñÿ â íà÷àëå ïîäïðîãðàììû UART_RX_PARSE
call UART_RX_PARSE
menu_event_handler_end:
rjmp MENU_EVENT_HANDLER
;------------------------------------------------------------------------------
; Ãëàâíûé ýêðàí
; Îæèäàíèå ñîáûòèé â öèêëå
; Îáðàáîòêà ñîáûòèé ýíêîäåðà
; - ñáðîñ ôëàãîâ
; - ïåðåõîä íà ïîäïðîãðàììó-îáðàáîò÷èê
; Îáðàáîòêà îáíîâëåíèÿ ïàðàìåòðîâ (update)
;
; TODO: ñäåëàòü ðåãóëèðîâêó "òî÷íî/ãðóáî" âìåñòî "çíà÷åíèå+øàã"
; TODO: äîëãîå íàæàòèå íà êíîïêó ýíêîäåðà - ñáðîñ çíà÷åíèÿ íà äåôîëòíîå
;------------------------------------------------------------------------------
MAIN_SCREEN:
rcall PRINT_MAIN_SCREEN
rcall PRINT_MAIN_DEFAULT
; Îáíóëÿåì óêàçàåëü òåêóùåãî ïóíêòà ìåíþ
sts menu_ID,__zero_reg__
; Äåàêòèâèðóåì ïóíêò
lds r16,Flags
andi r16,~(1<<menu_edit)
sts Flags,r16
; Êóðñîð íà ïåðâóþ ñòðî÷êó ìåíþ
ldi r18,0
ldi r19,2
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
ret
;------------------------------------------------------------------------------
; Ãëàâíûé ýêðàí
; Ñîáûòèå: ïîâîðîò ýíêîäåðà âëåâî
;
;------------------------------------------------------------------------------
main_scr_encoder_left:
; ñíà÷àëà ïðîâåðÿåì ôëàã ðåäàêòèðîâàíèÿ
lds r16,Flags
sbrs r16,menu_edit
rjmp main_scr_encoder_left_noedit
;..............................................................................
; ïóíêò â ðåæèìå ðåäàêòèðîâàíèÿ
lds r16,menu_ID
cpi r16,0
breq main_scr_encoder_left_dec_dac
cpi r16,1
breq main_scr_encoder_left_dec_dac_step
rjmp main_scr_encoder_left_exit
main_scr_encoder_left_dec_dac:
rcall Encoder_left
rjmp main_scr_encoder_left_exit
main_scr_encoder_left_dec_dac_step:
rcall main_scr_dec_dac_step
rjmp main_scr_encoder_left_exit
;..............................................................................
; ïóíêò íå â ðåæèìå ðåäàêòèðîâàíèÿ
main_scr_encoder_left_noedit:
lds r16,menu_ID
; Çàãðóæàåì â Z àäðåñ òàáëèöû ïåðåõîäîâ
ldi ZH,high(main_scr_encoder_left_TABLE)
ldi ZL,low(main_scr_encoder_left_TABLE)
; äîáàâëÿåì ñìåùåíèå àäðåñà
add ZL,r16
adc ZH,__zero_reg__
ijmp
main_scr_encoder_left_TABLE:
rjmp main_scr_encoder_left_0
rjmp main_scr_encoder_left_1
rjmp main_scr_encoder_left_2
rjmp main_scr_encoder_left_3
main_scr_encoder_left_0:
ldi r16,3
sts menu_ID,r16
ldi r18,0
ldi r19,2
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,5
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp main_scr_encoder_left_exit
main_scr_encoder_left_1:
ldi r16,0
sts menu_ID,r16
ldi r18,0
ldi r19,3
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,2
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp main_scr_encoder_left_exit
main_scr_encoder_left_2:
ldi r16,1
sts menu_ID,r16
ldi r18,0
ldi r19,4
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,3
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp main_scr_encoder_left_exit
main_scr_encoder_left_3:
ldi r16,2
sts menu_ID,r16
ldi r18,0
ldi r19,5
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,4
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp main_scr_encoder_left_exit
main_scr_encoder_left_exit:
ret
;------------------------------------------------------------------------------
; Ãëàâíûé ýêðàí
; Ñîáûòèå: ïîâîðîò ýíêîäåðà âïðàâî
;
;------------------------------------------------------------------------------
main_scr_encoder_right:
; ñíà÷àëà ïðîâåðÿåì ôëàã ðåäàêòèðîâàíèÿ
lds r16,Flags
sbrs r16,menu_edit
rjmp main_scr_encoder_right_noedit
;..............................................................................
; ïóíêò â ðåæèìå ðåäàêòèðîâàíèÿ
lds r16,menu_ID
cpi r16,0
breq main_scr_encoder_right_inc_dac
cpi r16,1
breq main_scr_encoder_right_inc_dac_step
rjmp main_scr_encoder_right_exit
main_scr_encoder_right_inc_dac:
rcall Encoder_right
rjmp main_scr_encoder_right_exit
main_scr_encoder_right_inc_dac_step:
rcall main_scr_inc_dac_step
rjmp main_scr_encoder_right_exit
;..............................................................................
; ïóíêò íå â ðåæèìå ðåäàêòèðîâàíèÿ
main_scr_encoder_right_noedit:
lds r16,menu_ID
; Çàãðóæàåì â Z àäðåñ òàáëèöû ïåðåõîäîâ
ldi ZH,high(main_scr_encoder_right_TABLE)
ldi ZL,low(main_scr_encoder_right_TABLE)
; äîáàâëÿåì ñìåùåíèå àäðåñà
add ZL,r16
adc ZH,__zero_reg__
ijmp
main_scr_encoder_right_TABLE:
rjmp main_scr_encoder_right_0
rjmp main_scr_encoder_right_1
rjmp main_scr_encoder_right_2
rjmp main_scr_encoder_right_3
main_scr_encoder_right_0:
ldi r16,1
sts menu_ID,r16
ldi r18,0
ldi r19,2
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,3
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp main_scr_encoder_right_exit
main_scr_encoder_right_1:
ldi r16,2
sts menu_ID,r16
ldi r18,0
ldi r19,3
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,4
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp main_scr_encoder_right_exit
main_scr_encoder_right_2:
ldi r16,3
sts menu_ID,r16
ldi r18,0
ldi r19,4
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,5
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp main_scr_encoder_right_exit
main_scr_encoder_right_3:
ldi r16,0
sts menu_ID,r16
ldi r18,0
ldi r19,5
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,2
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp main_scr_encoder_right_exit
main_scr_encoder_right_exit:
ret
;------------------------------------------------------------------------------
;
;
;
;
;------------------------------------------------------------------------------
main_scr_dec_dac_step:
lds r24,DAC_STEP+0
lds r25,DAC_STEP+1
ldi r26,1
ldi r27,0
rcall DECREMENT
sts DAC_STEP+0,r24
sts DAC_STEP+1,r25
; Âûâîäèì çíà÷åíèå DAC_STEP íà äèñïëåé
; Ïðåîáðàçîâàòü ÷èñëî â ñòðîêó
mov XL,r24
mov XH,r25
ldi YL,low(STRING)
ldi YH,high(STRING)
call DEC_TO_STR5
; Óñòàíîâèòü êîîðäèíàòû âûâîäà
ldi r18,11
ldi r19,3
call T6963C_TextGoTo
; Âûâåñòè ÷èñëà íà äèñïëåé
ldi XL,low(STRING)
ldi XH,high(STRING)
call T6963C_WriteString
ret
;------------------------------------------------------------------------------
;
;
;
;
;------------------------------------------------------------------------------
main_scr_inc_dac_step:
lds r24,DAC_STEP+0
lds r25,DAC_STEP+1
ldi r26,1
ldi r27,0
rcall INCREMENT
sts DAC_STEP+0,r24
sts DAC_STEP+1,r25
; Âûâîäèì çíà÷åíèå DAC_STEP íà äèñïëåé
; Ïðåîáðàçîâàòü ÷èñëî â ñòðîêó
mov XL,r24
mov XH,r25
ldi YL,low(STRING)
ldi YH,high(STRING)
call DEC_TO_STR5
; Óñòàíîâèòü êîîðäèíàòû âûâîäà
ldi r18,11
ldi r19,3
call T6963C_TextGoTo
; Âûâåñòè ÷èñëà íà äèñïëåé
ldi XL,low(STRING)
ldi XH,high(STRING)
call T6963C_WriteString
ret
;------------------------------------------------------------------------------
; Ãëàâíûé ýêðàí
; Ñîáûòèå: íàæàòèå êíîïêè ýíêîäåðà
;
;
;------------------------------------------------------------------------------
main_scr_btn_press:
; îáðàáîò÷èê äëÿ ïóíêòîâ "IVC Trace" è "Calibration"
lds r16,menu_ID
cpi r16,2 ; ïóíêò "IVC Trace"
brne main_scr_btn_press_3
ldi r16,IVC_TRACE_SCREEN_ID
rjmp main_scr_btn_press_change_screen
main_scr_btn_press_3:
cpi r16,3 ; ïóíêò "Calibration"
brne main_scr_btn_press_act
ldi r16,CALIBRATION_SCREEN_ID
main_scr_btn_press_change_screen:
sts screen_ID,r16
lds r16,Flags
ori r16,(1<<change_screen) ; óñòàíîâêà ôëàãà ñìåíû ìåíþ
sts Flags,r16
ret
;..............................................................................
main_scr_btn_press_act:
; ïðîâåðÿåì ôëàã ðåäàêòèðîâàíèÿ
lds r16,Flags
sbrs r16,menu_edit
rjmp main_scr_btn_press_noedit
; ïóíêò â ðåæèìå ðåäàêòèðîâàíèÿ (àêòèâèðîâàí)
; òîãäà äåàêòèâèðóåì ïóíêò:
andi r16,~(1<<menu_edit)
rjmp main_scr_btn_press_exit
main_scr_btn_press_noedit:
; ïóíêò íå â ðåæèìå ðåäàêòèðîâàíèÿ (äåàêòèâèðîâàí)
; òîãäà àêòèâèðóåì ïóíêò:
ori r16,(1<<menu_edit) ; óñòàíîâêà ôëàãà
main_scr_btn_press_exit:
sts Flags,r16
ret
;------------------------------------------------------------------------------
;
;
;
;------------------------------------------------------------------------------
main_scr_update:
rcall Event_update
ret
;==============================================================================
; Ýêðàí êàëèáðîâêè
;
; Ïîâîðîòîì ðó÷êè ýíêîäåðà âûáèðàåòñÿ ïóíêò ìåíþ,
; íàæàòèåì êíîïêè ýíêîäåðà ýòîò ïóíêò àêòèâèðóåòñÿ,
; ïîâîðîòîì ðó÷êè ýíêîäåðà ðåãóëèðóåòñÿ çíà÷åíèå ïóíêòà ìåíþ,
; íàæàòèåì êíîïêè ýíêîäåðà ïóíêò äåàêòèâèðóåòñÿ.
; Îáðàáîò÷èê ñîáûòèé ýíêîäåðà
; Â çàâèñèìîñòè îò òîãî, àêòèâèðîâàí ïóíêò ìåíþ èëè íåò:
; Ïîâîðîò âëåâî:
; - ïåðåõîä íà ïðåäûäóùèé ïóíêò ìåíþ
; - óìåíüøåíèå òåêóùåãî çíà÷åíèÿ
; Ïîâîðîò âïðàâî:
; - ïåðåõîä íà ñëåäóþùèé ïóíêò ìåíþ
; - óâåëè÷åíèå òåêóùåãî çíà÷åíèÿ
;==============================================================================
;------------------------------------------------------------------------------
; Ýêðàí êàëèáðîâêè
; Îæèäàíèå ñîáûòèé â öèêëå
; Îáðàáîòêà ñîáûòèé ýíêîäåðà
; - ñáðîñ ôëàãîâ
; - ïåðåõîä íà ïîäïðîãðàììó-îáðàáîò÷èê
; Îáðàáîòêà ñîáûòèÿ âûõîäà èç ìåíþ
;
;
;------------------------------------------------------------------------------
CALIBRATION_SCREEN:
; Âûâîäèì ñîäåðæèìîå ìåíþ
rcall PRINT_CALIBRATION_SCREEN
; Âûâåñòè òåêóùèå çíà÷åíèÿ
rcall PRINT_CALIBRATION_DEFAULT
; Îáíóëÿåì óêàçàåëü òåêóùåãî ïóíêòà ìåíþ
sts menu_ID,__zero_reg__
; Äåàêòèâèðóåì ïóíêò
lds r16,Flags
andi r16,~(1<<menu_edit)
sts Flags,r16
; Êóðñîð íà ïåðâóþ ñòðî÷êó ìåíþ
ldi r18,0
ldi r19,6
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
ret
;------------------------------------------------------------------------------
; Ýêðàí êàëèáðîâêè
; Ñîáûòèå: ïîâîðîò ýíêîäåðà âëåâî
;
;
;------------------------------------------------------------------------------
calib_scr_encoder_left:
; ñíà÷àëà ïðîâåðÿåì ôëàã ðåäàêòèðîâàíèÿ
lds r16,Flags
sbrs r16,menu_edit
rjmp calib_scr_encoder_left_noedit
;..............................................................................
; ïóíêò â ðåæèìå ðåäàêòèðîâàíèÿ
lds r16,menu_ID
; Çàãðóæàåì â Z àäðåñ òàáëèöû ïåðåõîäîâ
ldi ZH,high(calib_scr_encoder_left_ed_TABLE)
ldi ZL,low(calib_scr_encoder_left_ed_TABLE)
; äîáàâëÿåì ñìåùåíèå àäðåñà
add ZL,r16
adc ZH,__zero_reg__
ijmp
calib_scr_encoder_left_ed_TABLE:
rjmp ZERO_DAC_DEC
rjmp VREF_DAC_DEC
rjmp CH0_DELTA_DEC
rjmp CH1_DELTA_DEC
rjmp ADC_V_REF_DEC
rjmp ACS712_KI_DEC
rjmp RESDIV_KU_DEC
;rjmp calib_scr_encoder_left_exit
ZERO_DAC_DEC:
lds r25,ZERO_DAC+1
lds r24,ZERO_DAC+0
ldi r27,0
ldi r26,1
rcall DECREMENT
sts ZERO_DAC+1,r25
sts ZERO_DAC+0,r24
rjmp calib_scr_encoder_left_exit
VREF_DAC_DEC:
lds r25,VREF_DAC+1
lds r24,VREF_DAC+0
ldi r27,0
ldi r26,1
rcall DECREMENT
sts VREF_DAC+1,r25
sts VREF_DAC+0,r24
sts DAC_CH_A+1,r25
sts DAC_CH_A+0,r24
rcall DAC_SET_A
rjmp calib_scr_encoder_left_exit
CH0_DELTA_DEC:
lds r25,CH0_DELTA+1
lds r24,CH0_DELTA+0
ldi r27,0
ldi r26,1
rcall DECREMENT
sts CH0_DELTA+1,r25
sts CH0_DELTA+0,r24
rjmp calib_scr_encoder_left_exit
CH1_DELTA_DEC:
lds r25,CH1_DELTA+1
lds r24,CH1_DELTA+0
ldi r27,0
ldi r26,1
rcall DECREMENT
sts CH1_DELTA+1,r25
sts CH1_DELTA+0,r24
rjmp calib_scr_encoder_left_exit
ADC_V_REF_DEC:
lds r25,ADC_V_REF+1
lds r24,ADC_V_REF+0
ldi r27,0
ldi r26,1
rcall DECREMENT
sts ADC_V_REF+1,r25
sts ADC_V_REF+0,r24
rjmp calib_scr_encoder_left_exit
ACS712_KI_DEC:
lds r24,ACS712_KI
dec r24
sts ACS712_KI,r24
rjmp calib_scr_encoder_left_exit
RESDIV_KU_DEC:
lds r24,RESDIV_KU
dec r24
sts RESDIV_KU,r24
rjmp calib_scr_encoder_left_exit
;..............................................................................
calib_scr_encoder_left_noedit:
; ïóíêò íå â ðåæèìå ðåäàêòèðîâàíèÿ
lds r16,menu_ID
; Çàãðóæàåì â Z àäðåñ òàáëèöû ïåðåõîäîâ
ldi ZH,high(calib_scr_encoder_left_TABLE)
ldi ZL,low(calib_scr_encoder_left_TABLE)
; äîáàâëÿåì ñìåùåíèå àäðåñà
add ZL,r16
adc ZH,__zero_reg__
ijmp
calib_scr_encoder_left_TABLE:
rjmp calib_scr_encoder_left_0
rjmp calib_scr_encoder_left_1
rjmp calib_scr_encoder_left_2
rjmp calib_scr_encoder_left_3
rjmp calib_scr_encoder_left_4
rjmp calib_scr_encoder_left_5
rjmp calib_scr_encoder_left_6
rjmp calib_scr_encoder_left_7
rjmp calib_scr_encoder_left_8
calib_scr_encoder_left_0:
ldi r16,8
sts menu_ID,r16
ldi r18,0
ldi r19,6
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,14
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp calib_scr_encoder_left_exit
calib_scr_encoder_left_1:
ldi r16,0
sts menu_ID,r16
ldi r18,0
ldi r19,7
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,6
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp calib_scr_encoder_left_exit
calib_scr_encoder_left_2:
ldi r16,1
sts menu_ID,r16
ldi r18,0
ldi r19,8
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,7
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp calib_scr_encoder_left_exit
calib_scr_encoder_left_3:
ldi r16,2
sts menu_ID,r16
ldi r18,0
ldi r19,9
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,8
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp calib_scr_encoder_left_exit
calib_scr_encoder_left_4:
ldi r16,3
sts menu_ID,r16
ldi r18,0
ldi r19,10
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,9
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp calib_scr_encoder_left_exit
calib_scr_encoder_left_5:
ldi r16,4
sts menu_ID,r16
ldi r18,0
ldi r19,11
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,10
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp calib_scr_encoder_left_exit
calib_scr_encoder_left_6:
ldi r16,5
sts menu_ID,r16
ldi r18,0
ldi r19,12
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,11
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp calib_scr_encoder_left_exit
calib_scr_encoder_left_7:
ldi r16,6
sts menu_ID,r16
ldi r18,0
ldi r19,13
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,12
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
rjmp calib_scr_encoder_left_exit
calib_scr_encoder_left_8:
ldi r16,7
sts menu_ID,r16
ldi r18,0
ldi r19,14
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0
ldi r19,13
call T6963C_TextGoTo
ldi r18,'>'
call T6963C_WriteChar
calib_scr_encoder_left_exit:
ret
;------------------------------------------------------------------------------
; Ýêðàí êàëèáðîâêè
; Ñîáûòèå: ïîâîðîò ýíêîäåðà âïðàâî
;
;
;------------------------------------------------------------------------------
calib_scr_encoder_right:
; ñíà÷àëà ïðîâåðÿåì ôëàã ðåäàêòèðîâàíèÿ
lds r16,Flags
sbrs r16,menu_edit
rjmp calib_scr_encoder_right_noedit
;..............................................................................
; ïóíêò â ðåæèìå ðåäàêòèðîâàíèÿ
lds r16,menu_ID
; Çàãðóæàåì â Z àäðåñ òàáëèöû ïåðåõîäîâ
ldi ZH,high(calib_scr_encoder_right_ed_TABLE)
ldi ZL,low(calib_scr_encoder_right_ed_TABLE)
; äîáàâëÿåì ñìåùåíèå àäðåñà
add ZL,r16
adc ZH,__zero_reg__
ijmp
calib_scr_encoder_right_ed_TABLE:
rjmp ZERO_DAC_INC
rjmp VREF_DAC_INC
rjmp CH0_DELTA_INC
rjmp CH1_DELTA_INC
rjmp ADC_V_REF_INC
rjmp ACS712_KI_INC
rjmp RESDIV_KU_INC
ZERO_DAC_INC:
lds r25,ZERO_DAC+1
lds r24,ZERO_DAC+0
ldi r27,0
ldi r26,1
rcall INCREMENT
sts ZERO_DAC+1,r25
sts ZERO_DAC+0,r24
rjmp calib_scr_encoder_right_exit
VREF_DAC_INC:
lds r25,VREF_DAC+1
lds r24,VREF_DAC+0
ldi r27,0
ldi r26,1
rcall INCREMENT
sts VREF_DAC+1,r25
sts VREF_DAC+0,r24
sts DAC_CH_A+1,r25
sts DAC_CH_A+0,r24
rcall DAC_SET_A
rjmp calib_scr_encoder_right_exit
CH0_DELTA_INC:
lds r25,CH0_DELTA+1
lds r24,CH0_DELTA+0
ldi r27,0
ldi r26,1
rcall INCREMENT
sts CH0_DELTA+1,r25
sts CH0_DELTA+0,r24
rjmp calib_scr_encoder_right_exit
CH1_DELTA_INC:
lds r25,CH1_DELTA+1
lds r24,CH1_DELTA+0
ldi r27,0
ldi r26,1
rcall INCREMENT
sts CH1_DELTA+1,r25
sts CH1_DELTA+0,r24
rjmp calib_scr_encoder_right_exit
ADC_V_REF_INC:
lds r25,ADC_V_REF+1
lds r24,ADC_V_REF+0
ldi r27,0
ldi r26,1
rcall INCREMENT
sts ADC_V_REF+1,r25
sts ADC_V_REF+0,r24
rjmp calib_scr_encoder_right_exit
ACS712_KI_INC:
lds r24,ACS712_KI
inc r24
sts ACS712_KI,r24
rjmp calib_scr_encoder_right_exit
RESDIV_KU_INC:
lds r24,RESDIV_KU
inc r24
sts RESDIV_KU,r24
rjmp calib_scr_encoder_right_exit
;..............................................................................
calib_scr_encoder_right_noedit:
; ïóíêò íå â ðåæèìå ðåäàêòèðîâàíèÿ
lds r16,menu_ID
; Çàãðóæàåì â Z àäðåñ òàáëèöû ïåðåõîäîâ
ldi ZH,high(calib_scr_encoder_right_TABLE)
ldi ZL,low(calib_scr_encoder_right_TABLE)
; äîáàâëÿåì ñìåùåíèå àäðåñà
add ZL,r16
adc ZH,__zero_reg__
ijmp
calib_scr_encoder_right_TABLE:
rjmp calib_scr_encoder_right_0
rjmp calib_scr_encoder_right_1
rjmp calib_scr_encoder_right_2
rjmp calib_scr_encoder_right_3
rjmp calib_scr_encoder_right_4
rjmp calib_scr_encoder_right_5
rjmp calib_scr_encoder_right_6
rjmp calib_scr_encoder_right_7
rjmp calib_scr_encoder_right_8
calib_scr_encoder_right_0:
ldi r16,1
sts menu_ID,r16
ldi r18,0
ldi r19,6
call T6963C_TextGoTo
ldi r18,' '
call T6963C_WriteChar
ldi r18,0