Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 366:ca3d15e6240e 64kByte Logbook
small work in the logbook
author | Heinrichsweikamp |
---|---|
date | Thu, 09 Jun 2011 19:30:55 +0200 |
parents | 64da813d4726 |
children | 584741726190 |
comparison
equal
deleted
inserted
replaced
365:6ea83f22b48b | 366:ca3d15e6240e |
---|---|
325 call I2CREAD2 ; Year | 325 call I2CREAD2 ; Year |
326 movff SSPBUF,convert_value_temp+2 | 326 movff SSPBUF,convert_value_temp+2 |
327 call PLED_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 | 327 call PLED_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2 |
328 | 328 |
329 PUTC ' ' | 329 PUTC ' ' |
330 PUTC 0x94 ; "End of dive" icon | |
330 call I2CREAD2 ; hour | 331 call I2CREAD2 ; hour |
331 movff SSPBUF,lo | 332 movff SSPBUF,lo |
332 output_99x | 333 output_99x |
333 PUTC ':' | 334 PUTC ':' |
334 call I2CREAD2 ; Minute | 335 call I2CREAD2 ; Minute |
383 movwf xB+0 | 384 movwf xB+0 |
384 clrf xB+1 | 385 clrf xB+1 |
385 call mult16x16 ; result is in xC:2 ! | 386 call mult16x16 ; result is in xC:2 ! |
386 | 387 |
387 bsf leftbind | 388 bsf leftbind |
389 PUTC 0x95 ; "duration o dive" icon | |
388 output_16 ; divetime minutes | 390 output_16 ; divetime minutes |
389 | 391 |
392 btfss logbook_format_0x21 ; Dive made with new 0x21 format? | |
393 bra display_profile_old_spacing ; No | |
394 ; Yes, get real sample time | |
395 incf_eeprom_address d'35' ; Skip Bytes in EEPROM | |
396 call I2CREAD2 ; Total sample time in seconds | |
397 movff SSPBUF,xA+0 | |
398 call I2CREAD2 ; Total sample time in seconds | |
399 movff SSPBUF,xA+1 | |
400 movlw LOW d'600' | |
401 movwf xB+0 | |
402 movlw HIGH d'600' | |
403 movwf xB+1 ; A vertical line every 600 seconds | |
404 call div16x16 ; xA/xB=xC with xA as remainder | |
405 decf_eeprom_address d'37' ; Macro, that subtracts 8Bit from eeprom_address:2 | |
406 bra display_profile_spacing ; continue below | |
407 | |
408 display_profile_old_spacing: | |
390 ; Compute spacing between 10min lines | 409 ; Compute spacing between 10min lines |
391 movff lo,xA+0 | 410 movff lo,xA+0 |
392 movff hi,xA+1 ; divetime in minutes | 411 movff hi,xA+1 ; divetime in minutes |
393 movlw d'10' | 412 movlw d'10' |
394 movwf xB+0 | 413 movwf xB+0 |
395 clrf xB+1 ; A vertical line every 10 minutes | 414 clrf xB+1 ; A vertical line every 10 minutes |
396 call div16x16 ;xA/xB=xC with xA as remainder | 415 call div16x16 ; xA/xB=xC with xA as remainder |
416 display_profile_spacing: | |
397 ; xC now holds number of lines | 417 ; xC now holds number of lines |
398 movlw d'1' | 418 movlw d'1' |
399 addwf xC+0 ; Add one line... | 419 addwf xC+0 ; Add one line... |
400 movff xC+0,xB+0 | 420 movff xC+0,xB+0 |
401 clrf xB+1 ; No more then 255 lines... | 421 clrf xB+1 ; No more then 255 lines... |
406 ; xC now holds spacing between vertical 10min lines | 426 ; xC now holds spacing between vertical 10min lines |
407 movff xC+0,avr_rel_pressure+0 | 427 movff xC+0,avr_rel_pressure+0 |
408 movff xC+1,avr_rel_pressure+1 ; spacing between 10min lines (1-159) | 428 movff xC+1,avr_rel_pressure+1 ; spacing between 10min lines (1-159) |
409 | 429 |
410 ; Restore divetime in minutes: | 430 ; Restore divetime in minutes: |
431 btfss logbook_format_0x21 ; Dive made with new 0x21 format? | |
432 bra display_profile_old_xscale ; No | |
433 ; Yes, get real sample time | |
434 incf_eeprom_address d'35' ; Skip Bytes in EEPROM | |
435 call I2CREAD2 ; Total sample time in seconds | |
436 movff SSPBUF,xC+0 | |
437 call I2CREAD2 ; Total sample time in seconds | |
438 movff SSPBUF,xC+1 | |
439 decf_eeprom_address d'37' ; Macro, that subtracts 8Bit from eeprom_address:2 | |
440 PUTC ':' | |
441 call I2CREAD2 ; read divetime seconds | |
442 movff SSPBUF,lo | |
443 bra display_profile_xscale ; continue below | |
444 | |
445 display_profile_old_xscale: | |
411 movff lo,xA+0 ; calculate x-scale for profile display | 446 movff lo,xA+0 ; calculate x-scale for profile display |
412 movff hi,xA+1 ; calculate total diveseconds first | 447 movff hi,xA+1 ; calculate total diveseconds first |
413 movlw d'60' ; 60seconds are one minute... | 448 movlw d'60' ; 60seconds are one minute... |
414 movwf xB+0 | 449 movwf xB+0 |
415 clrf xB+1 | 450 clrf xB+1 |
416 call mult16x16 ; result is in xC:2 ! | 451 call mult16x16 ; result is in xC:2 ! |
417 | 452 PUTC ':' |
418 PUTC d'39' ;"'" | |
419 call I2CREAD2 ; read divetime seconds | 453 call I2CREAD2 ; read divetime seconds |
420 movff SSPBUF,lo | 454 movff SSPBUF,lo |
421 movf lo,W ; add seconds to total seconds | 455 movf lo,W ; add seconds to total seconds |
422 addwf xC+0 | 456 addwf xC+0 |
423 movlw d'0' | 457 movlw d'0' |
424 addwfc xC+1 ; xC:2 now holds total dive seconds! | 458 addwfc xC+1 ; xC:2 now holds total dive seconds! |
459 | |
460 display_profile_xscale: | |
425 movff xC+0,xA+0 ; now calculate x-scale value | 461 movff xC+0,xA+0 ; now calculate x-scale value |
426 movff xC+1,xA+1 | 462 movff xC+1,xA+1 |
427 movlw d'154' ; 154pix width available | 463 movlw d'154' ; 154pix width available |
428 movwf xB+0 | 464 movwf xB+0 |
429 clrf xB+1 | 465 clrf xB+1 |
441 addwfc profile_temp+1,F | 477 addwfc profile_temp+1,F |
442 | 478 |
443 | 479 |
444 bsf leftbind | 480 bsf leftbind |
445 output_99x ; divetime seconds | 481 output_99x ; divetime seconds |
446 STRCAT "\" " | 482 PUTC ' ' |
447 call I2CREAD2 | 483 call I2CREAD2 |
448 movff SSPBUF,lo | 484 movff SSPBUF,lo |
449 call I2CREAD2 | 485 call I2CREAD2 |
450 movff SSPBUF,hi | 486 movff SSPBUF,hi |
451 movlw d'3' | 487 movlw d'3' |
1176 movlw HIGH 0x100 | 1212 movlw HIGH 0x100 |
1177 movwf EEADRH | 1213 movwf EEADRH |
1178 movlw 0xAA | 1214 movlw 0xAA |
1179 movwf EEDATA | 1215 movwf EEDATA |
1180 call write_eeprom ; write 0xAA to indicate the logbook is already converted | 1216 call write_eeprom ; write 0xAA to indicate the logbook is already converted |
1217 return | |
1181 ; convert logbook: | 1218 ; convert logbook: |
1182 ; Step 1: Copy 32k from 0xFE + 1 with bank switching to bank1 | 1219 ; Step 1: Copy 32k from 0xFE + 1 with bank switching to bank1 |
1183 ; Step 2: Copy 32k from bank1 to bank0 | 1220 ; Step 2: Copy 32k from bank1 to bank0 |
1184 ; Step 3: delete bank1 | 1221 ; Step 3: delete bank1 |
1185 call get_free_EEPROM_location ; Searches 0xFD, 0xFD, 0xFE and sets Pointer to 0xFE | 1222 call get_free_EEPROM_location ; Searches 0xFD, 0xFD, 0xFE and sets Pointer to 0xFE |
1257 btg LED_red | 1294 btg LED_red |
1258 decfsz uart2_temp,F ; 32kByte done? | 1295 decfsz uart2_temp,F ; 32kByte done? |
1259 bra logbook_convert4 ; No, continue | 1296 bra logbook_convert4 ; No, continue |
1260 ; Step 2 done. | 1297 ; Step 2 done. |
1261 bcf LED_red | 1298 bcf LED_red |
1299 ; Do Step 3: | |
1262 movlw HIGH 0x8000 | 1300 movlw HIGH 0x8000 |
1263 movwf logbook_temp2 | 1301 movwf logbook_temp2 |
1264 movlw LOW 0x8000 | 1302 movlw LOW 0x8000 |
1265 movwf logbook_temp1 ; load address for bank1 | 1303 movwf logbook_temp1 ; load address for bank1 |
1266 movlw 0x80 | 1304 movlw 0x80 |