comparison code_part1/OSTC_code_asm_part1/menu_gassetup.asm @ 36:3c38ba950dfb

Gas Setup now sorts Gases for new Deco code
author heinrichsweikamp
date Sun, 30 May 2010 11:44:03 +0200
parents d4f0c097a7fa
children 3ab1188651af
comparison
equal deleted inserted replaced
35:d4f0c097a7fa 36:3c38ba950dfb
26 menu_gassetup: 26 menu_gassetup:
27 movlw d'1' 27 movlw d'1'
28 movwf menupos 28 movwf menupos
29 29
30 menu_gassetup_prelist: 30 menu_gassetup_prelist:
31 call PLED_ClearScreen
31 call gassetup_sort_gaslist ; Sorts Gaslist according to change depth 32 call gassetup_sort_gaslist ; Sorts Gaslist according to change depth
32
33 call PLED_ClearScreen
34 clrf timeout_counter2 33 clrf timeout_counter2
35 bcf sleepmode 34 bcf sleepmode
36 bcf menubit2 35 bcf menubit2
37 bcf menubit3 36 bcf menubit3
38 call PLED_topline_box 37 call PLED_topline_box
1160 ; O2 Current:22 1159 ; O2 Current:22
1161 ; He Current:23 1160 ; He Current:23
1162 ; Change: 32 1161 ; Change: 32
1163 ; Active: 27,4 1162 ; Active: 27,4
1164 1163
1164 ; Find deepest Gas
1165
1166 ; Copy all to RAM
1167 movlw d'3'
1168 movwf EEADR
1169 clrf EEADRH
1170 lfsr FSR2,letter ; Store gases in Letter buffer (max. 26Byte!)
1171 gassetup_sort_gaslist1:
1172 incf EEADR,F ; Next Adress
1173 call read_eeprom ; Read byte
1174 movff EEDATA,POSTINC2 ; Copy into RAM
1175 movlw d'23'
1176 cpfseq EEADR ; All done?
1177 bra gassetup_sort_gaslist1 ; No, not yet
1178 ; Letter+0 = EEPROM 4
1179 ; ...
1180 ; Letter+20 = EEPROM 23
1181 read_int_eeprom d'28'
1182 movff EEDATA,POSTINC2 ; Change Depth Gas1 -> Letter+21
1183 read_int_eeprom d'29'
1184 movff EEDATA,POSTINC2 ; Change Depth Gas2 -> Letter+22
1185 read_int_eeprom d'30'
1186 movff EEDATA,POSTINC2 ; Change Depth Gas3 -> Letter+23
1187 read_int_eeprom d'31'
1188 movff EEDATA,POSTINC2 ; Change Depth Gas4 -> Letter+24
1189 read_int_eeprom d'32'
1190 movff EEDATA,POSTINC2 ; Change Depth Gas5 -> Letter+25
1191 read_int_eeprom d'27'
1192 movff EEDATA,POSTINC2 ; Active Byte -> Letter+26
1193
1194 ; All change depths = 0? -> Skip sort!
1195 lfsr FSR2,letter+.20 ; Change depths...
1196 movlw d'5'
1197 movwf logbook_temp3 ; Gas (0-4)
1198 clrf logbook_temp1 ; counter
1199 gassetup_sort_gaslist1a:
1200 movf POSTINC2,W
1201 addwf logbook_temp1,F ; sum
1202 decfsz logbook_temp3,F ; Loop
1203 bra gassetup_sort_gaslist1a
1204
1205 tstfsz logbook_temp1 ; All depths = 0?
1206 bra gassetup_sort_gaslist1b ; No
1207 return ; Yes, skip all!
1208
1209 gassetup_sort_gaslist1b:
1210 ; Initialize sorting...
1211 bcf menubit2 ; Change Start gas only 1x
1212 movlw d'99'
1213 movwf logbook_temp4 ; Last Gas change depth
1214
1215 rcall gassetup_sort_sort ; Sort!
1216 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 5
1217 movlw d'5' ; Gas 5
1218 movwf logbook_temp5
1219 rcall gassetup_sort_store
1220 movff logbook_temp1,EEDATA ; Change depth -> EEDATA
1221 write_int_eeprom d'32' ; Write Change Depth Gas 5
1222
1223 rcall gassetup_sort_sort ; Sort!
1224 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 4
1225 movlw d'4' ; Gas 4
1226 movwf logbook_temp5
1227 rcall gassetup_sort_store
1228 movff logbook_temp1,EEDATA ; Change depth -> EEDATA
1229 write_int_eeprom d'31' ; Write Change Depth Gas 4
1230
1231 rcall gassetup_sort_sort ; Sort!
1232 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 3
1233 movlw d'3' ; Gas 3
1234 movwf logbook_temp5
1235 rcall gassetup_sort_store
1236 movff logbook_temp1,EEDATA ; Change depth -> EEDATA
1237 write_int_eeprom d'30' ; Write Change Depth Gas 3
1238
1239 rcall gassetup_sort_sort ; Sort!
1240 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 2
1241 movlw d'2' ; Gas 2
1242 movwf logbook_temp5
1243 rcall gassetup_sort_store
1244 movff logbook_temp1,EEDATA ; Change depth -> EEDATA
1245 write_int_eeprom d'29' ; Write Change Depth Gas 2
1246
1247 rcall gassetup_sort_sort ; Sort!
1248 ; Done. Copy Gas #logbook_temp3 into EEPROM Place Gas 1
1249 movlw d'1' ; Gas 1
1250 movwf logbook_temp5
1251 rcall gassetup_sort_store
1252 movff logbook_temp1,EEDATA ; Change depth -> EEDATA
1253 write_int_eeprom d'28' ; Write Change Depth Gas 1
1254 return
1255
1256 gassetup_sort_sort:
1257 clrf logbook_temp2 ; Gas (0-4)
1258 clrf logbook_temp1 ; Here: Change depth in m
1259 clrf logbook_temp3 ; Gas (0-4)
1260
1261 lfsr FSR2,letter+.20 ; Change depths...
1262 gassetup_sort_gaslist2:
1263 movf POSTINC2,W ; Get Change depth into WREG
1264
1265 cpfsgt logbook_temp4 ; logbook_temp4 < W? Here: Change depth of last sort run
1266 bra gassetup_sort_gaslist3 ; Skip, tested depth > max. Depth from last run
1267
1268 cpfslt logbook_temp1 ; logbook_temp1 < W?
1269 bra gassetup_sort_gaslist3 ; Skip, tested depth < max. Depth from this run
1270
1271 movwf logbook_temp1 ; copy new depth (current run)
1272 movff logbook_temp2,logbook_temp3 ; Holds deepest Gas 0-4 of this run
1273 gassetup_sort_gaslist3:
1274 incf logbook_temp2,F ; Check next Gas
1275 movlw d'5'
1276 cpfseq logbook_temp2 ; All done?
1277 bra gassetup_sort_gaslist2 ; No
1278 gassetup_sort_gaslist4:
1279 movff logbook_temp1,logbook_temp4 ; copy new depth (Store for next run)
1280
1281 ; Debugger
1282 ;call enable_rs232
1283 ; movff logbook_temp1,TXREG
1284 ; call rs232_wait_tx ; wait for UART
1285 ; movff logbook_temp2,TXREG
1286 ; call rs232_wait_tx ; wait for UART
1287 ; movff logbook_temp3,TXREG
1288 ; call rs232_wait_tx ; wait for UART
1289 ; movff logbook_temp4,TXREG
1290 ; call rs232_wait_tx ; wait for UART
1291 ; movff logbook_temp5,TXREG
1292 ; call rs232_wait_tx ; wait for UART
1293 ; WAITMS d'255'
1294 return
1295
1296 gassetup_sort_store:
1297 lfsr FSR2,letter ; Point to Gas0
1298 movf logbook_temp3,W
1299 mullw d'4'
1300 movf PRODL,W ; x4
1301 addwf FSR2L,F
1302 movlw d'0'
1303 addwfc FSR2H,F ; Point to Gas #logbook_temp3 (0-4)
1304
1305 btfsc menubit2 ; Change Start gas only 1x
1306 bra gassetup_sort_store2 ; Skip
1165 ; First Gas: 33 (1-5) 1307 ; First Gas: 33 (1-5)
1166 1308 ; Was gas #logbook_temp3 first gas?
1309 read_int_eeprom d'33' ; Get old first gas (1-5)
1310 incf logbook_temp3,W ; Gas 1-5 -> WREG
1311 cpfseq EEDATA ; Compare with EEDATA d'33'
1312 bra gassetup_sort_store2 ; Was not first gas!
1313 movff logbook_temp5,EEDATA ; Copy new first gas
1314 write_int_eeprom d'33' ; Store
1315 bsf menubit2 ; Done. Do change again.
1316
1317 gassetup_sort_store2:
1318 ;; Was Gas #logbook_temp3 active?
1319 ;; Letter+26 holds active bits 25?
1320 ; movff logbook_temp3,logbook_temp6 ; Counter 0-4
1321 ; incf logbook_temp6,F ; Counter 1-5
1322 ; movff letter+.25, logbook_temp2 ; No longer used
1323 ; read_int_eeprom d'27' ; Active flag register
1324 ;gassetup_sort_store3:
1325 ; rrcf logbook_temp2,F ; Shift into Carry
1326 ; decfsz logbook_temp6,F ; 1-5 x
1327 ; bra gassetup_sort_store3 ; Loop
1328 ;; Carry now holds active bit of gas #logbook_temp3 (0-4)
1329 ;
1330 ; movff logbook_temp3,logbook_temp6 ; Counter 0-4
1331 ; incf logbook_temp6,F ; Counter 1-5
1332 ; clrf logbook_temp2
1333 ;gassetup_sort_store4:
1334 ; rlcf logbook_temp2,F ; Shift into logbook_temp2
1335 ; decfsz logbook_temp6,F ; 1-5 x
1336 ; bra gassetup_sort_store4 ; Loop
1337 ; movf logbook_temp2
1338 ;
1339
1340 movf logbook_temp5,W
1341 mullw d'4'
1342 movff PRODL,EEADR ; Point to EEPROM of Gas #logbook_temp5
1343 movff POSTINC2,EEDATA ; O2 Default
1344 call write_eeprom ; store in internal EEPROM
1345 incf EEADR,F ; +1
1346 movff POSTINC2,EEDATA ; He Default
1347 call write_eeprom ; store in internal EEPROM
1348 incf EEADR,F ; +1
1349 movff POSTINC2,EEDATA ; O2 Current
1350 call write_eeprom ; store in internal EEPROM
1351 incf EEADR,F ; +1
1352 movff POSTINC2,EEDATA ; He Current
1353 call write_eeprom ; store in internal EEPROM
1167 return 1354 return