Mercurial > public > hwos_code
annotate src/customview.asm @ 54:7d626c15b577
some cleanup/changelog
author | heinrichsweikamp |
---|---|
date | Sun, 29 Sep 2013 19:10:12 +0200 |
parents | 2825f1d2262f |
children | 37275e0fa7f5 |
rev | line source |
---|---|
0 | 1 ;============================================================================= |
2 ; | |
3 ; File customview.asm | |
4 ; | |
5 ; Customview in Surfacemode and Divemode | |
6 ; | |
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved. | |
8 ;============================================================================= | |
9 ; HISTORY | |
10 ; 2011-08-10 : [mH] moving from OSTC code | |
11 | |
12 ;============================================================================= | |
13 | |
14 #include "ostc3.inc" ; Mandatory header | |
15 #include "tft_outputs.inc" | |
16 #include "strings.inc" | |
17 #include "tft.inc" | |
18 #include "isr.inc" | |
19 #include "wait.inc" | |
20 #include "surfmode.inc" | |
21 #include "convert.inc" | |
22 #include "divemode.inc" | |
23 #include "i2c.inc" | |
24 | |
25 gui CODE | |
26 | |
27 ;============================================================================= | |
28 ; Do every-second tasks for the custom view area (Dive mode) | |
29 | |
30 global customview_second | |
31 customview_second: | |
32 movff menupos3,WREG ; copy | |
33 dcfsnz WREG,F | |
34 bra customview_1sec_view1 | |
35 dcfsnz WREG,F | |
36 bra customview_1sec_view2 | |
37 dcfsnz WREG,F | |
38 bra customview_1sec_view3 | |
39 dcfsnz WREG,F | |
40 bra customview_1sec_view4 | |
41 dcfsnz WREG,F | |
42 bra customview_1sec_view5 | |
53
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
43 dcfsnz WREG,F |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
44 bra customview_1sec_view6 |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
45 dcfsnz WREG,F |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
46 bra customview_1sec_view7 |
0 | 47 ; Menupos3=0, do nothing |
48 return | |
49 | |
50 customview_1sec_view3: | |
51 call TFT_decoplan ; Show decoplan | |
52 return | |
53 customview_1sec_view2: | |
54 call TFT_update_avr_stopwatch ; Update average depth and stopwatch | |
55 return | |
56 customview_1sec_view1: | |
57 call TFT_update_hud ; Update HUD data | |
58 return | |
59 customview_1sec_view4: | |
60 call TFT_ead_end_tissues_clock ; Update EAD/END, Tissues and clock | |
61 return | |
62 customview_1sec_view5: | |
63 call TFT_gf_info ; Update GF informations | |
64 return | |
53
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
65 customview_1sec_view6: |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
66 ; Compass updated seperately (Faster) in divemode |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
67 return |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
68 customview_1sec_view7: ; Dynamic gaslist |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
69 call TFT_dyn_gaslist ; Update the gaslist |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
70 return |
0 | 71 |
72 ;============================================================================= | |
73 ; Do every-minute tasks for the custom view area | |
74 | |
75 global customview_minute | |
76 customview_minute: | |
77 return | |
78 ; movff menupos3,WREG ; copy | |
79 ; dcfsnz WREG,F | |
80 ; bra customview_1min_view1 | |
81 ; dcfsnz WREG,F | |
82 ; bra customview_1min_view2 | |
83 ; dcfsnz WREG,F | |
84 ; bra customview_1min_view3 | |
85 ; dcfsnz WREG,F | |
86 ; bra customview_1min_view4 | |
87 ; dcfsnz WREG,F | |
88 ; bra customview_1min_view5 | |
89 ; dcfsnz WREG,F | |
90 ; bra customview_1min_view6 | |
91 ; dcfsnz WREG,F | |
92 ; bra customview_1min_view7 | |
93 ; dcfsnz WREG,F | |
94 ; bra customview_1min_view8 | |
95 ; dcfsnz WREG,F | |
96 ; bra customview_1min_view9 | |
97 ; dcfsnz WREG,F | |
98 ; bra customview_1min_view10 | |
99 ; dcfsnz WREG,F | |
100 ; bra customview_1min_view11 | |
101 ; ; Menupos3=0, do nothing | |
102 ; return | |
103 ; | |
104 ;customview_1min_view1: | |
105 ;customview_1min_view2: | |
106 ;customview_1min_view3: | |
107 ;customview_1min_view4: | |
108 ;customview_1min_view5: | |
109 ;customview_1min_view6: | |
110 ;customview_1min_view7: | |
111 ;customview_1min_view8: | |
112 ;customview_1min_view9: | |
113 ;customview_1min_view10: | |
114 ;customview_1min_view11: | |
115 ; return | |
116 | |
117 global surf_customview_toggle | |
118 surf_customview_toggle: | |
119 bcf switch_right | |
120 incf menupos3,F ; Number of customview to show | |
41 | 121 movlw d'7' ; Max number of customsviews in surface mode |
0 | 122 cpfsgt menupos3 ; Max reached? |
123 bra surf_customview_mask ; No, show | |
124 movlw .1 | |
125 movwf menupos3 ; Reset to one (Always one custom view visible) | |
126 | |
127 global surf_customview_mask | |
128 surf_customview_mask: | |
48 | 129 WIN_BOX_BLACK .50,surf_warning1_row-1, .0, surf_decotype_column-.1 ; top, bottom, left, right |
0 | 130 call TFT_standard_color |
131 movff menupos3,WREG ; Menupos3 holds number of customview function | |
132 dcfsnz WREG,F | |
133 bra surf_customview_init_view1 ; OC Gas list | |
134 dcfsnz WREG,F | |
135 bra surf_customview_init_view2 ; CC Dil list | |
136 dcfsnz WREG,F | |
137 bra surf_customview_init_view3 ; CC SP list | |
138 dcfsnz WREG,F | |
139 bra surf_customview_init_view4 ; Custom Text | |
140 dcfsnz WREG,F | |
141 bra surf_customview_init_view5 ; Tissue Diagram | |
41 | 142 dcfsnz WREG,F |
0 | 143 bra surf_customview_init_view6 ; Compass |
41 | 144 dcfsnz WREG,F |
145 bra surf_customview_init_view7 ; Deco settings | |
0 | 146 |
147 call I2C_sleep_accelerometer ; Stop accelerometer | |
148 call I2C_sleep_compass ; Stop compass | |
149 | |
150 movlw .1 | |
151 movwf menupos3 ; Reset to one (Always one custom view visible) | |
152 | |
153 surf_customview_init_view1: ; View1: OC Gas list | |
154 btfsc FLAG_ccr_mode | |
155 bra surf_customview_toggle | |
156 btfsc FLAG_gauge_mode | |
157 bra surf_customview_toggle | |
158 btfsc FLAG_apnoe_mode | |
159 bra surf_customview_toggle | |
160 call TFT_gaslist_surfmode ; Show gas list | |
161 bra customview_toggle_exit ; Done. | |
162 | |
163 surf_customview_init_view2: ; View2: CC Dil list | |
164 btfss FLAG_ccr_mode | |
165 bra surf_customview_toggle | |
166 btfsc FLAG_gauge_mode | |
167 bra surf_customview_toggle | |
168 btfsc FLAG_apnoe_mode | |
169 bra surf_customview_toggle | |
170 call TFT_dillist_surfmode ; Show diluent list | |
171 bra customview_toggle_exit ; Done. | |
172 | |
173 surf_customview_init_view3: ; View3: CC SP list | |
174 btfss FLAG_ccr_mode | |
175 bra surf_customview_toggle | |
176 btfsc FLAG_gauge_mode | |
177 bra surf_customview_toggle | |
178 btfsc FLAG_apnoe_mode | |
179 bra surf_customview_toggle | |
180 call TFT_splist_surfmode ; Show Setpoint list | |
181 bra customview_toggle_exit ; Done. | |
182 | |
183 surf_customview_init_view4: ; View4: Custom text | |
184 call TFT_custom_text ; Show the custom text | |
185 bra customview_toggle_exit ; Done. | |
186 | |
187 surf_customview_init_view5: ; View5: Tissue Diagram | |
188 btfsc FLAG_gauge_mode | |
189 bra surf_customview_toggle | |
190 btfsc FLAG_apnoe_mode | |
191 bra surf_customview_toggle | |
192 call TFT_surface_tissues ; Show Tissue diagram | |
193 bra customview_toggle_exit ; Done. | |
194 | |
195 surf_customview_init_view6: ; View6: Compass | |
196 call I2C_init_accelerometer ; Start accelerometer | |
197 call I2C_init_compass ; Start compass | |
198 call TFT_surface_compass_mask ; Show compass | |
199 bra customview_toggle_exit ; Done. | |
41 | 200 surf_customview_init_view7: |
201 btfsc FLAG_gauge_mode | |
202 bra surf_customview_toggle | |
203 btfsc FLAG_apnoe_mode | |
204 bra surf_customview_toggle | |
205 extern deco_setup_dive | |
206 call deco_setup_dive | |
207 call TFT_surface_decosettings ; Show all deco settings | |
208 bra customview_toggle_exit ; Done. | |
0 | 209 |
210 global menuview_toggle | |
211 menuview_toggle: ; Show Menu or the simulator tasks | |
212 movlw divemode_menuview_timeout | |
213 movwf timeout_counter3 | |
214 bsf menuview | |
215 bcf switch_left | |
216 incf menupos2,F ; Number of options to show | |
217 movlw d'6' ; Max number of options in divemode | |
218 cpfsgt menupos2 ; Max reached? | |
219 bra menuview_mask ; No, show | |
220 global menuview_toggle_reset | |
221 menuview_toggle_reset: ; Timeout occured | |
222 clrf menupos2 | |
223 bcf menuview | |
224 menuview_mask: | |
225 WIN_BOX_BLACK divemode_simtext_row, divemode_simtext_row+.24, divemode_simtext_column, divemode_simtext_column+.49 ; top, bottom, left, right | |
226 btfss FLAG_gauge_mode | |
227 bra menuview_mask2 | |
228 ; Clear some more in gauge mode | |
229 WIN_BOX_BLACK divemode_simtext_row, divemode_simtext_row+.24, divemode_simtext_column+.50, divemode_simtext_column+.70 ; top, bottom, left, right | |
230 menuview_mask2: | |
231 movlw color_yellow | |
232 call TFT_set_color | |
233 WIN_SMALL_INVERT divemode_simtext_column,divemode_simtext_row | |
234 movff menupos2,WREG ; Menupos2 holds number of menu option to show | |
235 dcfsnz WREG,F | |
236 bra menuview_view1 | |
237 dcfsnz WREG,F | |
238 bra menuview_view2 | |
239 dcfsnz WREG,F | |
240 bra menuview_view3 | |
241 dcfsnz WREG,F | |
242 bra menuview_view4 | |
243 dcfsnz WREG,F | |
244 bra menuview_view5 | |
245 dcfsnz WREG,F | |
246 bra menuview_view6 | |
247 menuview_exit: | |
248 call TFT_standard_color | |
249 WIN_INVERT .0 | |
250 return ; Menupos2 = 0, Show nothing | |
251 menuview_view1: | |
252 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
253 bra menuview_toggle ; Call next option | |
254 btfsc FLAG_gauge_mode ; In Gauge mode? | |
255 bra menuview_toggle ; Call next option | |
256 STRCPY_TEXT_PRINT tDivePreMenu ; "Menu?" | |
257 bra menuview_exit ; Done. | |
258 menuview_view2: | |
259 btfss simulatormode_active ; View only for simulator mode | |
260 bra menuview_toggle ; Call next option | |
261 STRCPY_TEXT_PRINT tQuitSim ;"Quit Simulation?" | |
262 bra menuview_exit ; Done. | |
263 menuview_view3: | |
264 btfss simulatormode_active ; View only for simulator mode | |
265 bra menuview_toggle ; Call next option | |
266 STRCPY_TEXT_PRINT tDescent1m ; "Descent 1m" | |
267 bra menuview_exit ; Done. | |
268 menuview_view4: | |
269 btfss simulatormode_active ; View only for simulator mode | |
270 bra menuview_toggle ; Call next option | |
271 STRCPY_TEXT_PRINT tAscent1m ; "Ascend 1m" | |
272 bra menuview_exit ; Done. | |
273 menuview_view5: | |
274 btfss FLAG_apnoe_mode ; In Apnoe mode? | |
275 bra menuview_toggle ; No, call next option | |
276 btfsc FLAG_active_descent ; Are we descending? | |
277 bra menuview_toggle ; Yes | |
278 ; We are at the surface: | |
279 STRCPY_TEXT_PRINT tQuitApnea ; "Quit Apnea mode?" | |
280 bra menuview_exit ; Done. | |
281 menuview_view6: | |
282 btfss FLAG_gauge_mode ; In Gauge mode? | |
283 bra menuview_toggle ; No, call next option | |
284 STRCPY_TEXT_PRINT tDivemenu_ResetAvr ; "Reset Avr." | |
285 bra menuview_exit ; Done. | |
286 | |
287 | |
288 ;============================================================================= | |
289 ; Show next customview (and delete this flag) | |
290 global customview_toggle | |
291 customview_toggle: | |
292 bcf switch_right | |
293 incf menupos3,F ; Number of customview to show | |
53
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
294 movlw d'7' ; Max number of customsviews in divemode |
0 | 295 cpfsgt menupos3 ; Max reached? |
296 bra customview_mask ; No, show | |
297 customview_toggle_reset: ; Timeout occured | |
298 clrf menupos3 ; Reset to zero (Zero=no custom view) | |
39
e4e91fe8b09d
remember last customview in dive and surface mode
mh@mh-THINK.fritz.box
parents:
0
diff
changeset
|
299 global customview_mask |
0 | 300 customview_mask: |
301 call TFT_clear_customview_divemode | |
302 WIN_SMALL divemode_customview_column,divemode_customview_row | |
303 call TFT_standard_color | |
304 movff menupos3,WREG ; Menupos3 holds number of customview function | |
305 dcfsnz WREG,F | |
306 bra customview_init_view1 | |
307 dcfsnz WREG,F | |
308 bra customview_init_view2 | |
309 dcfsnz WREG,F | |
310 bra customview_init_view3 | |
311 dcfsnz WREG,F | |
312 bra customview_init_view4 | |
313 dcfsnz WREG,F | |
314 bra customview_init_view5 ; GF informations | |
315 dcfsnz WREG,F | |
316 bra customview_init_view6 ; Compass | |
53
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
317 dcfsnz WREG,F |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
318 bra customview_init_view7 ; Dynamic gaslist |
0 | 319 customview_init_nocustomview: |
320 call I2C_sleep_accelerometer ; Stop accelerometer | |
321 call I2C_sleep_compass ; Stop compass | |
322 bra customview_toggle_exit | |
323 | |
324 customview_init_view1: | |
325 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
326 bra customview_toggle ; yes, Call next view... | |
327 btfss FLAG_ccr_mode ; In CC mode? | |
328 bra customview_toggle ; no, Call next view... | |
329 | |
330 bsf dive_hud1_displayed ; Set display flag | |
331 bsf dive_hud2_displayed ; Set display flag | |
332 bsf dive_hud3_displayed ; Set display flag | |
333 call TFT_hud_mask ; Setup HUD mask | |
334 call TFT_update_hud ; Update HUD data | |
335 bra customview_toggle_exit | |
336 | |
337 customview_init_view2: | |
338 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
339 bra customview_toggle ; Yes, Call next view... | |
340 call TFT_mask_avr_stopwatch ; Show mask for average depth and stopwatch | |
341 call TFT_update_avr_stopwatch ; Update average depth and stopwatch | |
342 bra customview_toggle_exit | |
343 | |
344 customview_init_view3: | |
345 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
346 bra customview_toggle ; Yes, Call next view... | |
347 btfsc FLAG_gauge_mode ; In Gauge mode? | |
348 bra customview_toggle ; Yes, Call next view... | |
349 call TFT_decoplan ; Show decoplan | |
350 bra customview_toggle_exit | |
351 | |
352 customview_init_view4: | |
353 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
354 bra customview_toggle ; Yes, Call next view... | |
355 btfsc FLAG_gauge_mode ; In Gauge mode? | |
356 bra customview_toggle ; Yes, Call next view... | |
357 call TFT_ead_end_tissues_clock_mask ; Setup Mask | |
358 call TFT_ead_end_tissues_clock ; Show EAD/END, Tissues and clock | |
359 bra customview_toggle_exit | |
360 | |
361 customview_init_view5: | |
362 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
363 bra customview_toggle ; Yes, Call next view... | |
364 btfsc FLAG_gauge_mode ; In Gauge mode? | |
365 bra customview_toggle ; Yes, Call next view... | |
366 call TFT_gf_mask ; Setup Mask | |
367 call TFT_gf_info ; Show GF informations | |
368 bra customview_toggle_exit | |
369 | |
370 customview_init_view6: ; Compass (View 6) | |
371 call I2C_init_accelerometer ; Start accelerometer | |
372 call I2C_init_compass ; Start compass | |
373 call TFT_dive_compass_mask ; Show compass | |
374 bra customview_toggle_exit | |
375 | |
53
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
376 customview_init_view7: ; Dynamic gaslist (View 7) |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
377 btfsc FLAG_apnoe_mode ; In Apnoe mode? |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
378 bra customview_toggle ; Yes, Call next view... |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
379 btfsc FLAG_ccr_mode ; In CC mode? |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
380 bra customview_toggle ; Yes, Call next view... |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
381 call TFT_dyn_gaslist ; Show the dyn gaslist |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
382 bra customview_toggle_exit |
2825f1d2262f
NEW: Dynamic Gaslist in OC mode (Divemode, Customview 7)
heinrichsweikamp
parents:
48
diff
changeset
|
383 |
0 | 384 customview_toggle_exit: |
385 call TFT_standard_color | |
386 bcf toggle_customview ; Clear flag | |
387 return | |
388 | |
389 global customview_show_change_depth | |
390 customview_show_change_depth: ; Put " lom" or " loft" into Postinc2 | |
391 PUTC " " | |
392 TSTOSS opt_units ; 0=m, 1=ft | |
393 bra customview_show_mix_metric | |
394 movf lo,W | |
395 mullw .100 ; convert meters to mbar | |
396 movff PRODL,lo | |
397 movff PRODH,hi | |
398 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
399 bsf leftbind | |
400 output_16 ; Change depth in lo:hi | |
401 bcf leftbind | |
402 STRCAT_TEXT tFeets | |
403 return | |
404 customview_show_mix_metric: | |
405 output_99 ; Change depth in lo | |
406 STRCAT_TEXT tMeters | |
407 return | |
408 | |
409 | |
410 global customview_show_mix | |
411 customview_show_mix: ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
412 tstfsz hi ; He=0? | |
413 bra customview_show_mix5 ; No, Show a TX | |
414 movlw .21 | |
415 cpfseq lo ; Air? | |
416 bra customview_show_mix2 ; No | |
417 STRCAT_TEXT tSelectAir ; Yes, show "Air" | |
418 bra customview_show_mix4b | |
419 customview_show_mix2: | |
420 movlw .100 | |
421 cpfseq lo ; O2? | |
422 bra customview_show_mix3 ; No | |
423 STRCAT_TEXT tSelectO2 ; Yes, show "O2" | |
424 bra customview_show_mix4b | |
425 | |
426 customview_show_mix3: | |
427 movlw .21 | |
428 cpfslt lo ; < Nx21? | |
429 bra customview_show_mix4 ; No | |
430 STRCAT_TEXT tGasErr ; Yes, show "Err" | |
431 output_99 ; O2 ratio is still in "lo" | |
432 bra customview_show_mix4c | |
433 | |
434 customview_show_mix4: | |
435 STRCAT_TEXT tSelectNx ; Show "Nx" | |
436 output_99 ; O2 ratio is still in "lo" | |
437 customview_show_mix4b: | |
438 STRCAT " " | |
439 customview_show_mix4c: | |
440 btfsc divemode ; In divemode | |
441 return ; Yes | |
442 STRCAT " " | |
443 return | |
444 | |
445 customview_show_mix5: | |
446 btfsc divemode | |
447 bra customview_show_mix6 | |
448 STRCAT_TEXT tSelectTx ; Show "Tx" | |
449 customview_show_mix6: | |
450 output_99 ; O2 ratio is still in "lo" | |
451 PUTC "/" | |
452 movff hi,lo | |
453 output_99 ; He ratio | |
454 return | |
455 | |
456 END |