0
|
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
|
123
|
59 STRCAT " ("
|
0
|
60
|
|
61 OUTPUTTEXT d'192' ; Dil.
|
123
|
62 PUTC ' '
|
0
|
63
|
|
64 read_int_eeprom d'33' ; Read byte (stored in EEDATA)
|
|
65 movff EEDATA,active_gas ; Read start gas (1-5)
|
|
66
|
|
67 decf active_gas,W ; Gas 0-4
|
|
68 mullw d'4'
|
|
69 movf PRODL,W
|
|
70 addlw d'6' ; = address for O2 ratio
|
|
71 movwf EEADR
|
|
72 call read_eeprom ; Read O2 ratio
|
|
73 movff EEDATA, lo ; O2 ratio
|
|
74
|
|
75
|
|
76 bsf leftbind
|
|
77 output_99
|
|
78
|
123
|
79 PUTC '/'
|
0
|
80
|
|
81 decf active_gas,W ; Gas 0-4
|
|
82 mullw d'4'
|
|
83 movf PRODL,W
|
|
84 addlw d'7' ; = address for He ratio
|
|
85 movwf EEADR
|
|
86 call read_eeprom ; Read He ratio
|
|
87 movff EEDATA,lo ; And copy into hold register
|
|
88
|
|
89 bsf leftbind
|
|
90 output_99
|
123
|
91 STRCAT_PRINT ")"
|
0
|
92
|
|
93
|
|
94 WIN_LEFT .20
|
|
95 WIN_TOP .65
|
|
96
|
|
97 lfsr FSR2,letter
|
|
98 OUTPUTTEXT .97 ; "Current: "
|
|
99 movf decodata+0,W
|
|
100 addlw d'36' ; offset in eeprom
|
|
101 movwf EEADR
|
|
102 call read_eeprom ; ppO2 value
|
|
103 movff EEDATA,lo
|
|
104 clrf hi
|
|
105 bsf leftbind
|
|
106 output_16dp d'3'
|
|
107 bcf leftbind
|
445
|
108 STRCAT_PRINT TXT_BAR4
|
0
|
109
|
|
110 WIN_LEFT .20
|
|
111 WIN_TOP .95
|
|
112
|
|
113 lfsr FSR2,letter
|
|
114 OUTPUTTEXT d'190' ; ppO2 +
|
|
115 call word_processor
|
|
116
|
|
117 WIN_LEFT .20
|
|
118 WIN_TOP .125
|
|
119
|
|
120 lfsr FSR2,letter
|
|
121 OUTPUTTEXT d'191' ; ppO2 -
|
|
122 call word_processor
|
|
123
|
|
124 WIN_LEFT .20
|
|
125 WIN_TOP .155
|
|
126
|
|
127 lfsr FSR2,letter
|
|
128 OUTPUTTEXT .89 ; "Default: "
|
123
|
129 STRCAT_PRINT "1.00"
|
0
|
130
|
|
131 DISPLAYTEXT .11 ; Exit
|
|
132 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
133 call PLED_menu_cursor
|
|
134
|
|
135 menu_const_ppO2_loop:
|
|
136 call check_switches_logbook
|
|
137
|
|
138 btfsc menubit3
|
575
|
139 bra menu_const_ppO22 ; move cursor
|
0
|
140
|
|
141 btfsc menubit2
|
575
|
142 bra do_menu_const_ppO2 ; call submenu
|
0
|
143
|
|
144 btfsc onesecupdate
|
575
|
145 call menu_check_dive_and_timeout ; "Goto restart" or sets sleepmode flag
|
0
|
146
|
|
147 bcf onesecupdate ; 1 sec. functions done
|
|
148
|
|
149 btfsc sleepmode
|
575
|
150 bra exit_menu_const_ppO2
|
0
|
151
|
575
|
152 bra menu_const_ppO2_loop
|
0
|
153
|
|
154 menu_const_ppO22:
|
|
155 incf menupos,F
|
|
156
|
|
157 movlw d'2'
|
|
158 cpfseq menupos ; =2?
|
|
159 bra menu_const_ppO22a ; No
|
|
160 incf menupos,F ; Skip pos. 2
|
|
161
|
|
162 menu_const_ppO22a:
|
|
163 movlw d'7'
|
|
164 cpfseq menupos ; =7?
|
|
165 bra menu_const_ppO23 ; No
|
|
166 movlw d'1'
|
|
167 movwf menupos
|
|
168
|
|
169 menu_const_ppO23:
|
|
170 clrf timeout_counter2
|
|
171 call PLED_menu_cursor
|
|
172
|
|
173 ; debounce switches
|
|
174 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
175 bcf menubit3 ; clear flag
|
|
176 bra menu_const_ppO2_loop
|
|
177
|
|
178 do_menu_const_ppO2:
|
|
179 dcfsnz menupos,F
|
|
180 bra next_ppO2
|
|
181 dcfsnz menupos,F
|
|
182 bra change_ppo2_plus
|
|
183 dcfsnz menupos,F
|
|
184 bra change_ppo2_plus
|
|
185 dcfsnz menupos,F
|
|
186 bra change_ppo2_minus
|
|
187 dcfsnz menupos,F
|
|
188 bra change_ppo2_reset
|
|
189 exit_menu_const_ppO2: ; exit...
|
|
190 movlw d'2'
|
|
191 movwf menupos
|
|
192 goto more_menu2
|
|
193
|
|
194 change_ppo2_plus:
|
|
195 movf decodata+0,W ; read current value
|
|
196 addlw d'36' ; offset in memory
|
|
197 movwf EEADR
|
|
198 call read_eeprom ; Low-value
|
|
199 movff EEDATA,lo
|
|
200
|
|
201 incf lo,F ; increase depth
|
|
202 movlw d'251'
|
|
203 cpfseq lo
|
|
204 bra change_ppo2_plus2
|
|
205 movlw d'250'
|
|
206 movwf lo
|
|
207 change_ppo2_plus2:
|
|
208 movff lo,EEDATA ; write result
|
|
209 call write_eeprom ; save result in EEPROM
|
|
210 movlw d'3'
|
|
211 movwf menupos
|
|
212 bra menu_const_ppO21
|
|
213
|
|
214 change_ppo2_minus:
|
|
215 movf decodata+0,W ; read current value
|
|
216 addlw d'36' ; offset in memory
|
|
217 movwf EEADR
|
|
218 call read_eeprom ; Low-value
|
|
219 movff EEDATA,lo
|
|
220
|
|
221 decf lo,F ; decrease depth
|
|
222 movlw d'255'
|
|
223 cpfseq lo
|
|
224 bra change_ppo2_minus2
|
|
225 movlw d'0'
|
|
226 movwf lo
|
|
227
|
|
228 change_ppo2_minus2:
|
|
229 movff lo,EEDATA ; write result
|
|
230 call write_eeprom ; save result in EEPROM
|
|
231
|
|
232 movlw d'4'
|
|
233 movwf menupos
|
|
234 bra menu_const_ppO21
|
|
235
|
|
236 change_ppo2_reset: ; reset to 1.00Bar
|
|
237 movf decodata+0,W ; read current value
|
|
238 addlw d'36' ; offset in memory
|
|
239 movwf EEADR
|
|
240 movlw d'100'
|
|
241 movwf EEDATA
|
|
242 call write_eeprom ; save result in EEPROM
|
|
243 movlw d'5'
|
|
244 movwf menupos
|
|
245 bra menu_const_ppO21
|
|
246
|
|
247 next_ppO2:
|
|
248 incf decodata+0,F
|
|
249 movlw d'3'
|
|
250 cpfseq decodata+0 ; =3?
|
|
251 bra next_ppO22
|
|
252 clrf decodata+0 ; yes, so reset to zero
|
|
253 next_ppO22:
|
|
254 movlw d'1'
|
|
255 movwf menupos
|
|
256 bra menu_const_ppO21 |