Mercurial > public > hwos_code
comparison src/customview.asm @ 0:11d4fc797f74
init
author | heinrichsweikamp |
---|---|
date | Wed, 24 Apr 2013 19:22:45 +0200 |
parents | |
children | e4e91fe8b09d |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:11d4fc797f74 |
---|---|
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) | |
279 customview_mask: | |
280 call TFT_clear_customview_divemode | |
281 WIN_SMALL divemode_customview_column,divemode_customview_row | |
282 call TFT_standard_color | |
283 movff menupos3,WREG ; Menupos3 holds number of customview function | |
284 dcfsnz WREG,F | |
285 bra customview_init_view1 | |
286 dcfsnz WREG,F | |
287 bra customview_init_view2 | |
288 dcfsnz WREG,F | |
289 bra customview_init_view3 | |
290 dcfsnz WREG,F | |
291 bra customview_init_view4 | |
292 dcfsnz WREG,F | |
293 bra customview_init_view5 ; GF informations | |
294 dcfsnz WREG,F | |
295 bra customview_init_view6 ; Compass | |
296 customview_init_nocustomview: | |
297 call I2C_sleep_accelerometer ; Stop accelerometer | |
298 call I2C_sleep_compass ; Stop compass | |
299 bra customview_toggle_exit | |
300 | |
301 customview_init_view1: | |
302 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
303 bra customview_toggle ; yes, Call next view... | |
304 btfss FLAG_ccr_mode ; In CC mode? | |
305 bra customview_toggle ; no, Call next view... | |
306 | |
307 bsf dive_hud1_displayed ; Set display flag | |
308 bsf dive_hud2_displayed ; Set display flag | |
309 bsf dive_hud3_displayed ; Set display flag | |
310 call TFT_hud_mask ; Setup HUD mask | |
311 call TFT_update_hud ; Update HUD data | |
312 bra customview_toggle_exit | |
313 | |
314 customview_init_view2: | |
315 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
316 bra customview_toggle ; Yes, Call next view... | |
317 call TFT_mask_avr_stopwatch ; Show mask for average depth and stopwatch | |
318 call TFT_update_avr_stopwatch ; Update average depth and stopwatch | |
319 bra customview_toggle_exit | |
320 | |
321 customview_init_view3: | |
322 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
323 bra customview_toggle ; Yes, Call next view... | |
324 btfsc FLAG_gauge_mode ; In Gauge mode? | |
325 bra customview_toggle ; Yes, Call next view... | |
326 call TFT_decoplan ; Show decoplan | |
327 bra customview_toggle_exit | |
328 | |
329 customview_init_view4: | |
330 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
331 bra customview_toggle ; Yes, Call next view... | |
332 btfsc FLAG_gauge_mode ; In Gauge mode? | |
333 bra customview_toggle ; Yes, Call next view... | |
334 call TFT_ead_end_tissues_clock_mask ; Setup Mask | |
335 call TFT_ead_end_tissues_clock ; Show EAD/END, Tissues and clock | |
336 bra customview_toggle_exit | |
337 | |
338 customview_init_view5: | |
339 btfsc FLAG_apnoe_mode ; In Apnoe mode? | |
340 bra customview_toggle ; Yes, Call next view... | |
341 btfsc FLAG_gauge_mode ; In Gauge mode? | |
342 bra customview_toggle ; Yes, Call next view... | |
343 call TFT_gf_mask ; Setup Mask | |
344 call TFT_gf_info ; Show GF informations | |
345 bra customview_toggle_exit | |
346 | |
347 customview_init_view6: ; Compass (View 6) | |
348 call I2C_init_accelerometer ; Start accelerometer | |
349 call I2C_init_compass ; Start compass | |
350 call TFT_dive_compass_mask ; Show compass | |
351 bra customview_toggle_exit | |
352 | |
353 customview_toggle_exit: | |
354 call TFT_standard_color | |
355 bcf toggle_customview ; Clear flag | |
356 return | |
357 | |
358 global customview_show_change_depth | |
359 customview_show_change_depth: ; Put " lom" or " loft" into Postinc2 | |
360 PUTC " " | |
361 TSTOSS opt_units ; 0=m, 1=ft | |
362 bra customview_show_mix_metric | |
363 movf lo,W | |
364 mullw .100 ; convert meters to mbar | |
365 movff PRODL,lo | |
366 movff PRODH,hi | |
367 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet | |
368 bsf leftbind | |
369 output_16 ; Change depth in lo:hi | |
370 bcf leftbind | |
371 STRCAT_TEXT tFeets | |
372 return | |
373 customview_show_mix_metric: | |
374 output_99 ; Change depth in lo | |
375 STRCAT_TEXT tMeters | |
376 return | |
377 | |
378 | |
379 global customview_show_mix | |
380 customview_show_mix: ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2 | |
381 tstfsz hi ; He=0? | |
382 bra customview_show_mix5 ; No, Show a TX | |
383 movlw .21 | |
384 cpfseq lo ; Air? | |
385 bra customview_show_mix2 ; No | |
386 STRCAT_TEXT tSelectAir ; Yes, show "Air" | |
387 bra customview_show_mix4b | |
388 customview_show_mix2: | |
389 movlw .100 | |
390 cpfseq lo ; O2? | |
391 bra customview_show_mix3 ; No | |
392 STRCAT_TEXT tSelectO2 ; Yes, show "O2" | |
393 bra customview_show_mix4b | |
394 | |
395 customview_show_mix3: | |
396 movlw .21 | |
397 cpfslt lo ; < Nx21? | |
398 bra customview_show_mix4 ; No | |
399 STRCAT_TEXT tGasErr ; Yes, show "Err" | |
400 output_99 ; O2 ratio is still in "lo" | |
401 bra customview_show_mix4c | |
402 | |
403 customview_show_mix4: | |
404 STRCAT_TEXT tSelectNx ; Show "Nx" | |
405 output_99 ; O2 ratio is still in "lo" | |
406 customview_show_mix4b: | |
407 STRCAT " " | |
408 customview_show_mix4c: | |
409 btfsc divemode ; In divemode | |
410 return ; Yes | |
411 STRCAT " " | |
412 return | |
413 | |
414 customview_show_mix5: | |
415 btfsc divemode | |
416 bra customview_show_mix6 | |
417 STRCAT_TEXT tSelectTx ; Show "Tx" | |
418 customview_show_mix6: | |
419 output_99 ; O2 ratio is still in "lo" | |
420 PUTC "/" | |
421 movff hi,lo | |
422 output_99 ; He ratio | |
423 return | |
424 | |
425 END |