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 ; menu "Set Time"
|
|
20 ; written by: Matthias Heinrichs, info@heinrichsweikamp.com
|
|
21 ; written: 5/19/06
|
|
22 ; last updated: 080904
|
|
23 ; known bugs:
|
|
24 ; ToDo:
|
|
25
|
|
26
|
|
27 menu_settime:
|
|
28 call PLED_ClearScreen
|
|
29
|
|
30 bcf set_minutes
|
|
31 bcf menubit4
|
|
32 bcf cursor
|
|
33 clrf timeout_counter2
|
|
34 bcf menubit2
|
|
35 bcf menubit3
|
|
36 bcf sleepmode
|
|
37 bcf set_year
|
|
38 bcf set_day
|
|
39 bcf set_month
|
|
40 clrf menupos2
|
|
41
|
|
42 call PLED_topline_box
|
|
43 WIN_INVERT .1 ; Init new Wordprocessor
|
|
44 DISPLAYTEXT .29 ; Set Time
|
|
45 WIN_INVERT .0 ; Init new Wordprocessor
|
|
46 DISPLAYTEXT .22 ; Time:
|
|
47 DISPLAYTEXT .23 ; Date:
|
|
48
|
|
49 call set_time_refresh
|
|
50
|
|
51 DISPLAYTEXT .24 ; Set Hours
|
|
52
|
|
53 bcf switch_left
|
|
54 bcf switch_right
|
|
55
|
|
56 settime_loop:
|
|
57 btfsc switch_left
|
|
58 call add_hours_or_minutes_or_date
|
|
59
|
|
60 btfsc switch_right
|
|
61 call set_time_next_or_exit
|
|
62
|
|
63 btfsc menubit4
|
|
64 bra set_time_done
|
|
65
|
|
66 btfsc onesecupdate
|
|
67 call timeout_surfmode
|
|
68
|
|
69 btfsc onesecupdate
|
|
70 call set_dive_modes
|
|
71
|
|
72 bcf onesecupdate
|
|
73
|
|
74 btfsc sleepmode
|
|
75 bra exit_settime
|
|
76
|
|
77 btfsc divemode
|
|
78 goto restart
|
|
79
|
|
80 bra settime_loop
|
|
81
|
|
82 set_time_refresh:
|
|
83 WIN_LEFT .70
|
|
84 WIN_TOP .65
|
|
85 lfsr FSR2,letter
|
|
86 movff hours,lo
|
|
87 output_99x
|
|
88 movlw ':'
|
|
89 movwf POSTINC2
|
|
90 movff mins,lo
|
|
91 output_99x
|
|
92 movlw ' '
|
|
93 movwf POSTINC2
|
|
94 movlw ' '
|
|
95 movwf POSTINC2
|
|
96 call word_processor
|
|
97
|
|
98 set_date_refresh:
|
|
99 WIN_LEFT .70
|
|
100 WIN_TOP .95
|
|
101 lfsr FSR2,letter
|
|
102 movff month,convert_value_temp+0
|
|
103 movff day,convert_value_temp+1
|
|
104 movff year,convert_value_temp+2
|
|
105 call PLED_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
|
|
106 movlw ' '
|
|
107 movwf POSTINC2
|
|
108 movlw ' '
|
|
109 movwf POSTINC2
|
|
110 call word_processor
|
|
111 return
|
|
112
|
|
113
|
|
114 set_time_done: ; Check date
|
|
115 movff month,lo ; new month
|
|
116 dcfsnz lo,F
|
|
117 movlw .31
|
|
118 dcfsnz lo,F
|
|
119 movlw .28
|
|
120 dcfsnz lo,F
|
|
121 movlw .31
|
|
122 dcfsnz lo,F
|
|
123 movlw .30
|
|
124 dcfsnz lo,F
|
|
125 movlw .31
|
|
126 dcfsnz lo,F
|
|
127 movlw .30
|
|
128 dcfsnz lo,F
|
|
129 movlw .31
|
|
130 dcfsnz lo,F
|
|
131 movlw .31
|
|
132 dcfsnz lo,F
|
|
133 movlw .30
|
|
134 dcfsnz lo,F
|
|
135 movlw .31
|
|
136 dcfsnz lo,F
|
|
137 movlw .30
|
|
138 dcfsnz lo,F
|
|
139 movlw .31
|
|
140 cpfsgt day ; day ok?
|
|
141 bra set_time_done2 ; OK
|
|
142 movlw .1 ; not OK, set to 1st
|
|
143 movwf day
|
|
144
|
|
145 set_time_done2:
|
|
146 WIN_LEFT .32
|
|
147 WIN_TOP .155
|
|
148 movlw d'8'
|
|
149 movwf temp1
|
|
150 call PLED_display_clear_common_y1
|
|
151
|
|
152 movlw d'5'
|
|
153 movwf wait_temp
|
|
154 clrf secs
|
|
155 bcf onesecupdate
|
|
156
|
|
157 set_time_done_loop
|
|
158 btfss onesecupdate
|
50
|
159 bra set_time_done_loop
|
0
|
160 bcf onesecupdate
|
|
161
|
|
162 call set_date_refresh
|
|
163
|
|
164 WIN_LEFT .70
|
|
165 WIN_TOP .65
|
|
166 lfsr FSR2,letter
|
|
167 movff hours,lo
|
|
168 output_99x
|
|
169 movlw ':'
|
|
170 movwf POSTINC2
|
|
171 movff mins,lo
|
|
172 output_99x
|
|
173 movlw ':'
|
|
174 movwf POSTINC2
|
|
175 movff secs,lo
|
|
176 output_99x
|
|
177 movlw ' '
|
|
178 movwf POSTINC2
|
|
179 call word_processor
|
|
180
|
|
181 decfsz wait_temp,F
|
|
182 bra set_time_done_loop
|
|
183 exit_settime: ;Exit
|
|
184 movlw d'1'
|
|
185 movwf menupos
|
|
186 goto more_menu2
|
|
187
|
|
188
|
|
189 set_time_next_or_exit:
|
|
190 btfsc set_year
|
|
191 bsf menubit4 ; quit settime
|
|
192 incf menupos2,F
|
|
193 movff menupos2,menupos3
|
|
194
|
|
195 dcfsnz menupos3,F
|
|
196 bsf set_minutes
|
|
197 dcfsnz menupos3,F
|
|
198 bsf set_month
|
|
199 dcfsnz menupos3,F
|
|
200 bsf set_day
|
|
201 dcfsnz menupos3,F
|
|
202 bsf set_year
|
|
203
|
|
204 WIN_LEFT .32
|
|
205 WIN_TOP .155
|
|
206 lfsr FSR2,letter
|
|
207 OUTPUTTEXT .94 ; Set
|
|
208
|
|
209 movff menupos2,menupos3
|
|
210 decfsz menupos3,F
|
|
211 bra set_time_next_or_exit2
|
|
212 OUTPUTTEXT .90 ; Minutes
|
|
213 bra set_time_next_or_exit5
|
|
214 set_time_next_or_exit2:
|
|
215 decfsz menupos3,F
|
|
216 bra set_time_next_or_exit3
|
|
217 OUTPUTTEXT .91 ; Month
|
|
218 bra set_time_next_or_exit5
|
|
219 set_time_next_or_exit3:
|
|
220 decfsz menupos3,F
|
|
221 bra set_time_next_or_exit4
|
|
222 OUTPUTTEXT .92 ; Day
|
|
223 bra set_time_next_or_exit5
|
|
224 set_time_next_or_exit4:
|
|
225 OUTPUTTEXT .93 ; Year
|
|
226
|
|
227 set_time_next_or_exit5:
|
|
228 call word_processor
|
|
229 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
230 return
|
|
231
|
|
232 add_hours_or_minutes_or_date:
|
|
233 bcf switch_right
|
|
234 clrf secs
|
|
235
|
|
236 btfsc set_year
|
50
|
237 bra add_year
|
0
|
238
|
|
239 btfsc set_day
|
50
|
240 bra add_day
|
0
|
241
|
|
242 btfsc set_month
|
50
|
243 bra add_month
|
0
|
244
|
|
245 btfsc set_minutes
|
50
|
246 bra add_minutes
|
|
247 ; Increase hours
|
0
|
248 add_hours:
|
|
249 incf hours,F
|
|
250 movlw d'23'
|
|
251 cpfsgt hours
|
|
252 bra set_time_refresh_x
|
|
253 clrf hours
|
|
254 bra set_time_refresh_x
|
|
255 add_minutes:
|
|
256 incf mins,F
|
|
257 movlw d'59'
|
|
258 cpfsgt mins
|
|
259 bra set_time_refresh_x
|
|
260 clrf mins
|
|
261 bra set_time_refresh_x
|
|
262 add_day:
|
|
263 incf day,F
|
|
264 movlw d'31'
|
|
265 cpfsgt day
|
|
266 bra set_time_refresh_x
|
|
267 movlw d'1'
|
|
268 movwf day
|
|
269 bra set_time_refresh_x
|
|
270 add_month:
|
|
271 incf month,F
|
|
272 movlw d'12'
|
|
273 cpfsgt month
|
|
274 bra set_time_refresh_x
|
|
275 movlw d'1'
|
|
276 movwf month
|
|
277 bra set_time_refresh_x
|
|
278 add_year:
|
|
279 incf year,F
|
|
280 movlw d'20' ; calendar until 2020
|
|
281 cpfsgt year
|
|
282 bra set_time_refresh_x
|
|
283 movlw d'8'
|
|
284 movwf year ; Set Year to 2008
|
|
285
|
|
286 set_time_refresh_x:
|
|
287 call set_time_refresh
|
|
288 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
289 return
|