comparison code_part1/OSTC_code_asm_part1/simulator.asm @ 369:93c0cb14b0d2

Dive interval function * Adding interval menu
author JeanDo
date Fri, 10 Jun 2011 01:14:38 +0200
parents 797e2ac42d24
children 61742b3ef842
comparison
equal deleted inserted replaced
368:de3b267e1fd9 369:93c0cb14b0d2
23 ; known bugs: 23 ; known bugs:
24 ; ToDo: 24 ; ToDo:
25 25
26 menu_simulator: 26 menu_simulator:
27 movlw d'1' 27 movlw d'1'
28 movwf logbook_temp1 ; Bottom time 28 movwf logbook_temp1 ; Bottom time
29 movlw d'15' 29 movlw d'15'
30 movwf logbook_temp2 ; Max. Depth 30 movwf logbook_temp2 ; Max. Depth
31 movlw d'1' 31 movlw d'1'
32 movwf menupos 32 movwf menupos
33 clrf WREG ; Interval
34 movff WREG,char_I_dive_interval
33 35
34 menu_simulator1: 36 menu_simulator1:
35 clrf timeout_counter2 37 clrf timeout_counter2
36 bsf menubit 38 bsf menubit
37 bsf cursor 39 bsf cursor
74 goto restart ; exit menu, restart and enter divemode 76 goto restart ; exit menu, restart and enter divemode
75 77
76 bra menu_simulator_loop 78 bra menu_simulator_loop
77 79
78 menu_simulator_do: ; calls submenu 80 menu_simulator_do: ; calls submenu
81 dcfsnz menupos,F
82 bra simulator_inc_interval
79 dcfsnz menupos,F 83 dcfsnz menupos,F
80 bra simulator_startdive 84 bra simulator_startdive
81 dcfsnz menupos,F 85 dcfsnz menupos,F
82 bra simulator_inc_bottomtime 86 bra simulator_inc_bottomtime
83 dcfsnz menupos,F 87 dcfsnz menupos,F
84 bra simulator_inc_maxdepth 88 bra simulator_inc_maxdepth
85 dcfsnz menupos,F 89 dcfsnz menupos,F
86 bra simulator_calc_deco 90 bra simulator_calc_deco
87 dcfsnz menupos,F 91
88 bra simulator_show_decoplan
89 menu_simulator_exit: 92 menu_simulator_exit:
90 movlw d'4' 93 movlw d'4'
91 movwf menupos 94 movwf menupos
92 goto more_menu2 ; exit... 95 goto more_menu2 ; exit...
93 96
97 simulator_inc_interval:
98 movff char_I_dive_interval,PRODL
99 incf PRODL,F
100 movlw .24*6 ; Max 24h delay.
101 cpfslt PRODL
102 clrf PRODL
103 movff PRODL,char_I_dive_interval
104
105 movlw d'1'
106 movwf menupos
107 bra menu_simulator2
108
94 simulator_inc_bottomtime: 109 simulator_inc_bottomtime:
95 movlw d'2' 110 movlw d'2'
96 addwf logbook_temp1,F ; Here: Bottomtime in m 111 addwf logbook_temp1,F ; Here: Bottomtime in m
97 movlw d'199' 112 movlw d'199'
98 cpfslt logbook_temp1 113 cpfslt logbook_temp1
99 movwf logbook_temp1 114 movwf logbook_temp1
100 movlw d'2' 115 movlw d'3'
101 movwf menupos 116 movwf menupos
102 bra menu_simulator2 117 bra menu_simulator2
103 118
104 simulator_inc_maxdepth: 119 simulator_inc_maxdepth:
105 movlw d'3' 120 movlw d'3'
106 addwf logbook_temp2,F ; Here: Maxdepth in m 121 addwf logbook_temp2,F ; Here: Maxdepth in m
107 movlw d'99' 122 movlw d'99'
108 cpfslt logbook_temp2 123 cpfslt logbook_temp2
109 movwf logbook_temp2 124 movwf logbook_temp2
110 movlw d'3' 125 movlw d'4'
111 movwf menupos 126 movwf menupos
112 bra menu_simulator2 127 bra menu_simulator2
128
129 ;=============================================================================
113 130
114 simulator_startdive: 131 simulator_startdive:
115 ; Descent to -15m depth 132 ; Descent to -15m depth
116 ; Set standalone_simulator flag (Displays Simulator menu during simulation by pressing ENTER button) 133 ; Set standalone_simulator flag (Displays Simulator menu during simulation by pressing ENTER button)
117 ; Clear standalone_simulator after (any) dive 134 ; Clear standalone_simulator after (any) dive
118 bsf simulatormode_active ; normal simulator mode 135 bsf simulatormode_active ; normal simulator mode
119 bsf standalone_simulator ; Standalone Simulator active 136 bsf standalone_simulator ; Standalone Simulator active
120 137
121 movff logbook_temp2,xA+0 138 movff logbook_temp2,xA+0
122 clrf xA+1 139 clrf xA+1
123 movlw d'100' 140 movlw d'100'
124 movwf xB+0 141 movwf xB+0
125 clrf xB+1 142 clrf xB+1
141 bcf menubit3 158 bcf menubit3
142 bcf menubit 159 bcf menubit
143 bcf switch_left 160 bcf switch_left
144 bcf switch_right 161 bcf switch_right
145 162
146 call simulator_save_tissue_data ; Stores 32 floats "pre_tissue" into bank3 163 call simulator_save_tissue_data ; Stores 32 floats "pre_tissue" into bank3
147 164
148 movlw d'3' ; Begin of deco cycle (reset table). 165 movff char_I_dive_interval,WREG ; Any interval ?
149 movff WREG,char_O_deco_status ; Reset Deco module. 166 iorlw 0 ; Test for null
150 167 btfss STATUS,Z
151 bsf divemode ; Set divemode flag 168 call deco_calc_dive_interval ; NZ: call interval subroutine.
152 ostc_debug 'P' ; Sends debug-information to screen if debugmode active 169 movlb 1
153 goto diveloop ; Start Divemode 170
171 movlw d'3' ; Begin of deco cycle (reset table).
172 movff WREG,char_O_deco_status ; Reset Deco module.
173
174 bsf divemode ; Set divemode flag
175 ostc_debug 'P' ; Sends debug-information to screen if debugmode active
176 goto diveloop ; Start Divemode
154 177
155 ;============================================================================= 178 ;=============================================================================
156 ; Show decoplanning result. 179 ; Show decoplanning result.
157 ; 180 ;
158 simulator_show_decoplan: 181 simulator_show_decoplan:
192 WIN_INVERT .1 ; Init new Wordprocessor 215 WIN_INVERT .1 ; Init new Wordprocessor
193 DISPLAYTEXT .188 ; Sim. Results: 216 DISPLAYTEXT .188 ; Sim. Results:
194 WIN_INVERT .0 ; Init new Wordprocessor 217 WIN_INVERT .0 ; Init new Wordprocessor
195 218
196 simulator_show_decoplan1: 219 simulator_show_decoplan1:
197 bcf switch_left 220 bcf switch_left
198 bcf switch_right 221 bcf switch_right
199 simulator_show_decoplan2: 222 simulator_show_decoplan2:
200 btfsc uart_dump_screen ; Asked to dump screen contains ? 223 btfsc uart_dump_screen ; Asked to dump screen contains ?
201 call dump_screen ; Yes! 224 call dump_screen ; Yes!
202 225
203 btfss onesecupdate 226 btfss onesecupdate
204 bra simulator_show_decoplan3 227 bra simulator_show_decoplan3
205 228
206 call timeout_surfmode 229 call timeout_surfmode
207 call set_dive_modes 230 call set_dive_modes
208 call test_charger ; check if charger IC is active 231 call test_charger ; check if charger IC is active
209 call get_battery_voltage ; get battery voltage 232 call get_battery_voltage ; get battery voltage
210 233
211 bcf onesecupdate ; End of one second tasks 234 bcf onesecupdate ; End of one second tasks
212 235
213 simulator_show_decoplan3: 236 simulator_show_decoplan3:
214 btfsc switch_right 237 btfsc switch_right
215 bra simulator_show_decoplan4 ; Quit display 238 bra menu_simulator1 ; Quit display
216 239
217 btfsc switch_left 240 btfsc switch_left
218 bra simulator_show_decoplan5 ; Next decoplan-page. 241 bra simulator_show_decoplan5 ; Next decoplan-page.
219 242
220 btfsc sleepmode 243 btfsc sleepmode
234 bra simulator_show_decoplan1 257 bra simulator_show_decoplan1
235 258
236 ;---- In OCR mode, show the gas Usage special page --------------------------- 259 ;---- In OCR mode, show the gas Usage special page ---------------------------
237 simulator_show_decoplan5_0: 260 simulator_show_decoplan5_0:
238 btfss display_see_deco ; Already displayed ? 261 btfss display_see_deco ; Already displayed ?
239 bra simulator_show_decoplan4 ; Exit to menu. 262 bra menu_simulator1 ; Exit to menu.
240 263
241 bcf display_see_deco ; clear flag 264 bcf display_see_deco ; clear flag
242 265
243 btfsc FLAG_const_ppO2_mode ; In CCR mode ? 266 btfsc FLAG_const_ppO2_mode ; In CCR mode ?
244 bra simulator_show_decoplan4 ; YES: finished. 267 bra menu_simulator1 ; YES: finished.
245 268
246 ; Make sure to pass first gas 269 ; Make sure to pass first gas
247 clrf EEADRH 270 clrf EEADRH
248 read_int_eeprom .33 ; First gas. 271 read_int_eeprom .33 ; First gas.
249 movff EEDATA,char_I_first_gas 272 movff EEDATA,char_I_first_gas
306 bra simulator_show_decoplan1 329 bra simulator_show_decoplan1
307 330
308 ;============================================================================= 331 ;=============================================================================
309 ; OSTC Simulator: compute a new runtime 332 ; OSTC Simulator: compute a new runtime
310 ; 333 ;
311 simulator_show_decoplan4:
312 movlw d'5'
313 movwf menupos
314 bra menu_simulator1
315
316 simulator_calc_deco: 334 simulator_calc_deco:
317 call simulator_save_tissue_data ; Stores 32 floats "pre_tissue" into bank3 335 call simulator_save_tissue_data ; Stores 32 floats "pre_tissue" into bank3
336
337 movff char_I_dive_interval,WREG ; Any interval ?
338 iorlw 0 ; Test for null
339 btfss STATUS,Z
340 call deco_calc_dive_interval ; NZ: call interval subroutine.
341 movlb 1
318 342
319 bsf simulatormode_active ; normal simulator mode 343 bsf simulatormode_active ; normal simulator mode
320 bsf standalone_simulator ; Standalone Simulator active 344 bsf standalone_simulator ; Standalone Simulator active
321 bsf no_sensor_int ; Disable sensor interrupt 345 bsf no_sensor_int ; Disable sensor interrupt
322 clrf T3CON ; Restart time3 counter, 346 clrf T3CON ; Restart time3 counter,
419 443
420 movlw d'5' ; Pre-Set Cursor to "Show Decoplan" 444 movlw d'5' ; Pre-Set Cursor to "Show Decoplan"
421 movwf menupos 445 movwf menupos
422 movff char_I_bottom_time,logbook_temp1 ; Restore bottom time, 446 movff char_I_bottom_time,logbook_temp1 ; Restore bottom time,
423 movff char_I_bottom_depth,logbook_temp2 ; and depth. 447 movff char_I_bottom_depth,logbook_temp2 ; and depth.
424 bra menu_simulator1 ; Done. 448
449 clrf timeout_counter2 ; Restart menu timeout.
450 bra simulator_show_decoplan ; Done.
425 451
426 simulator_save_tissue_data: 452 simulator_save_tissue_data:
427 bsf restore_deco_data ; Set restore flag 453 bsf restore_deco_data ; Set restore flag
428 ostc_debug 'S' ; Sends debug-information to screen if debugmode active 454 ostc_debug 'S' ; Sends debug-information to screen if debugmode active
429 call deco_push_tissues_to_vault 455 call deco_push_tissues_to_vault