comparison code_part1/OSTC_code_asm_part1/menu_custom.asm @ 361:88660a400338 64kByte Logbook

Updated 64K logbook to changeset 360.
author JeanDo
date Wed, 08 Jun 2011 01:37:14 +0200
parents d4ca9196e830
children 6e57b5bb98ce
comparison
equal deleted inserted replaced
357:562f1bc79f3c 361:88660a400338
54 CF_MILI EQU 4 ; Displays 1.015 54 CF_MILI EQU 4 ; Displays 1.015
55 CF_BOOL EQU 5 ; Displays ON/OFF 55 CF_BOOL EQU 5 ; Displays ON/OFF
56 CF_SEC EQU 6 ; Displays 4:00 56 CF_SEC EQU 6 ; Displays 4:00
57 CF_COLOR EQU 7 ; Display 240 plus a color watch (inverse video space) 57 CF_COLOR EQU 7 ; Display 240 plus a color watch (inverse video space)
58 ; 58 ;
59 CF_TYPES EQU 0x1F 59 CF_TYPES EQU 0x0F
60 CF_MAX_BIT EQU 6 ; Default is the highest safe value. 60 CF_MAX_BIT EQU 6 ; Default is the highest safe value.
61 CF_MAX EQU (1<<CF_MAX_BIT) 61 CF_MAX EQU (1<<CF_MAX_BIT)
62 CF_MIN_BIT EQU 5 ; Default is the lowest safe value. 62 CF_MIN_BIT EQU 5 ; Default is the lowest safe value.
63 CF_MIN EQU (1<<CF_MIN_BIT) 63 CF_MIN EQU (1<<CF_MIN_BIT)
64 CF_NEG_BIT EQU 4 ; Allow negativ values.
65 CF_NEG EQU (1<<CF_NEG_BIT)
64 ; 66 ;
65 CF_INT15 EQU 0x80; Default display. Flag for 15bit, typeless values. 67 CF_INT15 EQU 0x80; Default display. Flag for 15bit, typeless values.
66 68
67 ; Overlay our tmp data with some unused variables. But use more 69 ;=============================================================================
68 ; meaningfull labels... 70 ; Overlay our tmp data in ACCESS0 bank
69 #define cf32_x4 divemins+0 ; CF# modulus 32, time 4. 71 CBLOCK 0x010 ; Keep space for aa_wordprocessor module.
70 #define cf_type divemins+1 ; Type of the edited CF 72 cf32_x4 ; CF# modulus 32, time 4.
71 #define cf_value divesecs 73 cf_type ; Type of the edited CF
72 #define cf_min apnoe_mins 74 cf_default:2
73 #define cf_max apnoe_secs 75 cf_value:2
74 76 cf_min
77 cf_max
78 cf_step ; Value ad add/substract: 1, 10, 100
79 ENDC
80
81 ;=============================================================================
82
75 GETCUSTOM8 macro custom8 83 GETCUSTOM8 macro custom8
76 movlw custom8 84 movlw custom8
77 call getcustom8_1 85 call getcustom8_1
78 endm 86 endm
79 87
160 bcf cursor 168 bcf cursor
161 bcf sleepmode 169 bcf sleepmode
162 clrf decodata+0 ; here: # of CustomFunction 170 clrf decodata+0 ; here: # of CustomFunction
163 clrf cf32_x4 ; here: # of CustomFunction*4 171 clrf cf32_x4 ; here: # of CustomFunction*4
164 bcf first_FA ; here: =1: -, =0: + 172 bcf first_FA ; here: =1: -, =0: +
165 bcf second_FA ; here: =1: stepsize 1, =0: stepsize 10 173 movlw 1 ; Stepsize: 1, 10, or 100.
174 movwf cf_step
166 175
167 call PLED_topline_box 176 call PLED_topline_box
168 WIN_INVERT .1 ; Init new Wordprocessor 177 WIN_INVERT .1 ; Init new Wordprocessor
169 178
170 btfss customfunction_page ; 179 btfss customfunction_page ;
235 movlw '-' 244 movlw '-'
236 movwf POSTINC2 245 movwf POSTINC2
237 call word_processor 246 call word_processor
238 247
239 WIN_TOP .95 248 WIN_TOP .95
240 STRCPY "1/10: 1" 249 STRCPY "Step:"
241 movlw '0' 250 clrf hi
242 btfsc second_FA 251 movff cf_step,lo
243 movwf POSTINC2 252 call display_formated ; Typed display, w/o fill line.
244 STRCAT_PRINT " " 253 STRCAT_PRINT " " ; 2 spaces for "0.01"->"1"
245 254
246 menu_custom_functions10b: 255 menu_custom_functions10b:
247 WIN_LEFT .20 256 WIN_LEFT .20
248 WIN_TOP .125 257 WIN_TOP .125
249 lfsr FSR2,letter 258 lfsr FSR2,letter
250 OUTPUTTEXT d'89' ;"Default:" 259 OUTPUTTEXT d'89' ; "Default:"
251 260
252 call display_customfunction ; Typed display. 261 movff cf_default+0,lo
262 movff cf_default+1,hi
263 call display_customfunction ; Typed display.
253 264
254 WIN_LEFT .20 265 WIN_LEFT .20
255 WIN_TOP .155 266 WIN_TOP .155
256 lfsr FSR2,letter 267 lfsr FSR2,letter
257 OUTPUTTEXT d'97' ; "Current:" 268 OUTPUTTEXT d'97' ; "Current:"
258 269
259 movf cf32_x4,W 270 movf cf32_x4,W
260 addlw 0x82 271 addlw 0x82
261 movwf EEADR 272 movwf EEADR
262 call read_eeprom ; Lowbyte 273 call read_eeprom ; Lowbyte
263 movff EEDATA,lo 274 movff EEDATA,cf_value+0
264 movff EEDATA, cf_value ; Backup low 8bit value.
265 275
266 movf cf32_x4,W 276 movf cf32_x4,W
267 addlw 0x83 277 addlw 0x83
268 movwf EEADR 278 movwf EEADR
269 call read_eeprom ; Highbyte 279 call read_eeprom ; Highbyte
270 movff EEDATA,hi 280 movff EEDATA,cf_value+1
271 281
272 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
273 call display_customfunction 285 call display_customfunction
274 286
275 ; End of mask: min/max and the exit line... 287 ; End of mask: min/max and the exit line...
276 rcall display_minmax 288 rcall display_minmax
277 DISPLAYTEXT .11 ; Exit 289 DISPLAYTEXT .11 ; Exit
332 344
333 ;----------------------------------------------------------------------------- 345 ;-----------------------------------------------------------------------------
334 ; Read default value, type, and constraints 346 ; Read default value, type, and constraints
335 ; 347 ;
336 ; Input: customfunction_page, cf32_x4 348 ; Input: customfunction_page, cf32_x4
337 ; Output: hi:lo, cf_type, cf_min, cf_max. 349 ; Output: cf_default, cf_type, cf_min, cf_max.
338 ; Trashes: TBLPTR 350 ; Trashes: TBLPTR
339 351
340 cf_read_default: 352 cf_read_default:
341 movlw LOW(cf_default_table0) ; Get 24bit PROM pointer. SKIP 353 movlw LOW(cf_default_table0) ; Get 24bit PROM pointer. SKIP
342 movwf TBLPTRL 354 movwf TBLPTRL
352 addwf TBLPTRL,F ; And to a 8+16 add into TBLPTR 364 addwf TBLPTRL,F ; And to a 8+16 add into TBLPTR
353 movlw 0 ; (keep carry) 365 movlw 0 ; (keep carry)
354 addwfc TBLPTRH,F ; Propagate to 16bit (but not 24bits). 366 addwfc TBLPTRH,F ; Propagate to 16bit (but not 24bits).
355 367
356 tblrd*+ 368 tblrd*+
357 movff TABLAT,lo ; Low byte --> lo 369 movff TABLAT,cf_default+0 ; Low byte
358 tblrd*+ 370 tblrd*+
359 movff TABLAT,hi ; High byte --> hi 371 movff TABLAT,cf_default+1 ; High byte
360 btfss hi,7 ; 15bit ? 372 btfss cf_default+1,7 ; 15bit ?
361 clrf hi ; NO: clear extra type flags 373 clrf cf_default+1 ; NO: clear extra type flags
362 bcf hi,7 ; clear 15bit flag 374 bcf cf_default+1,7 ; clear 15bit flag
363 375
364 movff TABLAT,cf_type ; type (high byte) --> cf_type 376 movff TABLAT,cf_type ; type (high byte) --> cf_type
365 377
366 tblrd*+ 378 tblrd*+
367 movff TABLAT,cf_min ; Then get optional min/max 379 movff TABLAT,cf_min ; Then get optional min/max
406 lfsr FSR2, letter 418 lfsr FSR2, letter
407 419
408 btfsc cf_type,7 ; A 15bit value ? 420 btfsc cf_type,7 ; A 15bit value ?
409 bra cf_no_min ; Don't display, hence clear line... 421 bra cf_no_min ; Don't display, hence clear line...
410 422
411 btfss cf_type, CF_MIN_BIT ; A min value exists ? 423 btfss cf_type,CF_MIN_BIT ; A min value exists ?
412 bra cf_no_min 424 bra cf_no_min
413 425
426 btfss cf_type,CF_NEG_BIT
427 bra cf_min_unsigned
428
429 ; Uses 16bit sub for checking signed min value.
430 movff cf_value,sub_a+0 ; A <- value
431 clrf sub_a+1
432 btfsc cf_value,7 ; extend sign if value < 0
433 setf sub_a+1
434
435 movff cf_min,sub_b+0 ; B <- min (with signed extend)
436 setf sub_b+1 ; min have to be negativ.
437 call sub16 ; Compute (A-B)
438
439 btfss neg_flag ; Result < 0 ?
440 bra cf_min_passed ; NO
441 bra cf_min_failed ; YES
442
443 cf_min_unsigned:
414 movf cf_min,W ; Retrieve current 8b value 444 movf cf_min,W ; Retrieve current 8b value
415 subwf cf_value,W ; Compute (lo-min) 445 subwf cf_value,W ; Compute (value-min)
416 bc cf_min_passed ; Ok if CARRY, ie. min >= lo 446 bc cf_min_passed ; Ok if CARRY, ie. min >= lo
447
448 cf_min_failed:
417 call PLED_warnings_color 449 call PLED_warnings_color
418 WIN_INVERT 1 450 WIN_INVERT 1
419 cf_min_passed: 451
420 452 cf_min_passed:
421 STRCAT "> " ; A min value follows 453 STRCAT "> " ; A min value follows
422 movff cf_min, lo 454 movff cf_min, lo
423 rcall display_formated 455 rcall display_formated
424 456
425 cf_no_min: 457 cf_no_min:
437 bra cf_no_max ; Don't display, hence clear line too... 469 bra cf_no_max ; Don't display, hence clear line too...
438 470
439 btfss cf_type, CF_MAX_BIT ; A max value exists ? 471 btfss cf_type, CF_MAX_BIT ; A max value exists ?
440 bra cf_no_max 472 bra cf_no_max
441 473
474 btfss cf_type,CF_NEG_BIT
475 bra cf_max_unsigned
476
477 ; Uses 16bit sub for checking signed min value.
478 movff cf_max,sub_a+0 ; A <- max (with signed extend)
479 clrf sub_a+1 ; max have to be positiv.
480
481 movff cf_value,sub_b+0 ; B <- value
482 clrf sub_b+1
483 btfsc cf_value,7 ; extend sign if value < 0
484 setf sub_b+1
485 call sub16 ; Compute (A-B)
486
487 btfss neg_flag ; Result < 0 ?
488 bra cf_max_passed ; NO
489 bra cf_max_failed ; YES
490
491 cf_max_unsigned:
442 movf cf_value,W ; Retrieve current max bound 492 movf cf_value,W ; Retrieve current max bound
443 subwf cf_max,W ; Compute (max-lo) 493 subwf cf_max,W ; Compute (max-lo)
444 bc cf_max_passed ; Ok if no carry, ie. max <= lo 494 bc cf_max_passed ; Ok if no carry, ie. max <= lo
495
496 cf_max_failed:
445 call PLED_warnings_color 497 call PLED_warnings_color
446 WIN_INVERT 1 498 WIN_INVERT 1
447 cf_max_passed: 499
448 500 cf_max_passed:
449 STRCAT "< " ; A max value follows 501 STRCAT "< " ; A max value follows
450 movff cf_max, lo 502 movff cf_max, lo
451 rcall display_formated 503 rcall display_formated
452 504
453 cf_no_max: 505 cf_no_max:
466 ; Input : hi:lo = data to display. 518 ; Input : hi:lo = data to display.
467 ; cf_type = the type. 519 ; cf_type = the type.
468 ; cf_min, cf_max : the optional min/max. 520 ; cf_min, cf_max : the optional min/max.
469 ; FSR2 = current string pointer. 521 ; FSR2 = current string pointer.
470 display_formated: 522 display_formated:
523 movf cf_type,W ; Just set N flags
524 bn cf_type_80 ; Keep 15bits value in old format.
525
526 ;---- handle signed values -----------------------------------------------
527 ; NOTE: only 8bit values can have a negativ flag right now.
528 btfss cf_type,CF_NEG_BIT ; Signed value ?
529 bra cf_type_unsigned ; NO: display unsigned as-is
530
531 btfss lo,7 ; Negativ value ?
532 bra cf_type_pos ; NO: display positives with a + sign.
533
534 PUTC '-' ; YES: display with a - sign.
535 negf lo ; and correct the said value.
536 bra cf_type_unsigned
537
538 cf_type_pos:
539 PUTC '+'
471 540
472 ;---- decode type -------------------------------------------------------- 541 ;---- decode type --------------------------------------------------------
473 movf cf_type,W ; Just set N/Z flags 542 cf_type_unsigned:
474 bn cf_type_neg ; Keep 15bits value in old format. 543 ; Jump table: ; test the value with cleared flags...
475 andlw CF_TYPES ; Look just at types 544 movf cf_type,W
545 andlw CF_TYPES ; Look just at types
476 bz cf_type_00 ; 8bit standard mode 546 bz cf_type_00 ; 8bit standard mode
477 547
478 ; Jump table: ; test the value with cleared flags...
479 dcfsnz WREG 548 dcfsnz WREG
480 bra cf_type_01 549 bra cf_type_01
481 dcfsnz WREG 550 dcfsnz WREG
482 bra cf_type_02 551 bra cf_type_02
483 dcfsnz WREG 552 dcfsnz WREG
537 retlw 0 606 retlw 0
538 607
539 cf_type_07: ; Type == 7 is CF_COLOR swatch. 608 cf_type_07: ; Type == 7 is CF_COLOR swatch.
540 bcf leftbind ; Keep leading space (better alignement) 609 bcf leftbind ; Keep leading space (better alignement)
541 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
542 STRCAT_PRINT " " 617 STRCAT_PRINT " "
543
544 movf lo,W ; Get color. 618 movf lo,W ; Get color.
545 call PLED_set_color 619 call PLED_set_color
546 movlw .23 620 movlw .23
547 movff WREG,win_height ; row bottom (0-239) 621 movff WREG,win_height ; row bottom (0-239)
548 movlw .110 622 movlw .110
555 629
556 cf_type_00: ; 8bit mode. Or unrecognized type... 630 cf_type_00: ; 8bit mode. Or unrecognized type...
557 clrf hi 631 clrf hi
558 bsf leftbind 632 bsf leftbind
559 633
560 cf_type_neg: ; 15bit mode. 634 cf_type_80: ; 15bit mode.
561 bcf hi,7 635 bcf hi,7
562 output_16 636 output_16
563 retlw 0 637 retlw 0
564 638
565 ;----------------------------------------------------------------------------- 639 ;-----------------------------------------------------------------------------
625 bra menu_custom_functions1 ; also debounces switches 699 bra menu_custom_functions1 ; also debounces switches
626 700
627 ;----------------------------------------------------------------------------- 701 ;-----------------------------------------------------------------------------
628 702
629 toggle_oneorten: 703 toggle_oneorten:
630 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:
631 movlw d'3' 728 movlw d'3'
632 movwf menupos 729 movwf menupos
633 bra menu_custom_functions1 ; also debounces switches 730 bra menu_custom_functions1 ; also debounces switches
634 731
635 ;----------------------------------------------------------------------------- 732 ;-----------------------------------------------------------------------------
636 733
637 restore_cfn_value: 734 restore_cfn_value:
638 rcall cf_read_default ; hi:lo is trashed by min/max display.
639
640 movf cf32_x4,W ; store default value 735 movf cf32_x4,W ; store default value
641 addlw 0x82 736 addlw 0x82
642 movwf EEADR 737 movwf EEADR
643 movff lo,EEDATA 738 movff cf_default+0,EEDATA
739 movff cf_default+0,cf_value+0
644 call write_eeprom ; Lowbyte 740 call write_eeprom ; Lowbyte
645 movf cf32_x4,W 741 movf cf32_x4,W
646 addlw 0x83 742 addlw 0x83
647 movwf EEADR 743 movwf EEADR
648 movff hi,EEDATA 744 movff cf_default+1,EEDATA
745 movff cf_default+1,cf_value+1
649 call write_eeprom ; Highbyte 746 call write_eeprom ; Highbyte
650 747
651 movlw d'4' 748 movlw d'4'
652 movwf menupos 749 movwf menupos
653 bra menu_custom_functions1 ; also debounces switches 750 bra menu_custom_functions1 ; also debounces switches
672 769
673 btg lo,0 ; Change lower bit. 770 btg lo,0 ; Change lower bit.
674 bra adjust_cfn_value3 ; Store result 771 bra adjust_cfn_value3 ; Store result
675 772
676 adjust_cfn_value1: 773 adjust_cfn_value1:
677 movlw d'1' 774 movf cf_step,W ; 1, 10, 100 ?
678 btfsc second_FA ; -10?
679 movlw d'10'
680 775
681 btfss first_FA ; Minus? 776 btfss first_FA ; Minus?
682 bra adjust_cfn_value2 ; No, Plus 777 bra adjust_cfn_value2 ; No, Plus
683 778
684 subwf lo,F ; substract value 779 subwf lo,F ; substract value
772 movwf cf_checker_counter 867 movwf cf_checker_counter
773 return 868 return
774 869
775 ; Check one CF value --------------------------------------------------------- 870 ; Check one CF value ---------------------------------------------------------
776 check_one_cf: 871 check_one_cf:
777 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.
778 873
779 btfsc cf_type,7 ; A 15bit type ? 874 btfsc cf_type,7 ; A 15bit type ?
780 bra check_cf_check ; Then we have to check it... 875 bra check_cf_check ; Then we have to check it...
781 876
782 movf cf_type,W ; 8bit MIN or MAX set ? 877 movf cf_type,W ; 8bit MIN or MAX set ?
819 rcall getcustom8_1 ; Read into WREG 914 rcall getcustom8_1 ; Read into WREG
820 movwf lo ; Save it. 915 movwf lo ; Save it.
821 916
822 btfss cf_type,CF_MIN_BIT 917 btfss cf_type,CF_MIN_BIT
823 bra check_no_min 918 bra check_no_min
824 919
920 btfss cf_type,CF_NEG_BIT
921 bra check_min_unsigned
922
923 ; Uses 16bit sub for checking signed min value.
924 movff lo,sub_a+0 ; A <- value
925 clrf sub_a+1
926 btfsc lo,7 ; extend sign if value < 0
927 setf sub_a+1
928
929 movff cf_min,sub_b+0 ; B <- min (with signed extend)
930 setf sub_b+1 ; min have to be negativ.
931 call sub16 ; Compute (A-B)
932
933 btfss neg_flag ; Result < 0 ?
934 bra check_no_min ; NO
935 retlw 0 ; YES = FAILED
936
937 check_min_unsigned:
825 cpfsgt cf_min ; Compare to cf_min 938 cpfsgt cf_min ; Compare to cf_min
826 bra check_no_min ; PASSED: continue. 939 bra check_no_min ; PASSED: continue.
827 retlw 0 ; NO: return failed. 940 retlw 0 ; NO: return failed.
828 941
829 check_no_min: 942 check_no_min:
830 btfss cf_type,CF_MAX_BIT ; Is there a MAX bound ? 943 btfss cf_type,CF_MAX_BIT ; Is there a MAX bound ?
831 retlw -1 ; No check: return OK. 944 retlw -1 ; No check: return OK.
832 945
946 btfss cf_type,CF_NEG_BIT
947 bra check_max_unsigned
948
949 ; Uses 16bit sub for checking signed min value.
950 movff cf_max,sub_a+0 ; A <- max (with signed extend)
951 clrf sub_a+1 ; max have to be positiv.
952
953 movff lo,sub_b+0 ; B <- value
954 clrf sub_b+1
955 btfsc lo,7 ; extend sign if value < 0
956 setf sub_b+1
957 call sub16 ; Compute (A-B)
958
959 btfss neg_flag ; Result < 0 ?
960 retlw -1 ; NO
961 retlw 0 ; YES
962
963 check_max_unsigned:
833 movf lo,W ; Compute value-max 964 movf lo,W ; Compute value-max
834 cpfslt cf_max 965 cpfslt cf_max
835 retlw -1 ; Bound met: return OK. 966 retlw -1 ; Bound met: return OK.
836 retlw 0 ; NO: return failed. 967 retlw 0 ; NO: return failed.