Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/menu_custom.asm @ 360:d4ca9196e830
Added 1/10/100 steps for CF menu.
* Displays steps formated with type.
* Special 0:01, 0:10, 1:00 steps for mm:ss type.
* * *
* * *
author | JeanDo |
---|---|
date | Wed, 08 Jun 2011 00:01:53 +0200 |
parents | f49d6f0fc870 |
children | 6e57b5bb98ce |
comparison
equal
deleted
inserted
replaced
359:91352bb698cf | 360:d4ca9196e830 |
---|---|
64 CF_NEG_BIT EQU 4 ; Allow negativ values. | 64 CF_NEG_BIT EQU 4 ; Allow negativ values. |
65 CF_NEG EQU (1<<CF_NEG_BIT) | 65 CF_NEG EQU (1<<CF_NEG_BIT) |
66 ; | 66 ; |
67 CF_INT15 EQU 0x80; Default display. Flag for 15bit, typeless values. | 67 CF_INT15 EQU 0x80; Default display. Flag for 15bit, typeless values. |
68 | 68 |
69 ; Overlay our tmp data with some unused variables. But use more | 69 ;============================================================================= |
70 ; meaningfull labels... | 70 ; Overlay our tmp data in ACCESS0 bank |
71 #define cf32_x4 divemins+0 ; CF# modulus 32, time 4. | 71 CBLOCK 0x010 ; Keep space for aa_wordprocessor module. |
72 #define cf_type divemins+1 ; Type of the edited CF | 72 cf32_x4 ; CF# modulus 32, time 4. |
73 #define cf_value divesecs | 73 cf_type ; Type of the edited CF |
74 #define cf_min apnoe_mins | 74 cf_default:2 |
75 #define cf_max apnoe_secs | 75 cf_value:2 |
76 | 76 cf_min |
77 cf_max | |
78 cf_step ; Value ad add/substract: 1, 10, 100 | |
79 ENDC | |
80 | |
81 ;============================================================================= | |
82 | |
77 GETCUSTOM8 macro custom8 | 83 GETCUSTOM8 macro custom8 |
78 movlw custom8 | 84 movlw custom8 |
79 call getcustom8_1 | 85 call getcustom8_1 |
80 endm | 86 endm |
81 | 87 |
162 bcf cursor | 168 bcf cursor |
163 bcf sleepmode | 169 bcf sleepmode |
164 clrf decodata+0 ; here: # of CustomFunction | 170 clrf decodata+0 ; here: # of CustomFunction |
165 clrf cf32_x4 ; here: # of CustomFunction*4 | 171 clrf cf32_x4 ; here: # of CustomFunction*4 |
166 bcf first_FA ; here: =1: -, =0: + | 172 bcf first_FA ; here: =1: -, =0: + |
167 bcf second_FA ; here: =1: stepsize 1, =0: stepsize 10 | 173 movlw 1 ; Stepsize: 1, 10, or 100. |
174 movwf cf_step | |
168 | 175 |
169 call PLED_topline_box | 176 call PLED_topline_box |
170 WIN_INVERT .1 ; Init new Wordprocessor | 177 WIN_INVERT .1 ; Init new Wordprocessor |
171 | 178 |
172 btfss customfunction_page ; | 179 btfss customfunction_page ; |
237 movlw '-' | 244 movlw '-' |
238 movwf POSTINC2 | 245 movwf POSTINC2 |
239 call word_processor | 246 call word_processor |
240 | 247 |
241 WIN_TOP .95 | 248 WIN_TOP .95 |
242 STRCPY "1/10: 1" | 249 STRCPY "Step:" |
243 movlw '0' | 250 clrf hi |
244 btfsc second_FA | 251 movff cf_step,lo |
245 movwf POSTINC2 | 252 call display_formated ; Typed display, w/o fill line. |
246 STRCAT_PRINT " " | 253 STRCAT_PRINT " " ; 2 spaces for "0.01"->"1" |
247 | 254 |
248 menu_custom_functions10b: | 255 menu_custom_functions10b: |
249 WIN_LEFT .20 | 256 WIN_LEFT .20 |
250 WIN_TOP .125 | 257 WIN_TOP .125 |
251 lfsr FSR2,letter | 258 lfsr FSR2,letter |
252 OUTPUTTEXT d'89' ;"Default:" | 259 OUTPUTTEXT d'89' ; "Default:" |
253 | 260 |
254 call display_customfunction ; Typed display. | 261 movff cf_default+0,lo |
262 movff cf_default+1,hi | |
263 call display_customfunction ; Typed display. | |
255 | 264 |
256 WIN_LEFT .20 | 265 WIN_LEFT .20 |
257 WIN_TOP .155 | 266 WIN_TOP .155 |
258 lfsr FSR2,letter | 267 lfsr FSR2,letter |
259 OUTPUTTEXT d'97' ; "Current:" | 268 OUTPUTTEXT d'97' ; "Current:" |
260 | 269 |
261 movf cf32_x4,W | 270 movf cf32_x4,W |
262 addlw 0x82 | 271 addlw 0x82 |
263 movwf EEADR | 272 movwf EEADR |
264 call read_eeprom ; Lowbyte | 273 call read_eeprom ; Lowbyte |
265 movff EEDATA,lo | 274 movff EEDATA,cf_value+0 |
266 movff EEDATA, cf_value ; Backup low 8bit value. | |
267 | 275 |
268 movf cf32_x4,W | 276 movf cf32_x4,W |
269 addlw 0x83 | 277 addlw 0x83 |
270 movwf EEADR | 278 movwf EEADR |
271 call read_eeprom ; Highbyte | 279 call read_eeprom ; Highbyte |
272 movff EEDATA,hi | 280 movff EEDATA,cf_value+1 |
273 | 281 |
274 call PLED_standard_color ; Changed by color swatches, but trash EEADRH... | 282 call PLED_standard_color ; Changed by color swatches, but trash EEADRH... |
283 movff cf_value+0,lo | |
284 movff cf_value+1,hi | |
275 call display_customfunction | 285 call display_customfunction |
276 | 286 |
277 ; End of mask: min/max and the exit line... | 287 ; End of mask: min/max and the exit line... |
278 rcall display_minmax | 288 rcall display_minmax |
279 DISPLAYTEXT .11 ; Exit | 289 DISPLAYTEXT .11 ; Exit |
334 | 344 |
335 ;----------------------------------------------------------------------------- | 345 ;----------------------------------------------------------------------------- |
336 ; Read default value, type, and constraints | 346 ; Read default value, type, and constraints |
337 ; | 347 ; |
338 ; Input: customfunction_page, cf32_x4 | 348 ; Input: customfunction_page, cf32_x4 |
339 ; Output: hi:lo, cf_type, cf_min, cf_max. | 349 ; Output: cf_default, cf_type, cf_min, cf_max. |
340 ; Trashes: TBLPTR | 350 ; Trashes: TBLPTR |
341 | 351 |
342 cf_read_default: | 352 cf_read_default: |
343 movlw LOW(cf_default_table0) ; Get 24bit PROM pointer. SKIP | 353 movlw LOW(cf_default_table0) ; Get 24bit PROM pointer. SKIP |
344 movwf TBLPTRL | 354 movwf TBLPTRL |
354 addwf TBLPTRL,F ; And to a 8+16 add into TBLPTR | 364 addwf TBLPTRL,F ; And to a 8+16 add into TBLPTR |
355 movlw 0 ; (keep carry) | 365 movlw 0 ; (keep carry) |
356 addwfc TBLPTRH,F ; Propagate to 16bit (but not 24bits). | 366 addwfc TBLPTRH,F ; Propagate to 16bit (but not 24bits). |
357 | 367 |
358 tblrd*+ | 368 tblrd*+ |
359 movff TABLAT,lo ; Low byte --> lo | 369 movff TABLAT,cf_default+0 ; Low byte |
360 tblrd*+ | 370 tblrd*+ |
361 movff TABLAT,hi ; High byte --> hi | 371 movff TABLAT,cf_default+1 ; High byte |
362 btfss hi,7 ; 15bit ? | 372 btfss cf_default+1,7 ; 15bit ? |
363 clrf hi ; NO: clear extra type flags | 373 clrf cf_default+1 ; NO: clear extra type flags |
364 bcf hi,7 ; clear 15bit flag | 374 bcf cf_default+1,7 ; clear 15bit flag |
365 | 375 |
366 movff TABLAT,cf_type ; type (high byte) --> cf_type | 376 movff TABLAT,cf_type ; type (high byte) --> cf_type |
367 | 377 |
368 tblrd*+ | 378 tblrd*+ |
369 movff TABLAT,cf_min ; Then get optional min/max | 379 movff TABLAT,cf_min ; Then get optional min/max |
479 bra cf_max_failed ; YES | 489 bra cf_max_failed ; YES |
480 | 490 |
481 cf_max_unsigned: | 491 cf_max_unsigned: |
482 movf cf_value,W ; Retrieve current max bound | 492 movf cf_value,W ; Retrieve current max bound |
483 subwf cf_max,W ; Compute (max-lo) | 493 subwf cf_max,W ; Compute (max-lo) |
484 bc cf_max_passed ; Ok if no carry, ie. max <= lo | 494 bc cf_max_passed ; Ok if no carry, ie. max <= lo |
485 | 495 |
486 cf_max_failed: | 496 cf_max_failed: |
487 call PLED_warnings_color | 497 call PLED_warnings_color |
488 WIN_INVERT 1 | 498 WIN_INVERT 1 |
489 | 499 |
596 retlw 0 | 606 retlw 0 |
597 | 607 |
598 cf_type_07: ; Type == 7 is CF_COLOR swatch. | 608 cf_type_07: ; Type == 7 is CF_COLOR swatch. |
599 bcf leftbind ; Keep leading space (better alignement) | 609 bcf leftbind ; Keep leading space (better alignement) |
600 output_8 | 610 output_8 |
611 | |
612 movff win_top,WREG ; Is it the step value ? | |
613 xorlw .95 ; Line for "Step:" | |
614 btfsc STATUS,Z | |
615 retlw -1 ; YES : return | |
616 | |
601 STRCAT_PRINT " " | 617 STRCAT_PRINT " " |
602 | |
603 movf lo,W ; Get color. | 618 movf lo,W ; Get color. |
604 call PLED_set_color | 619 call PLED_set_color |
605 movlw .23 | 620 movlw .23 |
606 movff WREG,win_height ; row bottom (0-239) | 621 movff WREG,win_height ; row bottom (0-239) |
607 movlw .110 | 622 movlw .110 |
684 bra menu_custom_functions1 ; also debounces switches | 699 bra menu_custom_functions1 ; also debounces switches |
685 | 700 |
686 ;----------------------------------------------------------------------------- | 701 ;----------------------------------------------------------------------------- |
687 | 702 |
688 toggle_oneorten: | 703 toggle_oneorten: |
689 btg second_FA | 704 movlw .10 ; Multiply step by 10, |
705 mulwf cf_step ; Result in PROD low. | |
706 | |
707 movf PRODH,W ; Check 1000 | |
708 bz toggle_oneorten_1 ; HIGH(new step) null == no overflow | |
709 movlw .1 ; Cycle to 1. | |
710 movwf cf_step | |
711 bra toggle_oneorten_3 | |
712 | |
713 toggle_oneorten_1: ; Special case for mm:ss | |
714 movf cf_type,W ; Get type | |
715 andlw CF_TYPES ; w/o min/max/neg flags. | |
716 xorlw CF_SEC ; Check for mm:ss ? | |
717 bnz toggle_oneorten_2 ; no: continue | |
718 movlw .100 ; Step = 100 ? | |
719 xorwf PRODL,W | |
720 bnz toggle_oneorten_2 ; no: continue | |
721 movlw .60 ; yes: replace by 1:00 | |
722 movff WREG,cf_step | |
723 bra toggle_oneorten_3 ; Done. | |
724 | |
725 toggle_oneorten_2: | |
726 movff PRODL,cf_step ; Just keep result. | |
727 toggle_oneorten_3: | |
690 movlw d'3' | 728 movlw d'3' |
691 movwf menupos | 729 movwf menupos |
692 bra menu_custom_functions1 ; also debounces switches | 730 bra menu_custom_functions1 ; also debounces switches |
693 | 731 |
694 ;----------------------------------------------------------------------------- | 732 ;----------------------------------------------------------------------------- |
695 | 733 |
696 restore_cfn_value: | 734 restore_cfn_value: |
697 rcall cf_read_default ; hi:lo is trashed by min/max display. | |
698 | |
699 movf cf32_x4,W ; store default value | 735 movf cf32_x4,W ; store default value |
700 addlw 0x82 | 736 addlw 0x82 |
701 movwf EEADR | 737 movwf EEADR |
702 movff lo,EEDATA | 738 movff cf_default+0,EEDATA |
739 movff cf_default+0,cf_value+0 | |
703 call write_eeprom ; Lowbyte | 740 call write_eeprom ; Lowbyte |
704 movf cf32_x4,W | 741 movf cf32_x4,W |
705 addlw 0x83 | 742 addlw 0x83 |
706 movwf EEADR | 743 movwf EEADR |
707 movff hi,EEDATA | 744 movff cf_default+1,EEDATA |
745 movff cf_default+1,cf_value+1 | |
708 call write_eeprom ; Highbyte | 746 call write_eeprom ; Highbyte |
709 | 747 |
710 movlw d'4' | 748 movlw d'4' |
711 movwf menupos | 749 movwf menupos |
712 bra menu_custom_functions1 ; also debounces switches | 750 bra menu_custom_functions1 ; also debounces switches |
731 | 769 |
732 btg lo,0 ; Change lower bit. | 770 btg lo,0 ; Change lower bit. |
733 bra adjust_cfn_value3 ; Store result | 771 bra adjust_cfn_value3 ; Store result |
734 | 772 |
735 adjust_cfn_value1: | 773 adjust_cfn_value1: |
736 movlw d'1' | 774 movf cf_step,W ; 1, 10, 100 ? |
737 btfsc second_FA ; -10? | |
738 movlw d'10' | |
739 | 775 |
740 btfss first_FA ; Minus? | 776 btfss first_FA ; Minus? |
741 bra adjust_cfn_value2 ; No, Plus | 777 bra adjust_cfn_value2 ; No, Plus |
742 | 778 |
743 subwf lo,F ; substract value | 779 subwf lo,F ; substract value |
831 movwf cf_checker_counter | 867 movwf cf_checker_counter |
832 return | 868 return |
833 | 869 |
834 ; Check one CF value --------------------------------------------------------- | 870 ; Check one CF value --------------------------------------------------------- |
835 check_one_cf: | 871 check_one_cf: |
836 rcall cf_read_default ; Sets hi:lo, cf_type, cf_min, cf_max. | 872 rcall cf_read_default ; Sets cf_value, cf_type, cf_min, cf_max. |
837 | 873 |
838 btfsc cf_type,7 ; A 15bit type ? | 874 btfsc cf_type,7 ; A 15bit type ? |
839 bra check_cf_check ; Then we have to check it... | 875 bra check_cf_check ; Then we have to check it... |
840 | 876 |
841 movf cf_type,W ; 8bit MIN or MAX set ? | 877 movf cf_type,W ; 8bit MIN or MAX set ? |
885 bra check_min_unsigned | 921 bra check_min_unsigned |
886 | 922 |
887 ; Uses 16bit sub for checking signed min value. | 923 ; Uses 16bit sub for checking signed min value. |
888 movff lo,sub_a+0 ; A <- value | 924 movff lo,sub_a+0 ; A <- value |
889 clrf sub_a+1 | 925 clrf sub_a+1 |
890 btfsc cf_value,7 ; extend sign if value < 0 | 926 btfsc lo,7 ; extend sign if value < 0 |
891 setf sub_a+1 | 927 setf sub_a+1 |
892 | 928 |
893 movff cf_min,sub_b+0 ; B <- min (with signed extend) | 929 movff cf_min,sub_b+0 ; B <- min (with signed extend) |
894 setf sub_b+1 ; min have to be negativ. | 930 setf sub_b+1 ; min have to be negativ. |
895 call sub16 ; Compute (A-B) | 931 call sub16 ; Compute (A-B) |
914 movff cf_max,sub_a+0 ; A <- max (with signed extend) | 950 movff cf_max,sub_a+0 ; A <- max (with signed extend) |
915 clrf sub_a+1 ; max have to be positiv. | 951 clrf sub_a+1 ; max have to be positiv. |
916 | 952 |
917 movff lo,sub_b+0 ; B <- value | 953 movff lo,sub_b+0 ; B <- value |
918 clrf sub_b+1 | 954 clrf sub_b+1 |
919 btfsc cf_value,7 ; extend sign if value < 0 | 955 btfsc lo,7 ; extend sign if value < 0 |
920 setf sub_b+1 | 956 setf sub_b+1 |
921 call sub16 ; Compute (A-B) | 957 call sub16 ; Compute (A-B) |
922 | 958 |
923 btfss neg_flag ; Result < 0 ? | 959 btfss neg_flag ; Result < 0 ? |
924 retlw -1 ; NO | 960 retlw -1 ; NO |