Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/menu_logbook.asm @ 33:6e5db85382a2
Speedy simulator! New Deco code test 1
author | heinrichsweikamp |
---|---|
date | Tue, 25 May 2010 17:37:26 +0200 |
parents | 68825abc35f7 |
children | 3ab1188651af |
comparison
equal
deleted
inserted
replaced
32:a776039bda63 | 33:6e5db85382a2 |
---|---|
598 | 598 |
599 btfsc menubit2 ; SET/MENU? | 599 btfsc menubit2 ; SET/MENU? |
600 bra exit_profileview ; back to list | 600 bra exit_profileview ; back to list |
601 | 601 |
602 btfsc menubit3 ; ENTER? | 602 btfsc menubit3 ; ENTER? |
603 bra profileview_menu ; Switch to the Profileview menu | 603 bra exit_profileview ; back to list |
604 ; bra profileview_menu ; Switch to the Profileview menu | |
604 | 605 |
605 btfsc onesecupdate | 606 btfsc onesecupdate |
606 call timeout_surfmode ; timeout | 607 call timeout_surfmode ; timeout |
607 | 608 |
608 btfsc onesecupdate | 609 btfsc onesecupdate |
880 | 881 |
881 call word_processor ; Display header-row in list | 882 call word_processor ; Display header-row in list |
882 return | 883 return |
883 | 884 |
884 | 885 |
885 profileview_menu: | 886 ;profileview_menu: |
886 movlw d'1' | 887 ; movlw d'1' |
887 movwf menupos | 888 ; movwf menupos |
888 profileview_menu1: | 889 ;profileview_menu1: |
889 call PLED_clear_divemode_menu | 890 ; call PLED_clear_divemode_menu |
890 call PLED_profileview_menu ; Displays Menu | 891 ; call PLED_profileview_menu ; Displays Menu |
891 profileview_menu2: | 892 ;profileview_menu2: |
892 call PLED_divemenu_cursor | 893 ; call PLED_divemenu_cursor |
893 bcf sleepmode ; clear some flags | 894 ; bcf sleepmode ; clear some flags |
894 bcf menubit2 | 895 ; bcf menubit2 |
895 bcf menubit3 | 896 ; bcf menubit3 |
896 bcf switch_right | 897 ; bcf switch_right |
897 bcf switch_left | 898 ; bcf switch_left |
898 clrf timeout_counter2 | 899 ; clrf timeout_counter2 |
899 | 900 ; |
900 profileview_menu_loop: | 901 ;profileview_menu_loop: |
901 call check_switches_logbook | 902 ; call check_switches_logbook |
902 | 903 ; |
903 btfsc menubit3 ; SET/MENU? | 904 ; btfsc menubit3 ; SET/MENU? |
904 bra profileview_menu_move_cursor; Move Cursor | 905 ; bra profileview_menu_move_cursor; Move Cursor |
905 btfsc menubit2 ; ENTER? | 906 ; btfsc menubit2 ; ENTER? |
906 bra profileview_menu_do ; Do task | 907 ; bra profileview_menu_do ; Do task |
907 | 908 ; |
908 btfsc onesecupdate | 909 ; btfsc onesecupdate |
909 call timeout_surfmode ; timeout | 910 ; call timeout_surfmode ; timeout |
910 btfsc onesecupdate | 911 ; btfsc onesecupdate |
911 call set_dive_modes ; check, if divemode must be entered | 912 ; call set_dive_modes ; check, if divemode must be entered |
912 bcf onesecupdate ; one second update | 913 ; bcf onesecupdate ; one second update |
913 btfsc sleepmode ; Timeout? | 914 ; btfsc sleepmode ; Timeout? |
914 bra exit_profileview ; back to list | 915 ; bra exit_profileview ; back to list |
915 btfsc divemode | 916 ; btfsc divemode |
916 goto restart ; Enter Divemode if required | 917 ; goto restart ; Enter Divemode if required |
917 | 918 ; |
918 bra profileview_menu_loop ; wait for something to do | 919 ; bra profileview_menu_loop ; wait for something to do |
919 | 920 ; |
920 profileview_menu_do: | 921 ;profileview_menu_do: |
921 dcfsnz menupos,F | |
922 bra exit_profileview ; back to list, quit profileview menu | |
923 dcfsnz menupos,F | |
924 bra profileview_menu_delete ; Delete Dive from external EEPROM | |
925 ; dcfsnz menupos,F | 922 ; dcfsnz menupos,F |
926 ; bra profileview_menu_format ; Delete all Dives from external EEPROM | 923 ; bra exit_profileview ; back to list, quit profileview menu |
927 ; | 924 ; dcfsnz menupos,F |
928 profileview_menu_move_cursor: | 925 ; bra profileview_menu_delete ; Delete Dive from external EEPROM |
929 incf menupos,F | 926 ;; dcfsnz menupos,F |
930 movlw d'3' ; number of menu options+1 | 927 ;; bra profileview_menu_format ; Delete all Dives from external EEPROM |
931 cpfseq menupos ; =limit? | 928 ;; |
932 bra profileview_menu_move_cursor2 ; No! | 929 ;profileview_menu_move_cursor: |
933 movlw d'1' ; Yes, reset to position 1! | 930 ; incf menupos,F |
934 movwf menupos | 931 ; movlw d'3' ; number of menu options+1 |
935 profileview_menu_move_cursor2: | 932 ; cpfseq menupos ; =limit? |
936 bra profileview_menu2 ; Return to Profile Menu, also updates cursor | 933 ; bra profileview_menu_move_cursor2 ; No! |
937 | 934 ; movlw d'1' ; Yes, reset to position 1! |
938 profileview_menu_format: | 935 ; movwf menupos |
939 call PLED_confirmbox ; Returns WREG=0 for Cancel (Or Timeout) and WREG=1 for OK! | 936 ;profileview_menu_move_cursor2: |
940 | 937 ; bra profileview_menu2 ; Return to Profile Menu, also updates cursor |
941 movwf menupos ; Used as temp | 938 |
942 tstfsz menupos | 939 ;profileview_menu_format: |
943 bra profileview_menu_format_loop2 ; Format now! | 940 ; call PLED_confirmbox ; Returns WREG=0 for Cancel (Or Timeout) and WREG=1 for OK! |
944 | 941 ; |
945 bra exit_profileview ; back to list, quit profileview menu | 942 ; movwf menupos ; Used as temp |
946 | 943 ; tstfsz menupos |
947 profileview_menu_format_loop2: ; Do now format! | 944 ; bra profileview_menu_format_loop2 ; Format now! |
948 call PLED_ClearScreen | 945 ; |
949 DISPLAYTEXT .12 ; "Wait.." | 946 ; bra exit_profileview ; back to list, quit profileview menu |
950 call reset_external_eeprom ; delete profile memory | 947 ; |
951 goto menu ; Return to Menu | 948 ;profileview_menu_format_loop2: ; Do now format! |
952 | 949 ; call PLED_ClearScreen |
953 profileview_menu_delete: | 950 ; DISPLAYTEXT .12 ; "Wait.." |
954 call PLED_confirmbox ; Returns WREG=0 for Cancel (Or Timeout) and WREG=1 for OK! | 951 ; call reset_external_eeprom ; delete profile memory |
955 movwf menupos ; Used as temp | 952 ; goto menu ; Return to Menu |
956 tstfsz menupos | 953 |
957 bra profileview_menu_delete_loop2 ; Delete now! | 954 ;profileview_menu_delete: |
958 | 955 ; call PLED_confirmbox ; Returns WREG=0 for Cancel (Or Timeout) and WREG=1 for OK! |
959 bra exit_profileview ; back to list, quit profileview menu | 956 ; movwf menupos ; Used as temp |
960 | 957 ; tstfsz menupos |
961 profileview_menu_delete_loop2: ; Do now delete | 958 ; bra profileview_menu_delete_loop2 ; Delete now! |
962 call PLED_ClearScreen | 959 ; |
963 DISPLAYTEXT .12 ; "Wait.." | 960 ; bra exit_profileview ; back to list, quit profileview menu |
964 | 961 ; |
965 ; eeprom_address:2 is set to the second byte after the ending 0xFD 0xFD | 962 ;profileview_menu_delete_loop2: ; Do now delete |
966 ; eeprom_address:2 - 1 -> set to the last byte after the 0xFD 0xFD of the current dive | 963 ; call PLED_ClearScreen |
967 | 964 ; DISPLAYTEXT .12 ; "Wait.." |
968 ; Set pointer to Byte after the final "0xFD 0xFD" | 965 ; |
969 decf_eeprom_address d'1' ; Macro, that subtracts 8Bit from eeprom_address:2 with banking at 0x8000 | 966 ;; eeprom_address:2 is set to the second byte after the ending 0xFD 0xFD |
970 movff eeprom_address+0,divemins+0 | 967 ;; eeprom_address:2 - 1 -> set to the last byte after the 0xFD 0xFD of the current dive |
971 movff eeprom_address+1,divemins+1 | 968 ; |
972 | 969 ;; Set pointer to Byte after the final "0xFD 0xFD" |
973 ; eeprom_header_address:2 + 1 -> set to the first 0xFA of the 0xFA 0xFA start bytes of the header | 970 ; decf_eeprom_address d'1' ; Macro, that subtracts 8Bit from eeprom_address:2 with banking at 0x8000 |
974 movlw d'1' ; | 971 ; movff eeprom_address+0,divemins+0 |
975 addwf eeprom_header_address+0,F | 972 ; movff eeprom_address+1,divemins+1 |
976 movlw d'0' | 973 ; |
977 addwfc eeprom_header_address+1,F ; eeprom_header_address:2 + 1 | 974 ;; eeprom_header_address:2 + 1 -> set to the first 0xFA of the 0xFA 0xFA start bytes of the header |
978 btfsc eeprom_header_address+1,7 ; at 7FFF? | 975 ; movlw d'1' ; |
979 clrf eeprom_header_address+0 ; Yes, clear address (+0 first!) | 976 ; addwf eeprom_header_address+0,F |
980 btfsc eeprom_header_address+1,7 ; at 7FFF? | 977 ; movlw d'0' |
981 clrf eeprom_header_address+1 ; Yes, clear address | 978 ; addwfc eeprom_header_address+1,F ; eeprom_header_address:2 + 1 |
982 | 979 ; btfsc eeprom_header_address+1,7 ; at 7FFF? |
983 movff divemins+0,eeprom_address+0 | 980 ; clrf eeprom_header_address+0 ; Yes, clear address (+0 first!) |
984 movff divemins+1,eeprom_address+1 ; Read source | 981 ; btfsc eeprom_header_address+1,7 ; at 7FFF? |
985 call I2CREAD ; reads one byte (Slow! Better use Blockread!) | 982 ; clrf eeprom_header_address+1 ; Yes, clear address |
986 movwf profile_temp+0 | 983 ; |
987 movlw 0xFE | 984 ; movff divemins+0,eeprom_address+0 |
988 cpfseq profile_temp+0 | 985 ; movff divemins+1,eeprom_address+1 ; Read source |
989 bra profileview_menu_delete_notlast ; we're not deleting the last dive.... | 986 ; call I2CREAD ; reads one byte (Slow! Better use Blockread!) |
990 | 987 ; movwf profile_temp+0 |
991 ; Just move the 0xFE after the dive and delete the rest with 0xFF | 988 ; movlw 0xFE |
992 movff eeprom_header_address+0, eeprom_address+0 | 989 ; cpfseq profile_temp+0 |
993 movff eeprom_header_address+1, eeprom_address+1 ; Write target | 990 ; bra profileview_menu_delete_notlast ; we're not deleting the last dive.... |
994 movlw 0xFE | 991 ; |
995 call I2CWRITE ; Write the byte | 992 ;; Just move the 0xFE after the dive and delete the rest with 0xFF |
996 | 993 ; movff eeprom_header_address+0, eeprom_address+0 |
997 ; Now, delete everything _between_ eeprom_header_address and divemins:2+2 with 0xFF | 994 ; movff eeprom_header_address+1, eeprom_address+1 ; Write target |
998 movlw d'1' ; | 995 ; movlw 0xFE |
999 addwf eeprom_header_address+0,F | 996 ; call I2CWRITE ; Write the byte |
1000 movlw d'0' | 997 ; |
1001 addwfc eeprom_header_address+1,F ; eeprom_header_address:2 + 1 | 998 ;; Now, delete everything _between_ eeprom_header_address and divemins:2+2 with 0xFF |
1002 btfsc eeprom_header_address+1,7 ; at 7FFF? | 999 ; movlw d'1' ; |
1003 clrf eeprom_header_address+0 ; Yes, clear address (+0 first!) | 1000 ; addwf eeprom_header_address+0,F |
1004 btfsc eeprom_header_address+1,7 ; at 7FFF? | 1001 ; movlw d'0' |
1005 clrf eeprom_header_address+1 ; Yes, clear address | 1002 ; addwfc eeprom_header_address+1,F ; eeprom_header_address:2 + 1 |
1006 | 1003 ; btfsc eeprom_header_address+1,7 ; at 7FFF? |
1007 movff eeprom_header_address+0,eeprom_address+0 | 1004 ; clrf eeprom_header_address+0 ; Yes, clear address (+0 first!) |
1008 movff eeprom_header_address+1,eeprom_address+1 | 1005 ; btfsc eeprom_header_address+1,7 ; at 7FFF? |
1009 | 1006 ; clrf eeprom_header_address+1 ; Yes, clear address |
1010 movlw d'1' ; | 1007 ; |
1011 addwf divemins+0,F | |
1012 movlw d'0' | |
1013 addwfc divemins+1,F ; divemins:2 + 1 | |
1014 btfss divemins+1,7 ; at 7FFF? | |
1015 bra profileview_menu_delete_loop2a ; Skip | |
1016 clrf divemins+0 ; Yes, clear address | |
1017 clrf divemins+1 | |
1018 | |
1019 ; movff eeprom_header_address+0,eeprom_address+0 | 1008 ; movff eeprom_header_address+0,eeprom_address+0 |
1020 ; movff eeprom_header_address+1,eeprom_address+1 | 1009 ; movff eeprom_header_address+1,eeprom_address+1 |
1021 | 1010 ; |
1022 | 1011 ; movlw d'1' ; |
1023 profileview_menu_delete_loop2a: | 1012 ; addwf divemins+0,F |
1024 movlw 0xFF | 1013 ; movlw d'0' |
1025 call I2CWRITE ; Write the byte | 1014 ; addwfc divemins+1,F ; divemins:2 + 1 |
1026 | 1015 ; btfss divemins+1,7 ; at 7FFF? |
1027 incf_eeprom_address d'1' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000 | 1016 ; bra profileview_menu_delete_loop2a ; Skip |
1028 | 1017 ; clrf divemins+0 ; Yes, clear address |
1029 movff divemins+0,sub_a+0 | 1018 ; clrf divemins+1 |
1030 movff divemins+1,sub_a+1 | 1019 ; |
1031 movff eeprom_address+0,sub_b+0 | 1020 ;; movff eeprom_header_address+0,eeprom_address+0 |
1032 movff eeprom_address+1,sub_b+1 | 1021 ;; movff eeprom_header_address+1,eeprom_address+1 |
1033 call sub16 ; sub_c = sub_a - sub_b | 1022 ; |
1034 tstfsz sub_c+0 ; Done (Result=Zero?) ? | 1023 ; |
1035 bra profileview_menu_delete_loop2a ; No, continue | 1024 ;profileview_menu_delete_loop2a: |
1036 tstfsz sub_c+1 ; Done (Result=Zero?) ? | 1025 ; movlw 0xFF |
1037 bra profileview_menu_delete_loop2a ; No, continue | 1026 ; call I2CWRITE ; Write the byte |
1038 goto menu_logbook ; Return to list when done deleting | 1027 ; |
1039 | 1028 ; incf_eeprom_address d'1' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000 |
1040 profileview_menu_delete_notlast: | 1029 ; |
1041 ; Move everything byte-wise from divemins:2 to eeprom_header_address:2 until 0xFD 0xFD 0xFE is found and were moved | 1030 ; movff divemins+0,sub_a+0 |
1042 call get_free_EEPROM_location ; Searches 0xFD, 0xFD, 0xFE and sets Pointer to 0xFE | 1031 ; movff divemins+1,sub_a+1 |
1043 | 1032 ; movff eeprom_address+0,sub_b+0 |
1044 incf_eeprom_address d'2' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000 | 1033 ; movff eeprom_address+1,sub_b+1 |
1045 movff eeprom_address+0,profile_temp+0 | 1034 ; call sub16 ; sub_c = sub_a - sub_b |
1046 movff eeprom_address+1,profile_temp+1 | 1035 ; tstfsz sub_c+0 ; Done (Result=Zero?) ? |
1047 ; holds now address of 0xFE + 2 (Abort condition....) | 1036 ; bra profileview_menu_delete_loop2a ; No, continue |
1048 decf_eeprom_address d'2' ; Macro, that subtracts 8Bit from eeprom_address:2 with banking at 0x8000 | 1037 ; tstfsz sub_c+1 ; Done (Result=Zero?) ? |
1049 ; holds now address of 0xFE again | 1038 ; bra profileview_menu_delete_loop2a ; No, continue |
1050 movff eeprom_address+0,divemins+0 | 1039 ; goto menu_logbook ; Return to list when done deleting |
1051 movff eeprom_address+1,divemins+1 ; Copy to working read registers | 1040 ; |
1052 | 1041 ;profileview_menu_delete_notlast: |
1053 profileview_menu_delete_loop3: | 1042 ;; Move everything byte-wise from divemins:2 to eeprom_header_address:2 until 0xFD 0xFD 0xFE is found and were moved |
1054 movff divemins+0,eeprom_address+0 | 1043 ; call get_free_EEPROM_location ; Searches 0xFD, 0xFD, 0xFE and sets Pointer to 0xFE |
1055 movff divemins+1,eeprom_address+1 ; Read source | 1044 ; |
1056 call I2CREAD ; reads one byte (Slow! Better use Blockread!) | 1045 ; incf_eeprom_address d'2' ; Macro, that adds 8Bit to eeprom_address:2 with banking at 0x8000 |
1057 movff eeprom_header_address+0, eeprom_address+0 | 1046 ; movff eeprom_address+0,profile_temp+0 |
1058 movff eeprom_header_address+1, eeprom_address+1 ; Write target | 1047 ; movff eeprom_address+1,profile_temp+1 |
1059 call I2CWRITE ; Write the byte | 1048 ;; holds now address of 0xFE + 2 (Abort condition....) |
1060 | 1049 ; decf_eeprom_address d'2' ; Macro, that subtracts 8Bit from eeprom_address:2 with banking at 0x8000 |
1061 movff divemins+0,eeprom_address+0 | 1050 ;; holds now address of 0xFE again |
1062 movff divemins+1,eeprom_address+1 ; Set to source again | 1051 ; movff eeprom_address+0,divemins+0 |
1063 movlw 0xFF | 1052 ; movff eeprom_address+1,divemins+1 ; Copy to working read registers |
1064 call I2CWRITE ; Delete the source.... | 1053 ; |
1065 | 1054 ;profileview_menu_delete_loop3: |
1066 movlw d'1' | 1055 ; movff divemins+0,eeprom_address+0 |
1067 addwf divemins+0,F ; Increase source (Divemins:2) | 1056 ; movff divemins+1,eeprom_address+1 ; Read source |
1068 movlw d'0' | 1057 ; call I2CREAD ; reads one byte (Slow! Better use Blockread!) |
1069 addwfc divemins+1,F | 1058 ; movff eeprom_header_address+0, eeprom_address+0 |
1070 btfsc divemins+1,7 ; at 0x8000? | 1059 ; movff eeprom_header_address+1, eeprom_address+1 ; Write target |
1071 clrf divemins+0 ; Yes, clear address (+0 first!) | 1060 ; call I2CWRITE ; Write the byte |
1072 btfsc divemins+1,7 ; at 0x8000? | 1061 ; |
1073 clrf divemins+1 ; Yes, clear address | 1062 ; movff divemins+0,eeprom_address+0 |
1074 | 1063 ; movff divemins+1,eeprom_address+1 ; Set to source again |
1075 movlw d'1' ; Increase target (eeprom_header_address:2) | 1064 ; movlw 0xFF |
1076 addwf eeprom_header_address+0,F | 1065 ; call I2CWRITE ; Delete the source.... |
1077 movlw d'0' | 1066 ; |
1078 addwfc eeprom_header_address+1,F ; eeprom_header_address:2 + 1 | 1067 ; movlw d'1' |
1079 btfsc eeprom_header_address+1,7 ; at 7FFF? | 1068 ; addwf divemins+0,F ; Increase source (Divemins:2) |
1080 clrf eeprom_header_address+0 ; Yes, clear address (+0 first!) | 1069 ; movlw d'0' |
1081 btfsc eeprom_header_address+1,7 ; at 7FFF? | 1070 ; addwfc divemins+1,F |
1082 clrf eeprom_header_address+1 ; Yes, clear address | 1071 ; btfsc divemins+1,7 ; at 0x8000? |
1083 | 1072 ; clrf divemins+0 ; Yes, clear address (+0 first!) |
1084 movff divemins+0,sub_a+0 | 1073 ; btfsc divemins+1,7 ; at 0x8000? |
1085 movff divemins+1,sub_a+1 | 1074 ; clrf divemins+1 ; Yes, clear address |
1086 movff profile_temp+0,sub_b+0 | 1075 ; |
1087 movff profile_temp+1,sub_b+1 | 1076 ; movlw d'1' ; Increase target (eeprom_header_address:2) |
1088 call sub16 ; sub_c = sub_a - sub_b | 1077 ; addwf eeprom_header_address+0,F |
1089 tstfsz sub_c+0 ; Done (Result=Zero?) ? | 1078 ; movlw d'0' |
1090 bra profileview_menu_delete_loop3 ; No, continue | 1079 ; addwfc eeprom_header_address+1,F ; eeprom_header_address:2 + 1 |
1091 tstfsz sub_c+1 ; Done (Result=Zero?) ? | 1080 ; btfsc eeprom_header_address+1,7 ; at 7FFF? |
1092 bra profileview_menu_delete_loop3 ; No, continue | 1081 ; clrf eeprom_header_address+0 ; Yes, clear address (+0 first!) |
1093 | 1082 ; btfsc eeprom_header_address+1,7 ; at 7FFF? |
1094 goto menu_logbook ; Return to list when done deleting | 1083 ; clrf eeprom_header_address+1 ; Yes, clear address |
1095 | 1084 ; |
1096 | 1085 ; movff divemins+0,sub_a+0 |
1097 | 1086 ; movff divemins+1,sub_a+1 |
1087 ; movff profile_temp+0,sub_b+0 | |
1088 ; movff profile_temp+1,sub_b+1 | |
1089 ; call sub16 ; sub_c = sub_a - sub_b | |
1090 ; tstfsz sub_c+0 ; Done (Result=Zero?) ? | |
1091 ; bra profileview_menu_delete_loop3 ; No, continue | |
1092 ; tstfsz sub_c+1 ; Done (Result=Zero?) ? | |
1093 ; bra profileview_menu_delete_loop3 ; No, continue | |
1094 ; | |
1095 ; goto menu_logbook ; Return to list when done deleting | |
1096 | |
1097 | |
1098 |