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
|
123
|
88 PUTC ':'
|
0
|
89 movff mins,lo
|
|
90 output_99x
|
123
|
91 STRCAT_PRINT " "
|
0
|
92
|
|
93 set_date_refresh:
|
|
94 WIN_LEFT .70
|
|
95 WIN_TOP .95
|
|
96 lfsr FSR2,letter
|
|
97 movff month,convert_value_temp+0
|
|
98 movff day,convert_value_temp+1
|
|
99 movff year,convert_value_temp+2
|
|
100 call PLED_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
|
123
|
101 STRCAT_PRINT " "
|
|
102 return
|
0
|
103
|
|
104 set_time_done: ; Check date
|
|
105 movff month,lo ; new month
|
|
106 dcfsnz lo,F
|
|
107 movlw .31
|
|
108 dcfsnz lo,F
|
|
109 movlw .28
|
|
110 dcfsnz lo,F
|
|
111 movlw .31
|
|
112 dcfsnz lo,F
|
|
113 movlw .30
|
|
114 dcfsnz lo,F
|
|
115 movlw .31
|
|
116 dcfsnz lo,F
|
|
117 movlw .30
|
|
118 dcfsnz lo,F
|
|
119 movlw .31
|
|
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 cpfsgt day ; day ok?
|
|
131 bra set_time_done2 ; OK
|
|
132 movlw .1 ; not OK, set to 1st
|
|
133 movwf day
|
|
134
|
|
135 set_time_done2:
|
|
136 WIN_LEFT .32
|
|
137 WIN_TOP .155
|
|
138 movlw d'8'
|
|
139 movwf temp1
|
|
140 call PLED_display_clear_common_y1
|
|
141
|
|
142 movlw d'5'
|
|
143 movwf wait_temp
|
|
144 clrf secs
|
|
145 bcf onesecupdate
|
|
146
|
|
147 set_time_done_loop
|
|
148 btfss onesecupdate
|
50
|
149 bra set_time_done_loop
|
0
|
150 bcf onesecupdate
|
|
151
|
|
152 call set_date_refresh
|
|
153
|
|
154 WIN_LEFT .70
|
|
155 WIN_TOP .65
|
|
156 lfsr FSR2,letter
|
|
157 movff hours,lo
|
|
158 output_99x
|
123
|
159 PUTC ':'
|
0
|
160 movff mins,lo
|
|
161 output_99x
|
123
|
162 PUTC ':'
|
0
|
163 movff secs,lo
|
|
164 output_99x
|
123
|
165 STRCAT_PRINT " "
|
0
|
166
|
|
167 decfsz wait_temp,F
|
|
168 bra set_time_done_loop
|
|
169 exit_settime: ;Exit
|
|
170 movlw d'1'
|
|
171 movwf menupos
|
|
172 goto more_menu2
|
|
173
|
|
174
|
|
175 set_time_next_or_exit:
|
|
176 btfsc set_year
|
|
177 bsf menubit4 ; quit settime
|
|
178 incf menupos2,F
|
|
179 movff menupos2,menupos3
|
|
180
|
|
181 dcfsnz menupos3,F
|
|
182 bsf set_minutes
|
|
183 dcfsnz menupos3,F
|
|
184 bsf set_month
|
|
185 dcfsnz menupos3,F
|
|
186 bsf set_day
|
|
187 dcfsnz menupos3,F
|
|
188 bsf set_year
|
|
189
|
|
190 WIN_LEFT .32
|
|
191 WIN_TOP .155
|
123
|
192 call PLED_standard_color
|
0
|
193 lfsr FSR2,letter
|
|
194 OUTPUTTEXT .94 ; Set
|
|
195
|
|
196 movff menupos2,menupos3
|
|
197 decfsz menupos3,F
|
|
198 bra set_time_next_or_exit2
|
|
199 OUTPUTTEXT .90 ; Minutes
|
|
200 bra set_time_next_or_exit5
|
|
201 set_time_next_or_exit2:
|
|
202 decfsz menupos3,F
|
|
203 bra set_time_next_or_exit3
|
|
204 OUTPUTTEXT .91 ; Month
|
|
205 bra set_time_next_or_exit5
|
|
206 set_time_next_or_exit3:
|
|
207 decfsz menupos3,F
|
|
208 bra set_time_next_or_exit4
|
|
209 OUTPUTTEXT .92 ; Day
|
|
210 bra set_time_next_or_exit5
|
|
211 set_time_next_or_exit4:
|
|
212 OUTPUTTEXT .93 ; Year
|
|
213
|
|
214 set_time_next_or_exit5:
|
|
215 call word_processor
|
|
216 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
217 return
|
|
218
|
|
219 add_hours_or_minutes_or_date:
|
|
220 bcf switch_right
|
|
221 clrf secs
|
|
222
|
|
223 btfsc set_year
|
50
|
224 bra add_year
|
0
|
225
|
|
226 btfsc set_day
|
50
|
227 bra add_day
|
0
|
228
|
|
229 btfsc set_month
|
50
|
230 bra add_month
|
0
|
231
|
|
232 btfsc set_minutes
|
50
|
233 bra add_minutes
|
|
234 ; Increase hours
|
0
|
235 add_hours:
|
|
236 incf hours,F
|
|
237 movlw d'23'
|
|
238 cpfsgt hours
|
|
239 bra set_time_refresh_x
|
|
240 clrf hours
|
|
241 bra set_time_refresh_x
|
|
242 add_minutes:
|
|
243 incf mins,F
|
|
244 movlw d'59'
|
|
245 cpfsgt mins
|
|
246 bra set_time_refresh_x
|
|
247 clrf mins
|
|
248 bra set_time_refresh_x
|
|
249 add_day:
|
|
250 incf day,F
|
|
251 movlw d'31'
|
|
252 cpfsgt day
|
|
253 bra set_time_refresh_x
|
|
254 movlw d'1'
|
|
255 movwf day
|
|
256 bra set_time_refresh_x
|
|
257 add_month:
|
|
258 incf month,F
|
|
259 movlw d'12'
|
|
260 cpfsgt month
|
|
261 bra set_time_refresh_x
|
|
262 movlw d'1'
|
|
263 movwf month
|
|
264 bra set_time_refresh_x
|
|
265 add_year:
|
|
266 incf year,F
|
|
267 movlw d'20' ; calendar until 2020
|
|
268 cpfsgt year
|
|
269 bra set_time_refresh_x
|
53
|
270 movlw d'10'
|
|
271 movwf year ; Set Year to 2010
|
0
|
272
|
|
273 set_time_refresh_x:
|
|
274 call set_time_refresh
|
|
275 call wait_switches ; Waits until switches are released, resets flag if button stays pressed!
|
|
276 return
|