comparison code_part1/OSTC_code_asm_part1/menu_ppO2.asm @ 0:96a35aeda5f2

Initial setup
author heinrichsweikamp
date Tue, 12 Jan 2010 15:05:59 +0100
parents
children 6a94f96e9cea
comparison
equal deleted inserted replaced
-1:000000000000 0:96a35aeda5f2
1
2 ; OSTC - diving computer code
3 ; Copyright (C) 2008 HeinrichsWeikamp GbR
4
5 ; This program is free software: you can redistribute it and/or modify
6 ; it under the terms of the GNU General Public License as published by
7 ; the Free Software Foundation, either version 3 of the License, or
8 ; (at your option) any later version.
9
10 ; This program is distributed in the hope that it will be useful,
11 ; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 ; GNU General Public License for more details.
14
15 ; You should have received a copy of the GNU General Public License
16 ; along with this program. If not, see <http://www.gnu.org/licenses/>.
17
18
19 ; Constant ppO2 Setup menu
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
21 ; written: 08/04/04
22 ; last updated: 080904
23 ; known bugs:
24 ; ToDo:
25
26 menu_const_ppO2:
27 movlw d'1'
28 movwf menupos
29
30 bcf menubit4
31 bcf cursor
32 bcf sleepmode
33 clrf decodata+0 ; Here: # of SP
34 bcf first_FA ; Here: =1: -, =0: +
35 bcf second_FA ; Here: =1: 1, =0: 10 steps
36
37 menu_const_ppO20:
38 call PLED_ClearScreen
39 call PLED_topline_box
40
41 WIN_INVERT .1 ; Init new Wordprocessor
42 DISPLAYTEXT .111 ; Constant ppO2 Setup
43 WIN_INVERT .0 ; Init new Wordprocessor
44
45
46 menu_const_ppO21:
47 clrf timeout_counter2
48 bcf menubit2
49 bcf menubit3
50
51 WIN_LEFT .20
52 WIN_TOP .35
53 lfsr FSR2,letter
54 OUTPUTTEXT .112 ; SP#
55 movff decodata+0,lo
56 incf lo,F
57 bsf leftbind
58 output_99
59 movlw ' '
60 movwf POSTINC2
61 movlw '('
62 movwf POSTINC2
63
64 OUTPUTTEXT d'192' ; Dil.
65 movlw ' '
66 movwf POSTINC2
67
68 read_int_eeprom d'33' ; Read byte (stored in EEDATA)
69 movff EEDATA,active_gas ; Read start gas (1-5)
70
71 decf active_gas,W ; Gas 0-4
72 mullw d'4'
73 movf PRODL,W
74 addlw d'6' ; = address for O2 ratio
75 movwf EEADR
76 call read_eeprom ; Read O2 ratio
77 movff EEDATA, lo ; O2 ratio
78
79
80 bsf leftbind
81 output_99
82
83 movlw '/'
84 movwf POSTINC2
85
86 decf active_gas,W ; Gas 0-4
87 mullw d'4'
88 movf PRODL,W
89 addlw d'7' ; = address for He ratio
90 movwf EEADR
91 call read_eeprom ; Read He ratio
92 movff EEDATA,lo ; And copy into hold register
93
94 bsf leftbind
95 output_99
96 movlw ')'
97 movwf POSTINC2
98 call word_processor
99
100
101 WIN_LEFT .20
102 WIN_TOP .65
103
104 lfsr FSR2,letter
105 OUTPUTTEXT .97 ; "Current: "
106 movf decodata+0,W
107 addlw d'36' ; offset in eeprom
108 movwf EEADR
109 call read_eeprom ; ppO2 value
110 movff EEDATA,lo
111 clrf hi
112 bsf leftbind
113 output_16dp d'3'
114 bcf leftbind
115 movlw 'B'
116 movwf POSTINC2
117 movlw 'a'
118 movwf POSTINC2
119 movlw 'r'
120 movwf POSTINC2
121 movlw ' '
122 movwf POSTINC2
123 call word_processor
124
125 WIN_LEFT .20
126 WIN_TOP .95
127
128 lfsr FSR2,letter
129 OUTPUTTEXT d'190' ; ppO2 +
130 call word_processor
131
132 WIN_LEFT .20
133 WIN_TOP .125
134
135 lfsr FSR2,letter
136 OUTPUTTEXT d'191' ; ppO2 -
137 call word_processor
138
139 WIN_LEFT .20
140 WIN_TOP .155
141
142 lfsr FSR2,letter
143 OUTPUTTEXT .89 ; "Default: "
144 movlw '1'
145 movwf POSTINC2
146 movlw '.'
147 movwf POSTINC2
148 movlw '0'
149 movwf POSTINC2
150 movlw '0'
151 movwf POSTINC2
152 call word_processor
153
154 DISPLAYTEXT .11 ; Exit
155 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
156 call PLED_menu_cursor
157
158 menu_const_ppO2_loop:
159 call check_switches_logbook
160
161 btfsc menubit3
162 bra menu_const_ppO22 ; move cursor
163
164 btfsc menubit2
165 bra do_menu_const_ppO2 ; call submenu
166
167 btfsc divemode
168 goto restart ; dive started!
169
170 btfsc onesecupdate
171 call timeout_surfmode
172
173 btfsc onesecupdate
174 call set_dive_modes
175
176 bcf onesecupdate ; 1 sec. functions done
177
178 btfsc sleepmode
179 bra exit_menu_const_ppO2
180
181 bra menu_const_ppO2_loop
182
183 menu_const_ppO22:
184 incf menupos,F
185
186 movlw d'2'
187 cpfseq menupos ; =2?
188 bra menu_const_ppO22a ; No
189 incf menupos,F ; Skip pos. 2
190
191 menu_const_ppO22a:
192 movlw d'7'
193 cpfseq menupos ; =7?
194 bra menu_const_ppO23 ; No
195 movlw d'1'
196 movwf menupos
197
198 menu_const_ppO23:
199 clrf timeout_counter2
200 call PLED_menu_cursor
201
202 ; debounce switches
203 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
204 bcf menubit3 ; clear flag
205 bra menu_const_ppO2_loop
206
207 do_menu_const_ppO2:
208 dcfsnz menupos,F
209 bra next_ppO2
210 dcfsnz menupos,F
211 bra change_ppo2_plus
212 dcfsnz menupos,F
213 bra change_ppo2_plus
214 dcfsnz menupos,F
215 bra change_ppo2_minus
216 dcfsnz menupos,F
217 bra change_ppo2_reset
218 exit_menu_const_ppO2: ; exit...
219 movlw d'2'
220 movwf menupos
221 goto more_menu2
222
223 change_ppo2_plus:
224 movf decodata+0,W ; read current value
225 addlw d'36' ; offset in memory
226 movwf EEADR
227 call read_eeprom ; Low-value
228 movff EEDATA,lo
229
230 incf lo,F ; increase depth
231 movlw d'251'
232 cpfseq lo
233 bra change_ppo2_plus2
234 movlw d'250'
235 movwf lo
236 change_ppo2_plus2:
237 movff lo,EEDATA ; write result
238 call write_eeprom ; save result in EEPROM
239 movlw d'3'
240 movwf menupos
241 bra menu_const_ppO21
242
243 change_ppo2_minus:
244 movf decodata+0,W ; read current value
245 addlw d'36' ; offset in memory
246 movwf EEADR
247 call read_eeprom ; Low-value
248 movff EEDATA,lo
249
250 decf lo,F ; decrease depth
251 movlw d'255'
252 cpfseq lo
253 bra change_ppo2_minus2
254 movlw d'0'
255 movwf lo
256
257 change_ppo2_minus2:
258 movff lo,EEDATA ; write result
259 call write_eeprom ; save result in EEPROM
260
261 movlw d'4'
262 movwf menupos
263 bra menu_const_ppO21
264
265 change_ppo2_reset: ; reset to 1.00Bar
266 movf decodata+0,W ; read current value
267 addlw d'36' ; offset in memory
268 movwf EEADR
269 movlw d'100'
270 movwf EEDATA
271 call write_eeprom ; save result in EEPROM
272 movlw d'5'
273 movwf menupos
274 bra menu_const_ppO21
275
276 next_ppO2:
277 incf decodata+0,F
278 movlw d'3'
279 cpfseq decodata+0 ; =3?
280 bra next_ppO22
281 clrf decodata+0 ; yes, so reset to zero
282 next_ppO22:
283 movlw d'1'
284 movwf menupos
285 bra menu_const_ppO21