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