Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 430:f36b93f2fbed
Minor logbook cleanups.
Created a 20byte tmp area, safe from C-library footprint.
author | JeanDo |
---|---|
date | Thu, 04 Aug 2011 18:54:26 +0200 |
parents | 04535df08575 |
children | 1f1af9482d00 |
comparison
equal
deleted
inserted
replaced
429:1da600c4e139 | 430:f36b93f2fbed |
---|---|
21 ; written: 060107 | 21 ; written: 060107 |
22 ; last updated: 081026 | 22 ; last updated: 081026 |
23 ; known bugs: | 23 ; known bugs: |
24 ; ToDo: | 24 ; ToDo: |
25 | 25 |
26 ;============================================================================= | |
27 ; Temp data, local to this module, moved to ACCES0 area. | |
28 ; | |
29 CBLOCK 0x010 ; Keep space for aa_wordprocessor's temp. | |
30 count_temperature ; Current sample count for temperature divisor | |
31 count_deco ; Current sample count for deco (ceiling) divisor | |
32 logbook0_ptr:2 ; Loogbook pointer inside EEPROM Bank0 | |
33 logbook1_ptr:2 ; Loogbook pointer inside EEPROM Bank1 | |
34 logbook_cur_depth:2 ; Current depth, for drawing profile. | |
35 logbook_cur_tp:2 ; Current temperature, for drawing profile. | |
36 logbook_last_tp ; Y of the last item in Tp° curve. | |
37 logbook_min_tp:2 ; Min temperature, for drawing profile. | |
38 logbook_ceiling ; Current ceiling, for drawing profile. | |
39 ENDC | |
40 | |
41 ;============================================================================= | |
26 ; searches external EEPROM for dive headers and displays them in a list | 42 ; searches external EEPROM for dive headers and displays them in a list |
27 ; a detailed view with all informations and profile can be selected | 43 ; a detailed view with all informations and profile can be selected |
28 ; does not require a FAT, will work with other profile intervals as ten seconds, too | 44 ; does not require a FAT, will work with other profile intervals as ten seconds, too |
29 | 45 |
30 menu_logbook: | 46 menu_logbook: |
45 DISPLAYTEXT .12 ;" Wait.." | 61 DISPLAYTEXT .12 ;" Wait.." |
46 WIN_INVERT .0 | 62 WIN_INVERT .0 |
47 call I2CReset ; Reset I2C Bus | 63 call I2CReset ; Reset I2C Bus |
48 call get_free_EEPROM_location ; search from "here" backwards through the external memory | 64 call get_free_EEPROM_location ; search from "here" backwards through the external memory |
49 | 65 |
50 movff eeprom_address+0,logbook_temp5 | 66 movff eeprom_address+0,logbook1_ptr+0 |
51 movff eeprom_address+1,logbook_temp6 ; Store Pointer to 0xFE (From 0xFD, 0xFD, 0xFE sequence) for faster display | 67 movff eeprom_address+1,logbook1_ptr+1 ; Store Pointer to 0xFE (From 0xFD, 0xFD, 0xFE sequence) for faster display |
52 | 68 |
53 menu_logbook1a_no_get_free: ; Without repeated search for dive | 69 menu_logbook1a_no_get_free: ; Without repeated search for dive |
54 clrf divemins+0 ; Here: used as temp variables | 70 clrf divemins+0 ; Here: used as temp variables |
55 clrf divemins+1 | 71 clrf divemins+1 |
56 movlw d'5' | 72 movlw d'5' |
251 call PLED_ClearScreen ; search for dive | 267 call PLED_ClearScreen ; search for dive |
252 bsf logbook_profile_view ; set flag for search routine | 268 bsf logbook_profile_view ; set flag for search routine |
253 | 269 |
254 clrf divenumber ; search from scratch | 270 clrf divenumber ; search from scratch |
255 | 271 |
256 movff logbook_temp5,eeprom_address+0 | 272 movff logbook1_ptr+0,eeprom_address+0 |
257 movff logbook_temp6,eeprom_address+1 ; Restore Pointer to 0xFE (From 0xFD, 0xFD, 0xFE sequence) for faster display | 273 movff logbook1_ptr+1,eeprom_address+1 ; Restore Pointer to 0xFE (From 0xFD, 0xFD, 0xFE sequence) for faster display |
258 | 274 |
259 bra menu_logbook1a_no_get_free ; Start Search for Dive (Without get_free_EEPROM_location) | 275 bra menu_logbook1a_no_get_free ; Start Search for Dive (Without get_free_EEPROM_location) |
260 | 276 |
261 display_profile2: | 277 display_profile2: |
262 bcf logbook_profile_view ; clear flag for search routine | 278 bcf logbook_profile_view ; clear flag for search routine |
520 | 536 |
521 call I2CREAD2 ; Read Tp° divisor | 537 call I2CREAD2 ; Read Tp° divisor |
522 movf SSPBUF,W | 538 movf SSPBUF,W |
523 andlw 0x0F ; Clear extra bits. | 539 andlw 0x0F ; Clear extra bits. |
524 movwf divisor_temperature ; Store divisor | 540 movwf divisor_temperature ; Store divisor |
525 movwf logbook_temp1 ; Store to tp° counter too. | 541 movwf count_temperature ; Store to tp° counter too. |
526 | 542 |
527 call I2CREAD2 ; Read divisor | 543 call I2CREAD2 ; Read divisor |
528 movf SSPBUF,W | 544 movf SSPBUF,W |
529 andlw 0x0F | 545 andlw 0x0F |
530 movwf divisor_deco ; Store divisor | 546 movwf divisor_deco ; Store divisor |
531 movwf logbook_temp2 ; Store as temp, too | 547 movwf count_deco ; Store as temp, too |
532 | 548 |
533 call I2CREAD2 ; Read divisor | 549 call I2CREAD2 ; Read divisor |
534 movff SSPBUF,divisor_gf ; Store divisor | 550 movff SSPBUF,divisor_gf ; Store divisor |
535 call I2CREAD2 ; Read divisor | 551 call I2CREAD2 ; Read divisor |
536 movff SSPBUF,divisor_ppo2 ; Store divisor | 552 movff SSPBUF,divisor_ppo2 ; Store divisor |
1171 rcall profile_view_get_depth_new2 ; Yes, get information about this event | 1187 rcall profile_view_get_depth_new2 ; Yes, get information about this event |
1172 | 1188 |
1173 ;---- Read Tp°, if any AND divisor reached AND bytes available ----------- | 1189 ;---- Read Tp°, if any AND divisor reached AND bytes available ----------- |
1174 movf divisor_temperature,W ; Is Tp° divisor null ? | 1190 movf divisor_temperature,W ; Is Tp° divisor null ? |
1175 bz profile_view_get_depth_no_tp; Yes: no Tp° curve. | 1191 bz profile_view_get_depth_no_tp; Yes: no Tp° curve. |
1176 decf logbook_temp1,F ; Decrement tp° counter | 1192 decf count_temperature,F ; Decrement tp° counter |
1177 bnz profile_view_get_depth_no_tp; No temperature this time | 1193 bnz profile_view_get_depth_no_tp; No temperature this time |
1178 | 1194 |
1179 call I2CREAD2 ; Tp° low | 1195 call I2CREAD2 ; Tp° low |
1180 movff SSPBUF,logbook_cur_tp+0 | 1196 movff SSPBUF,logbook_cur_tp+0 |
1181 call I2CREAD2 ; Tp° high | 1197 call I2CREAD2 ; Tp° high |
1182 movff SSPBUF,logbook_cur_tp+1 | 1198 movff SSPBUF,logbook_cur_tp+1 |
1183 decf timeout_counter2,F | 1199 decf timeout_counter2,F |
1184 decf timeout_counter2,F | 1200 decf timeout_counter2,F |
1185 movff divisor_temperature,logbook_temp1 ; Restart counter. | 1201 movff divisor_temperature,count_temperature ; Restart counter. |
1186 | 1202 |
1187 ;---- Read deco, if any AND divisor=0 AND bytes available ---------------- | 1203 ;---- Read deco, if any AND divisor=0 AND bytes available ---------------- |
1188 profile_view_get_depth_no_tp: | 1204 profile_view_get_depth_no_tp: |
1189 movf divisor_deco,W | 1205 movf divisor_deco,W |
1190 bz profile_view_get_depth_no_deco | 1206 bz profile_view_get_depth_no_deco |
1191 decf logbook_temp2,F | 1207 decf count_deco,F |
1192 bnz profile_view_get_depth_no_deco | 1208 bnz profile_view_get_depth_no_deco |
1193 | 1209 |
1194 call I2CREAD2 | 1210 call I2CREAD2 |
1195 movff SSPBUF,logbook_ceiling | 1211 movff SSPBUF,logbook_ceiling |
1196 decf timeout_counter2,F | 1212 decf timeout_counter2,F |
1197 movff divisor_deco,logbook_temp2 ; Restart counter. | 1213 movff divisor_deco,count_deco ; Restart counter. |
1198 | 1214 |
1199 ;---- Read GF, if any AND divisor=0 AND bytes available ------------------ | 1215 ;---- Read GF, if any AND divisor=0 AND bytes available ------------------ |
1200 profile_view_get_depth_no_deco: | 1216 profile_view_get_depth_no_deco: |
1201 | 1217 |
1202 movf timeout_counter2,W ; No more extra bytes ? | 1218 movf timeout_counter2,W ; No more extra bytes ? |
1392 clrf EEADRH ; Restore EEADRH | 1408 clrf EEADRH ; Restore EEADRH |
1393 ; convert logbook: | 1409 ; convert logbook: |
1394 ; Step 1: Copy 32k from 0xFE + 1 with bank switching to bank1 | 1410 ; Step 1: Copy 32k from 0xFE + 1 with bank switching to bank1 |
1395 ; Step 2: Copy 32k from bank1 to bank0 | 1411 ; Step 2: Copy 32k from bank1 to bank0 |
1396 ; Step 3: delete bank1 | 1412 ; Step 3: delete bank1 |
1397 call get_free_EEPROM_location ; Searches 0xFD, 0xFD, 0xFE and sets Pointer to 0xFE | 1413 call get_free_EEPROM_location ; Searches 0xFD, 0xFD, 0xFE and sets Pointer to 0xFE |
1398 rcall incf_eeprom_bank0 ; eeprom_address:2 now at 0xFE+1 | 1414 rcall incf_eeprom_bank0 ; eeprom_address:2 now at 0xFE+1 |
1399 ; Do Step 1: | 1415 ; Do Step 1: |
1400 ;logbook_temp5 and logbook_temp6 hold address in bank1 | 1416 ;logbook1_ptr+0 and logbook1_ptr+1 hold address in bank1 |
1401 ;logbook_temp1 and logbook_temp2 hold address in bank0 | 1417 ;logbook0_ptr+0 and logbook0_ptr+1 hold address in bank0 |
1402 movlw HIGH 0x8000 | 1418 movlw HIGH 0x8000 |
1403 movwf logbook_temp6 | 1419 movwf logbook1_ptr+1 |
1404 movlw LOW 0x8000 | 1420 movlw LOW 0x8000 |
1405 movwf logbook_temp5 ; load address for bank1 | 1421 movwf logbook1_ptr+0 ; load address for bank1 |
1406 movff eeprom_address+0,logbook_temp1 | 1422 movff eeprom_address+0,logbook0_ptr+0 |
1407 movff eeprom_address+1,logbook_temp2 ; load address for bank0 | 1423 movff eeprom_address+1,logbook0_ptr+1 ; load address for bank0 |
1408 movlw 0x80 | 1424 movlw 0x80 |
1409 movwf uart2_temp | 1425 movwf uart2_temp |
1410 logbook_convert2: | 1426 logbook_convert2: |
1411 clrf uart1_temp ; counter for copy operation | 1427 clrf uart1_temp ; counter for copy operation |
1412 logbook_convert3: | 1428 logbook_convert3: |
1413 ; read source | 1429 ; read source |
1414 movff logbook_temp1,eeprom_address+0 | 1430 movff logbook0_ptr+0,eeprom_address+0 |
1415 movff logbook_temp2,eeprom_address+1 | 1431 movff logbook0_ptr+1,eeprom_address+1 |
1416 call I2CREAD | 1432 call I2CREAD |
1417 movff SSPBUF,lo ; hold read value | 1433 movff SSPBUF,lo ; hold read value |
1418 rcall incf_eeprom_bank0 ; eeprom_address:2 +1 with bank switching | 1434 rcall incf_eeprom_bank0 ; eeprom_address:2 +1 with bank switching |
1419 movff eeprom_address+0,logbook_temp1 | 1435 movff eeprom_address+0,logbook0_ptr+0 |
1420 movff eeprom_address+1,logbook_temp2 ; write source address | 1436 movff eeprom_address+1,logbook0_ptr+1 ; write source address |
1421 ; write target | 1437 ; write target |
1422 movff logbook_temp5,eeprom_address+0 | 1438 movff logbook1_ptr+0,eeprom_address+0 |
1423 movff logbook_temp6,eeprom_address+1 | 1439 movff logbook1_ptr+1,eeprom_address+1 |
1424 movf lo,W | 1440 movf lo,W |
1425 call I2CWRITE ; writes WREG into EEPROM@eeprom_address | 1441 call I2CWRITE ; writes WREG into EEPROM@eeprom_address |
1426 movlw d'1' | 1442 movlw d'1' |
1427 addwf logbook_temp5,F | 1443 addwf logbook1_ptr+0,F |
1428 movlw d'0' | 1444 movlw d'0' |
1429 addwfc logbook_temp6,F ; increase target address | 1445 addwfc logbook1_ptr+1,F ; increase target address |
1430 decfsz uart1_temp,F | 1446 decfsz uart1_temp,F |
1431 bra logbook_convert3 | 1447 bra logbook_convert3 |
1432 btg LED_blue | 1448 btg LED_blue |
1433 decfsz uart2_temp,F ; 32kByte done? | 1449 decfsz uart2_temp,F ; 32kByte done? |
1434 bra logbook_convert2 ; No, continue | 1450 bra logbook_convert2 ; No, continue |
1435 ; Step 1 done. | 1451 ; Step 1 done. |
1436 bcf LED_blue | 1452 bcf LED_blue |
1437 ; Do Step 2: | 1453 ; Do Step 2: |
1438 movlw HIGH 0x0000 | 1454 movlw HIGH 0x0000 |
1439 movwf logbook_temp6 | 1455 movwf logbook1_ptr+1 |
1440 movlw LOW 0x0000 | 1456 movlw LOW 0x0000 |
1441 movwf logbook_temp5 ; load address for bank0 | 1457 movwf logbook1_ptr+0 ; load address for bank0 |
1442 movlw HIGH 0x8000 | 1458 movlw HIGH 0x8000 |
1443 movwf logbook_temp2 | 1459 movwf logbook0_ptr+1 |
1444 movlw LOW 0x8000 | 1460 movlw LOW 0x8000 |
1445 movwf logbook_temp1 ; load address for bank1 | 1461 movwf logbook0_ptr+0 ; load address for bank1 |
1446 movlw 0x80 | 1462 movlw 0x80 |
1447 movwf uart2_temp | 1463 movwf uart2_temp |
1448 logbook_convert4: | 1464 logbook_convert4: |
1449 clrf uart1_temp ; counter for copy operation | 1465 clrf uart1_temp ; counter for copy operation |
1450 logbook_convert5: | 1466 logbook_convert5: |
1451 ; read source | 1467 ; read source |
1452 movff logbook_temp1,eeprom_address+0 | 1468 movff logbook0_ptr+0,eeprom_address+0 |
1453 movff logbook_temp2,eeprom_address+1 | 1469 movff logbook0_ptr+1,eeprom_address+1 |
1454 call I2CREAD | 1470 call I2CREAD |
1455 movff SSPBUF,lo ; hold read value | 1471 movff SSPBUF,lo ; hold read value |
1456 incf_eeprom_address d'1' | 1472 incf_eeprom_address d'1' |
1457 movff eeprom_address+0,logbook_temp1 | 1473 movff eeprom_address+0,logbook0_ptr+0 |
1458 movff eeprom_address+1,logbook_temp2 ; write source address | 1474 movff eeprom_address+1,logbook0_ptr+1 ; write source address |
1459 ; write target | 1475 ; write target |
1460 movff logbook_temp5,eeprom_address+0 | 1476 movff logbook1_ptr+0,eeprom_address+0 |
1461 movff logbook_temp6,eeprom_address+1 | 1477 movff logbook1_ptr+1,eeprom_address+1 |
1462 movf lo,W | 1478 movf lo,W |
1463 call I2CWRITE ; writes WREG into EEPROM@eeprom_address | 1479 call I2CWRITE ; writes WREG into EEPROM@eeprom_address |
1464 incf_eeprom_address d'1' | 1480 incf_eeprom_address d'1' |
1465 movff eeprom_address+0,logbook_temp5 | 1481 movff eeprom_address+0,logbook1_ptr+0 |
1466 movff eeprom_address+1,logbook_temp6 ; write target address | 1482 movff eeprom_address+1,logbook1_ptr+1; write target address |
1467 decfsz uart1_temp,F | 1483 decfsz uart1_temp,F |
1468 bra logbook_convert5 | 1484 bra logbook_convert5 |
1469 btg LED_red | 1485 btg LED_red |
1470 decfsz uart2_temp,F ; 32kByte done? | 1486 decfsz uart2_temp,F ; 32kByte done? |
1471 bra logbook_convert4 ; No, continue | 1487 bra logbook_convert4 ; No, continue |
1472 ; Step 2 done. | 1488 ; Step 2 done. |
1473 bcf LED_red | 1489 bcf LED_red |
1474 ; Do Step 3: | 1490 ; Do Step 3: |
1475 movlw HIGH 0x8000 | 1491 movlw HIGH 0x8000 |
1476 movwf logbook_temp2 | 1492 movwf logbook0_ptr+1 |
1477 movlw LOW 0x8000 | 1493 movlw LOW 0x8000 |
1478 movwf logbook_temp1 ; load address for bank1 | 1494 movwf logbook0_ptr+0 ; load address for bank1 |
1479 movlw 0x80 | 1495 movlw 0x80 |
1480 movwf uart2_temp | 1496 movwf uart2_temp |
1481 logbook_convert6: | 1497 logbook_convert6: |
1482 clrf uart1_temp ; counter for copy operation | 1498 clrf uart1_temp ; counter for copy operation |
1483 logbook_convert7: | 1499 logbook_convert7: |
1484 ; write target | 1500 ; write target |
1485 movff logbook_temp1,eeprom_address+0 | 1501 movff logbook0_ptr+0,eeprom_address+0 |
1486 movff logbook_temp2,eeprom_address+1 | 1502 movff logbook0_ptr+1,eeprom_address+1 |
1487 movlw 0xFF | 1503 movlw 0xFF |
1488 call I2CWRITE ; writes WREG into EEPROM@eeprom_address | 1504 call I2CWRITE ; writes WREG into EEPROM@eeprom_address |
1489 incf_eeprom_address d'1' | 1505 incf_eeprom_address d'1' |
1490 movff eeprom_address+0,logbook_temp1 | 1506 movff eeprom_address+0,logbook0_ptr+0 |
1491 movff eeprom_address+1,logbook_temp2 ; write target address | 1507 movff eeprom_address+1,logbook0_ptr+1 ; write target address |
1492 decfsz uart1_temp,F | 1508 decfsz uart1_temp,F |
1493 bra logbook_convert7 | 1509 bra logbook_convert7 |
1494 btg LED_red | 1510 btg LED_red |
1495 btg LED_blue | 1511 btg LED_blue |
1496 decfsz uart2_temp,F ; 32kByte done? | 1512 decfsz uart2_temp,F ; 32kByte done? |