comparison code_part1/OSTC_code_asm_part1/menu_custom.asm @ 79:69c462400279

Making CF edition esier
author JeanDo
date Mon, 06 Dec 2010 18:00:13 +0100
parents c6cab044a338
children 3e351e25f5d1
comparison
equal deleted inserted replaced
78:bd16d5830b06 79:69c462400279
41 ; 2 byte (low:high) store the actual value 41 ; 2 byte (low:high) store the actual value
42 ; defaults for custom functions are in menu "reset" 42 ; defaults for custom functions are in menu "reset"
43 ; get values with GETCUSTOM8 .x with x=0...32 for 8 Bit values (stored in WREG) 43 ; get values with GETCUSTOM8 .x with x=0...32 for 8 Bit values (stored in WREG)
44 ; or with GETCUSTOM15 .x with x=0...32 for 15 Bit values (stored in lo and hi) 44 ; or with GETCUSTOM15 .x with x=0...32 for 15 Bit values (stored in lo and hi)
45 45
46 ; [jDG] 2010-11-30 More fancy displsy of the various CF types
47 ; data types. When we do have a 8bit data (bit16=0), the high byte serves to
48 ; define the display format:
49
50 CF_INT8 EQU 0 ; Default display, 8 or 15 bits values.
51 CF_PERCENT EQU 1 ; Displays 110%
52 CF_DECI EQU 2 ; Displays 1.6
53 CF_CENTI EQU 3 ; Displays 1.50
54 CF_MILI EQU 4 ; Displays 1.015
55 CF_BOOL EQU 5 ; Displays ON/OFF
56 CF_SEC EQU 6 ; Displays 4:00
57 CF_COLOR EQU 7 ; Display 240 plus a color watch (inverse video space)
58 CF_INT15 EQU 0x80; Default display. Flag for 15bit, typeless values.
46 59
47 GETCUSTOM8 macro custom8 60 GETCUSTOM8 macro custom8
48 movlw custom8 61 movlw custom8
49 call getcustom8_1 62 call getcustom8_1
50 endm 63 endm
148 161
149 menu_custom_functions11: 162 menu_custom_functions11:
150 WIN_INVERT .0 ; Init new Wordprocessor 163 WIN_INVERT .0 ; Init new Wordprocessor
151 164
152 menu_custom_functions1: 165 menu_custom_functions1:
166
167 #ifndef NO_CF_TYPES
168 ;---- Clear color swatches area ------------------------------------------
169 ; BEWARE: PLED_box reset the EEADRH register, so t should be
170 ; be done before setting CF page I/II...
171 clrf WREG ; Black background
172 movff WREG,box_temp+0 ; Set color
173 movlw .125
174 movff WREG,box_temp+1 ; row top (0-239)
175 movlw .178
176 movff WREG,box_temp+2 ; row bottom (0-239)
177 movlw .75
178 movff WREG,box_temp+3 ; column left (0-159)
179 movlw .150
180 movff WREG,box_temp+4 ; column right (0-159)
181 call PLED_box
182 #endif
153 call PLED_standard_color 183 call PLED_standard_color
154 184
155 movlw d'1' 185 movlw d'1'
156 btfss customfunction_page ; Use Page II... 186 btfss customfunction_page ; Use Page II...
157 movlw d'0' 187 movlw d'0'
167 197
168 movlw d'0' 198 movlw d'0'
169 btfsc customfunction_page ; Add offset for display 199 btfsc customfunction_page ; Add offset for display
170 movlw d'32' 200 movlw d'32'
171 addwf lo,F 201 addwf lo,F
172 movff lo,apnoe_mins ; apnoe_mins used as temp for binary CFs 202 movff lo, apnoe_mins ; Copy use when NO_CF_TYPES
173 203
174 output_99x 204 output_99x
175 movlw ':' 205 movlw ':'
176 movwf POSTINC2 206 movwf POSTINC2
177 movlw ' ' 207 movlw ' '
180 210
181 movf customfunction_temp1,W ; start of custom function descriptors 211 movf customfunction_temp1,W ; start of custom function descriptors
182 addwf decodata+0,W ; add # of current custom function, place result in wreg 212 addwf decodata+0,W ; add # of current custom function, place result in wreg
183 call displaytext1 ; shows descriptor 213 call displaytext1 ; shows descriptor
184 214
215 ; Read defaults into hi:lo
216 movf divemins+0,W
217 addlw 0x80
218 movwf EEADR
219 call read_eeprom ; Lowbyte
220 movff EEDATA,lo
221 movf divemins+0,W
222 addlw 0x81
223 movwf EEADR
224 call read_eeprom ; Highbyte
225 movff EEDATA,hi
226
227 #ifdef NO_CF_TYPES
185 movlw binary_cf1 228 movlw binary_cf1
186 subwf apnoe_mins,W ; Binary cf? 229 subwf apnoe_mins,W ; Binary cf?
187 btfsc STATUS,Z 230 bz menu_custom_functions10c ; Yes
188 bra menu_custom_functions10c ; Yes
189 231
190 movlw binary_cf2 232 movlw binary_cf2
191 subwf apnoe_mins,W ; Binary cf? 233 subwf apnoe_mins,W ; Binary cf?
192 btfsc STATUS,Z 234 bz menu_custom_functions10c ; Yes
193 bra menu_custom_functions10c ; Yes
194 235
195 movlw binary_cf3 236 movlw binary_cf3
196 subwf apnoe_mins,W ; Binary cf? 237 subwf apnoe_mins,W ; Binary cf?
197 btfsc STATUS,Z 238 bz menu_custom_functions10c ; Yes
198 bra menu_custom_functions10c ; Yes
199 239
200 movlw binary_cf4 240 movlw binary_cf4
201 subwf apnoe_mins,W ; Binary cf? 241 subwf apnoe_mins,W ; Binary cf?
202 btfsc STATUS,Z 242 bz menu_custom_functions10c ; Yes
203 bra menu_custom_functions10c ; Yes
204 243
205 movlw binary_cf5 244 movlw binary_cf5
206 subwf apnoe_mins,W ; Binary cf? 245 subwf apnoe_mins,W ; Binary cf?
207 btfsc STATUS,Z 246 bz menu_custom_functions10c ; Yes
208 bra menu_custom_functions10c ; Yes
209 247
210 movlw binary_cf6 248 movlw binary_cf6
211 subwf apnoe_mins,W ; Binary cf? 249 subwf apnoe_mins,W ; Binary cf?
212 btfsc STATUS,Z 250 bz menu_custom_functions10c ; Yes
213 bra menu_custom_functions10c ; Yes 251
214 252 bra menu_custom_functions10a ; Not a binary CF...
215 253 #else
216 bra menu_custom_functions10a ; Not a binary CF selected 254 movf hi,W ; Is it a ON/OFF flag ?
255 xorlw CF_BOOL
256 bnz menu_custom_functions10a ; Not a binary CF selected
257 #endif
217 258
218 menu_custom_functions10c: 259 menu_custom_functions10c:
219 movlw d'1' 260 setf apnoe_mins ; Yes, set apnoe_mins to 0xFF
220 movwf apnoe_mins ; Yes, set apnoe_mins to "1" 261
262 WIN_LEFT .20
263 WIN_TOP .65
264 lfsr FSR2,letter ; Make a string of 8 spaces
265 movlw ' '
266 movwf POSTINC2
267 movwf POSTINC2
268 movwf POSTINC2
269 movwf POSTINC2
270 movwf POSTINC2
271 movwf POSTINC2
272 movwf POSTINC2
273 movwf POSTINC2
274 call word_processor ; Clear +/- line
275
276 WIN_TOP .95
277 call word_processor ; Clear 1/10 line
221 bra menu_custom_functions10b 278 bra menu_custom_functions10b
222 279
223 menu_custom_functions10a: 280 menu_custom_functions10a:
224 clrf apnoe_mins ; Yes, clear apnoe_mins 281 clrf apnoe_mins ; Yes, clear apnoe_mins
225 menu_custom_functions10b: 282
226 WIN_LEFT .20 283 WIN_LEFT .20
227 WIN_TOP .65 284 WIN_TOP .65
228 lfsr FSR2,letter 285 lfsr FSR2,letter
229 movlw '+' 286 movlw '+'
230 movwf POSTINC2 287 movwf POSTINC2
264 movwf POSTINC2 321 movwf POSTINC2
265 movlw ' ' 322 movlw ' '
266 movwf POSTINC2 323 movwf POSTINC2
267 call word_processor 324 call word_processor
268 325
326 menu_custom_functions10b:
269 WIN_LEFT .20 327 WIN_LEFT .20
270 WIN_TOP .125 328 WIN_TOP .125
271 lfsr FSR2,letter 329 lfsr FSR2,letter
272 OUTPUTTEXT d'89' ;"Default:" 330 OUTPUTTEXT d'89' ;"Default:"
273
274 movf divemins+0,W
275 addlw 0x80
276 movwf EEADR
277 call read_eeprom ; Lowbyte
278 movff EEDATA,lo
279 movf divemins+0,W
280 addlw 0x81
281 movwf EEADR
282 call read_eeprom ; Highbyte
283 movff EEDATA,hi
284 bcf hi,7 ; clear Bit 7 of value
285 output_16
286 movlw ','
287 movwf POSTINC2
288
289 movlw '1'
290 btfss EEDATA,7 ; 15Bit?
291 movlw '8' ; 8Bit!
292 tstfsz apnoe_mins ; apnoe_mins=0?
293 movlw '1' ; No, 1Bit!
294 movwf POSTINC2
295
296 movlw '5'
297 btfsc EEDATA,7 ; 15Bit?
298 movwf POSTINC2
299 movlw 'B'
300 movwf POSTINC2
301 movlw ' ' 331 movlw ' '
302 movwf POSTINC2 332 movwf POSTINC2
303 movlw ' ' 333
304 movwf POSTINC2 334 call display_customfunction ; Typed display.
305 movlw ' '
306 movwf POSTINC2
307 call word_processor
308 335
309 WIN_LEFT .20 336 WIN_LEFT .20
310 WIN_TOP .155 337 WIN_TOP .155
311 lfsr FSR2,letter 338 lfsr FSR2,letter
312 OUTPUTTEXT d'97' ; "Current:" 339 OUTPUTTEXT d'97' ; "Current:"
340 movlw ' '
341 movwf POSTINC2
313 342
314 movf divemins+0,W 343 movf divemins+0,W
315 addlw 0x82 344 addlw 0x82
316 movwf EEADR 345 movwf EEADR
317 call read_eeprom ; Lowbyte 346 call read_eeprom ; Lowbyte
318 movff EEDATA,lo 347 movff EEDATA,lo
348
319 movf divemins+0,W 349 movf divemins+0,W
320 addlw 0x83 350 addlw 0x83
321 movwf EEADR 351 movwf EEADR
322 call read_eeprom ; Highbyte 352 call read_eeprom ; Highbyte
353
354 btfss hi,7 ; A 15bit value ?
355 bra menu_custom_functions1b ; No : keep types there !
356
323 movff EEDATA,hi 357 movff EEDATA,hi
324 output_16 358 bsf hi,7 ; Mark it a 15bit value.
325 movlw ' ' 359
326 movwf POSTINC2 360 menu_custom_functions1b:
327 movlw ' ' 361 call display_customfunction
328 movwf POSTINC2
329 movlw ' '
330 movwf POSTINC2
331 call word_processor
332 362
333 menu_custom_functions1a: 363 menu_custom_functions1a:
334 DISPLAYTEXT .11 ; Exit 364 DISPLAYTEXT .11 ; Exit
335 365
336 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! 366 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
376 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! 406 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
377 407
378 bcf menubit3 ; clear flag 408 bcf menubit3 ; clear flag
379 bra customfunctions_loop 409 bra customfunctions_loop
380 410
411 ;-----------------------------------------------------------------------------
412 ; Input : hi:lo = data to display, with type embebed into hi
413 ; FSR2 = current string pointer.
414 ; Trash : FSR1 (used to backup EEADRH and hi)
415
416 display_customfunction:
417 #ifndef NO_CF_TYPES
418 movff EEADRH, FSR1H ; Backup...
419 movff hi, FSR1L
420
421 ;---- decode type --------------------------------------------------------
422 movf hi,W ; Just set N/Z flags
423 bn cf_type_0 ; Keep 15bits value in old format.
424 bz cf_type_99 ; 8bit standard mode
425
426 ; Jump table:
427 dcfsnz hi
428 bra cf_type_01
429 dcfsnz hi
430 bra cf_type_02
431 dcfsnz hi
432 bra cf_type_03
433 dcfsnz hi
434 bra cf_type_04
435 dcfsnz hi
436 bra cf_type_05
437 dcfsnz hi
438 bra cf_type_06
439 dcfsnz hi
440 bra cf_type_07
441 bra cf_type_99 ; Default to 8bit mode...
442
443 cf_type_01: ; Type == 1 is percent mode
444 output_16dp 0 ; NOTE : hi is already reseted...
445 movlw '%'
446 movwf POSTINC2
447 bra cf_done
448
449 cf_type_02: ; Type == 2 is deci mode.
450 output_16dp 4
451 bra cf_done
452
453 cf_type_03: ; Type == 3 is centi mode.
454 output_16dp 3
455 bra cf_done
456
457 cf_type_04: ; Type == 4 is mili mode
458 output_16dp 2
459 bra cf_done
460
461 cf_type_05: ; Type == 5 is on/off mode.
462 movf lo,W ; Get flag value...
463 bz cf_type_off
464 OUTPUTTEXT d'130' ; ON
465 bra cf_done
466 cf_type_off:
467 OUTPUTTEXT d'131' ; OFF
468 bra cf_done
469
470 cf_type_06: ; Type == 6 is mm:ss mode (... or hh:mm)
471 call convert_time ; Convert to min:sec into hi:low.
472 movff lo,wp_temp ; Save seconds,
473 movff hi,lo ; Get minutes
474 output_8 ; Print them
475 movlw ':' ; Separator
476 movwf POSTINC2
477 movff wp_temp,lo ; Get back seconds
478 output_99x ; lo in 2 digits with trailing zeros.
479 bra cf_done
480
481 cf_type_07: ; Type == 7 is Color swatch.
482 output_8
483
484 movf lo,W ; Get color.
485 movff WREG,box_temp+0 ; Set color
486 movff win_top,WREG ; BEWARE : this is a bank0 variable !
487 movff WREG,box_temp+1 ; row top (0-239)
488 addlw .23
489 movff WREG,box_temp+2 ; row bottom (0-239)
490 movlw .110
491 movff WREG,box_temp+3 ; column left (0-159)
492 movlw .140
493 movff WREG,box_temp+4 ; column right (0-159)
494
495 call PLED_box
496 bra cf_done ; W/o trailling spaces...
497
498 cf_type_99: ; 8bit mode. Or unrecognized type...
499 clrf hi
500
501 cf_type_0: ; 15bit mode.
502 bcf hi,7
503 output_16
504
505 cf_done:
506 movff FSR1L, hi ; Restore saved registers...
507 movff FSR1H, EEADRH
508 #else
509 bcf hi,7 ; clear Bit 7 of value
510 output_16
511
512 movff win_top,WREG ; Get "Default:" line position (BANK0 !)
513 xorlw .125 ; This is the default value ?
514 bnz cf_no_bits ; NO: skip bits for current value
515
516 movlw ','
517 movwf POSTINC2
518
519 movlw '1'
520 btfss EEDATA,7 ; 15Bit?
521 movlw '8' ; 8Bit!
522 tstfsz apnoe_mins ; apnoe_mins=0?
523 movlw '1' ; No, 1Bit!
524 movwf POSTINC2
525
526 movlw '5'
527 btfsc EEDATA,7 ; 15Bit?
528 movwf POSTINC2
529 movlw 'B'
530 movwf POSTINC2
531
532 cf_no_bits:
533 movlw ' '
534 movwf POSTINC2
535 movwf POSTINC2
536 movwf POSTINC2
537 #endif
538 goto word_processor
539
540 ;-----------------------------------------------------------------------------
381 541
382 do_customfunction: 542 do_customfunction:
383 CLRF EEADRH 543 CLRF EEADRH
384 movlw d'1' 544 movlw d'1'
385 btfsc customfunction_page 545 btfsc customfunction_page
473 addlw 0x81 633 addlw 0x81
474 movwf EEADR 634 movwf EEADR
475 call read_eeprom ; Highbyte 635 call read_eeprom ; Highbyte
476 movff EEDATA,divemins+1 ; Highbyte of default value 636 movff EEDATA,divemins+1 ; Highbyte of default value
477 637
478 movlw d'1' 638 btfss apnoe_mins,0 ; If apnoe_mins=1 then CF is binary
479 cpfseq apnoe_mins ; If apnoe_mins=1 then CF is binary
480 bra adjust_cfn_value1 ; Not Binary 639 bra adjust_cfn_value1 ; Not Binary
481 640
482 tstfsz lo ; =0? 641 tstfsz lo ; =0?
483 setf lo ; No, Set to 255 642 setf lo ; No, Set to 255
484 incf lo,F ; Increase by one 643 incf lo,F ; Increase by one
557 movff EEDATA,lo 716 movff EEDATA,lo
558 incf EEADR,F 717 incf EEADR,F
559 call read_eeprom ; Highbyte 718 call read_eeprom ; Highbyte
560 movff EEDATA,hi 719 movff EEDATA,hi
561 clrf EEADRH 720 clrf EEADRH
721 #ifndef NO_CF_TYPES
722 btfss hi,7 ; Is it a 15bit value ?
723 clrf hi ; NO: clear type flags.
724 #endif
725 bcf hi,7 ; Always clear 15bit flag.
562 return ; return 726 return ; return
563 727
564 custom_functions_check_divemode: ;displays warning if a critical custom function is not set to default 728 custom_functions_check_divemode: ;displays warning if a critical custom function is not set to default
565 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol 729 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol
566 bra check_cf11 730 bra check_cf11