Mercurial > public > hwos_code
annotate src/surfmode.asm @ 49:fe01bbaf6014
minor german update
author | heinrichsweikamp |
---|---|
date | Fri, 27 Sep 2013 14:17:21 +0200 |
parents | 7c7d7644ca37 |
children | ec4d8503ec45 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File surfmode.asm | |
4 ; | |
5 ; Surfacemode | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-08-07 : [mH] moving from OSTC code | |
11 | |
12 #include "ostc3.inc" ; Mandatory header | |
13 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c | |
14 #include "start.inc" | |
15 #include "tft.inc" | |
16 #include "tft_outputs.inc" | |
17 #include "isr.inc" | |
18 #include "adc_lightsensor.inc" | |
19 #include "menu_processor.inc" | |
20 #include "strings.inc" | |
21 #include "sleepmode.inc" | |
22 #include "wait.inc" ; speed_* | |
23 #include "external_flash.inc" | |
24 #include "customview.inc" | |
25 #include "divemode.inc" | |
26 #include "mcp.inc" ; RX | |
27 #include "i2c.inc" | |
28 #include "comm.inc" | |
29 #include "eeprom_rs232.inc" | |
30 | |
31 #DEFINE menu_pos_row .215 | |
32 #DEFINE menu_pos_column .0 | |
33 #DEFINE view_row .215 | |
34 #DEFINE view_column .124 | |
35 | |
36 extern do_main_menu | |
37 | |
38 gui CODE | |
39 | |
40 | |
41 ;============================================================================= | |
42 ; Boot tasks for all modes | |
43 global surfloop | |
44 surfloop: | |
45 call speed_normal | |
46 bcf no_sensor_int ; Normal pressure mode | |
47 | |
48 clrf CCP1CON ; stop PWM | |
49 bcf PORTC,2 ; Pull PWM output to GND | |
50 call TFT_boot ; Initialize TFT (includes clear screen) | |
51 bcf restore_deco_data | |
52 | |
53 WIN_TOP .50 | |
54 WIN_LEFT .10 | |
55 movlw LOW 0x1E000 | |
56 movwf TBLPTRL | |
57 movlw HIGH 0x1E000 | |
58 movwf TBLPTRH | |
59 movlw UPPER 0x1E000 | |
60 movwf TBLPTRU | |
61 extern color_image | |
62 call color_image ; Show logo | |
63 | |
64 WIN_TOP .100 | |
65 WIN_LEFT .34 | |
66 extern ostc3_logo_block | |
67 movlw LOW(ostc3_logo_block) | |
68 movwf TBLPTRL | |
69 movlw HIGH ostc3_logo_block;&0xFFFF | |
70 movwf TBLPTRH | |
71 movlw UPPER(ostc3_logo_block) | |
72 movwf TBLPTRU | |
73 call color_image | |
74 call TFT_Display_FadeIn ; Show splash | |
75 call TFT_serial ; Show serial and firmware version | |
76 | |
77 ;---- Do any usefull initializes that takes time ------------------------- | |
78 call restart_set_modes_and_flags ; Sets decomode flags | |
79 ; call speed_fastest | |
80 bcf pressure_refresh | |
81 call I2C_init_compass | |
82 call I2C_init_accelerometer | |
83 clrf ext_flash_address+0 | |
84 clrf ext_flash_address+1 | |
85 clrf ext_flash_address+2 | |
86 | |
87 clrf timeout_counter2 | |
88 clrf timeout_counter3 | |
89 bcf premenu ; clear premenu flag | |
90 bcf menubit ; clear menu flag | |
91 clrf last_pressure+0 | |
92 clrf last_pressure+1 | |
93 bcf is_bailout ; =1: Bailout | |
94 bcf ccr_diluent_setup ; Use OC gases for gaslist routine | |
95 | |
96 bcf simulatormode_active ; Quit simulator mode (if active) | |
97 bcf switch_left | |
98 bcf switch_right | |
99 bcf LEDg | |
100 bcf LEDr | |
101 | |
102 ;---- Fade to standard surface view -------------------------------------- | |
103 ; Wait 1 second | |
104 bcf onesecupdate | |
105 btfss onesecupdate | |
106 bra $-2 | |
107 ; Wait 1 second | |
108 bcf onesecupdate | |
109 btfss onesecupdate | |
110 bra $-2 | |
111 | |
112 call TFT_Display_FadeOut ; Go to black screen | |
113 call TFT_ClearScreen ; Then change everything | |
114 WIN_TOP .0 | |
115 WIN_LEFT .0 | |
116 WIN_FONT FT_SMALL | |
117 WIN_INVERT .0 ; Init new Wordprocessor | |
118 | |
119 ; call TFT_user_image ; Show the user image/text | |
120 | |
121 WIN_COLOR color_lightblue | |
122 WIN_SMALL menu_pos_column,menu_pos_row | |
123 STRCPY_TEXT_PRINT tMenu ;"<Menu" | |
124 WIN_SMALL view_column,view_row | |
125 STRCPY_TEXT_PRINT tView ;"View>" | |
126 call TFT_standard_color | |
127 | |
128 call mcp_reset ; Setup RX | |
129 call TFT_clock ; display time | |
130 call update_surfloop60 | |
131 call get_battery_voltage ; get battery voltage | |
132 call TFT_update_batt_voltage ; display battery voltage | |
133 call TFT_update_surf_press ; display surface pressure | |
134 call TFT_temp_surfmode ; Displays temperature | |
135 call TFT_display_decotype_surface | |
39
e4e91fe8b09d
remember last customview in dive and surface mode
mh@mh-THINK.fritz.box
parents:
0
diff
changeset
|
136 movff customview_surfmode,menupos3 ; Reload last customview |
0 | 137 call surf_customview_mask ; Update #menupos3 view |
138 | |
48 | 139 ; Logo |
0 | 140 WIN_TOP .0 |
141 WIN_LEFT .70 | |
142 movlw LOW(ostc3_logo_block) | |
143 movwf TBLPTRL | |
144 movlw HIGH ostc3_logo_block;&0xFFFF | |
145 movwf TBLPTRH | |
146 movlw UPPER(ostc3_logo_block) | |
147 movwf TBLPTRU | |
148 call color_image | |
149 | |
150 btfsc FLAG_apnoe_mode ; Ignore in Apnoe mode | |
151 bra surfloop1 | |
152 btfsc FLAG_gauge_mode ; Ignore in Gauge mode | |
153 bra surfloop1 | |
154 | |
155 surfloop1: | |
156 call TFT_Display_FadeIn ; Display resulting surface screen. | |
157 | |
158 ;---- Late initialisations ----------------------------------------------- | |
159 movff last_surfpressure_30min+0,int_I_pres_respiration+0 ; copy surface air pressure to deco routine | |
160 movff last_surfpressure_30min+1,int_I_pres_respiration+1 ; 30min old values | |
161 movff last_surfpressure_30min+0,int_I_pres_surface+0 ; copy surface air pressure to deco routine | |
162 movff last_surfpressure_30min+1,int_I_pres_surface+1 ; 30min old values | |
163 movff last_surfpressure_30min+0,last_surfpressure+0 ; Use 30min old airpressure | |
164 movff last_surfpressure_30min+1,last_surfpressure+1 ; Use 30min old airpressure | |
165 | |
166 extern do_demo_divemode | |
167 ; goto do_demo_divemode | |
168 | |
169 ; Startup tasks for all modes | |
170 ; Desaturation time needs: | |
171 ; int_I_pres_surface | |
172 ; char_I_desaturation_multiplier | |
173 call deco_calc_desaturation_time ; calculate desaturation time | |
174 movlb b'00000001' ; select ram bank 1 | |
175 | |
176 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | |
177 call enable_rs232 ; Also sets to speed_normal ... | |
178 | |
179 surfloop_loop: | |
180 btfss onesecupdate ; do every second tasks? | |
181 bra surfloop_loop2 ; no, loop | |
182 | |
183 ; One Second tasks for all modes | |
184 call speed_normal | |
185 call TFT_debug_output | |
186 call TFT_clock ; update clock | |
187 call timeout_surfmode ; check timeout | |
188 call get_battery_voltage ; get battery voltage | |
189 call TFT_update_batt_voltage ; display battery voltage | |
190 call timeout_premenu ; timeout premenu | |
191 call set_dive_modes ; tests if depth>threshold | |
192 btfss secs,0 ; Every two seconds... | |
193 call TFT_temp_surfmode ; Displays temperature | |
194 btfss secs,0 ; Every two seconds... | |
195 call surfmode_check_for_warnings ; ... check for warnings (and display/update) them | |
196 | |
197 btfsc FLAG_ccr_mode ; In CCR mode... | |
198 call TFT_surface_hud ; ...update HUD data in surface mode | |
199 | |
200 bcf onesecupdate ; every second tasks done | |
201 | |
202 surfloop_loop2: | |
203 ; Tasks approx. every 50ms for all modes | |
204 call test_switches_surfmode ; check switches | |
205 call speed_normal | |
206 | |
207 ; One minute tasks for all modes | |
208 btfsc oneminupdate ; do every minute tasks | |
209 call update_surfloop60 ; yes, e.g. update time and date | |
210 | |
211 ; Mode tasks | |
212 btfsc menubit ; Menu? | |
213 goto do_main_menu ; Menu! | |
214 | |
215 btfsc pressure_refresh ; new pressure available? | |
216 call TFT_update_surf_press ; display surface pressure | |
217 bcf pressure_refresh ; until new pressure is available | |
218 | |
219 btfss quarter_second_update | |
220 bra surfloop_loop2a | |
221 bcf quarter_second_update | |
222 movlw .6 | |
223 cpfseq menupos3 ; in compass view? | |
224 bra surfloop_loop2a ; No | |
225 call TFT_surface_compass_heading ; Yes, update compass heading value | |
226 | |
227 surfloop_loop2a: | |
228 btfsc toggle_customview ; Next view? | |
229 call surf_customview_toggle ; Yes, show next customview (and delete this flag) | |
230 | |
231 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump) | |
232 bra surfloop_loop3 | |
233 btfsc vusb_in ; USB plugged in? | |
234 goto comm_mode ; Start COMM mode | |
235 bra surfloop_loop4 | |
236 surfloop_loop3: | |
237 btfss vusb_in ; USB (still) plugged in? | |
238 bcf enable_screen_dumps ; No, clear flag | |
239 call rs232_get_byte | |
240 btfsc rs232_recieve_overflow | |
241 bra surfloop_loop4 | |
242 movlw "l" | |
243 cpfseq RCREG1 | |
244 bra surfloop_loop4 | |
245 call TFT_dump_screen ; Dump the screen contents | |
246 surfloop_loop4: | |
247 btfsc divemode ; Divemode active? | |
248 goto diveloop ; Yes, switch into Divemode! | |
249 btfsc sleepmode ; Sleepmode active? | |
250 goto sleeploop ; Yes, switch into sleepmode! | |
251 | |
252 bra surfloop_loop ; loop surfacemode | |
253 | |
254 update_surfloop60: | |
255 ; One minute tasks for all modes | |
256 call TFT_date ; Update date | |
257 call calc_deko_surfmode ; calculate desaturation every minute | |
258 bcf oneminupdate | |
259 return | |
260 | |
261 extern check_cns_violation,check_warn_battery,check_and_store_gf_violation | |
262 surfmode_check_for_warnings: | |
263 movf warning_counter_backup,W | |
264 cpfseq warning_counter ; warning_counter_backup = warning_counter? | |
265 call TFT_clear_warning_text ; No, clear all warnings | |
266 movff warning_counter,warning_counter_backup ; copy warning_counter | |
267 | |
268 bcf warning_active ; Clear flag | |
269 clrf warning_counter ; Clear counter | |
270 | |
271 ; Warnings for all modes | |
272 call check_warn_battery ; Check if the battery level should be displayed/warned | |
273 call surfmode_check_for_nofly ; Check if nofly time should be shown | |
274 call surfmode_check_for_desat ; Check if desat time should be shown | |
275 call surfmode_check_for_interval ; Check if surface interval should be shown | |
276 | |
277 btfsc FLAG_apnoe_mode ; Done for Apnoe or Gauge mode | |
278 bra surfmode_check_for_warnings2 | |
279 btfsc FLAG_gauge_mode ; Done for Apnoe or Gauge mode | |
280 bra surfmode_check_for_warnings2 | |
281 | |
282 ; Warnings only in deco modes | |
283 call check_cns_violation ; Check CNS value and display it, if required | |
284 call check_and_store_gf_violation ; Check GF value and display it, if required | |
285 | |
286 surfmode_check_for_warnings2: | |
287 ; Setup warning_page number | |
288 incf warning_page,F | |
289 bcf STATUS,C | |
290 rlcf warning_page,W ; *2 | |
291 cpfsgt warning_counter ; > warning_counter | |
292 clrf warning_page ; No, clear | |
293 | |
294 ; Clear 2nd row of warnings if there is nothing to show (on this page) | |
295 btfss second_row_warning ; =1: The second row contains a warning | |
296 call TFT_clear_warning_text_2nd_row ; No, clear this row | |
297 return ; Done. | |
298 | |
299 surfmode_check_for_interval: | |
300 movf surface_interval+0,W ; Is interval null ? | |
301 iorwf surface_interval+0,W | |
302 bnz surfmode_check_for_interval2 ; No | |
303 return | |
304 surfmode_check_for_interval2: | |
305 incf warning_counter,F ; increase counter | |
306 call TFT_interval | |
307 return | |
308 | |
309 | |
310 surfmode_check_for_desat: | |
311 movf desaturation_time+0,W ; Is nofly null ? | |
312 iorwf desaturation_time+1,W | |
313 bnz surfmode_check_for_desat2 ; No | |
314 return | |
315 surfmode_check_for_desat2: | |
316 incf warning_counter,F ; increase counter | |
317 call TFT_desaturation_time | |
318 return | |
319 | |
320 surfmode_check_for_nofly: | |
321 movf nofly_time+0,W ; Is nofly null ? | |
322 iorwf nofly_time+1,W | |
323 bnz surfmode_check_for_nofly2 ; No... | |
324 return | |
325 surfmode_check_for_nofly2: | |
326 incf warning_counter,F ; increase counter | |
327 call TFT_nofly_time | |
328 return | |
329 | |
330 | |
331 ;============================================================================= | |
332 global calc_deko_surfmode | |
333 calc_deko_surfmode: | |
334 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy surface air pressure to deco routine | |
335 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode | |
336 banksel common | |
337 return | |
338 | |
339 timeout_premenu: | |
340 btfsc premenu ; is "<Menu" displayed? | |
341 bra timeout_premenu1 ; Yes | |
342 return | |
343 | |
344 timeout_premenu1: | |
345 incf timeout_counter3,F ; Yes... | |
346 movlw d'2' | |
347 cpfsgt timeout_counter3 ; ... longer then premenu_timeout | |
348 return ; No! | |
349 | |
350 bcf premenu ; Yes, so clear "Menu?" and clear pre_menu bit | |
351 | |
352 WIN_SMALL menu_pos_column,menu_pos_row | |
353 WIN_COLOR color_lightblue | |
354 STRCPY_TEXT_PRINT tMenu ; "<Menu" | |
355 call TFT_standard_color | |
356 clrf timeout_counter3 ; Also clear timeout | |
357 bcf switch_left ; and debounce switches | |
358 bcf switch_right | |
359 return | |
360 | |
361 test_switches_surfmode: ; checks switches in surfacemode | |
362 btfsc switch_right | |
363 bra test_switches_surfmode2 | |
364 btfsc switch_left | |
365 bra test_switches_surfmode3 | |
366 | |
367 ; No button press | |
368 return | |
369 | |
370 test_switches_surfmode3: | |
371 bcf switch_left | |
372 btfss premenu | |
373 bra test_switches_surfmode4 | |
374 bsf menubit ; Enter Menu! | |
375 return | |
376 | |
377 test_switches_surfmode4: | |
378 WIN_COLOR color_lightblue | |
379 WIN_SMALL view_column,view_row | |
380 STRCPY_TEXT_PRINT tView ;"View" | |
381 WIN_SMALL menu_pos_column,menu_pos_row | |
382 call TFT_standard_color | |
383 WIN_INVERT .1 ; Init new Wordprocessor | |
384 STRCPY_TEXT_PRINT tMenu ;"<Menu" | |
385 WIN_INVERT .0 ; Init new Wordprocessor | |
386 bsf premenu | |
387 clrf timeout_counter2 | |
388 return | |
389 | |
390 test_switches_surfmode2: | |
391 bcf switch_right | |
392 bsf toggle_customview | |
393 clrf timeout_counter2 ; and reset timeout | |
394 return | |
395 | |
396 test_switches_surfmode5: | |
397 WIN_SMALL menu_pos_column,menu_pos_row | |
398 WIN_COLOR color_lightblue | |
399 STRCPY_TEXT_PRINT tMenu ;"<Menu" | |
400 call TFT_standard_color | |
401 bcf premenu | |
402 clrf timeout_counter2 | |
403 return | |
404 | |
405 global timeout_surfmode | |
406 timeout_surfmode: | |
407 movlw timeout_surfacemode ; [s] | |
408 global timeout_testmode | |
409 timeout_testmode: | |
410 incf timeout_counter2,F ; increase timeout counter | |
411 cpfsgt timeout_counter2 ; Compare with timeout_counter2 | |
412 return ; return, no timeout | |
413 bsf sleepmode ; Set Flag | |
414 return ; Return | |
415 | |
416 END |