annotate src/start.asm @ 169:dcf3e08f31ac

CHANGE: Improve internal logbook usability
author heinrichsweikamp
date Mon, 29 Sep 2014 22:26:47 +0200
parents 9b82239fa062
children 669b5d00706d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
heinrichsweikamp
parents:
diff changeset
1 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
2 ;
heinrichsweikamp
parents:
diff changeset
3 ; File start.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Startup subroutines
heinrichsweikamp
parents:
diff changeset
6 ;
heinrichsweikamp
parents:
diff changeset
7 ; Copyright (c) 2011, JD Gascuel, HeinrichsWeikamp, all right reserved.
heinrichsweikamp
parents:
diff changeset
8 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
9 ; HISTORY
heinrichsweikamp
parents:
diff changeset
10 ; 2011-08-06 : [mH] moving from OSTC code
heinrichsweikamp
parents:
diff changeset
11
heinrichsweikamp
parents:
diff changeset
12 #include "ostc3.inc" ; Mandatory header
heinrichsweikamp
parents:
diff changeset
13 #include "ms5541.inc"
heinrichsweikamp
parents:
diff changeset
14 #include "isr.inc"
heinrichsweikamp
parents:
diff changeset
15 #include "shared_definitions.h" ; Mailbox from/to p2_deco.c
heinrichsweikamp
parents:
diff changeset
16 #include "eeprom_rs232.inc"
heinrichsweikamp
parents:
diff changeset
17 #include "math.inc"
heinrichsweikamp
parents:
diff changeset
18 #include "tft.inc"
heinrichsweikamp
parents:
diff changeset
19 #include "surfmode.inc"
heinrichsweikamp
parents:
diff changeset
20 #include "wait.inc"
heinrichsweikamp
parents:
diff changeset
21 #include "rtc.inc"
heinrichsweikamp
parents:
diff changeset
22 #include "external_flash.inc"
heinrichsweikamp
parents:
diff changeset
23 #include "convert.inc"
heinrichsweikamp
parents:
diff changeset
24 #include "strings.inc"
heinrichsweikamp
parents:
diff changeset
25 #include "tft_outputs.inc"
113
heinrichsweikamp
parents: 93
diff changeset
26 #include "adc_lightsensor.inc"
heinrichsweikamp
parents: 93
diff changeset
27 #include "i2c.inc"
0
heinrichsweikamp
parents:
diff changeset
28
heinrichsweikamp
parents:
diff changeset
29 extern init_ostc3
heinrichsweikamp
parents:
diff changeset
30 extern option_restore_all
heinrichsweikamp
parents:
diff changeset
31
heinrichsweikamp
parents:
diff changeset
32 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
33 ; Reset vector: What to do on device wake-up and hard reset.
heinrichsweikamp
parents:
diff changeset
34 ;
heinrichsweikamp
parents:
diff changeset
35 reset_v code 0x00000
heinrichsweikamp
parents:
diff changeset
36 ; goto start
heinrichsweikamp
parents:
diff changeset
37 goto 0x1FF00 ; Bootloader
heinrichsweikamp
parents:
diff changeset
38
heinrichsweikamp
parents:
diff changeset
39 ORG 0x00004 ; Needed for second-level bootloader
heinrichsweikamp
parents:
diff changeset
40 goto start
heinrichsweikamp
parents:
diff changeset
41 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
42 boot CODE
heinrichsweikamp
parents:
diff changeset
43 global start
heinrichsweikamp
parents:
diff changeset
44
heinrichsweikamp
parents:
diff changeset
45 start:
heinrichsweikamp
parents:
diff changeset
46 lfsr FSR0,0x000 ; Clear rambank 0-14
heinrichsweikamp
parents:
diff changeset
47 clear_rambank:
heinrichsweikamp
parents:
diff changeset
48 clrf POSTINC0
heinrichsweikamp
parents:
diff changeset
49 movlw 0x0F
heinrichsweikamp
parents:
diff changeset
50 cpfseq FSR0H ; Bank 14 done?
heinrichsweikamp
parents:
diff changeset
51 bra clear_rambank ; clear...
heinrichsweikamp
parents:
diff changeset
52
heinrichsweikamp
parents:
diff changeset
53 call init_ostc3
heinrichsweikamp
parents:
diff changeset
54 call speed_normal
heinrichsweikamp
parents:
diff changeset
55
heinrichsweikamp
parents:
diff changeset
56 bsf no_sensor_int ; disable sensor interrupt
heinrichsweikamp
parents:
diff changeset
57
heinrichsweikamp
parents:
diff changeset
58 call disable_rs232 ; disable UART module
heinrichsweikamp
parents:
diff changeset
59 ; Air pressure compensation after reset
heinrichsweikamp
parents:
diff changeset
60 call get_calibration_data ; Get calibration data from pressure sensor
heinrichsweikamp
parents:
diff changeset
61 banksel common ; get_calibration_data uses isr_backup
heinrichsweikamp
parents:
diff changeset
62 bcf no_sensor_int ; normal sensor interrupt mode
heinrichsweikamp
parents:
diff changeset
63
113
heinrichsweikamp
parents: 93
diff changeset
64 call piezo_config
10
55dfc8f6093f sensor status on power-on reset
heinrichsweikamp
parents: 0
diff changeset
65 call TFT_DisplayOff ; display off
55dfc8f6093f sensor status on power-on reset
heinrichsweikamp
parents: 0
diff changeset
66 bsf LEDr ; Status LED
0
heinrichsweikamp
parents:
diff changeset
67 bcf pressure_refresh
heinrichsweikamp
parents:
diff changeset
68 ; First pass will not have valid temperature!
heinrichsweikamp
parents:
diff changeset
69 btfss pressure_refresh ; Air pressure compensation
heinrichsweikamp
parents:
diff changeset
70 bra $-2
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 45
diff changeset
71 bcf LEDr
0
heinrichsweikamp
parents:
diff changeset
72 ; Second pass
heinrichsweikamp
parents:
diff changeset
73 bcf pressure_refresh
heinrichsweikamp
parents:
diff changeset
74 btfss pressure_refresh ; Air pressure compensation
heinrichsweikamp
parents:
diff changeset
75 bra $-2
heinrichsweikamp
parents:
diff changeset
76
heinrichsweikamp
parents:
diff changeset
77 clrf rel_pressure+0
heinrichsweikamp
parents:
diff changeset
78 clrf rel_pressure+1
heinrichsweikamp
parents:
diff changeset
79 clrf surface_interval+0
heinrichsweikamp
parents:
diff changeset
80 clrf surface_interval+1
heinrichsweikamp
parents:
diff changeset
81
heinrichsweikamp
parents:
diff changeset
82 SAFE_2BYTE_COPY amb_pressure, last_surfpressure
heinrichsweikamp
parents:
diff changeset
83
heinrichsweikamp
parents:
diff changeset
84 movlw LOW max_surfpressure
heinrichsweikamp
parents:
diff changeset
85 movff WREG,sub_a+0 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
86 movlw HIGH max_surfpressure
heinrichsweikamp
parents:
diff changeset
87 movff WREG,sub_a+1 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
88 movff last_surfpressure+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
89 movff last_surfpressure+1,sub_b+1
heinrichsweikamp
parents:
diff changeset
90 call subU16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
91 btfss neg_flag ; Is 1080mbar < amb_pressure ?
heinrichsweikamp
parents:
diff changeset
92 bra start_copy_pressure ; NO: current airpressure is lower then "allowed" airpressure, ok!
heinrichsweikamp
parents:
diff changeset
93
heinrichsweikamp
parents:
diff changeset
94 ; not ok! Overwrite with max. "allowed" airpressure
heinrichsweikamp
parents:
diff changeset
95 movlw LOW max_surfpressure
heinrichsweikamp
parents:
diff changeset
96 movff WREG,last_surfpressure+0 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
97 movlw HIGH max_surfpressure
heinrichsweikamp
parents:
diff changeset
98 movff WREG,last_surfpressure+1 ; max. "allowed" airpressure in mbar
heinrichsweikamp
parents:
diff changeset
99
heinrichsweikamp
parents:
diff changeset
100 start_copy_pressure:
heinrichsweikamp
parents:
diff changeset
101 movff last_surfpressure+0,last_surfpressure_15min+0
heinrichsweikamp
parents:
diff changeset
102 movff last_surfpressure+1,last_surfpressure_15min+1
heinrichsweikamp
parents:
diff changeset
103 movff last_surfpressure+0,last_surfpressure_30min+0
heinrichsweikamp
parents:
diff changeset
104 movff last_surfpressure+1,last_surfpressure_30min+1 ; Rests all airpressure registers
heinrichsweikamp
parents:
diff changeset
105
heinrichsweikamp
parents:
diff changeset
106 ; reset deco data for surface mode
heinrichsweikamp
parents:
diff changeset
107 movlw d'79'
heinrichsweikamp
parents:
diff changeset
108 movff WREG,char_I_N2_ratio ; 79% N2
heinrichsweikamp
parents:
diff changeset
109 SAFE_2BYTE_COPY amb_pressure,int_I_pres_respiration ; copy for deco routine
heinrichsweikamp
parents:
diff changeset
110 movff int_I_pres_respiration+0,int_I_pres_surface+0 ; copy for desat routine
heinrichsweikamp
parents:
diff changeset
111 movff int_I_pres_respiration+1,int_I_pres_surface+1
heinrichsweikamp
parents:
diff changeset
112
heinrichsweikamp
parents:
diff changeset
113 extern deco_reset
heinrichsweikamp
parents:
diff changeset
114 call deco_reset
heinrichsweikamp
parents:
diff changeset
115 clrf nofly_time+0 ; Reset NoFly
heinrichsweikamp
parents:
diff changeset
116 clrf nofly_time+1
heinrichsweikamp
parents:
diff changeset
117 clrf desaturation_time+0 ; Reset Desat
heinrichsweikamp
parents:
diff changeset
118 clrf desaturation_time+1
133
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
119
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
120 call rtc_init ; init clock
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
121
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
122 movlw HIGH .512 ; =2
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
123 movwf EEADRH
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
124 read_int_eeprom .0
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
125 clrf EEADRH
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
126 movlw 0xAA
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
127 cpfseq EEDATA ; =0xAA
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
128 bra no_deco_restore ; No
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
129
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
130 extern restore_decodata_from_eeprom
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
131 call restore_decodata_from_eeprom ; Reload deco data and date/time from eeprom
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
132
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
133 no_deco_restore:
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
134 call deco_calc_desaturation_time ; calculate desaturation time
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
135 banksel common
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
136 call deco_calc_wo_deco_step_1_min ; calculate deco in surface mode
939f1e83c4c2 BUGFIX: Surface interval was not displayed correctly in some cases
heinrichsweikamp
parents: 113
diff changeset
137 banksel common
0
heinrichsweikamp
parents:
diff changeset
138 bcf menubit ; clear menu flag
heinrichsweikamp
parents:
diff changeset
139 ; Check for Power-on reset here
heinrichsweikamp
parents:
diff changeset
140 extern new_battery_menu
heinrichsweikamp
parents:
diff changeset
141 extern use_old_batteries
heinrichsweikamp
parents:
diff changeset
142
heinrichsweikamp
parents:
diff changeset
143 btfsc RCON,POR ; Was this a power-on reset?
heinrichsweikamp
parents:
diff changeset
144 goto use_old_batteries ; No, load last stored battery values
heinrichsweikamp
parents:
diff changeset
145 ; "new_battery_menu" and "use_old_batteries" 'goto' back to "power_on_return"
heinrichsweikamp
parents:
diff changeset
146
heinrichsweikamp
parents:
diff changeset
147 ; Yes
heinrichsweikamp
parents:
diff changeset
148 goto new_battery_menu ; show "New battery dialog"
heinrichsweikamp
parents:
diff changeset
149 ; "new_battery_menu" and "use_old_batteries" 'goto' back to "power_on_return"
heinrichsweikamp
parents:
diff changeset
150
heinrichsweikamp
parents:
diff changeset
151 global power_on_return
heinrichsweikamp
parents:
diff changeset
152 power_on_return:
heinrichsweikamp
parents:
diff changeset
153 bsf RCON,POR ; Set bit for next detection
heinrichsweikamp
parents:
diff changeset
154
heinrichsweikamp
parents:
diff changeset
155 ; check firmware and reset Custom Functions after an update
heinrichsweikamp
parents:
diff changeset
156 movlw d'1'
heinrichsweikamp
parents:
diff changeset
157 movwf EEADR
heinrichsweikamp
parents:
diff changeset
158 movlw d'1'
heinrichsweikamp
parents:
diff changeset
159 movwf EEADRH
heinrichsweikamp
parents:
diff changeset
160 call read_eeprom ; read current version x
heinrichsweikamp
parents:
diff changeset
161 movff EEDATA,temp1
heinrichsweikamp
parents:
diff changeset
162 incf EEADR,F ; set to 0x102
heinrichsweikamp
parents:
diff changeset
163 call read_eeprom ; read current version y
heinrichsweikamp
parents:
diff changeset
164 movff EEDATA,temp2
heinrichsweikamp
parents:
diff changeset
165 clrf EEADRH ; Reset EEADRH
heinrichsweikamp
parents:
diff changeset
166
heinrichsweikamp
parents:
diff changeset
167 movlw softwareversion_x
heinrichsweikamp
parents:
diff changeset
168 cpfseq temp1 ; compare version x
heinrichsweikamp
parents:
diff changeset
169 bra check_firmware_new ; is not equal -> reset CF and store new version in EEPROM
heinrichsweikamp
parents:
diff changeset
170
heinrichsweikamp
parents:
diff changeset
171 movlw softwareversion_y
heinrichsweikamp
parents:
diff changeset
172 cpfseq temp2 ; compare version y
heinrichsweikamp
parents:
diff changeset
173 bra check_firmware_new ; is not equal -> reset CF and store new version in EEPROM
heinrichsweikamp
parents:
diff changeset
174 bra restart ; x and y are equal -> do not reset cf
heinrichsweikamp
parents:
diff changeset
175
heinrichsweikamp
parents:
diff changeset
176 check_firmware_new:
heinrichsweikamp
parents:
diff changeset
177 call speed_normal
heinrichsweikamp
parents:
diff changeset
178 call TFT_boot ; Initialize TFT (includes clear screen)
heinrichsweikamp
parents:
diff changeset
179 clrf CCPR1L ; Backlight off
heinrichsweikamp
parents:
diff changeset
180 WIN_TOP .50
heinrichsweikamp
parents:
diff changeset
181 WIN_LEFT .10
heinrichsweikamp
parents:
diff changeset
182 movlw LOW 0x1E000
heinrichsweikamp
parents:
diff changeset
183 movwf TBLPTRL
heinrichsweikamp
parents:
diff changeset
184 movlw HIGH 0x1E000
heinrichsweikamp
parents:
diff changeset
185 movwf TBLPTRH
heinrichsweikamp
parents:
diff changeset
186 movlw UPPER 0x1E000
heinrichsweikamp
parents:
diff changeset
187 movwf TBLPTRU
heinrichsweikamp
parents:
diff changeset
188 extern color_image
heinrichsweikamp
parents:
diff changeset
189 call color_image ; Show logo
heinrichsweikamp
parents:
diff changeset
190 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
191 WIN_SMALL .10,.100
52
0fae975af741 english correction
heinrichsweikamp
parents: 50
diff changeset
192 STRCPY_TEXT_PRINT tNewFirmware1 ; "Update successfull!"
0
heinrichsweikamp
parents:
diff changeset
193 WIN_SMALL .10,.140
heinrichsweikamp
parents:
diff changeset
194 STRCPY_TEXT tNewFirmware2 ; "New Firmware: "
heinrichsweikamp
parents:
diff changeset
195 movlw softwareversion_x
heinrichsweikamp
parents:
diff changeset
196 movwf lo
heinrichsweikamp
parents:
diff changeset
197 bsf leftbind
heinrichsweikamp
parents:
diff changeset
198 output_8
heinrichsweikamp
parents:
diff changeset
199 PUTC "."
heinrichsweikamp
parents:
diff changeset
200 movlw softwareversion_y
heinrichsweikamp
parents:
diff changeset
201 movwf lo
45
76dfe320e6ec 1.01 beta start
heinrichsweikamp
parents: 24
diff changeset
202 output_99x
0
heinrichsweikamp
parents:
diff changeset
203 bcf leftbind
heinrichsweikamp
parents:
diff changeset
204 STRCAT_PRINT "" ; Print second row
heinrichsweikamp
parents:
diff changeset
205 call TFT_Display_FadeIn ; Display resulting surface screen.
heinrichsweikamp
parents:
diff changeset
206
heinrichsweikamp
parents:
diff changeset
207 ; place "after-update reset" here...
93
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
208
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
209 extern oPressureAdjust, option_reset, option_save
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
210 lfsr FSR0,oPressureAdjust
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
211 call option_reset ; Reset FSR0 option to factory default.
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
212 lfsr FSR0,oPressureAdjust
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
213 call option_save ; Save in EEPROM
5e1ef9bf32ec clear pressure sensor compensation upon update
heinrichsweikamp
parents: 52
diff changeset
214
0
heinrichsweikamp
parents:
diff changeset
215 movlw d'1' ; store current version in EEPROM
heinrichsweikamp
parents:
diff changeset
216 movwf EEADR
heinrichsweikamp
parents:
diff changeset
217 movlw d'1'
heinrichsweikamp
parents:
diff changeset
218 movwf EEADRH
heinrichsweikamp
parents:
diff changeset
219 movlw softwareversion_x
heinrichsweikamp
parents:
diff changeset
220 movwf EEDATA
heinrichsweikamp
parents:
diff changeset
221 call write_eeprom ; write version x
heinrichsweikamp
parents:
diff changeset
222 incf EEADR,F ; set to 0x102
heinrichsweikamp
parents:
diff changeset
223 movlw softwareversion_y
heinrichsweikamp
parents:
diff changeset
224 movwf EEDATA
heinrichsweikamp
parents:
diff changeset
225 call write_eeprom ; write version y
heinrichsweikamp
parents:
diff changeset
226 clrf EEADRH ; Reset EEADRH
heinrichsweikamp
parents:
diff changeset
227
heinrichsweikamp
parents:
diff changeset
228 movlw .7
heinrichsweikamp
parents:
diff changeset
229 movwf lo
heinrichsweikamp
parents:
diff changeset
230 check_firmware_new2:
heinrichsweikamp
parents:
diff changeset
231 ; Wait 1 second
heinrichsweikamp
parents:
diff changeset
232 bcf onesecupdate
heinrichsweikamp
parents:
diff changeset
233 btfss onesecupdate
heinrichsweikamp
parents:
diff changeset
234 bra $-2
heinrichsweikamp
parents:
diff changeset
235 decfsz lo,F ; Wait 10 seconds...
heinrichsweikamp
parents:
diff changeset
236 bra check_firmware_new2
heinrichsweikamp
parents:
diff changeset
237
heinrichsweikamp
parents:
diff changeset
238 global restart
heinrichsweikamp
parents:
diff changeset
239 restart:
heinrichsweikamp
parents:
diff changeset
240 clrf STKPTR ; Never return from here
21
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 16
diff changeset
241 extern option_save_all, option_check_all
79b2084fd75a Reset options to default if they are not within the allowed min/max values
heinrichsweikamp
parents: 16
diff changeset
242
0
heinrichsweikamp
parents:
diff changeset
243 btfsc menubit ; Return from Menu/COMM mode or timeout?
heinrichsweikamp
parents:
diff changeset
244 call option_save_all ; Yes, save all settings into EEPROM
heinrichsweikamp
parents:
diff changeset
245
23
e402813343b6 new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents: 21
diff changeset
246 call option_check_all ; Check all options (and reset if not within their min/max boundaries)
e402813343b6 new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents: 21
diff changeset
247
0
heinrichsweikamp
parents:
diff changeset
248 clrf flag1 ; clear all flags
heinrichsweikamp
parents:
diff changeset
249 clrf flag2
heinrichsweikamp
parents:
diff changeset
250 clrf flag3
heinrichsweikamp
parents:
diff changeset
251 clrf flag4
heinrichsweikamp
parents:
diff changeset
252 clrf flag5
heinrichsweikamp
parents:
diff changeset
253 clrf flag6
heinrichsweikamp
parents:
diff changeset
254 clrf flag7
heinrichsweikamp
parents:
diff changeset
255 clrf flag8
16
7b06f20881be calm compass reading for minor heading changes
heinrichsweikamp
parents: 10
diff changeset
256 clrf flag9
113
heinrichsweikamp
parents: 93
diff changeset
257 clrf flag10
0
heinrichsweikamp
parents:
diff changeset
258 bsf tft_is_dimming ; TFT is dimming up (soon), ignore ambient sensor!
23
e402813343b6 new option to switch samplingrate between 10s and 2s
heinrichsweikamp
parents: 21
diff changeset
259
113
heinrichsweikamp
parents: 93
diff changeset
260 call lt2942_get_status ; Check for gauge IC
heinrichsweikamp
parents: 93
diff changeset
261 btfsc c3_hardware ; C3 hardware?
heinrichsweikamp
parents: 93
diff changeset
262 call lt2942_init ; Yes, init battery gauge IC
heinrichsweikamp
parents: 93
diff changeset
263
0
heinrichsweikamp
parents:
diff changeset
264 ; Select high altitude (Fly) mode?
heinrichsweikamp
parents:
diff changeset
265 movff last_surfpressure_30min+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
266 movff last_surfpressure_30min+1,sub_b+1
heinrichsweikamp
parents:
diff changeset
267 movlw HIGH high_altitude_threshold
heinrichsweikamp
parents:
diff changeset
268 movwf sub_a+1
heinrichsweikamp
parents:
diff changeset
269 movlw LOW high_altitude_threshold ; Hard-wired 880mbar
heinrichsweikamp
parents:
diff changeset
270 movwf sub_a+0
heinrichsweikamp
parents:
diff changeset
271 call subU16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
272 btfss neg_flag ; Result negative (Ambient>880mbar)?
heinrichsweikamp
parents:
diff changeset
273 bsf high_altitude_mode ; No, Set Flag!
heinrichsweikamp
parents:
diff changeset
274
165
9b82239fa062 testing consumption
heinrichsweikamp
parents: 155
diff changeset
275 btfss c3_hardware
9b82239fa062 testing consumption
heinrichsweikamp
parents: 155
diff changeset
276 bsf TRISB,3
9b82239fa062 testing consumption
heinrichsweikamp
parents: 155
diff changeset
277 btfss c3_hardware
9b82239fa062 testing consumption
heinrichsweikamp
parents: 155
diff changeset
278 bsf TRISG,0
0
heinrichsweikamp
parents:
diff changeset
279 call ext_flash_disable_protection ; Disable write protection for external flash
heinrichsweikamp
parents:
diff changeset
280
155
5f71e31bd5b3 CHANGE: Re-arranged Settings Menu, add 180? rotate to menu
heinrichsweikamp
parents: 154
diff changeset
281 bsf flip_screen ; Flip 180°
5f71e31bd5b3 CHANGE: Re-arranged Settings Menu, add 180? rotate to menu
heinrichsweikamp
parents: 154
diff changeset
282 TSTOSS opt_flip_screen ; =1: Flip the screen
5f71e31bd5b3 CHANGE: Re-arranged Settings Menu, add 180? rotate to menu
heinrichsweikamp
parents: 154
diff changeset
283 bcf flip_screen ; Normal orientation
151
5cb177f0948a work on flip screen...
heinrichsweikamp
parents: 147
diff changeset
284
0
heinrichsweikamp
parents:
diff changeset
285 goto surfloop ; Jump to Surfaceloop!
heinrichsweikamp
parents:
diff changeset
286
heinrichsweikamp
parents:
diff changeset
287 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
288 ; Setup all flags and parameters for divemode and simulator computations.
heinrichsweikamp
parents:
diff changeset
289 ;
heinrichsweikamp
parents:
diff changeset
290 global restart_set_modes_and_flags
heinrichsweikamp
parents:
diff changeset
291 restart_set_modes_and_flags: ; "Call"ed from divemode, as well!
heinrichsweikamp
parents:
diff changeset
292 call option_restore_all ; Restore everything from EEPROM
24
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
293
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
294 ; Setup sampling rate
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
295 movlw .2
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
296 movwf samplingrate
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
297 TSTOSS opt_sampling_rate ; =1: 10s, =0: 2s
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
298 bra restart_set_modes_and_flags1
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
299 movlw .10
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
300 movwf samplingrate
f51caad821b4 save logbook recording interval
heinrichsweikamp
parents: 23
diff changeset
301 restart_set_modes_and_flags1:
0
heinrichsweikamp
parents:
diff changeset
302 movff opt_dive_mode,lo ; 0=OC, 1=CC, 2=Gauge, 3=Apnea
heinrichsweikamp
parents:
diff changeset
303
heinrichsweikamp
parents:
diff changeset
304 bcf FLAG_apnoe_mode
heinrichsweikamp
parents:
diff changeset
305 bcf FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
heinrichsweikamp
parents:
diff changeset
306 bcf FLAG_gauge_mode ; =1: In Gauge mode
heinrichsweikamp
parents:
diff changeset
307 call disable_ir ; IR off
heinrichsweikamp
parents:
diff changeset
308
heinrichsweikamp
parents:
diff changeset
309 tstfsz lo
heinrichsweikamp
parents:
diff changeset
310 bra restart_set_modes_and_flags2
heinrichsweikamp
parents:
diff changeset
311 ; OC Mode
heinrichsweikamp
parents:
diff changeset
312 return
heinrichsweikamp
parents:
diff changeset
313
heinrichsweikamp
parents:
diff changeset
314 restart_set_modes_and_flags2:
heinrichsweikamp
parents:
diff changeset
315 decfsz lo,F
heinrichsweikamp
parents:
diff changeset
316 bra restart_set_modes_and_flags3
heinrichsweikamp
parents:
diff changeset
317 ; CC Mode
heinrichsweikamp
parents:
diff changeset
318 bsf FLAG_ccr_mode ; =1: CCR mode (Fixed ppO2 or Sensor) active
heinrichsweikamp
parents:
diff changeset
319 call enable_ir ; Enable IR-Port
heinrichsweikamp
parents:
diff changeset
320 return
heinrichsweikamp
parents:
diff changeset
321
heinrichsweikamp
parents:
diff changeset
322 restart_set_modes_and_flags3:
heinrichsweikamp
parents:
diff changeset
323 decfsz lo,F
heinrichsweikamp
parents:
diff changeset
324 bra restart_set_modes_and_flags4
heinrichsweikamp
parents:
diff changeset
325 ; Gauge Mode
heinrichsweikamp
parents:
diff changeset
326 bsf FLAG_gauge_mode ; =1: In Gauge mode
heinrichsweikamp
parents:
diff changeset
327 return
heinrichsweikamp
parents:
diff changeset
328
heinrichsweikamp
parents:
diff changeset
329 restart_set_modes_and_flags4:
heinrichsweikamp
parents:
diff changeset
330 ; Apnea Mode
heinrichsweikamp
parents:
diff changeset
331 bsf FLAG_apnoe_mode
heinrichsweikamp
parents:
diff changeset
332 return ; start in Surfacemode
heinrichsweikamp
parents:
diff changeset
333
heinrichsweikamp
parents:
diff changeset
334 END