comparison code_part1/OSTC_code_asm_part1/menu_gassetup.asm @ 227:8dbcc26878d3

BUGFIX sorting gaslist. When two gas have the same depth and the first one is not active: don't skip the second one.
author JeanDo
date Fri, 04 Mar 2011 02:35:21 +0100
parents f5e9db793dd3
children 9657a7bcc7e1
comparison
equal deleted inserted replaced
226:24cd6e256d61 227:8dbcc26878d3
1009 output_16dp d'3' 1009 output_16dp d'3'
1010 OUTPUTTEXT d'150' ; Bar: 1010 OUTPUTTEXT d'150' ; Bar:
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 ; EEPROM Locations of Gaslist 1016 ; EEPROM Locations of Gaslist
1017 ; Gas1: 1017 ; Gas1:
1018 ; O2 Default:4 1018 ; O2 Default:4
1019 ; He Default:5 1019 ; He Default:5
1090 movlw d'23' 1090 movlw d'23'
1091 cpfseq EEADR ; All done? 1091 cpfseq EEADR ; All done?
1092 bra gassetup_sort_gaslist1 ; No, not yet 1092 bra gassetup_sort_gaslist1 ; No, not yet
1093 ; Letter+0 = EEPROM 4 1093 ; Letter+0 = EEPROM 4
1094 ; ... 1094 ; ...
1095 ; Letter+20 = EEPROM 23 1095 ; Letter+19 = EEPROM 23
1096 read_int_eeprom d'28' 1096 read_int_eeprom d'28'
1097 movff EEDATA,POSTINC2 ; Change Depth Gas1 -> Letter+21 1097 movff EEDATA,POSTINC2 ; Change Depth Gas1 -> Letter+20
1098 read_int_eeprom d'29' 1098 read_int_eeprom d'29'
1099 movff EEDATA,POSTINC2 ; Change Depth Gas2 -> Letter+22 1099 movff EEDATA,POSTINC2 ; Change Depth Gas2 -> Letter+21
1100 read_int_eeprom d'30' 1100 read_int_eeprom d'30'
1101 movff EEDATA,POSTINC2 ; Change Depth Gas3 -> Letter+23 1101 movff EEDATA,POSTINC2 ; Change Depth Gas3 -> Letter+22
1102 read_int_eeprom d'31' 1102 read_int_eeprom d'31'
1103 movff EEDATA,POSTINC2 ; Change Depth Gas4 -> Letter+24 1103 movff EEDATA,POSTINC2 ; Change Depth Gas4 -> Letter+23
1104 read_int_eeprom d'32' 1104 read_int_eeprom d'32'
1105 movff EEDATA,POSTINC2 ; Change Depth Gas5 -> Letter+25 1105 movff EEDATA,POSTINC2 ; Change Depth Gas5 -> Letter+24
1106 read_int_eeprom d'27' 1106 read_int_eeprom d'27'
1107 movff EEDATA,POSTINC2 ; Active Byte -> Letter+26 1107 movff EEDATA,POSTINC2 ; Active Byte -> Letter+25
1108 1108
1109 ; All change depths = 0? -> Skip sort! 1109 ; All change depths = 0? -> Skip sort!
1110 lfsr FSR2,letter+.20 ; Change depths... 1110 lfsr FSR2,letter+.20 ; Change depths...
1111 movlw d'5' 1111 movlw d'5'
1112 movwf logbook_temp3 ; Gas (0-4) 1112 movwf logbook_temp3 ; Gas (0-4)
1125 ; Initialize sorting... 1125 ; Initialize sorting...
1126 bcf menubit2 ; Change Start gas only 1x 1126 bcf menubit2 ; Change Start gas only 1x
1127 movlw d'99' 1127 movlw d'99'
1128 movwf logbook_temp4 ; Last Gas change depth 1128 movwf logbook_temp4 ; Last Gas change depth
1129 1129
1130 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 5
1130 rcall gassetup_sort_sort ; Sort! 1131 rcall gassetup_sort_sort ; Sort!
1131 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 5
1132 movlw d'5' ; Gas 5 1132 movlw d'5' ; Gas 5
1133 movwf logbook_temp5 1133 movwf logbook_temp5
1134 rcall gassetup_sort_store 1134 rcall gassetup_sort_store
1135 movff logbook_temp1,EEDATA ; Change depth -> EEDATA 1135
1136 write_int_eeprom d'122' ; Write Change Depth Gas 5 1136 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 4
1137
1138 rcall gassetup_sort_sort ; Sort! 1137 rcall gassetup_sort_sort ; Sort!
1139 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 4
1140 movlw d'4' ; Gas 4 1138 movlw d'4' ; Gas 4
1141 movwf logbook_temp5 1139 movwf logbook_temp5
1142 rcall gassetup_sort_store 1140 rcall gassetup_sort_store
1143 movff logbook_temp1,EEDATA ; Change depth -> EEDATA 1141
1144 write_int_eeprom d'121' ; Write Change Depth Gas 4 1142 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 3
1145
1146 rcall gassetup_sort_sort ; Sort! 1143 rcall gassetup_sort_sort ; Sort!
1147 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 3
1148 movlw d'3' ; Gas 3 1144 movlw d'3' ; Gas 3
1149 movwf logbook_temp5 1145 movwf logbook_temp5
1150 rcall gassetup_sort_store 1146 rcall gassetup_sort_store
1151 movff logbook_temp1,EEDATA ; Change depth -> EEDATA 1147
1152 write_int_eeprom d'120' ; Write Change Depth Gas 3 1148 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 2
1153
1154 rcall gassetup_sort_sort ; Sort! 1149 rcall gassetup_sort_sort ; Sort!
1155 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 2
1156 movlw d'2' ; Gas 2 1150 movlw d'2' ; Gas 2
1157 movwf logbook_temp5 1151 movwf logbook_temp5
1158 rcall gassetup_sort_store 1152 rcall gassetup_sort_store
1159 movff logbook_temp1,EEDATA ; Change depth -> EEDATA 1153
1160 write_int_eeprom d'119' ; Write Change Depth Gas 2 1154 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 1
1161
1162 rcall gassetup_sort_sort ; Sort! 1155 rcall gassetup_sort_sort ; Sort!
1163 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 1
1164 movlw d'1' ; Gas 1 1156 movlw d'1' ; Gas 1
1165 movwf logbook_temp5 1157 movwf logbook_temp5
1166 rcall gassetup_sort_store 1158 bra gassetup_sort_store
1167 movff logbook_temp1,EEDATA ; Change depth -> EEDATA 1159
1168 write_int_eeprom d'118' ; Write Change Depth Gas 1 1160 ;-----------------------------------------------------------------------------
1169 return
1170
1171 gassetup_sort_sort: 1161 gassetup_sort_sort:
1172 clrf logbook_temp2 ; Gas (0-4) 1162 clrf logbook_temp2 ; Tested gas (0-4)
1173 clrf logbook_temp1 ; Here: Change depth in m 1163 clrf logbook_temp1 ; Found change depth in m
1174 clrf logbook_temp3 ; Gas (0-4) 1164 clrf logbook_temp3 ; Found gas (0-4)
1175 1165 movff letter+.25, logbook_temp5 ; Activity flags
1176 lfsr FSR2,letter+.20 ; Change depths... 1166
1167 lfsr FSR2,letter+.20 ; Change depths Gas1
1177 gassetup_sort_gaslist2: 1168 gassetup_sort_gaslist2:
1178 movf POSTINC2,W ; Get Change depth into WREG 1169 movf POSTINC2,W ; Get Change depth into WREG
1179 1170
1180 cpfsgt logbook_temp4 ; logbook_temp4 < W? Here: Change depth of last sort run 1171 cpfsgt logbook_temp4 ; logbook_temp4 < W? Here: Change depth of last sort run
1181 bra gassetup_sort_gaslist3 ; Skip, tested depth > max. Depth from last run 1172 bra gassetup_sort_gaslist3 ; Skip, tested depth > max. Depth from last run
1182 1173 cpfslt logbook_temp1 ; logbook_temp1 < W?
1183 cpfslt logbook_temp1 ; logbook_temp1 < W? 1174 bra gassetup_sort_gaslist3 ; Skip, tested depth < max. Depth from this run
1184 bra gassetup_sort_gaslist3 ; Skip, tested depth < max. Depth from this run 1175
1185 1176 ; Is gas active?
1186 movwf logbook_temp1 ; copy new depth (current run) 1177 ; Should not select inactive gas, because we might have several
1187 movff logbook_temp2,logbook_temp3 ; Holds deepest Gas 0-4 of this run 1178 ; gas with the same depth, some active, some not...
1179 rrcf logbook_temp5,F ; Shift into Carry bit
1180 btfss STATUS,C ; Was Gas active?
1181 bra gassetup_sort_gaslist3 ; No: Skip.
1182
1183 movwf logbook_temp1 ; copy new depth (current run)
1184 movff logbook_temp2,logbook_temp3 ; Holds deepest Gas 0-4 of this pass
1185
1188 gassetup_sort_gaslist3: 1186 gassetup_sort_gaslist3:
1189 incf logbook_temp2,F ; Check next Gas 1187 incf logbook_temp2,F ; Check next Gas
1190 movlw d'5' 1188 movlw d'5'
1191 cpfseq logbook_temp2 ; All done? 1189 cpfseq logbook_temp2 ; All done?
1192 bra gassetup_sort_gaslist2 ; No 1190 bra gassetup_sort_gaslist2 ; No
1193 gassetup_sort_gaslist4: 1191
1194 movff logbook_temp1,logbook_temp4 ; copy new depth (Store for next run) 1192 ; Done:
1193 movff logbook_temp1,logbook_temp4 ; copy new depth (Store for next run)
1195 1194
1196 ; Debugger 1195 ; Debugger
1197 ;call enable_rs232 1196 ;call enable_rs232
1198 ; movff logbook_temp1,TXREG 1197 ; movff logbook_temp1,TXREG
1199 ; call rs232_wait_tx ; wait for UART 1198 ; call rs232_wait_tx ; wait for UART
1208 ; WAITMS d'255' 1207 ; WAITMS d'255'
1209 return 1208 return
1210 1209
1211 gassetup_sort_store: 1210 gassetup_sort_store:
1212 lfsr FSR2,letter ; Point to Gas0 1211 lfsr FSR2,letter ; Point to Gas0
1213 movf logbook_temp3,W 1212 movf logbook_temp3,W ; 0..4
1214 mullw d'4' 1213 mullw d'4'
1215 movf PRODL,W ; x4 1214 movf PRODL,W ; letter+(0..4)x4
1216 addwf FSR2L,F 1215 addwf FSR2L,F
1217 movlw d'0' 1216 movlw d'0'
1218 addwfc FSR2H,F ; Point to Gas #logbook_temp3 (0-4) 1217 addwfc FSR2H,F ; Point to Gas #logbook_temp3 (0-4)
1219 1218
1220 ; btfsc menubit2 ; Change Start gas only 1x 1219 ; btfsc menubit2 ; Change Start gas only 1x
1228 ; movff logbook_temp5,EEDATA ; Copy new first gas 1227 ; movff logbook_temp5,EEDATA ; Copy new first gas
1229 ; write_int_eeprom d'123' ; Store 1228 ; write_int_eeprom d'123' ; Store
1230 ; bsf menubit2 ; Done. Do not change again. 1229 ; bsf menubit2 ; Done. Do not change again.
1231 1230
1232 gassetup_sort_store2: 1231 gassetup_sort_store2:
1233 ; Was Gas #logbook_temp3 active?
1234 ; Letter+26 holds active bits 25?
1235 movff logbook_temp3,logbook_temp6 ; Counter 0-4
1236 incf logbook_temp6,F ; Counter 1-5
1237 movff letter+.25, logbook_temp2 ; No longer used
1238 read_int_eeprom d'27' ; Active flag register
1239 gassetup_sort_store3:
1240 rrcf logbook_temp2,F ; Shift into Carry
1241 decfsz logbook_temp6,F ; 1-5 x
1242 bra gassetup_sort_store3 ; Loop
1243 ; Carry now holds active bit of gas #logbook_temp3 (0-4)
1244
1245 btfss STATUS,C ; Was Gas active?
1246 clrf logbook_temp1 ; No!, Clear change Depth to make it inactive for sorted list!
1247
1248 ;call enable_rs232 1232 ;call enable_rs232
1249 ;movff logbook_temp1,TXREG 1233 ;movff logbook_temp1,TXREG
1250 ;call rs232_wait_tx ; wait for UART 1234 ;call rs232_wait_tx ; wait for UART
1251 1235
1252 movf logbook_temp5,W ; 1-5 1236 movf logbook_temp5,W ; Destination slot : 1-5
1253 mullw d'4' 1237 mullw d'4'
1254 movff PRODL,EEADR ; Point to EEPROM of Gas #logbook_temp5 1238 movff PRODL,EEADR ; Point to EEPROM of Gas #logbook_temp5
1255 movlw d'90' ; +90 Offset to new... 1239 movlw d'90' ; +90 Offset to new...
1256 addwf EEADR,F ; ..sorted list! 1240 addwf EEADR,F ; ..sorted list!
1257 1241
1258 movff POSTINC2,EEDATA ; O2 Default 1242 movff POSTINC2,EEDATA ; O2 Default
1259 call write_eeprom ; store in internal EEPROM 1243 call write_eeprom ; store in internal EEPROM
1260 incf EEADR,F ; +1 1244 incf EEADR,F ; +1
1261 movff POSTINC2,EEDATA ; He Default 1245 movff POSTINC2,EEDATA ; He Default
1264 movff POSTINC2,EEDATA ; O2 Current 1248 movff POSTINC2,EEDATA ; O2 Current
1265 call write_eeprom ; store in internal EEPROM 1249 call write_eeprom ; store in internal EEPROM
1266 incf EEADR,F ; +1 1250 incf EEADR,F ; +1
1267 movff POSTINC2,EEDATA ; He Current 1251 movff POSTINC2,EEDATA ; He Current
1268 call write_eeprom ; store in internal EEPROM 1252 call write_eeprom ; store in internal EEPROM
1253
1254 movf logbook_temp5,W ; Destination slot : 1-5
1255 addlw d'117'
1256 movwf EEADR
1257 movff logbook_temp1,EEDATA ; Change depth -> EEDATA
1258 call write_eeprom ; store in internal EEPROM
1259
1269 return 1260 return