Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/menu_custom.asm @ 86:b40a0a6284da
adding custom functions with limits (jeando)
author | heinrichsweikamp |
---|---|
date | Thu, 09 Dec 2010 20:41:56 +0100 |
parents | 0f4c175ef824 |
children | 6655b1c59adc |
comparison
equal
deleted
inserted
replaced
85:8b813f67220f | 86:b40a0a6284da |
---|---|
46 ; [jDG] 2010-11-30 More fancy displsy of the various CF types | 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 | 47 ; data types. When we do have a 8bit data (bit16=0), the high byte serves to |
48 ; define the display format: | 48 ; define the display format: |
49 | 49 |
50 CF_INT8 EQU 0 ; Default display, 8 or 15 bits values. | 50 CF_INT8 EQU 0 ; Default display, 8 or 15 bits values. |
51 CF_PERCENT EQU 1 ; Displays 110% | 51 CF_PERCENT EQU 1 ; Displays 110% |
52 CF_DECI EQU 2 ; Displays 1.6 | 52 CF_DECI EQU 2 ; Displays 1.6 |
53 CF_CENTI EQU 3 ; Displays 1.50 | 53 CF_CENTI EQU 3 ; Displays 1.50 |
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 ; | |
59 CF_TYPES EQU 0x1F | |
60 CF_MAX_BIT EQU 6 ; Default is the highest safe value. | |
61 CF_MAX EQU (1<<CF_MAX_BIT) | |
62 CF_MIN_BIT EQU 5 ; Default is the lowest safe value. | |
63 CF_MIN EQU (1<<CF_MIN_BIT) | |
64 ; | |
58 CF_INT15 EQU 0x80; Default display. Flag for 15bit, typeless values. | 65 CF_INT15 EQU 0x80; Default display. Flag for 15bit, typeless values. |
59 | 66 |
67 ; Overlay our tmp data with some unused variables. But use more | |
68 ; meaningfull labels... | |
69 cf32_x4 EQU divemins+0 ; CF# modulus 32, time 4. | |
70 cf_type EQU divemins+1 ; Type of the edited CF | |
71 cf_value EQU divesecs | |
72 cf_min EQU apnoe_mins | |
73 cf_max EQU apnoe_secs | |
74 | |
60 GETCUSTOM8 macro custom8 | 75 GETCUSTOM8 macro custom8 |
61 movlw custom8 | 76 movlw custom8 |
62 call getcustom8_1 | 77 call getcustom8_1 |
63 endm | 78 endm |
64 | 79 |
142 | 157 |
143 bcf menubit4 | 158 bcf menubit4 |
144 bcf cursor | 159 bcf cursor |
145 bcf sleepmode | 160 bcf sleepmode |
146 clrf decodata+0 ; here: # of CustomFunction | 161 clrf decodata+0 ; here: # of CustomFunction |
147 clrf divemins+0 ; here: # of CustomFunction*4 | 162 clrf cf32_x4 ; here: # of CustomFunction*4 |
148 bcf first_FA ; here: =1: -, =0: + | 163 bcf first_FA ; here: =1: -, =0: + |
149 bcf second_FA ; here: =1: stepsize 1, =0: stepsize 10 | 164 bcf second_FA ; here: =1: stepsize 1, =0: stepsize 10 |
150 | 165 |
151 call PLED_topline_box | 166 call PLED_topline_box |
152 WIN_INVERT .1 ; Init new Wordprocessor | 167 WIN_INVERT .1 ; Init new Wordprocessor |
174 bcf menubit2 | 189 bcf menubit2 |
175 bcf menubit3 | 190 bcf menubit3 |
176 WIN_LEFT .20 | 191 WIN_LEFT .20 |
177 WIN_TOP .35 | 192 WIN_TOP .35 |
178 lfsr FSR2,letter | 193 lfsr FSR2,letter |
179 movff decodata+0,lo | 194 movff decodata+0,lo ; decodata == CF number % 32 |
180 | 195 |
181 movlw d'0' | 196 movlw d'0' |
182 btfsc customfunction_page ; Add offset for display | 197 btfsc customfunction_page ; Add offset for display in CF menu II |
183 movlw d'32' | 198 movlw d'32' |
184 addwf lo,F | 199 addwf lo,F |
185 movff lo, apnoe_mins ; Copy use when NO_CF_TYPES | 200 |
186 | |
187 output_99x | 201 output_99x |
188 movlw ':' | 202 movlw ':' |
189 movwf POSTINC2 | 203 movwf POSTINC2 |
190 movlw ' ' | 204 movlw ' ' |
191 movwf POSTINC2 | 205 movwf POSTINC2 |
193 | 207 |
194 movf customfunction_temp1,W ; start of custom function descriptors | 208 movf customfunction_temp1,W ; start of custom function descriptors |
195 addwf decodata+0,W ; add # of current custom function, place result in wreg | 209 addwf decodata+0,W ; add # of current custom function, place result in wreg |
196 call displaytext1 ; shows descriptor | 210 call displaytext1 ; shows descriptor |
197 | 211 |
198 ; Read defaults into hi:lo | 212 ; Read default, type and min/max from reset table. |
199 movf divemins+0,W | 213 rcall cf_read_default |
200 addlw 0x80 | 214 |
201 movwf EEADR | 215 movf cf_type,W ; Is it a ON/OFF flag ? |
202 call read_eeprom ; Lowbyte | |
203 movff EEDATA,lo | |
204 movf divemins+0,W | |
205 addlw 0x81 | |
206 movwf EEADR | |
207 call read_eeprom ; Highbyte | |
208 movff EEDATA,hi | |
209 | |
210 #ifdef NO_CF_TYPES | |
211 movlw binary_cf1 | |
212 subwf apnoe_mins,W ; Binary cf? | |
213 bz menu_custom_functions10c ; Yes | |
214 | |
215 movlw binary_cf2 | |
216 subwf apnoe_mins,W ; Binary cf? | |
217 bz menu_custom_functions10c ; Yes | |
218 | |
219 movlw binary_cf3 | |
220 subwf apnoe_mins,W ; Binary cf? | |
221 bz menu_custom_functions10c ; Yes | |
222 | |
223 movlw binary_cf4 | |
224 subwf apnoe_mins,W ; Binary cf? | |
225 bz menu_custom_functions10c ; Yes | |
226 | |
227 movlw binary_cf5 | |
228 subwf apnoe_mins,W ; Binary cf? | |
229 bz menu_custom_functions10c ; Yes | |
230 | |
231 movlw binary_cf6 | |
232 subwf apnoe_mins,W ; Binary cf? | |
233 bz menu_custom_functions10c ; Yes | |
234 | |
235 bra menu_custom_functions10a ; Not a binary CF... | |
236 #else | |
237 movf hi,W ; Is it a ON/OFF flag ? | |
238 xorlw CF_BOOL | 216 xorlw CF_BOOL |
239 bnz menu_custom_functions10a ; Not a binary CF selected | 217 bnz menu_custom_functions10a ; Not a binary CF selected |
240 #endif | |
241 | 218 |
242 menu_custom_functions10c: | 219 menu_custom_functions10c: |
243 setf apnoe_mins ; Yes, set apnoe_mins to 0xFF | 220 ; Erase unused lines when editing boolean... |
244 | |
245 WIN_LEFT .20 | 221 WIN_LEFT .20 |
246 WIN_TOP .65 | 222 WIN_TOP .65 |
247 lfsr FSR2,letter ; Make a string of 8 spaces | 223 lfsr FSR2,letter ; Make a string of 8 spaces |
248 call cf_fill_line | 224 call cf_fill_line |
249 call word_processor ; Clear +/- line | 225 call word_processor ; Clear +/- line |
250 | 226 |
251 WIN_TOP .95 | 227 WIN_TOP .95 |
252 call word_processor ; Clear 1/10 line | 228 call word_processor ; Clear 1/10 line |
253 | 229 |
254 bra menu_custom_functions10b | 230 bra menu_custom_functions10b |
255 | 231 |
256 menu_custom_functions10a: | 232 menu_custom_functions10a: |
257 clrf apnoe_mins ; Yes, clear apnoe_mins | |
258 | |
259 WIN_LEFT .20 | 233 WIN_LEFT .20 |
260 WIN_TOP .65 | 234 WIN_TOP .65 |
261 lfsr FSR2,letter | 235 lfsr FSR2,letter |
262 movlw '+' | 236 movlw '+' |
263 movwf POSTINC2 | 237 movwf POSTINC2 |
295 movlw '0' | 269 movlw '0' |
296 btfsc second_FA | 270 btfsc second_FA |
297 movwf POSTINC2 | 271 movwf POSTINC2 |
298 movlw ' ' | 272 movlw ' ' |
299 movwf POSTINC2 | 273 movwf POSTINC2 |
300 call word_processor | 274 call word_processor |
301 | 275 |
302 menu_custom_functions10b: | 276 menu_custom_functions10b: |
303 WIN_LEFT .20 | 277 WIN_LEFT .20 |
304 WIN_TOP .125 | 278 WIN_TOP .125 |
305 lfsr FSR2,letter | 279 lfsr FSR2,letter |
306 OUTPUTTEXT d'89' ;"Default:" | 280 OUTPUTTEXT d'89' ;"Default:" |
307 movlw ' ' | |
308 movwf POSTINC2 | |
309 | 281 |
310 call display_customfunction ; Typed display. | 282 call display_customfunction ; Typed display. |
311 | 283 |
312 WIN_LEFT .20 | 284 WIN_LEFT .20 |
313 WIN_TOP .155 | 285 WIN_TOP .155 |
314 lfsr FSR2,letter | 286 lfsr FSR2,letter |
315 OUTPUTTEXT d'97' ; "Current:" | 287 OUTPUTTEXT d'97' ; "Current:" |
316 movlw ' ' | 288 |
317 movwf POSTINC2 | 289 movf cf32_x4,W |
318 | |
319 movf divemins+0,W | |
320 addlw 0x82 | 290 addlw 0x82 |
321 movwf EEADR | 291 movwf EEADR |
322 call read_eeprom ; Lowbyte | 292 call read_eeprom ; Lowbyte |
323 movff EEDATA,lo | 293 movff EEDATA,lo |
324 | 294 movff EEDATA, cf_value ; Backup low 8bit value. |
325 movf divemins+0,W | 295 |
296 movf cf32_x4,W | |
326 addlw 0x83 | 297 addlw 0x83 |
327 movwf EEADR | 298 movwf EEADR |
328 call read_eeprom ; Highbyte | 299 call read_eeprom ; Highbyte |
329 | |
330 btfss hi,7 ; A 15bit value ? | |
331 bra menu_custom_functions1b ; No : keep types there ! | |
332 | |
333 movff EEDATA,hi | 300 movff EEDATA,hi |
334 bsf hi,7 ; Mark it a 15bit value. | 301 |
335 | |
336 menu_custom_functions1b: | |
337 call display_customfunction | 302 call display_customfunction |
338 | 303 |
339 menu_custom_functions1a: | 304 ; End of mask: min/max and the exit line... |
305 rcall display_minmax | |
340 DISPLAYTEXT .11 ; Exit | 306 DISPLAYTEXT .11 ; Exit |
341 | 307 |
342 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! | 308 call wait_switches ; Waits until switches are released, resets flag if button stays pressed! |
343 call PLED_menu_cursor | 309 call PLED_menu_cursor |
344 | 310 |
391 | 357 |
392 bcf menubit3 ; clear flag | 358 bcf menubit3 ; clear flag |
393 bra customfunctions_loop | 359 bra customfunctions_loop |
394 | 360 |
395 ;----------------------------------------------------------------------------- | 361 ;----------------------------------------------------------------------------- |
396 ; Input : hi:lo = data to display, with type embebed into hi | 362 ; Read default value (into hi:lo), cf_type, and cf_min/cf_max if any. |
363 ; | |
364 cf_read_default: | |
365 movlw LOW(cf_default_table0) ; Get 24bit PROM pointer. SKIP | |
366 movwf TBLPTRL | |
367 movlw HIGH(cf_default_table0) | |
368 movwf TBLPTRH | |
369 movlw UPPER(cf_default_table0) | |
370 movwf TBLPTRU | |
371 | |
372 movlw 0 | |
373 btfsc customfunction_page ; Page II CF# ? | |
374 movlw 0x80 ; YES: add 128 to ptr. | |
375 addwf cf32_x4,W ; Add 4 x (CF index modulus 32) | |
376 addwf TBLPTRL,F ; And to a 8+16 add into TBLPTR | |
377 movlw 0 ; (keep carry) | |
378 addwfc TBLPTRH,F ; Propagate to 16bit (but not 24bits). | |
379 | |
380 tblrd*+ | |
381 movff TABLAT,lo ; Low byte --> lo | |
382 tblrd*+ | |
383 movff TABLAT,hi ; High byte --> hi | |
384 btfss hi,7 ; 15bit ? | |
385 clrf hi ; NO: clear extra type flags | |
386 bcf hi,7 ; clear 15bit flag | |
387 | |
388 movff TABLAT,cf_type ; type (high byte) --> cf_type | |
389 movlw CF_MILI | |
390 btfsc cf_type,7 ; Display all 15bits as 1.234 floats. | |
391 movwf cf_type | |
392 | |
393 tblrd*+ | |
394 movff TABLAT,cf_min ; Then get optional min/max | |
395 tblrd*+ | |
396 movff TABLAT,cf_max | |
397 | |
398 return | |
399 | |
400 ;----------------------------------------------------------------------------- | |
401 ; Display a 8/15bit value, plus optional min and max bound. | |
402 ; Input : hi:lo = data to display. | |
403 ; cf_type = the type. | |
404 ; cf_min, cf_max : the optional min/max. | |
397 ; FSR2 = current string pointer. | 405 ; FSR2 = current string pointer. |
398 ; Trash : FSR1 (used to backup EEADRH and hi) | 406 ; Trash : hi:lo (when displaying min/max) |
399 | 407 |
400 display_customfunction: | 408 display_customfunction: |
401 #ifndef NO_CF_TYPES | |
402 movff EEADRH, FSR1H ; Backup... | 409 movff EEADRH, FSR1H ; Backup... |
403 movff hi, FSR1L | 410 |
411 rcall display_formated | |
412 rcall cf_fill_line | |
413 call word_processor | |
414 | |
415 movff FSR1H, EEADRH | |
416 return | |
417 | |
418 ;----------------------------------------------------------------------------- | |
419 ; Display optional min/max values. | |
420 ; Inputs: cf_value, cf_min, cf_max (and cf_type to display min/max). | |
421 ; Trashed: hi:lo while display min and max values. | |
422 display_minmax: | |
423 movff EEADRH, FSR1H ; Backup... | |
424 | |
425 ; Display min line | |
426 WIN_TOP .65 | |
427 WIN_LEFT .100 | |
428 lfsr FSR2, letter | |
429 | |
430 btfss cf_type, CF_MIN_BIT ; A min value exists ? | |
431 bra cf_no_min | |
432 | |
433 movf cf_min,W ; Retrieve current 8b value | |
434 subwf cf_value,W ; Compute (lo-min) | |
435 bc cf_min_passed ; Ok if CARRY, ie. min >= lo | |
436 call PLED_warnings_color | |
437 WIN_INVERT 1 | |
438 cf_min_passed: | |
439 | |
440 movlw '>' ; A min value follows | |
441 movwf POSTINC2 | |
442 movlw ' ' | |
443 movwf POSTINC2 | |
444 movff cf_min, lo | |
445 rcall display_formated | |
446 | |
447 cf_no_min: | |
448 rcall cf_fill_line ; Fill buffer | |
449 lfsr FSR2, letter+.7 ; Limit to 8 chars btw. | |
450 call word_processor | |
451 | |
452 ; Display max line | |
453 WIN_TOP .95 | |
454 call PLED_standard_color | |
455 WIN_INVERT 0 | |
456 lfsr FSR2, letter | |
457 | |
458 btfss cf_type, CF_MAX_BIT ; A max value exists ? | |
459 bra cf_no_max | |
460 | |
461 movf cf_value,W ; Retrieve current max bound | |
462 subwf cf_max,W ; Compute (max-lo) | |
463 bc cf_max_passed ; Ok if no carry, ie. max <= lo | |
464 call PLED_warnings_color | |
465 WIN_INVERT 1 | |
466 cf_max_passed: | |
467 | |
468 movlw '<' ; A max value follows | |
469 movwf POSTINC2 | |
470 movlw ' ' | |
471 movwf POSTINC2 | |
472 movff cf_max, lo | |
473 rcall display_formated | |
474 | |
475 cf_no_max: | |
476 rcall cf_fill_line ; Fill buffer | |
477 lfsr FSR2, letter+.7 ; Limit to 8 chars btw. | |
478 call word_processor | |
479 | |
480 cf_minmax_done: | |
481 call PLED_standard_color | |
482 WIN_INVERT 0 | |
483 movff FSR1H, EEADRH | |
484 return | |
485 | |
486 ;----------------------------------------------------------------------------- | |
487 ; Display a single 8/15 bit value, according to cf_type. | |
488 ; Input : hi:lo = data to display. | |
489 ; cf_type = the type. | |
490 ; cf_min, cf_max : the optional min/max. | |
491 ; FSR2 = current string pointer. | |
492 display_formated: | |
404 | 493 |
405 ;---- decode type -------------------------------------------------------- | 494 ;---- decode type -------------------------------------------------------- |
406 movf hi,W ; Just set N/Z flags | 495 movf cf_type,W ; Just set N/Z flags |
407 bn cf_type_0 ; Keep 15bits value in old format. | 496 bn cf_type_neg ; Keep 15bits value in old format. |
408 bz cf_type_99 ; 8bit standard mode | 497 andlw CF_TYPES ; Look just at types |
409 | 498 bz cf_type_00 ; 8bit standard mode |
410 ; Jump table: | 499 |
411 dcfsnz hi | 500 ; Jump table: ; test the value with cleared flags... |
501 dcfsnz WREG | |
412 bra cf_type_01 | 502 bra cf_type_01 |
413 dcfsnz hi | 503 dcfsnz WREG |
414 bra cf_type_02 | 504 bra cf_type_02 |
415 dcfsnz hi | 505 dcfsnz WREG |
416 bra cf_type_03 | 506 bra cf_type_03 |
417 dcfsnz hi | 507 dcfsnz WREG |
418 bra cf_type_04 | 508 bra cf_type_04 |
419 dcfsnz hi | 509 dcfsnz WREG |
420 bra cf_type_05 | 510 bra cf_type_05 |
421 dcfsnz hi | 511 dcfsnz WREG |
422 bra cf_type_06 | 512 bra cf_type_06 |
423 dcfsnz hi | 513 dcfsnz WREG |
424 bra cf_type_07 | 514 bra cf_type_07 |
425 bra cf_type_99 ; Default to 8bit mode... | 515 bra cf_type_00 ; Default to 8bit mode... |
426 | 516 |
427 cf_type_01: ; Type == 1 is percent mode | 517 cf_type_01: ; Type == 1 is CF_PERCENT mode |
428 output_16dp 0 ; NOTE : hi is already reseted... | 518 bcf leftbind |
519 output_8 | |
429 movlw '%' | 520 movlw '%' |
430 movwf POSTINC2 | 521 movwf POSTINC2 |
431 bra cf_do_wp | 522 retlw 0 |
432 | 523 |
433 cf_type_02: ; Type == 2 is deci mode. | 524 cf_type_02: ; Type == 2 is CF_DECI mode. |
525 clrf hi | |
526 bsf leftbind | |
434 output_16dp 4 | 527 output_16dp 4 |
435 bra cf_do_wp | 528 retlw 0 |
436 | 529 |
437 cf_type_03: ; Type == 3 is centi mode. | 530 cf_type_03: ; Type == 3 is CF_CENTI mode. |
531 clrf hi | |
532 bsf leftbind | |
438 output_16dp 3 | 533 output_16dp 3 |
439 bra cf_do_wp | 534 retlw 0 |
440 | 535 |
441 cf_type_04: ; Type == 4 is mili mode | 536 cf_type_04: ; Type == 4 is CF_MILI mode |
442 output_16dp 2 | 537 output_16dp 2 |
443 bra cf_do_wp | 538 retlw 0 |
444 | 539 |
445 cf_type_05: ; Type == 5 is on/off mode. | 540 cf_type_05: ; Type == 5 is CF_BOOL mode. |
446 movf lo,W ; Get flag value... | 541 movf lo,W ; Get flag value... |
447 bz cf_type_off | 542 bz cf_type_off |
448 OUTPUTTEXT d'130' ; ON | 543 OUTPUTTEXT d'130' ; ON |
449 bra cf_do_wp | 544 retlw 0 |
545 | |
450 cf_type_off: | 546 cf_type_off: |
451 OUTPUTTEXT d'131' ; OFF | 547 OUTPUTTEXT d'131' ; OFF |
452 bra cf_do_wp | 548 retlw 0 |
453 | 549 |
454 cf_type_06: ; Type == 6 is mm:ss mode (... or hh:mm) | 550 cf_type_06: ; Type == 6 is CF_SECS mode (mm:ss or hh:mm) |
551 clrf hi | |
455 call convert_time ; Convert to min:sec into hi:low. | 552 call convert_time ; Convert to min:sec into hi:low. |
456 movff lo,wp_temp ; Save seconds, | 553 movff lo,wp_temp ; Save seconds, |
457 movff hi,lo ; Get minutes | 554 movff hi,lo ; Get minutes |
555 bsf leftbind ; Skip leading space(s). | |
458 output_8 ; Print them | 556 output_8 ; Print them |
459 movlw ':' ; Separator | 557 movlw ':' ; Separator |
460 movwf POSTINC2 | 558 movwf POSTINC2 |
461 movff wp_temp,lo ; Get back seconds | 559 movff wp_temp,lo ; Get back seconds |
462 output_99x ; lo in 2 digits with trailing zeros. | 560 output_99x ; lo in 2 digits with trailing zeros. |
463 bra cf_do_wp | 561 retlw 0 |
464 | 562 |
465 cf_type_07: ; Type == 7 is Color swatch. | 563 cf_type_07: ; Type == 7 is CF_COLOR swatch. |
564 bcf leftbind ; Keep leading space (better alignement) | |
466 output_8 | 565 output_8 |
467 | 566 movlw ' ' |
468 call cf_fill_line ; it does less flickering when editing colors... | 567 movwf POSTINC2 |
469 call word_processor | 568 call word_processor |
470 | 569 |
471 movf lo,W ; Get color. | 570 movf lo,W ; Get color. |
472 movff WREG,box_temp+0 ; Set color | 571 movff WREG,box_temp+0 ; Set color |
473 movff win_top,WREG ; BEWARE : this is a bank0 variable ! | 572 movff win_top,WREG ; BEWARE : this is a bank0 variable ! |
474 movff WREG,box_temp+1 ; row top (0-239) | 573 movff WREG,box_temp+1 ; row top (0-239) |
475 addlw .23 | 574 addlw .23 |
476 movff WREG,box_temp+2 ; row bottom (0-239) | 575 movff WREG,box_temp+2 ; row bottom (0-239) |
477 movlw .110 | 576 movlw .110 |
478 movff WREG,box_temp+3 ; column left (0-159) | 577 movff WREG,box_temp+3 ; column left (0-159) |
479 movlw .140 | 578 movlw .148 |
480 movff WREG,box_temp+4 ; column right (0-159) | 579 movff WREG,box_temp+4 ; column right (0-159) |
481 | 580 |
482 call PLED_box | 581 call PLED_box |
483 bra cf_done ; wp already done. Skip it... | 582 retlw -1 ; wp already done. Skip it... |
484 | 583 |
485 cf_type_99: ; 8bit mode. Or unrecognized type... | 584 cf_type_00: ; 8bit mode. Or unrecognized type... |
486 clrf hi | 585 clrf hi |
487 | 586 bsf leftbind |
488 cf_type_0: ; 15bit mode. | 587 |
588 cf_type_neg: ; 15bit mode. | |
489 bcf hi,7 | 589 bcf hi,7 |
490 output_16 | 590 output_16 |
491 | 591 retlw 0 |
492 cf_do_wp: ; Process by calling wordprocessor | 592 |
493 call cf_fill_line | 593 ;----------------------------------------------------------------------------- |
494 call word_processor | |
495 | |
496 cf_done: | |
497 movff FSR1L, hi ; And restore saved registers before return. | |
498 movff FSR1H, EEADRH | |
499 return | |
500 | 594 |
501 cf_fill_line: ; Mattias: No flicker if u clear just what you need... | 595 cf_fill_line: ; Mattias: No flicker if u clear just what you need... |
502 movf FSR2L,W ; How many chars lefts ? | 596 movf FSR2L,W ; How many chars lefts ? |
503 sublw (LOW letter) + .17 ; Remaining chars to fill: (letter + 21) - PTR | 597 sublw (LOW letter) + .18 ; Remaining chars to fill: (letter + 18) - PTR |
504 btfsc STATUS,N ; Add chars until none left... | 598 btfsc STATUS,N ; Add chars until none left... |
505 return | 599 return |
506 movlw ' ' | 600 movlw ' ' |
507 movwf POSTINC2 | 601 movwf POSTINC2 |
508 bra cf_fill_line | 602 bra cf_fill_line |
509 | |
510 #else | |
511 bcf hi,7 ; clear Bit 7 of value | |
512 output_16 | |
513 | |
514 movff win_top,WREG ; Get "Default:" line position (BANK0 !) | |
515 xorlw .125 ; This is the default value ? | |
516 bnz cf_no_bits ; NO: skip bits for current value | |
517 | |
518 movlw ',' | |
519 movwf POSTINC2 | |
520 | |
521 movlw '1' | |
522 btfss EEDATA,7 ; 15Bit? | |
523 movlw '8' ; 8Bit! | |
524 tstfsz apnoe_mins ; apnoe_mins=0? | |
525 movlw '1' ; No, 1Bit! | |
526 movwf POSTINC2 | |
527 | |
528 movlw '5' | |
529 btfsc EEDATA,7 ; 15Bit? | |
530 movwf POSTINC2 | |
531 movlw 'B' | |
532 movwf POSTINC2 | |
533 | |
534 cf_no_bits: | |
535 movlw ' ' | |
536 movwf POSTINC2 | |
537 movwf POSTINC2 | |
538 movwf POSTINC2 | |
539 goto word_processor | |
540 #endif | |
541 | 603 |
542 ;----------------------------------------------------------------------------- | 604 ;----------------------------------------------------------------------------- |
543 | 605 |
544 do_customfunction: | 606 do_customfunction: |
545 CLRF EEADRH | 607 CLRF EEADRH |
556 dcfsnz menupos,F | 618 dcfsnz menupos,F |
557 bra restore_cfn_value | 619 bra restore_cfn_value |
558 dcfsnz menupos,F | 620 dcfsnz menupos,F |
559 bra adjust_cfn_value | 621 bra adjust_cfn_value |
560 | 622 |
623 ;----------------------------------------------------------------------------- | |
624 | |
561 exit_customfunctions: | 625 exit_customfunctions: |
562 movlw d'2' ; Return to correct list entry | 626 movlw d'2' ; Return to correct list entry |
563 btfss customfunction_page | 627 btfss customfunction_page |
564 movlw d'1' | 628 movlw d'1' |
565 movwf menupos ; | 629 movwf menupos ; |
566 clrf EEADRH ; Clear EEADRH ! | 630 clrf EEADRH ; Clear EEADRH ! |
567 goto setup_menu2 ; exit... | 631 goto setup_menu2 ; exit... |
568 | 632 |
633 ;----------------------------------------------------------------------------- | |
634 | |
569 next_customfunction: | 635 next_customfunction: |
570 incf decodata+0 | 636 incf decodata+0 |
571 btfsc decodata+0,5 ;>31? | 637 btfsc decodata+0,5 ;>31? |
572 clrf decodata+0 ;Yes, so reset to zero | 638 clrf decodata+0 ;Yes, so reset to zero |
573 | 639 |
574 movf decodata+0,W | 640 movf decodata+0,W |
575 mullw d'4' | 641 mullw d'4' |
576 movff PRODL, divemins+0 ;divemins+0 for correct addressing | 642 movff PRODL, cf32_x4 ; 12bit address for correct addressing |
577 | 643 |
578 movlw d'1' | 644 movlw d'1' |
579 movwf menupos | 645 movwf menupos |
580 bra menu_custom_functions1 ; also debounces switches | 646 bra menu_custom_functions1 ; also debounces switches |
647 | |
648 ;----------------------------------------------------------------------------- | |
581 | 649 |
582 toggle_plusminus: | 650 toggle_plusminus: |
583 btg first_FA | 651 btg first_FA |
584 movlw d'2' | 652 movlw d'2' |
585 movwf menupos | 653 movwf menupos |
586 bra menu_custom_functions1 ; also debounces switches | 654 bra menu_custom_functions1 ; also debounces switches |
587 | 655 |
656 ;----------------------------------------------------------------------------- | |
657 | |
588 toggle_oneorten: | 658 toggle_oneorten: |
589 btg second_FA | 659 btg second_FA |
590 movlw d'3' | 660 movlw d'3' |
591 movwf menupos | 661 movwf menupos |
592 bra menu_custom_functions1 ; also debounces switches | 662 bra menu_custom_functions1 ; also debounces switches |
593 | 663 |
664 ;----------------------------------------------------------------------------- | |
665 | |
594 restore_cfn_value: | 666 restore_cfn_value: |
595 movf divemins+0,W ; read default value | 667 rcall cf_read_default ; hi:lo is trashed by min/max display. |
596 addlw 0x80 | 668 |
597 movwf EEADR | 669 movf cf32_x4,W ; store default value |
598 call read_eeprom ; Lowbyte | |
599 movff EEDATA,lo | |
600 movf divemins+0,W | |
601 addlw 0x81 | |
602 movwf EEADR | |
603 call read_eeprom ; Highbyte | |
604 movff EEDATA,hi | |
605 bcf hi,7 ; clear bit 7 of value | |
606 | |
607 movf divemins+0,W ; store default value | |
608 addlw 0x82 | 670 addlw 0x82 |
609 movwf EEADR | 671 movwf EEADR |
610 movff lo,EEDATA | 672 movff lo,EEDATA |
611 call write_eeprom ; Lowbyte | 673 call write_eeprom ; Lowbyte |
612 movf divemins+0,W | 674 movf cf32_x4,W |
613 addlw 0x83 | 675 addlw 0x83 |
614 movwf EEADR | 676 movwf EEADR |
615 movff hi,EEDATA | 677 movff hi,EEDATA |
616 call write_eeprom ; Highbyte | 678 call write_eeprom ; Highbyte |
617 | 679 |
618 movlw d'4' | 680 movlw d'4' |
619 movwf menupos | 681 movwf menupos |
620 bra menu_custom_functions1 ; also debounces switches | 682 bra menu_custom_functions1 ; also debounces switches |
621 | 683 |
684 ;----------------------------------------------------------------------------- | |
685 ; Adjust current value. | |
622 adjust_cfn_value: | 686 adjust_cfn_value: |
623 movf divemins+0,W ; get current value | 687 movf cf32_x4,W ; get current value |
624 addlw 0x82 | 688 addlw 0x82 |
625 movwf EEADR | 689 movwf EEADR |
626 call read_eeprom ; Lowbyte | 690 call read_eeprom ; Lowbyte |
627 movff EEDATA,lo | 691 movff EEDATA,lo |
628 movf divemins+0,W | 692 movf cf32_x4,W |
629 addlw 0x83 | 693 addlw 0x83 |
630 movwf EEADR | 694 movwf EEADR |
631 call read_eeprom ; Highbyte | 695 call read_eeprom ; Highbyte |
632 movff EEDATA,hi | 696 movff EEDATA,hi |
633 | 697 |
634 movf divemins+0,W | 698 movf cf_type,W |
635 addlw 0x81 | 699 xorlw CF_BOOL |
636 movwf EEADR | 700 bnz adjust_cfn_value1 |
637 call read_eeprom ; Highbyte | 701 |
638 movff EEDATA,divemins+1 ; Highbyte of default value | 702 btg lo,0 ; Change lower bit. |
639 | 703 bra adjust_cfn_value3 ; Store result |
640 btfss apnoe_mins,0 ; If apnoe_mins=1 then CF is binary | |
641 bra adjust_cfn_value1 ; Not Binary | |
642 | |
643 tstfsz lo ; =0? | |
644 setf lo ; No, Set to 255 | |
645 incf lo,F ; Increase by one | |
646 clrf hi ; Delete hi byte (Not required but to make sure...) | |
647 bra adjust_cfn_value3 ; Store result | |
648 | 704 |
649 adjust_cfn_value1: | 705 adjust_cfn_value1: |
650 btfss first_FA ; Minus? | |
651 bra adjust_cfn_value2 ; No, Plus | |
652 | |
653 movlw d'1' | 706 movlw d'1' |
654 btfsc second_FA ; -10? | 707 btfsc second_FA ; -10? |
655 movlw d'10' | 708 movlw d'10' |
656 | 709 |
657 subwf lo,F ; substract value | 710 btfss first_FA ; Minus? |
711 bra adjust_cfn_value2 ; No, Plus | |
712 | |
713 subwf lo,F ; substract value | |
658 movlw d'0' | 714 movlw d'0' |
659 btfsc divemins+1,7 ; 8Bit value | 715 btfsc cf_type,7 ; 8Bit value |
660 subwfb hi,F | 716 subwfb hi,F |
661 | 717 |
662 movlw b'01111111' | 718 movlw b'01111111' |
663 btfsc hi,7 ; >32768? | 719 btfsc hi,7 ; >32768? |
664 movwf hi | 720 movwf hi |
665 | 721 |
666 bra adjust_cfn_value3 | 722 bra adjust_cfn_value3 |
667 | 723 |
668 adjust_cfn_value2: | 724 adjust_cfn_value2: |
669 movlw d'1' | 725 addwf lo,F ; add value |
670 btfsc second_FA ; +10? | |
671 movlw d'10' | |
672 | |
673 addwf lo,F ; add value | |
674 movlw d'0' | 726 movlw d'0' |
675 btfsc divemins+1,7 ; 8Bit value? | 727 btfsc cf_type,7 ; 8Bit value? |
676 addwfc hi,F | 728 addwfc hi,F |
677 | 729 |
678 btfsc hi,7 ; >32768? | 730 btfsc hi,7 ; >32768? |
679 clrf hi | 731 clrf hi |
680 | 732 |
681 adjust_cfn_value3: | 733 adjust_cfn_value3: |
682 movf divemins+0,W ; Store current value | 734 movf cf32_x4,W ; Store current value |
683 addlw 0x82 | 735 addlw 0x82 |
684 movwf EEADR | 736 movwf EEADR |
685 movff lo,EEDATA | 737 movff lo,EEDATA |
686 call write_eeprom ; Lowbyte | 738 call write_eeprom ; Lowbyte |
687 movf divemins+0,W | 739 movf cf32_x4,W |
688 addlw 0x83 | 740 addlw 0x83 |
689 movwf EEADR | 741 movwf EEADR |
690 movff hi,EEDATA | 742 movff hi,EEDATA |
691 call write_eeprom ; Highbyte | 743 call write_eeprom ; Highbyte |
692 movlw d'5' | 744 movlw d'5' |
693 movwf menupos | 745 movwf menupos |
694 bra menu_custom_functions1 ; also debounces switches | 746 bra menu_custom_functions1 ; also debounces switches |
695 | |
696 getcustom15_default: | |
697 ; # number of requested custom function in wreg | |
698 movwf customfunction_temp2 | |
699 | |
700 movlw d'31' | |
701 cpfsgt customfunction_temp2 | |
702 bra getcustom15_d2 ; Lower bank | |
703 | |
704 movlw d'1' ; Upper Bank | |
705 movwf EEADRH | |
706 movlw d'32' | |
707 subwf customfunction_temp2,F | |
708 bra getcustom15_d3 | |
709 getcustom15_d2: | |
710 clrf EEADRH | |
711 getcustom15_d3: | |
712 movf customfunction_temp2,W | |
713 mullw d'4' | |
714 movf PRODL,W ; x4 for adress | |
715 addlw d'128' | |
716 movwf EEADR ; +130 for LOW Byte of value | |
717 call read_eeprom ; Lowbyte | |
718 movff EEDATA,lo | |
719 incf EEADR,F | |
720 call read_eeprom ; Highbyte | |
721 movff EEDATA,hi | |
722 clrf EEADRH | |
723 #ifndef NO_CF_TYPES | |
724 btfss hi,7 ; Is it a 15bit value ? | |
725 clrf hi ; NO: clear type flags. | |
726 #endif | |
727 bcf hi,7 ; Always clear 15bit flag. | |
728 return ; return | |
729 | |
730 custom_functions_check_divemode: ;displays warning if a critical custom function is not set to default | |
731 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
732 bra check_cf11 | |
733 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
734 bra check_cf12 | |
735 return | |
736 | |
737 custom_functions_check_surfmode: ;displays warning if a critical custom function is not set to default | |
738 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
739 bra check_cf11 | |
740 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
741 bra check_cf12 | |
742 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
743 bra check_cf17 | |
744 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
745 bra check_cf18 | |
746 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
747 bra check_cf19 | |
748 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
749 bra check_cf29 | |
750 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
751 bra check_cf32 | |
752 dcfsnz cf_checker_counter,F ; counts custom functions to check for warning symbol | |
753 bra check_cf33 | |
754 return | |
755 | |
756 check_cf11: | |
757 movlw d'11' ; saturation factor | |
758 rcall custom_function_check_low ; compares current with default value | |
759 call test_and_display_warning ; displays the warning if the custom function is not correct | |
760 movlw d'2' ; next in testing row | |
761 movwf cf_checker_counter ; | |
762 return | |
763 | |
764 check_cf12: | |
765 movlw d'12' ; desaturation factor | |
766 rcall custom_function_check_high ; compares current with default value | |
767 call test_and_display_warning ; displays the warning if the custom function is not correct | |
768 movlw d'3' ; next in testing row | |
769 movwf cf_checker_counter ; | |
770 return | |
771 | |
772 check_cf17: | |
773 movlw d'17' ; lower threshold ppO2 | |
774 rcall custom_function_check_low ; compares current with default value | |
775 call test_and_display_warning ; displays the warning if the custom function is not correct | |
776 movlw d'4' ; next in testing row | |
777 movwf cf_checker_counter ; | |
778 return | |
779 | |
780 check_cf18: | |
781 movlw d'18' ; upper threshold ppO2 | |
782 rcall custom_function_check_high ; compares current with default value | |
783 call test_and_display_warning ; displays the warning if the custom function is not correct | |
784 movlw d'5' ; next in testing row | |
785 movwf cf_checker_counter ; | |
786 return | |
787 | |
788 check_cf19: | |
789 movlw d'19' ; upper threshold ppO2 display | |
790 rcall custom_function_check_high ; compares current with default value | |
791 call test_and_display_warning ; displays the warning if the custom function is not correct | |
792 movlw d'6' ; next in testing row | |
793 movwf cf_checker_counter ; | |
794 return | |
795 | |
796 check_cf29: | |
797 movlw d'6' | |
798 movwf cf_checker_counter ; upper limit for CF29, here: used as a temp variable | |
799 movlw d'29' ; last deco stop in [m] | |
800 rcall custom_function_check_high_limit ; compares current with default value | |
801 call test_and_display_warning ; displays the warning if the custom function is not correct | |
802 movlw d'7' ; next in testing row | |
803 movwf cf_checker_counter ; | |
804 return | |
805 | |
806 check_cf32: | |
807 movlw d'32' ; GF LOW | |
808 rcall custom_function_check_high ; compares current with default value | |
809 call test_and_display_warning ; displays the warning if the custom function is not correct | |
810 movlw d'8' ; next in testing row | |
811 movwf cf_checker_counter ; | |
812 return | |
813 | |
814 check_cf33: | |
815 movlw d'33' ; GF HIGH | |
816 rcall custom_function_check_high ; compares current with default value | |
817 call test_and_display_warning ; displays the warning if the custom function is not correct | |
818 movlw d'1' ; next in testing row | |
819 movwf cf_checker_counter ; | |
820 return | |
821 | |
822 | |
823 test_and_display_warning: | |
824 movwf lo ; copy result | |
825 tstfsz lo | |
826 return ; CF OK | |
827 goto custom_warn_surfmode | |
828 | |
829 custom_function_check_low: ; Checks CF (#WREG) | |
830 ; Returns WREG=0 if CF is lower then default | |
831 movwf temp1 ; save for custom value | |
832 call getcustom15_1 ; Get Current Value stored in hi and lo | |
833 movff lo,sub_a+0 | |
834 movff hi,sub_a+1 ; save value | |
835 | |
836 movf temp1,w | |
837 call getcustom15_default ; Get Default value stored in hi and lo | |
838 movff lo,sub_b+0 | |
839 movff hi,sub_b+1 ; save value | |
840 call sub16 ; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a | |
841 btfss neg_flag ; negative? | |
842 retlw .255 ; no | |
843 retlw .0 ; yes | |
844 | |
845 custom_function_check_high: ; Checks CF (#WREG) | |
846 ; Returns WREG=0 if CF is higher then default | |
847 movwf temp1 ; save for custom value | |
848 call getcustom15_1 ; Get Current Value stored in hi and lo | |
849 movff lo,sub_b+0 | |
850 movff hi,sub_b+1 ; save value | |
851 | |
852 movf temp1,w | |
853 call getcustom15_default ; Get Default value stored in hi and lo | |
854 movff lo,sub_a+0 | |
855 movff hi,sub_a+1 ; save value | |
856 call sub16 ; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a | |
857 btfss neg_flag ; negative? | |
858 retlw .255 ; no | |
859 retlw .0 ; yes | |
860 | |
861 custom_function_check_high_limit: ; Checks if CF (#WREG) is lower then limit (#cf_checker_counter) | |
862 movwf temp1 ; save for custom value | |
863 call getcustom15_1 ; Get Current Value stored in hi and lo | |
864 movff lo,sub_b+0 | |
865 movff hi,sub_b+1 ; save value | |
866 movff cf_checker_counter, sub_a+0 | |
867 clrf sub_a+1 | |
868 call sub16 ; sub_c = sub_a - sub_b with "neg_flag" bit set if sub_b > sub_a | |
869 btfss neg_flag ; negative? | |
870 retlw .255 ; no | |
871 retlw .0 ; yes |