Mercurial > public > mk2
comparison code_part1/OSTC_code_asm_part1/menu_gassetup.asm @ 286:5351d47ee28a
Active gas flags simplified
author | heinrichsweikamp |
---|---|
date | Wed, 20 Apr 2011 07:51:11 +0200 |
parents | f8f865c70a0d |
children | 5f2fe81fde9f |
comparison
equal
deleted
inserted
replaced
285:8874b6cd8f36 | 286:5351d47ee28a |
---|---|
1011 call word_processor | 1011 call word_processor |
1012 return | 1012 return |
1013 | 1013 |
1014 ;============================================================================= | 1014 ;============================================================================= |
1015 gassetup_sort_gaslist: ; Sorts Gaslist according to change depth | 1015 gassetup_sort_gaslist: ; Sorts Gaslist according to change depth |
1016 return ; No sort test | 1016 clrf sorted_gaslist_active ; Clear all flags |
1017 | |
1018 read_int_eeprom d'33' ; Get First gas (1-5) | |
1019 movff EEDATA,lo | |
1020 bsf STATUS,C | |
1021 gassetup_sort_gaslist2: | |
1022 rlcf sorted_gaslist_active,F ; Shift flag for first gas | |
1023 decfsz lo,F | |
1024 bra gassetup_sort_gaslist2 | |
1025 | |
1026 read_int_eeprom d'28' ; Change Depth Gas1 | |
1027 tstfsz EEDATA ; =0? | |
1028 bsf sorted_gaslist_active,0 ; No, set active | |
1029 | |
1030 read_int_eeprom d'29' ; Change Depth Gas2 | |
1031 tstfsz EEDATA ; =0? | |
1032 bsf sorted_gaslist_active,1; No, set active | |
1033 | |
1034 read_int_eeprom d'30' ; Change Depth Gas3 | |
1035 tstfsz EEDATA ; =0? | |
1036 bsf sorted_gaslist_active,2 ; No, set active | |
1037 | |
1038 read_int_eeprom d'31' ; Change Depth Gas4 | |
1039 tstfsz EEDATA ; =0? | |
1040 bsf sorted_gaslist_active,3 ; No, set active | |
1041 | |
1042 read_int_eeprom d'32' ; Change Depth Gas5 | |
1043 tstfsz EEDATA ; =0? | |
1044 bsf sorted_gaslist_active,4 ; No, set active | |
1045 | |
1046 movff sorted_gaslist_active,EEDATA | |
1047 clrf EEADRH | |
1048 write_int_eeprom d'27' ; Store results | |
1049 return | |
1017 | 1050 |
1018 | 1051 |
1019 ; EEPROM Locations of Gaslist | 1052 ; EEPROM Locations of Gaslist |
1020 ; Gas1: | 1053 ; Gas1: |
1021 ; O2 Default:4 | 1054 ; O2 Default:4 |
1054 ; He Default:21 | 1087 ; He Default:21 |
1055 ; O2 Current:22 | 1088 ; O2 Current:22 |
1056 ; He Current:23 | 1089 ; He Current:23 |
1057 ; Change: 32 | 1090 ; Change: 32 |
1058 ; Active: 27,4 | 1091 ; Active: 27,4 |
1059 | |
1060 ; reset Change depths (Important for all users who upgrade from <1.60!) | |
1061 clrf EEADRH | |
1062 clrf EEDATA | |
1063 write_int_eeprom d'118' ; | |
1064 write_int_eeprom d'119' ; | |
1065 write_int_eeprom d'120' ; | |
1066 write_int_eeprom d'121' ; | |
1067 write_int_eeprom d'122' ; | |
1068 movlw d'21' ; O2 Current | |
1069 movwf EEDATA | |
1070 write_int_eeprom d'96' ; | |
1071 write_int_eeprom d'100' ; | |
1072 write_int_eeprom d'104' ; | |
1073 write_int_eeprom d'108' ; | |
1074 write_int_eeprom d'112' ; | |
1075 | |
1076 clrf EEDATA ; He Current | |
1077 write_int_eeprom d'97' ; | |
1078 write_int_eeprom d'101' ; | |
1079 write_int_eeprom d'105' ; | |
1080 write_int_eeprom d'109' ; | |
1081 write_int_eeprom d'113' ; | |
1082 | |
1083 ; Find deepest Gas | |
1084 ; Copy all to RAM | |
1085 movlw d'3' | |
1086 movwf EEADR | |
1087 clrf EEADRH | |
1088 lfsr FSR2,letter ; Store gases in Letter buffer (max. 26Byte!) | |
1089 gassetup_sort_gaslist1: | |
1090 incf EEADR,F ; Next Adress | |
1091 call read_eeprom ; Read byte | |
1092 movff EEDATA,POSTINC2 ; Copy into RAM | |
1093 movlw d'23' | |
1094 cpfseq EEADR ; All done? | |
1095 bra gassetup_sort_gaslist1 ; No, not yet | |
1096 ; Letter+0 = EEPROM 4 | |
1097 ; ... | |
1098 ; Letter+19 = EEPROM 23 | |
1099 read_int_eeprom d'28' | |
1100 movff EEDATA,POSTINC2 ; Change Depth Gas1 -> Letter+20 | |
1101 read_int_eeprom d'29' | |
1102 movff EEDATA,POSTINC2 ; Change Depth Gas2 -> Letter+21 | |
1103 read_int_eeprom d'30' | |
1104 movff EEDATA,POSTINC2 ; Change Depth Gas3 -> Letter+22 | |
1105 read_int_eeprom d'31' | |
1106 movff EEDATA,POSTINC2 ; Change Depth Gas4 -> Letter+23 | |
1107 read_int_eeprom d'32' | |
1108 movff EEDATA,POSTINC2 ; Change Depth Gas5 -> Letter+24 | |
1109 read_int_eeprom d'27' | |
1110 movff EEDATA,POSTINC2 ; Active Byte -> Letter+25 | |
1111 | |
1112 ; All change depths = 0? -> Skip sort! | |
1113 lfsr FSR2,letter+.20 ; Change depths... | |
1114 movlw d'5' | |
1115 movwf logbook_temp3 ; Gas (0-4) | |
1116 clrf logbook_temp1 ; counter | |
1117 gassetup_sort_gaslist1a: | |
1118 movf POSTINC2,W | |
1119 addwf logbook_temp1,F ; sum | |
1120 decfsz logbook_temp3,F ; Loop | |
1121 bra gassetup_sort_gaslist1a | |
1122 | |
1123 tstfsz logbook_temp1 ; All depths = 0? | |
1124 bra gassetup_sort_gaslist1b ; No | |
1125 return ; Yes, skip all! | |
1126 | |
1127 gassetup_sort_gaslist1b: | |
1128 ; Initialize sorting... | |
1129 bcf menubit2 ; Change Start gas only 1x | |
1130 movlw d'99' | |
1131 movwf logbook_temp4 ; Last Gas change depth | |
1132 | |
1133 movff letter+.25, logbook_temp5 ; Activity flags | |
1134 | |
1135 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 5 | |
1136 rcall gassetup_sort_sort ; Sort! | |
1137 movlw d'5' ; Gas 5 | |
1138 movwf logbook_temp2 | |
1139 rcall gassetup_sort_store | |
1140 | |
1141 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 4 | |
1142 rcall gassetup_sort_sort ; Sort! | |
1143 movlw d'4' ; Gas 4 | |
1144 movwf logbook_temp2 | |
1145 rcall gassetup_sort_store | |
1146 | |
1147 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 3 | |
1148 rcall gassetup_sort_sort ; Sort! | |
1149 movlw d'3' ; Gas 3 | |
1150 movwf logbook_temp2 | |
1151 rcall gassetup_sort_store | |
1152 | |
1153 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 2 | |
1154 rcall gassetup_sort_sort ; Sort! | |
1155 movlw d'2' ; Gas 2 | |
1156 movwf logbook_temp2 | |
1157 rcall gassetup_sort_store | |
1158 | |
1159 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 1 | |
1160 rcall gassetup_sort_sort ; Sort! | |
1161 movlw d'1' ; Gas 1 | |
1162 movwf logbook_temp2 | |
1163 bra gassetup_sort_store | |
1164 | |
1165 ;----------------------------------------------------------------------------- | |
1166 gassetup_sort_sort: | |
1167 clrf logbook_temp2 ; Tested gas (0-4) | |
1168 clrf logbook_temp1 ; Found change depth in m | |
1169 clrf logbook_temp3 ; Found gas (0-4) | |
1170 ; movff letter+.25, logbook_temp5 ; Activity flags | |
1171 | |
1172 lfsr FSR2,letter+.20 ; Change depths Gas1 | |
1173 gassetup_sort_gaslist2: | |
1174 movf POSTINC2,W ; Get Change depth into WREG | |
1175 | |
1176 cpfsgt logbook_temp4 ; logbook_temp4 < W? Here: Change depth of last sort run | |
1177 bra gassetup_sort_gaslist3 ; Skip, tested depth > max. Depth from last run | |
1178 cpfslt logbook_temp1 ; logbook_temp1 < W? | |
1179 bra gassetup_sort_gaslist3 ; Skip, tested depth < max. Depth from this run | |
1180 | |
1181 ; Is gas active? | |
1182 ; Should not select inactive gas, because we might have several | |
1183 ; gas with the same depth, some active, some not... | |
1184 | |
1185 rrcf logbook_temp5,F ; Shift into Carry bit | |
1186 btfss STATUS,C ; Was Gas active? | |
1187 bra gassetup_sort_gaslist3 ; No: Skip. | |
1188 | |
1189 movwf logbook_temp1 ; copy new depth (current run) | |
1190 movff logbook_temp2,logbook_temp3 ; Holds deepest Gas 0-4 of this pass | |
1191 | |
1192 gassetup_sort_gaslist3: | |
1193 incf logbook_temp2,F ; Check next Gas | |
1194 movlw d'5' | |
1195 cpfseq logbook_temp2 ; All done? | |
1196 bra gassetup_sort_gaslist2 ; No | |
1197 | |
1198 ; Done: | |
1199 movff logbook_temp1,logbook_temp4 ; copy new depth (Store for next run) | |
1200 | |
1201 ; Debugger | |
1202 ; movff logbook_temp2,TXREG | |
1203 ; call rs232_wait_tx ; wait for UART | |
1204 ; movff logbook_temp3,TXREG | |
1205 ; call rs232_wait_tx ; wait for UART | |
1206 ; movff logbook_temp4,TXREG | |
1207 ; call rs232_wait_tx ; wait for UART | |
1208 ; movff logbook_temp5,TXREG | |
1209 ; call rs232_wait_tx ; wait for UART | |
1210 ; WAITMS d'255' | |
1211 return | |
1212 | |
1213 gassetup_sort_store: | |
1214 lfsr FSR2,letter ; Point to Gas0 | |
1215 movf logbook_temp3,W ; 0..4 | |
1216 mullw d'4' | |
1217 movf PRODL,W ; letter+(0..4)x4 | |
1218 addwf FSR2L,F | |
1219 movlw d'0' | |
1220 addwfc FSR2H,F ; Point to Gas #logbook_temp3 (0-4) | |
1221 | |
1222 ; btfsc menubit2 ; Change Start gas only 1x | |
1223 ; bra gassetup_sort_store2 ; Skip | |
1224 ;; First Gas: 33 (1-5) | |
1225 ;; Was gas #logbook_temp3 first gas? | |
1226 ; read_int_eeprom d'33' ; Get old first gas (1-5) | |
1227 ; incf logbook_temp3,W ; Gas 1-5 -> WREG | |
1228 ; cpfseq EEDATA ; Compare with EEDATA d'33' | |
1229 ; bra gassetup_sort_store2 ; Was not first gas! | |
1230 ; movff logbook_temp5,EEDATA ; Copy new first gas | |
1231 ; write_int_eeprom d'123' ; Store | |
1232 ; bsf menubit2 ; Done. Do not change again. | |
1233 | |
1234 gassetup_sort_store2: | |
1235 ;call enable_rs232 | |
1236 ;movff logbook_temp1,TXREG | |
1237 ;call rs232_wait_tx ; wait for UART | |
1238 | |
1239 movf logbook_temp2,W ; Destination slot : 1-5 | |
1240 mullw d'4' | |
1241 movff PRODL,EEADR ; Point to EEPROM of Gas #logbook_temp5 | |
1242 movlw d'90' ; +90 Offset to new... | |
1243 addwf EEADR,F ; ..sorted list! | |
1244 | |
1245 movff POSTINC2,EEDATA ; O2 Default | |
1246 call write_eeprom ; store in internal EEPROM | |
1247 incf EEADR,F ; +1 | |
1248 movff POSTINC2,EEDATA ; He Default | |
1249 call write_eeprom ; store in internal EEPROM | |
1250 incf EEADR,F ; +1 | |
1251 movff POSTINC2,EEDATA ; O2 Current | |
1252 call write_eeprom ; store in internal EEPROM | |
1253 incf EEADR,F ; +1 | |
1254 movff POSTINC2,EEDATA ; He Current | |
1255 call write_eeprom ; store in internal EEPROM | |
1256 | |
1257 movf logbook_temp2,W ; Destination slot : 1-5 | |
1258 addlw d'117' | |
1259 movwf EEADR | |
1260 movff logbook_temp1,EEDATA ; Change depth -> EEDATA | |
1261 call write_eeprom ; store in internal EEPROM | |
1262 | |
1263 return |