annotate src/logbook.asm @ 102:37275e0fa7f5

NEW: Show End-of-Dive time together with clock during deco
author heinrichsweikamp
date Wed, 07 May 2014 14:57:58 +0200
parents 87cc1adfe4da
children f3062a611eef
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 logbook.asm
heinrichsweikamp
parents:
diff changeset
4 ;
heinrichsweikamp
parents:
diff changeset
5 ; Logbook
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-11-12 : [mH] moving from OSTC code
heinrichsweikamp
parents:
diff changeset
11
heinrichsweikamp
parents:
diff changeset
12 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
13 ; Temp data, local to this module, moved to ACCES0 area.
heinrichsweikamp
parents:
diff changeset
14 ;
heinrichsweikamp
parents:
diff changeset
15
heinrichsweikamp
parents:
diff changeset
16 #include "ostc3.inc" ; Mandatory header
heinrichsweikamp
parents:
diff changeset
17 #include "tft.inc"
heinrichsweikamp
parents:
diff changeset
18 #include "external_flash.inc"
heinrichsweikamp
parents:
diff changeset
19 #include "math.inc"
heinrichsweikamp
parents:
diff changeset
20 #include "strings.inc"
heinrichsweikamp
parents:
diff changeset
21 #include "convert.inc"
heinrichsweikamp
parents:
diff changeset
22 #include "tft_outputs.inc"
heinrichsweikamp
parents:
diff changeset
23 #include "eeprom_rs232.inc"
heinrichsweikamp
parents:
diff changeset
24 #include "menu_processor.inc"
heinrichsweikamp
parents:
diff changeset
25 #include "wait.inc"
heinrichsweikamp
parents:
diff changeset
26 #include "start.inc"
heinrichsweikamp
parents:
diff changeset
27 #include "surfmode.inc"
heinrichsweikamp
parents:
diff changeset
28 #include "divemode.inc"
heinrichsweikamp
parents:
diff changeset
29 #include "ghostwriter.inc"
heinrichsweikamp
parents:
diff changeset
30
66
00636132cca6 BUGFIX: Maintain last selected customview in surface mode
heinrichsweikamp
parents: 50
diff changeset
31 extern do_main_menu2,comm_mode
0
heinrichsweikamp
parents:
diff changeset
32
heinrichsweikamp
parents:
diff changeset
33 CBLOCK tmp+0x40 ; Keep space for menu processor.
heinrichsweikamp
parents:
diff changeset
34 count_temperature ; Current sample count for temperature divisor
heinrichsweikamp
parents:
diff changeset
35 count_deco ; Current sample count for deco (ceiling) divisor
heinrichsweikamp
parents:
diff changeset
36 logbook_cur_depth:2 ; Current depth, for drawing profile.
heinrichsweikamp
parents:
diff changeset
37 logbook_cur_tp:2 ; Current temperature, for drawing profile.
heinrichsweikamp
parents:
diff changeset
38 logbook_last_tp ; Y of the last item in Tp° curve.
heinrichsweikamp
parents:
diff changeset
39 logbook_min_tp:2 ; Min temperature, for drawing profile.
heinrichsweikamp
parents:
diff changeset
40 logbook_max_tp:2 ; Maximum temperature, for drawing profile.
heinrichsweikamp
parents:
diff changeset
41 logbook_ceiling ; Current ceiling, for drawing profile.
heinrichsweikamp
parents:
diff changeset
42 logbook_flags ; Flags only used in logbook.asm
heinrichsweikamp
parents:
diff changeset
43 logbook_page_number ; Page# in logbook
heinrichsweikamp
parents:
diff changeset
44 logbook_divenumber ; # of dive in list during search
heinrichsweikamp
parents:
diff changeset
45 logbook_divenumber_temp ; # of dive in list during search
heinrichsweikamp
parents:
diff changeset
46 logbook_menupos_temp ; Last position of cursor
heinrichsweikamp
parents:
diff changeset
47 profile_temp:2 ; Temp for profile display
heinrichsweikamp
parents:
diff changeset
48 profile_temp2:2 ; Temp for profile display
heinrichsweikamp
parents:
diff changeset
49 logbook_max_dive_counter ; Counts dive# to zero
heinrichsweikamp
parents:
diff changeset
50 logbook_max_dive_counter_temp; Counts dive# to zero
heinrichsweikamp
parents:
diff changeset
51 logbook_sample_counter:2 ; Amount of read samples
heinrichsweikamp
parents:
diff changeset
52 divemins_backup ; Backup of divemins+0
heinrichsweikamp
parents:
diff changeset
53 y_scale:2 ; y-scale (The horizontal lines)
heinrichsweikamp
parents:
diff changeset
54 x_scale:2 ; x-scale (The vertical lines)
heinrichsweikamp
parents:
diff changeset
55 logbook_pixel_x_pos ; x2 position of current pixel in X-direction
heinrichsweikamp
parents:
diff changeset
56 ; Reserved to tmp+0x5F
heinrichsweikamp
parents:
diff changeset
57 ENDC
heinrichsweikamp
parents:
diff changeset
58
heinrichsweikamp
parents:
diff changeset
59 #DEFINE return_from_profileview logbook_flags,0
heinrichsweikamp
parents:
diff changeset
60 #DEFINE all_dives_shown logbook_flags,1
heinrichsweikamp
parents:
diff changeset
61 #DEFINE logbook_page_not_empty logbook_flags,2
heinrichsweikamp
parents:
diff changeset
62 #DEFINE end_of_profile logbook_flags,3
heinrichsweikamp
parents:
diff changeset
63
heinrichsweikamp
parents:
diff changeset
64
heinrichsweikamp
parents:
diff changeset
65 ; Logbook Coordinates
heinrichsweikamp
parents:
diff changeset
66 #DEFINE logbook_list_left .18 ; Column of dive# in list
heinrichsweikamp
parents:
diff changeset
67 #DEFINE logbook_row_offset .28 ; Distance between rows of list
heinrichsweikamp
parents:
diff changeset
68 #DEFINE logbook_row_number .6 ; Amount of rows in the list
heinrichsweikamp
parents:
diff changeset
69
heinrichsweikamp
parents:
diff changeset
70 ; Profile display
heinrichsweikamp
parents:
diff changeset
71 #DEFINE profile_height_pixels .157 ; Amount of pixels height for profile display
heinrichsweikamp
parents:
diff changeset
72 #DEFINE profile_width_pixels .156 ; Amount of pixels width for profile display
heinrichsweikamp
parents:
diff changeset
73 #DEFINE profile_left .1 ; Left border
heinrichsweikamp
parents:
diff changeset
74 #DEFINE profile_top .65 ; Top border
heinrichsweikamp
parents:
diff changeset
75
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
76 ; "Bailout"
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
77 #DEFINE logbook_bailout_column .124
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
78 #DEFINE logbook_bailout_row .207
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
79
0
heinrichsweikamp
parents:
diff changeset
80 ; Dive number
heinrichsweikamp
parents:
diff changeset
81 #DEFINE logbook_divenumer_column .1
heinrichsweikamp
parents:
diff changeset
82 #DEFINE logbook_divenumer_row .1
heinrichsweikamp
parents:
diff changeset
83 ; Date and Time
heinrichsweikamp
parents:
diff changeset
84 #DEFINE logbook_date_column .100
heinrichsweikamp
parents:
diff changeset
85 #DEFINE logbook_date_row .7
heinrichsweikamp
parents:
diff changeset
86 #DEFINE logbook_time_column .120
heinrichsweikamp
parents:
diff changeset
87 #DEFINE logbook_time_row .33
heinrichsweikamp
parents:
diff changeset
88 ; Max. Depth
heinrichsweikamp
parents:
diff changeset
89 #DEFINE log_max_value_row .38
heinrichsweikamp
parents:
diff changeset
90 #DEFINE log_max_value_column .1
heinrichsweikamp
parents:
diff changeset
91 ; Divetime
heinrichsweikamp
parents:
diff changeset
92 #DEFINE log_divetime_value_row .38
heinrichsweikamp
parents:
diff changeset
93 #DEFINE log_divetime_value_column .65
heinrichsweikamp
parents:
diff changeset
94 ; Gaslist below profile
heinrichsweikamp
parents:
diff changeset
95 #DEFINE log_gas_row .225
heinrichsweikamp
parents:
diff changeset
96 #DEFINE log_gas_column1 .0
heinrichsweikamp
parents:
diff changeset
97 #DEFINE log_gas_column2 log_gas_column1+(.1*.32)
heinrichsweikamp
parents:
diff changeset
98 #DEFINE log_gas_column3 log_gas_column1+(.2*.32)
heinrichsweikamp
parents:
diff changeset
99 #DEFINE log_gas_column4 log_gas_column1+(.3*.32)
heinrichsweikamp
parents:
diff changeset
100 #DEFINE log_gas_column5 log_gas_column1+(.4*.32)
heinrichsweikamp
parents:
diff changeset
101
heinrichsweikamp
parents:
diff changeset
102 ; Logbook Page2
heinrichsweikamp
parents:
diff changeset
103 ; Gaslist
heinrichsweikamp
parents:
diff changeset
104 #DEFINE log2_title_row1 .20
heinrichsweikamp
parents:
diff changeset
105 #DEFINE log2_title_column .90
heinrichsweikamp
parents:
diff changeset
106 #DEFINE log2_gas_column log2_title_column
heinrichsweikamp
parents:
diff changeset
107 #DEFINE log2_gas_row1 .36
heinrichsweikamp
parents:
diff changeset
108 #DEFINE log2_gas_row2 1*.16+log2_gas_row1
heinrichsweikamp
parents:
diff changeset
109 #DEFINE log2_gas_row3 2*.16+log2_gas_row1
heinrichsweikamp
parents:
diff changeset
110 #DEFINE log2_gas_row4 3*.16+log2_gas_row1
heinrichsweikamp
parents:
diff changeset
111 #DEFINE log2_gas_row5 4*.16+log2_gas_row1
heinrichsweikamp
parents:
diff changeset
112
heinrichsweikamp
parents:
diff changeset
113 ; Setpoint List
heinrichsweikamp
parents:
diff changeset
114 #DEFINE log2_title_sp_row .130
heinrichsweikamp
parents:
diff changeset
115 #DEFINE log2_sp_row1 .146
heinrichsweikamp
parents:
diff changeset
116 #DEFINE log2_sp_row2 1*.16+log2_sp_row1
heinrichsweikamp
parents:
diff changeset
117 #DEFINE log2_sp_row3 2*.16+log2_sp_row1
heinrichsweikamp
parents:
diff changeset
118 #DEFINE log2_sp_row4 3*.16+log2_sp_row1
heinrichsweikamp
parents:
diff changeset
119 #DEFINE log2_sp_row5 4*.16+log2_sp_row1
heinrichsweikamp
parents:
diff changeset
120
heinrichsweikamp
parents:
diff changeset
121 ; Details list
heinrichsweikamp
parents:
diff changeset
122 #DEFINE log2_salinity_row .55
heinrichsweikamp
parents:
diff changeset
123 #DEFINE log2_salinity_column .2
heinrichsweikamp
parents:
diff changeset
124 #DEFINE log2_cns_row .1*.16+log2_salinity_row
heinrichsweikamp
parents:
diff changeset
125 #DEFINE log2_cns_column log2_salinity_column
heinrichsweikamp
parents:
diff changeset
126 #DEFINE log2_avr_row .2*.16+log2_salinity_row
heinrichsweikamp
parents:
diff changeset
127 #DEFINE log2_avr_column log2_salinity_column
heinrichsweikamp
parents:
diff changeset
128 #DEFINE log2_decomodel2_row .3*.16+log2_salinity_row
heinrichsweikamp
parents:
diff changeset
129 #DEFINE log2_decomodel2_column log2_salinity_column
heinrichsweikamp
parents:
diff changeset
130 #DEFINE log2_decomodel3_row .4*.16+log2_salinity_row
heinrichsweikamp
parents:
diff changeset
131 #DEFINE log2_decomodel3_column log2_salinity_column
heinrichsweikamp
parents:
diff changeset
132 #DEFINE log2_decomodel_row .5*.16+log2_salinity_row
heinrichsweikamp
parents:
diff changeset
133 #DEFINE log2_decomodel_column log2_salinity_column
heinrichsweikamp
parents:
diff changeset
134 #DEFINE log2_firmware_row .6*.16+log2_salinity_row
heinrichsweikamp
parents:
diff changeset
135 #DEFINE log2_firmware_column log2_salinity_column
heinrichsweikamp
parents:
diff changeset
136 #DEFINE log2_battery_row .7*.16+log2_salinity_row
heinrichsweikamp
parents:
diff changeset
137 #DEFINE log2_battery_column log2_salinity_column
heinrichsweikamp
parents:
diff changeset
138 #DEFINE log2_divemode_row .8*.16+log2_salinity_row
heinrichsweikamp
parents:
diff changeset
139 #DEFINE log2_divemode_column log2_salinity_column
heinrichsweikamp
parents:
diff changeset
140 #DEFINE log2_lastdeco_row .9*.16+log2_salinity_row
heinrichsweikamp
parents:
diff changeset
141 #DEFINE log2_lastdeco_column log2_salinity_column
heinrichsweikamp
parents:
diff changeset
142 ; Air pressure
heinrichsweikamp
parents:
diff changeset
143 #DEFINE MBAR_row .10*.16+log2_salinity_row
heinrichsweikamp
parents:
diff changeset
144 #DEFINE MBAR_column log2_salinity_column
heinrichsweikamp
parents:
diff changeset
145
heinrichsweikamp
parents:
diff changeset
146
heinrichsweikamp
parents:
diff changeset
147 ; Header coordinates
heinrichsweikamp
parents:
diff changeset
148 #DEFINE log_date .12
heinrichsweikamp
parents:
diff changeset
149 #DEFINE log_time .15
heinrichsweikamp
parents:
diff changeset
150 #DEFINE log_max_depth .17
heinrichsweikamp
parents:
diff changeset
151 #DEFINE log_divetime .19
heinrichsweikamp
parents:
diff changeset
152 #DEFINE log_min_temp .22
heinrichsweikamp
parents:
diff changeset
153 #DEFINE log_surface_press .24
heinrichsweikamp
parents:
diff changeset
154 #DEFINE log_desattime .26
heinrichsweikamp
parents:
diff changeset
155 #DEFINE log_gas1 .28
heinrichsweikamp
parents:
diff changeset
156 #DEFINE log_gas2 .32
heinrichsweikamp
parents:
diff changeset
157 #DEFINE log_gas3 .36
heinrichsweikamp
parents:
diff changeset
158 #DEFINE log_gas4 .40
heinrichsweikamp
parents:
diff changeset
159 #DEFINE log_gas5 .44
heinrichsweikamp
parents:
diff changeset
160 #DEFINE log_firmware .48
heinrichsweikamp
parents:
diff changeset
161 #DEFINE log_battery .50
heinrichsweikamp
parents:
diff changeset
162 #DEFINE log_samplingrate .52
heinrichsweikamp
parents:
diff changeset
163 #DEFINE log_cns_start .53
heinrichsweikamp
parents:
diff changeset
164 #DEFINE log_gf_start .55
heinrichsweikamp
parents:
diff changeset
165 #DEFINE log_gf_end .56
heinrichsweikamp
parents:
diff changeset
166 #DEFINE log_sp1 .60
heinrichsweikamp
parents:
diff changeset
167 #DEFINE log_sp2 .62
heinrichsweikamp
parents:
diff changeset
168 #DEFINE log_sp3 .64
heinrichsweikamp
parents:
diff changeset
169 #DEFINE log_sp4 .66
heinrichsweikamp
parents:
diff changeset
170 #DEFINE log_sp5 .68
heinrichsweikamp
parents:
diff changeset
171 #DEFINE log_salinity .70
heinrichsweikamp
parents:
diff changeset
172 #DEFINE log_cns_end .71
heinrichsweikamp
parents:
diff changeset
173 #DEFINE log_avr_depth .73
heinrichsweikamp
parents:
diff changeset
174 #DEFINE log_total_seconds .75
heinrichsweikamp
parents:
diff changeset
175 #DEFINE log_gf_lo .77
heinrichsweikamp
parents:
diff changeset
176 #DEFINE log_sat_mult .77
heinrichsweikamp
parents:
diff changeset
177 #DEFINE log_gf_hi .78
heinrichsweikamp
parents:
diff changeset
178 #DEFINE log_desat_mult .78
heinrichsweikamp
parents:
diff changeset
179 #DEFINE log_decomodel .79
heinrichsweikamp
parents:
diff changeset
180 #DEFINE log_total_dives .80
heinrichsweikamp
parents:
diff changeset
181 #DEFINE log_divemode .82
heinrichsweikamp
parents:
diff changeset
182 #DEFINE log_last_stop .243
heinrichsweikamp
parents:
diff changeset
183
heinrichsweikamp
parents:
diff changeset
184 LOG_POINT_TO macro address
heinrichsweikamp
parents:
diff changeset
185 movlw address
heinrichsweikamp
parents:
diff changeset
186 movwf ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
187 endm
heinrichsweikamp
parents:
diff changeset
188
heinrichsweikamp
parents:
diff changeset
189 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
190
heinrichsweikamp
parents:
diff changeset
191 logbook code
heinrichsweikamp
parents:
diff changeset
192
heinrichsweikamp
parents:
diff changeset
193 TFT_logbook_cursor:
heinrichsweikamp
parents:
diff changeset
194 call speed_fastest
heinrichsweikamp
parents:
diff changeset
195 WIN_BOX_BLACK .0, .239, logbook_list_left-.16, logbook_list_left-.1 ;top, bottom, left, right
heinrichsweikamp
parents:
diff changeset
196
heinrichsweikamp
parents:
diff changeset
197 WIN_LEFT logbook_list_left-.16
heinrichsweikamp
parents:
diff changeset
198 WIN_FONT FT_SMALL
heinrichsweikamp
parents:
diff changeset
199 WIN_INVERT .0 ; Init new Wordprocessor
heinrichsweikamp
parents:
diff changeset
200 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
201
heinrichsweikamp
parents:
diff changeset
202 movff menupos,temp1
heinrichsweikamp
parents:
diff changeset
203 dcfsnz temp1,F
heinrichsweikamp
parents:
diff changeset
204 movlw d'0'
heinrichsweikamp
parents:
diff changeset
205 dcfsnz temp1,F
heinrichsweikamp
parents:
diff changeset
206 movlw logbook_row_offset
heinrichsweikamp
parents:
diff changeset
207 dcfsnz temp1,F
heinrichsweikamp
parents:
diff changeset
208 movlw .2*logbook_row_offset
heinrichsweikamp
parents:
diff changeset
209 dcfsnz temp1,F
heinrichsweikamp
parents:
diff changeset
210 movlw .3*logbook_row_offset
heinrichsweikamp
parents:
diff changeset
211 dcfsnz temp1,F
heinrichsweikamp
parents:
diff changeset
212 movlw .4*logbook_row_offset
heinrichsweikamp
parents:
diff changeset
213 dcfsnz temp1,F
heinrichsweikamp
parents:
diff changeset
214 movlw .5*logbook_row_offset
heinrichsweikamp
parents:
diff changeset
215 dcfsnz temp1,F
heinrichsweikamp
parents:
diff changeset
216 movlw .6*logbook_row_offset
heinrichsweikamp
parents:
diff changeset
217 dcfsnz temp1,F
heinrichsweikamp
parents:
diff changeset
218 movlw .7*logbook_row_offset
heinrichsweikamp
parents:
diff changeset
219 dcfsnz temp1,F
heinrichsweikamp
parents:
diff changeset
220 movlw .8*logbook_row_offset
heinrichsweikamp
parents:
diff changeset
221
heinrichsweikamp
parents:
diff changeset
222 movff WREG,win_top
heinrichsweikamp
parents:
diff changeset
223 STRCPY_PRINT "\xB7"
heinrichsweikamp
parents:
diff changeset
224 return
heinrichsweikamp
parents:
diff changeset
225
heinrichsweikamp
parents:
diff changeset
226 global logbook
heinrichsweikamp
parents:
diff changeset
227 logbook:
heinrichsweikamp
parents:
diff changeset
228 clrf logbook_flags
heinrichsweikamp
parents:
diff changeset
229 clrf CCP1CON ; stop PWM
heinrichsweikamp
parents:
diff changeset
230 bcf PORTC,2 ; Pull PWM out to GND
heinrichsweikamp
parents:
diff changeset
231 call TFT_ClearScreen ; Clear screen
heinrichsweikamp
parents:
diff changeset
232 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
233 clrf menupos3 ; Here: used rows on current logbook-page
heinrichsweikamp
parents:
diff changeset
234 clrf logbook_page_number ; Here: # of current displayed page
heinrichsweikamp
parents:
diff changeset
235 clrf logbook_divenumber ; # of dive in list during search
heinrichsweikamp
parents:
diff changeset
236 clrf divemins+0 ; Here: used as temp variables
heinrichsweikamp
parents:
diff changeset
237 clrf divemins+1
heinrichsweikamp
parents:
diff changeset
238 clrf timeout_counter2 ; For timeout
heinrichsweikamp
parents:
diff changeset
239 movlw logbook_row_number
heinrichsweikamp
parents:
diff changeset
240 movwf menupos ; Here: stores current position on display (logbook_row_number-x)
heinrichsweikamp
parents:
diff changeset
241 read_int_eeprom .2 ; Get low-byte of total dives
heinrichsweikamp
parents:
diff changeset
242 movff EEDATA,logbook_max_dive_counter
heinrichsweikamp
parents:
diff changeset
243
heinrichsweikamp
parents:
diff changeset
244 ;-----------------------------------------------------------------------------
heinrichsweikamp
parents:
diff changeset
245 ; display dive headers backwards from read_int_eeprom .2 = lo-1
heinrichsweikamp
parents:
diff changeset
246 ; 1st: 200000h-200FFFh -> lo=0
heinrichsweikamp
parents:
diff changeset
247 ; 2nd: 201000h-201FFFh -> lo=1
heinrichsweikamp
parents:
diff changeset
248 ; 3rd: 202000h-202FFFh -> lo=2
heinrichsweikamp
parents:
diff changeset
249 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...)
heinrichsweikamp
parents:
diff changeset
250 ; Stop when
heinrichsweikamp
parents:
diff changeset
251 ; a) no dive is stored (no valid header found)
heinrichsweikamp
parents:
diff changeset
252 ; b) current dive has no valid header (Number of stored dives < 256)
heinrichsweikamp
parents:
diff changeset
253 ; c) when 255 dives are reached divemins+0 = 255
heinrichsweikamp
parents:
diff changeset
254
heinrichsweikamp
parents:
diff changeset
255 logbook2:
heinrichsweikamp
parents:
diff changeset
256 call speed_fastest
heinrichsweikamp
parents:
diff changeset
257 incf divemins+0,F ; increase dive counter
heinrichsweikamp
parents:
diff changeset
258 incf divemins+0,W ; = 0x..FF ?
heinrichsweikamp
parents:
diff changeset
259 bz logbook_reset ; Yes: FF --> loop.
heinrichsweikamp
parents:
diff changeset
260
heinrichsweikamp
parents:
diff changeset
261 ; Set ext_flash_address:3 to TOC entry of this dive
heinrichsweikamp
parents:
diff changeset
262 ; 1st: 200000h-200FFFh -> logbook_max_dive_counter=0
heinrichsweikamp
parents:
diff changeset
263 ; 2nd: 201000h-201FFFh -> logbook_max_dive_counter=1
heinrichsweikamp
parents:
diff changeset
264 ; 3rd: 202000h-202FFFh -> logbook_max_dive_counter=2
heinrichsweikamp
parents:
diff changeset
265 ; 256: 2FF000h-2FFFFFh -> logbook_max_dive_counter=255 (And hi>0...)
heinrichsweikamp
parents:
diff changeset
266
heinrichsweikamp
parents:
diff changeset
267 decf logbook_max_dive_counter,F ; -1
heinrichsweikamp
parents:
diff changeset
268
heinrichsweikamp
parents:
diff changeset
269 clrf ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
270 clrf ext_flash_address+1
heinrichsweikamp
parents:
diff changeset
271 movlw 0x20
heinrichsweikamp
parents:
diff changeset
272 movwf ext_flash_address+2
heinrichsweikamp
parents:
diff changeset
273 movlw .16
heinrichsweikamp
parents:
diff changeset
274 mulwf logbook_max_dive_counter; logbook_max_dive_counter*16 = offset to 0x2000 (up:hi)
heinrichsweikamp
parents:
diff changeset
275 movf PRODL,W
heinrichsweikamp
parents:
diff changeset
276 addwf ext_flash_address+1,F
heinrichsweikamp
parents:
diff changeset
277 movf PRODH,W
heinrichsweikamp
parents:
diff changeset
278 addwfc ext_flash_address+2,F
heinrichsweikamp
parents:
diff changeset
279 ; pointer at the first 0xFA of header
heinrichsweikamp
parents:
diff changeset
280
heinrichsweikamp
parents:
diff changeset
281 call ext_flash_byte_read ; Reads one byte@ext_flash_address:3 into WREG and temp1
heinrichsweikamp
parents:
diff changeset
282 movwf temp1
heinrichsweikamp
parents:
diff changeset
283 movlw 0xFA
heinrichsweikamp
parents:
diff changeset
284 cpfseq temp1 ; 0xFA found?
heinrichsweikamp
parents:
diff changeset
285 bra logbook3b ; No, abort
heinrichsweikamp
parents:
diff changeset
286
heinrichsweikamp
parents:
diff changeset
287 incf logbook_divenumber,F ; new header found, increase logbook_divenumber
heinrichsweikamp
parents:
diff changeset
288 bra logbook4 ; Done with searching, display the header!
heinrichsweikamp
parents:
diff changeset
289
heinrichsweikamp
parents:
diff changeset
290 logbook3b:
heinrichsweikamp
parents:
diff changeset
291 btfss logbook_page_not_empty ; Was there at least one dive?
66
00636132cca6 BUGFIX: Maintain last selected customview in surface mode
heinrichsweikamp
parents: 50
diff changeset
292 goto do_main_menu2 ; Not a single header was found, leave logbook.
0
heinrichsweikamp
parents:
diff changeset
293 bra logbook_display_loop2
heinrichsweikamp
parents:
diff changeset
294
heinrichsweikamp
parents:
diff changeset
295 logbook_reset:
heinrichsweikamp
parents:
diff changeset
296 tstfsz logbook_divenumber ; Was there at least one dive?
heinrichsweikamp
parents:
diff changeset
297 bra logbook_reset2
heinrichsweikamp
parents:
diff changeset
298 bra logbook3b ; No, Nothing to do
heinrichsweikamp
parents:
diff changeset
299
heinrichsweikamp
parents:
diff changeset
300 logbook_reset2:
heinrichsweikamp
parents:
diff changeset
301 bsf all_dives_shown ; Yes
heinrichsweikamp
parents:
diff changeset
302 bra logbook_display_loop2 ; Continue
heinrichsweikamp
parents:
diff changeset
303
heinrichsweikamp
parents:
diff changeset
304 logbook4:
heinrichsweikamp
parents:
diff changeset
305 btfsc all_dives_shown ; All dives displayed?
heinrichsweikamp
parents:
diff changeset
306 bra logbook_display_loop2 ; Yes, but display first page again.
heinrichsweikamp
parents:
diff changeset
307
heinrichsweikamp
parents:
diff changeset
308 call display_listdive ; display short header for list on current list position
heinrichsweikamp
parents:
diff changeset
309
heinrichsweikamp
parents:
diff changeset
310 movlw logbook_row_number
heinrichsweikamp
parents:
diff changeset
311 cpfseq menupos ; first dive on list (top place)?
heinrichsweikamp
parents:
diff changeset
312 bra logbook_display_loop1 ; no, so skip saving of address
heinrichsweikamp
parents:
diff changeset
313
heinrichsweikamp
parents:
diff changeset
314 ; store all registered required to rebuilt the current logbookpage after the detail/profile view
heinrichsweikamp
parents:
diff changeset
315 movff logbook_divenumber,logbook_divenumber_temp ; # of dive in list of the current page
heinrichsweikamp
parents:
diff changeset
316 movff divemins+0,divemins_backup ; amount of dives drawn until now
heinrichsweikamp
parents:
diff changeset
317 movff logbook_max_dive_counter,logbook_max_dive_counter_temp ; backup Counter
heinrichsweikamp
parents:
diff changeset
318
heinrichsweikamp
parents:
diff changeset
319 logbook_display_loop1:
heinrichsweikamp
parents:
diff changeset
320 decfsz menupos,F ; List full?
heinrichsweikamp
parents:
diff changeset
321 bra logbook2 ; no, search another dive for our current logbook page
heinrichsweikamp
parents:
diff changeset
322
heinrichsweikamp
parents:
diff changeset
323 logbook_display_loop2:
heinrichsweikamp
parents:
diff changeset
324 btfss logbook_page_not_empty ; Was there one dive at all?
heinrichsweikamp
parents:
diff changeset
325 bra logbook ; Yes, so reload the first page
heinrichsweikamp
parents:
diff changeset
326
heinrichsweikamp
parents:
diff changeset
327 ; TFT_mask...
heinrichsweikamp
parents:
diff changeset
328
heinrichsweikamp
parents:
diff changeset
329 WIN_LEFT logbook_list_left
heinrichsweikamp
parents:
diff changeset
330 WIN_TOP logbook_row_offset*logbook_row_number
heinrichsweikamp
parents:
diff changeset
331 STRCPY_TEXT_PRINT tNextLog ; "Next Page"
heinrichsweikamp
parents:
diff changeset
332 WIN_LEFT logbook_list_left
heinrichsweikamp
parents:
diff changeset
333 WIN_TOP logbook_row_offset*(logbook_row_number+.1)
heinrichsweikamp
parents:
diff changeset
334 STRCPY_TEXT_PRINT tExitLog ; "Exit Logbook"
heinrichsweikamp
parents:
diff changeset
335
heinrichsweikamp
parents:
diff changeset
336 movlw d'1' ; Set cursor to position 1...
heinrichsweikamp
parents:
diff changeset
337 btfsc return_from_profileview ; .. unless we are returning from a detail/profile view
heinrichsweikamp
parents:
diff changeset
338 movf logbook_menupos_temp,W ; load last cursor position again
heinrichsweikamp
parents:
diff changeset
339 movwf menupos ; and set menupos byte
heinrichsweikamp
parents:
diff changeset
340 bcf return_from_profileview ; Do this only once while the page is loaded again!
heinrichsweikamp
parents:
diff changeset
341
heinrichsweikamp
parents:
diff changeset
342 bcf logbook_page_not_empty ; Obviously the current page is NOT empty
heinrichsweikamp
parents:
diff changeset
343 call TFT_logbook_cursor
heinrichsweikamp
parents:
diff changeset
344
heinrichsweikamp
parents:
diff changeset
345 call logbook_preloop_tasks ; Clear some flags and set to Speed_eco
heinrichsweikamp
parents:
diff changeset
346 logbook_loop:
heinrichsweikamp
parents:
diff changeset
347 btfsc switch_left ; SET/MENU?
heinrichsweikamp
parents:
diff changeset
348 goto next_logbook3 ; adjust cursor or create new page
heinrichsweikamp
parents:
diff changeset
349 btfsc switch_right ; ENTER?
heinrichsweikamp
parents:
diff changeset
350 bra display_profile_or_exit ; view details/profile or exit logbook
heinrichsweikamp
parents:
diff changeset
351
heinrichsweikamp
parents:
diff changeset
352 rcall log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second
heinrichsweikamp
parents:
diff changeset
353 btfsc sleepmode ; Timeout?
66
00636132cca6 BUGFIX: Maintain last selected customview in surface mode
heinrichsweikamp
parents: 50
diff changeset
354 goto do_main_menu2 ; Yes
0
heinrichsweikamp
parents:
diff changeset
355
heinrichsweikamp
parents:
diff changeset
356 bra logbook_loop ; Wait for something to do
heinrichsweikamp
parents:
diff changeset
357
heinrichsweikamp
parents:
diff changeset
358 display_profile_or_exit:
heinrichsweikamp
parents:
diff changeset
359 movlw logbook_row_number+.2 ; exit?
heinrichsweikamp
parents:
diff changeset
360 cpfseq menupos
heinrichsweikamp
parents:
diff changeset
361 bra display_profile_or_exit2 ; No, check for "Next Page"
66
00636132cca6 BUGFIX: Maintain last selected customview in surface mode
heinrichsweikamp
parents: 50
diff changeset
362 goto do_main_menu2
0
heinrichsweikamp
parents:
diff changeset
363
heinrichsweikamp
parents:
diff changeset
364 display_profile_or_exit2:
heinrichsweikamp
parents:
diff changeset
365 movlw logbook_row_number+.1 ; Next page?
heinrichsweikamp
parents:
diff changeset
366 cpfseq menupos
heinrichsweikamp
parents:
diff changeset
367 bra display_profile ; No, show details/profile
heinrichsweikamp
parents:
diff changeset
368 goto next_logbook2 ; Next page!
heinrichsweikamp
parents:
diff changeset
369
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
370 display_profile:
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
371 bcf is_bailout
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
372 bcf gas6_changed ; Clear event flags
0
heinrichsweikamp
parents:
diff changeset
373 call speed_fastest
heinrichsweikamp
parents:
diff changeset
374 movff menupos,logbook_menupos_temp; store current cursor position
heinrichsweikamp
parents:
diff changeset
375 bsf return_from_profileview ; tweak search routine to exit after found
heinrichsweikamp
parents:
diff changeset
376
heinrichsweikamp
parents:
diff changeset
377 movf logbook_page_number,W ; Number of page
heinrichsweikamp
parents:
diff changeset
378 mullw logbook_row_number
heinrichsweikamp
parents:
diff changeset
379 movf PRODL,W
heinrichsweikamp
parents:
diff changeset
380 addwf menupos,W ; page*logbook_row_number+menupos=
heinrichsweikamp
parents:
diff changeset
381 movwf divesecs ; # of dive to show
heinrichsweikamp
parents:
diff changeset
382
heinrichsweikamp
parents:
diff changeset
383 display_profile2:
heinrichsweikamp
parents:
diff changeset
384 call speed_fastest
heinrichsweikamp
parents:
diff changeset
385 clrf CCP1CON ; stop PWM
heinrichsweikamp
parents:
diff changeset
386 bcf PORTC,2 ; Pull PWM out to GND
heinrichsweikamp
parents:
diff changeset
387 call TFT_ClearScreen ; Clear screen
heinrichsweikamp
parents:
diff changeset
388 ; Set ext_flash pointer to "#divesecs-oldest" dive
heinrichsweikamp
parents:
diff changeset
389 ; compute read_int_eeprom .2 - divesecs
heinrichsweikamp
parents:
diff changeset
390 ; Read required header data for profile display
heinrichsweikamp
parents:
diff changeset
391 ; look in header for pointer to begin of diveprofile (Byte 2-4)
heinrichsweikamp
parents:
diff changeset
392 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing
heinrichsweikamp
parents:
diff changeset
393
heinrichsweikamp
parents:
diff changeset
394 decf divesecs,F ;-1
heinrichsweikamp
parents:
diff changeset
395 read_int_eeprom .2
heinrichsweikamp
parents:
diff changeset
396 movf EEDATA,W
heinrichsweikamp
parents:
diff changeset
397 bcf STATUS,C
heinrichsweikamp
parents:
diff changeset
398 subfwb divesecs,W ; max. dives (low value) - divesecs
heinrichsweikamp
parents:
diff changeset
399 movwf lo ; result
heinrichsweikamp
parents:
diff changeset
400 incf divesecs,F ;+1
heinrichsweikamp
parents:
diff changeset
401 ; Set ext_flash_address:3 to TOC entry of this dive
heinrichsweikamp
parents:
diff changeset
402 ; 1st: 200000h-200FFFh -> lo=0
heinrichsweikamp
parents:
diff changeset
403 ; 2nd: 201000h-201FFFh -> lo=1
heinrichsweikamp
parents:
diff changeset
404 ; 3rd: 202000h-202FFFh -> lo=2
heinrichsweikamp
parents:
diff changeset
405 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...)
heinrichsweikamp
parents:
diff changeset
406 clrf ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
407 clrf ext_flash_address+1
heinrichsweikamp
parents:
diff changeset
408 movlw 0x20
heinrichsweikamp
parents:
diff changeset
409 movwf ext_flash_address+2
heinrichsweikamp
parents:
diff changeset
410 movlw .16
heinrichsweikamp
parents:
diff changeset
411 mulwf lo ; lo*16 = offset to 0x2000 (up:hi)
heinrichsweikamp
parents:
diff changeset
412 movf PRODL,W
heinrichsweikamp
parents:
diff changeset
413 addwf ext_flash_address+1,F
heinrichsweikamp
parents:
diff changeset
414 movf PRODH,W
heinrichsweikamp
parents:
diff changeset
415 addwfc ext_flash_address+2,F
heinrichsweikamp
parents:
diff changeset
416 ; pointer at the first 0xFA of header
heinrichsweikamp
parents:
diff changeset
417
heinrichsweikamp
parents:
diff changeset
418 ; Now, show profile
heinrichsweikamp
parents:
diff changeset
419 LOG_POINT_TO log_samplingrate
heinrichsweikamp
parents:
diff changeset
420 call ext_flash_byte_read ; Read sampling rate
heinrichsweikamp
parents:
diff changeset
421 movff temp1,samplesecs_value ; needed later...
heinrichsweikamp
parents:
diff changeset
422
heinrichsweikamp
parents:
diff changeset
423 LOG_POINT_TO .2
heinrichsweikamp
parents:
diff changeset
424 call ext_flash_byte_read_plus ; Read start address of profile
heinrichsweikamp
parents:
diff changeset
425 movff temp1,ext_flash_log_pointer+0
heinrichsweikamp
parents:
diff changeset
426 call ext_flash_byte_read_plus ; Read start address of profile
heinrichsweikamp
parents:
diff changeset
427 movff temp1,ext_flash_log_pointer+1
heinrichsweikamp
parents:
diff changeset
428 call ext_flash_byte_read_plus ; Read start address of profile
heinrichsweikamp
parents:
diff changeset
429 movff temp1,ext_flash_log_pointer+2
heinrichsweikamp
parents:
diff changeset
430
heinrichsweikamp
parents:
diff changeset
431
heinrichsweikamp
parents:
diff changeset
432 clrf logbook_sample_counter+0
heinrichsweikamp
parents:
diff changeset
433 clrf logbook_sample_counter+1 ; holds amount of read samples
heinrichsweikamp
parents:
diff changeset
434
heinrichsweikamp
parents:
diff changeset
435 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
436 call logbook_show_divenumber ; Show the dive number in medium font
heinrichsweikamp
parents:
diff changeset
437
heinrichsweikamp
parents:
diff changeset
438 WIN_SMALL logbook_date_column, logbook_date_row
heinrichsweikamp
parents:
diff changeset
439 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
440 LOG_POINT_TO log_date
heinrichsweikamp
parents:
diff changeset
441 call ext_flash_byte_read_plus
heinrichsweikamp
parents:
diff changeset
442 movff temp1,convert_value_temp+2 ; Year
heinrichsweikamp
parents:
diff changeset
443 call ext_flash_byte_read_plus
heinrichsweikamp
parents:
diff changeset
444 movff temp1,convert_value_temp+0 ; Month
heinrichsweikamp
parents:
diff changeset
445 call ext_flash_byte_read_plus
heinrichsweikamp
parents:
diff changeset
446 movff temp1,convert_value_temp+1 ; Day
heinrichsweikamp
parents:
diff changeset
447 call TFT_convert_date ; converts into "DD/MM/YY" or "MM/DD/YY" or "YY/MM/DD" in postinc2
heinrichsweikamp
parents:
diff changeset
448 STRCAT_PRINT ""
heinrichsweikamp
parents:
diff changeset
449
heinrichsweikamp
parents:
diff changeset
450 WIN_SMALL logbook_time_column, logbook_time_row
heinrichsweikamp
parents:
diff changeset
451 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
452 call ext_flash_byte_read_plus ; hour
heinrichsweikamp
parents:
diff changeset
453 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
454 call ext_flash_byte_read_plus ; Minutes
heinrichsweikamp
parents:
diff changeset
455 movf lo,W
heinrichsweikamp
parents:
diff changeset
456 mullw .60
heinrichsweikamp
parents:
diff changeset
457 movff temp1,WREG
heinrichsweikamp
parents:
diff changeset
458 addwf PRODL,F
heinrichsweikamp
parents:
diff changeset
459 movlw .0
heinrichsweikamp
parents:
diff changeset
460 addwfc PRODH,F ; PRODH:PRODL has end-of-dive time in minutes
heinrichsweikamp
parents:
diff changeset
461
heinrichsweikamp
parents:
diff changeset
462 LOG_POINT_TO log_total_seconds
heinrichsweikamp
parents:
diff changeset
463 call ext_flash_byte_read_plus ; Total sample time in seconds
heinrichsweikamp
parents:
diff changeset
464 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
465 call ext_flash_byte_read_plus ; Total sample time in seconds
heinrichsweikamp
parents:
diff changeset
466 movff temp1,hi
heinrichsweikamp
parents:
diff changeset
467 call convert_time ; converts hi:lo in seconds to mins (hi) and seconds (lo)
heinrichsweikamp
parents:
diff changeset
468 clrf sub_b+1
heinrichsweikamp
parents:
diff changeset
469 movff hi,sub_b+0
heinrichsweikamp
parents:
diff changeset
470 movff PRODL,sub_a+0
heinrichsweikamp
parents:
diff changeset
471 movff PRODH,sub_a+1
heinrichsweikamp
parents:
diff changeset
472 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values)
heinrichsweikamp
parents:
diff changeset
473 ; sub_c:2 holds entry time in minutes
heinrichsweikamp
parents:
diff changeset
474 movff sub_c+0,lo
heinrichsweikamp
parents:
diff changeset
475 movff sub_c+1,hi
heinrichsweikamp
parents:
diff changeset
476 call convert_time ; converts hi:lo in minutes to hours (hi) and minutes (lo)
heinrichsweikamp
parents:
diff changeset
477 movff lo,PRODL ; temp
heinrichsweikamp
parents:
diff changeset
478 movff hi,lo
heinrichsweikamp
parents:
diff changeset
479 output_99x ; hour
heinrichsweikamp
parents:
diff changeset
480 PUTC ':'
heinrichsweikamp
parents:
diff changeset
481 movff PRODL,lo
heinrichsweikamp
parents:
diff changeset
482 output_99x ; minute
heinrichsweikamp
parents:
diff changeset
483 STRCAT_PRINT "" ; Display 1st row of details
heinrichsweikamp
parents:
diff changeset
484
heinrichsweikamp
parents:
diff changeset
485 LOG_POINT_TO log_max_depth
heinrichsweikamp
parents:
diff changeset
486 call ext_flash_byte_read_plus ; read max depth
heinrichsweikamp
parents:
diff changeset
487 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
488 call ext_flash_byte_read_plus ; read max depth
heinrichsweikamp
parents:
diff changeset
489 movff temp1,hi
heinrichsweikamp
parents:
diff changeset
490 movff lo,xA+0 ; calculate y-scale for profile display
heinrichsweikamp
parents:
diff changeset
491 movff hi,xA+1
heinrichsweikamp
parents:
diff changeset
492 movlw profile_height_pixels ; pixel height available for profile
heinrichsweikamp
parents:
diff changeset
493 movwf xB+0
heinrichsweikamp
parents:
diff changeset
494 clrf xB+1
heinrichsweikamp
parents:
diff changeset
495 call div16x16 ; does xA/xB=xC
heinrichsweikamp
parents:
diff changeset
496 movff xC+0,y_scale+0 ; holds LOW byte of y-scale (mbar/pixel!)
heinrichsweikamp
parents:
diff changeset
497 movff xC+1,y_scale+1 ; holds HIGH byte of y-scale (mbar/pixel!)
heinrichsweikamp
parents:
diff changeset
498 incf y_scale+0,F ; increase one, because there may be a remainder
heinrichsweikamp
parents:
diff changeset
499 movlw d'0'
heinrichsweikamp
parents:
diff changeset
500 addwfc y_scale+1,F
heinrichsweikamp
parents:
diff changeset
501
heinrichsweikamp
parents:
diff changeset
502 movlw LOW ((profile_height_pixels+1)*.1000)
heinrichsweikamp
parents:
diff changeset
503 movwf xC+0
heinrichsweikamp
parents:
diff changeset
504 movlw HIGH (((profile_height_pixels+1)*.1000) & h'FFFF')
heinrichsweikamp
parents:
diff changeset
505 movwf xC+1
heinrichsweikamp
parents:
diff changeset
506 movlw UPPER ((profile_height_pixels+1)*.1000)
heinrichsweikamp
parents:
diff changeset
507 movwf xC+2
heinrichsweikamp
parents:
diff changeset
508 clrf xC+3
heinrichsweikamp
parents:
diff changeset
509
heinrichsweikamp
parents:
diff changeset
510 movff lo,xB+0 ; Max. Depth in mbar
heinrichsweikamp
parents:
diff changeset
511 movff hi,xB+1 ; Max. Depth in mbar
heinrichsweikamp
parents:
diff changeset
512 call div32x16 ; xC:4 / xB:2 = xC+3:xC+2 with xC+1:xC+0 as remainder
heinrichsweikamp
parents:
diff changeset
513
heinrichsweikamp
parents:
diff changeset
514 movff xC+0,x_scale+0 ;
heinrichsweikamp
parents:
diff changeset
515 movff xC+1,x_scale+1 ; = Pixels/10m (For scale, draw any xx rows a scale-line)
heinrichsweikamp
parents:
diff changeset
516
heinrichsweikamp
parents:
diff changeset
517 movf x_scale+0,W
heinrichsweikamp
parents:
diff changeset
518 iorwf x_scale+1,W ; x_scale:2 = Null?
heinrichsweikamp
parents:
diff changeset
519 bnz display_profile_offset4 ; No, continue
heinrichsweikamp
parents:
diff changeset
520 incf x_scale+1,F ; Yes, make x_scale+1>1 to make "display_profile2e" working
heinrichsweikamp
parents:
diff changeset
521
heinrichsweikamp
parents:
diff changeset
522 display_profile_offset4:
heinrichsweikamp
parents:
diff changeset
523 WIN_SMALL log_max_value_column,log_max_value_row
heinrichsweikamp
parents:
diff changeset
524 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
525
heinrichsweikamp
parents:
diff changeset
526 TSTOSS opt_units ; 0=Meters, 1=Feets
heinrichsweikamp
parents:
diff changeset
527 bra display_profile_offset4_metric
heinrichsweikamp
parents:
diff changeset
528 ;display_profile_offset4_imperial:
heinrichsweikamp
parents:
diff changeset
529 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
heinrichsweikamp
parents:
diff changeset
530 PUTC ' '
25
f65d070a5b76 fix imperial units in logbook
heinrichsweikamp
parents: 0
diff changeset
531 bcf leftbind
f65d070a5b76 fix imperial units in logbook
heinrichsweikamp
parents: 0
diff changeset
532 output_16_3
0
heinrichsweikamp
parents:
diff changeset
533 STRCAT_TEXT_PRINT tFeets
heinrichsweikamp
parents:
diff changeset
534 bra display_profile_offset4_common
heinrichsweikamp
parents:
diff changeset
535
heinrichsweikamp
parents:
diff changeset
536 display_profile_offset4_metric:
heinrichsweikamp
parents:
diff changeset
537 bsf leftbind
heinrichsweikamp
parents:
diff changeset
538 output_16dp d'3' ; max. depth
heinrichsweikamp
parents:
diff changeset
539 STRCAT_TEXT_PRINT tMeters
heinrichsweikamp
parents:
diff changeset
540
heinrichsweikamp
parents:
diff changeset
541 display_profile_offset4_common:
heinrichsweikamp
parents:
diff changeset
542 call ext_flash_byte_read_plus ; divetime in minutes
heinrichsweikamp
parents:
diff changeset
543 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
544 call ext_flash_byte_read_plus
heinrichsweikamp
parents:
diff changeset
545 movff temp1,hi ; divetime in minutes
heinrichsweikamp
parents:
diff changeset
546
heinrichsweikamp
parents:
diff changeset
547 movff lo,xA+0 ; calculate x-scale for profile display
heinrichsweikamp
parents:
diff changeset
548 movff hi,xA+1 ; calculate total diveseconds first
heinrichsweikamp
parents:
diff changeset
549 movlw d'60' ; 60seconds are one minute...
heinrichsweikamp
parents:
diff changeset
550 movwf xB+0
heinrichsweikamp
parents:
diff changeset
551 clrf xB+1
heinrichsweikamp
parents:
diff changeset
552 call mult16x16 ; result is in xC:2 !
heinrichsweikamp
parents:
diff changeset
553
heinrichsweikamp
parents:
diff changeset
554 WIN_SMALL log_divetime_value_column,log_divetime_value_row
heinrichsweikamp
parents:
diff changeset
555 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
556 bsf leftbind
heinrichsweikamp
parents:
diff changeset
557 output_16 ; divetime minutes
heinrichsweikamp
parents:
diff changeset
558 movlw LOW d'600'
heinrichsweikamp
parents:
diff changeset
559 movwf xA+0
heinrichsweikamp
parents:
diff changeset
560 movlw HIGH d'600'
heinrichsweikamp
parents:
diff changeset
561 movwf xA+1 ; A vertical line every 600 seconds
heinrichsweikamp
parents:
diff changeset
562 movff samplesecs_value,xB+0 ; Copy sampling rate
heinrichsweikamp
parents:
diff changeset
563 clrf xB+1
heinrichsweikamp
parents:
diff changeset
564 call div16x16 ; xA/xB=xC with xA as remainder
heinrichsweikamp
parents:
diff changeset
565 movff xC+0,average_depth_hold_total+0
heinrichsweikamp
parents:
diff changeset
566 movff xC+1,average_depth_hold_total+1
heinrichsweikamp
parents:
diff changeset
567 ;average_depth_hold_total:2 holds interval of samples for vertical 10min line
heinrichsweikamp
parents:
diff changeset
568
heinrichsweikamp
parents:
diff changeset
569 ; Restore divetime in minutes:
heinrichsweikamp
parents:
diff changeset
570 ; get real sample time
heinrichsweikamp
parents:
diff changeset
571 LOG_POINT_TO log_total_seconds
heinrichsweikamp
parents:
diff changeset
572 call ext_flash_byte_read_plus ; Total sample time in seconds
heinrichsweikamp
parents:
diff changeset
573 movff temp1,xC+0
heinrichsweikamp
parents:
diff changeset
574 call ext_flash_byte_read_plus ; Total sample time in seconds
heinrichsweikamp
parents:
diff changeset
575 movff temp1,xC+1
heinrichsweikamp
parents:
diff changeset
576
heinrichsweikamp
parents:
diff changeset
577 PUTC ':'
heinrichsweikamp
parents:
diff changeset
578 LOG_POINT_TO log_divetime+.2
heinrichsweikamp
parents:
diff changeset
579 call ext_flash_byte_read_plus ; read divetime seconds
heinrichsweikamp
parents:
diff changeset
580 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
581 movff xC+0,xA+0 ; now calculate x-scale value
heinrichsweikamp
parents:
diff changeset
582 movff xC+1,xA+1
heinrichsweikamp
parents:
diff changeset
583 movlw profile_width_pixels ; pix width available
heinrichsweikamp
parents:
diff changeset
584 movwf xB+0
heinrichsweikamp
parents:
diff changeset
585 clrf xB+1
heinrichsweikamp
parents:
diff changeset
586 call div16x16 ; xA/xB=xC
heinrichsweikamp
parents:
diff changeset
587 movff xC+0,xA+0
heinrichsweikamp
parents:
diff changeset
588 movff xC+1,xA+1
heinrichsweikamp
parents:
diff changeset
589 movf samplesecs_value,W ; devide through sample interval!
heinrichsweikamp
parents:
diff changeset
590 movwf xB+0
heinrichsweikamp
parents:
diff changeset
591 clrf xB+1
heinrichsweikamp
parents:
diff changeset
592 call div16x16 ; xA/xB=xC
heinrichsweikamp
parents:
diff changeset
593 movff xC+0,profile_temp+0 ; store value (use any #xC sample, skip xC-1) into temp registers
heinrichsweikamp
parents:
diff changeset
594 movff xC+1,profile_temp+1 ; store value (use any #xC sample, skip xC-1) into temp registers
heinrichsweikamp
parents:
diff changeset
595 incf profile_temp+0,F ; Increase by one, there might be a remainder
heinrichsweikamp
parents:
diff changeset
596 movlw d'0'
heinrichsweikamp
parents:
diff changeset
597 addwfc profile_temp+1,F
heinrichsweikamp
parents:
diff changeset
598
heinrichsweikamp
parents:
diff changeset
599 bsf leftbind
heinrichsweikamp
parents:
diff changeset
600 output_99x ; divetime seconds
heinrichsweikamp
parents:
diff changeset
601 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
602 STRCAT_PRINT ""
heinrichsweikamp
parents:
diff changeset
603
heinrichsweikamp
parents:
diff changeset
604 call ext_flash_byte_read_plus ; Read min. Temperature
heinrichsweikamp
parents:
diff changeset
605 movff temp1,logbook_min_tp+0
heinrichsweikamp
parents:
diff changeset
606 call ext_flash_byte_read_plus ; Read min. Temperature
heinrichsweikamp
parents:
diff changeset
607 movff temp1,logbook_min_tp+1
heinrichsweikamp
parents:
diff changeset
608
heinrichsweikamp
parents:
diff changeset
609 ; Set pointer to Gas 1 Type.
heinrichsweikamp
parents:
diff changeset
610 LOG_POINT_TO log_gas1+.3
heinrichsweikamp
parents:
diff changeset
611 call ext_flash_byte_read_plus ; read Gas Type
heinrichsweikamp
parents:
diff changeset
612 decfsz temp1,W ; =1 (="First")?
heinrichsweikamp
parents:
diff changeset
613 bra logbook_find_first_gas2 ; No.
heinrichsweikamp
parents:
diff changeset
614 movlw .1
heinrichsweikamp
parents:
diff changeset
615 movwf temp1
heinrichsweikamp
parents:
diff changeset
616 bra logbook_find_first_gas_done
heinrichsweikamp
parents:
diff changeset
617 logbook_find_first_gas2:
heinrichsweikamp
parents:
diff changeset
618 ; Set pointer to Gas 2 Type.
heinrichsweikamp
parents:
diff changeset
619 LOG_POINT_TO log_gas2+.3
heinrichsweikamp
parents:
diff changeset
620 call ext_flash_byte_read_plus ; read Gas Type
heinrichsweikamp
parents:
diff changeset
621 decfsz temp1,W ; =1 (="First")?
heinrichsweikamp
parents:
diff changeset
622 bra logbook_find_first_gas3 ; No.
heinrichsweikamp
parents:
diff changeset
623 movlw .2
heinrichsweikamp
parents:
diff changeset
624 movwf temp1
heinrichsweikamp
parents:
diff changeset
625 bra logbook_find_first_gas_done
heinrichsweikamp
parents:
diff changeset
626 logbook_find_first_gas3:
heinrichsweikamp
parents:
diff changeset
627 ; Set pointer to Gas 3 Type.
heinrichsweikamp
parents:
diff changeset
628 LOG_POINT_TO log_gas3+.3
heinrichsweikamp
parents:
diff changeset
629 call ext_flash_byte_read_plus ; read Gas Type
heinrichsweikamp
parents:
diff changeset
630 decfsz temp1,W ; =1 (="First")?
heinrichsweikamp
parents:
diff changeset
631 bra logbook_find_first_gas4 ; No.
heinrichsweikamp
parents:
diff changeset
632 movlw .3
heinrichsweikamp
parents:
diff changeset
633 movwf temp1
heinrichsweikamp
parents:
diff changeset
634 bra logbook_find_first_gas_done
heinrichsweikamp
parents:
diff changeset
635 logbook_find_first_gas4:
heinrichsweikamp
parents:
diff changeset
636 ; Set pointer to Gas 4 Type.
heinrichsweikamp
parents:
diff changeset
637 LOG_POINT_TO log_gas4+.3
heinrichsweikamp
parents:
diff changeset
638 call ext_flash_byte_read_plus ; read Gas Type
heinrichsweikamp
parents:
diff changeset
639 decfsz temp1,W ; =1 (="First")?
heinrichsweikamp
parents:
diff changeset
640 bra logbook_find_first_gas5 ; No.
heinrichsweikamp
parents:
diff changeset
641 movlw .4
heinrichsweikamp
parents:
diff changeset
642 movwf temp1
heinrichsweikamp
parents:
diff changeset
643 bra logbook_find_first_gas_done
heinrichsweikamp
parents:
diff changeset
644 logbook_find_first_gas5:
heinrichsweikamp
parents:
diff changeset
645 movlw .5 ; Must be Gas5
heinrichsweikamp
parents:
diff changeset
646 movwf temp1
heinrichsweikamp
parents:
diff changeset
647 logbook_find_first_gas_done:
heinrichsweikamp
parents:
diff changeset
648 movff temp1,average_depth_hold_total+3; keep copy to restore color
heinrichsweikamp
parents:
diff changeset
649 rcall profile_display_color ; Back to normal profile color.
heinrichsweikamp
parents:
diff changeset
650 ; Pointer is now trashed!
heinrichsweikamp
parents:
diff changeset
651
heinrichsweikamp
parents:
diff changeset
652 ; Point to profile portion of this dive
heinrichsweikamp
parents:
diff changeset
653 movff ext_flash_log_pointer+0,ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
654 movff ext_flash_log_pointer+1,ext_flash_address+1
heinrichsweikamp
parents:
diff changeset
655 movff ext_flash_log_pointer+2,ext_flash_address+2
heinrichsweikamp
parents:
diff changeset
656
heinrichsweikamp
parents:
diff changeset
657 incf_ext_flash_address_0x20 d'2' ; Skip 0xFA 0xFA
heinrichsweikamp
parents:
diff changeset
658 call ext_flash_byte_read_plus_0x20 ; Read low byte of total dives into temp1 (at the time the dive was made)
heinrichsweikamp
parents:
diff changeset
659
heinrichsweikamp
parents:
diff changeset
660 ; Load total number of dives (low byte only)
heinrichsweikamp
parents:
diff changeset
661 read_int_eeprom .2
heinrichsweikamp
parents:
diff changeset
662 incf EEDATA,W ; +1
heinrichsweikamp
parents:
diff changeset
663 bsf STATUS,C ; Set borrow
heinrichsweikamp
parents:
diff changeset
664 subfwb divesecs,W ; total dives - dive# to show - 1 = low byte of total dives (at the time the dive was made)
heinrichsweikamp
parents:
diff changeset
665 cpfseq temp1 ; # of dive in logbook (Must be equal with low byte in short header)
heinrichsweikamp
parents:
diff changeset
666 bra display_profile_no_profile ; Not equal, no profile for this dive available!
heinrichsweikamp
parents:
diff changeset
667
heinrichsweikamp
parents:
diff changeset
668 ; Skip rest of short header: 3 Bytes
heinrichsweikamp
parents:
diff changeset
669 ; Skip length of profile data: 3 Bytes
heinrichsweikamp
parents:
diff changeset
670 ; Skip sampling rate in profile section: 1Byte
heinrichsweikamp
parents:
diff changeset
671 ; Skip number of divisors: 1Byte
heinrichsweikamp
parents:
diff changeset
672 incf_ext_flash_address_0x20 d'8'
heinrichsweikamp
parents:
diff changeset
673
heinrichsweikamp
parents:
diff changeset
674 ; Divisor temp
heinrichsweikamp
parents:
diff changeset
675 incf_ext_flash_address_0x20 d'2'
heinrichsweikamp
parents:
diff changeset
676 ; call ext_flash_byte_read_plus_0x20 ; Read information type
heinrichsweikamp
parents:
diff changeset
677 ; call ext_flash_byte_read_plus_0x20 ; Read information Length
heinrichsweikamp
parents:
diff changeset
678 call ext_flash_byte_read_plus_0x20 ; Read information Divisor
heinrichsweikamp
parents:
diff changeset
679 movf temp1,W
heinrichsweikamp
parents:
diff changeset
680 movwf divisor_temperature ; Store divisor
heinrichsweikamp
parents:
diff changeset
681 movwf count_temperature ; Store to tp° counter too.
heinrichsweikamp
parents:
diff changeset
682 ; Divisor Deco
heinrichsweikamp
parents:
diff changeset
683 incf_ext_flash_address_0x20 d'2'
heinrichsweikamp
parents:
diff changeset
684 ; call ext_flash_byte_read_plus_0x20 ; Read information type
heinrichsweikamp
parents:
diff changeset
685 ; call ext_flash_byte_read_plus_0x20 ; Read information Length
heinrichsweikamp
parents:
diff changeset
686 call ext_flash_byte_read_plus_0x20 ; Read information Divisor
heinrichsweikamp
parents:
diff changeset
687 movf temp1,W
heinrichsweikamp
parents:
diff changeset
688 movwf divisor_deco ; Store divisor
heinrichsweikamp
parents:
diff changeset
689 movwf count_deco ; Store as temp, too
heinrichsweikamp
parents:
diff changeset
690 ; Divisor GF
heinrichsweikamp
parents:
diff changeset
691 incf_ext_flash_address_0x20 d'2'
heinrichsweikamp
parents:
diff changeset
692 ; call ext_flash_byte_read_plus_0x20 ; Read information type
heinrichsweikamp
parents:
diff changeset
693 ; call ext_flash_byte_read_plus_0x20 ; Read information Length
heinrichsweikamp
parents:
diff changeset
694 call ext_flash_byte_read_plus_0x20 ; Read information Divisor
heinrichsweikamp
parents:
diff changeset
695 movff temp1,divisor_gf ; Store divisor
heinrichsweikamp
parents:
diff changeset
696 ; Divisor ppO2 Sensors
heinrichsweikamp
parents:
diff changeset
697 incf_ext_flash_address_0x20 d'2'
heinrichsweikamp
parents:
diff changeset
698 ; call ext_flash_byte_read_plus_0x20 ; Read information type
heinrichsweikamp
parents:
diff changeset
699 ; call ext_flash_byte_read_plus_0x20 ; Read information Length
heinrichsweikamp
parents:
diff changeset
700 call ext_flash_byte_read_plus_0x20 ; Read information Divisor
heinrichsweikamp
parents:
diff changeset
701 movff temp1,divisor_ppo2_sensors ; Store divisor
heinrichsweikamp
parents:
diff changeset
702 ; Divisor decoplan
heinrichsweikamp
parents:
diff changeset
703 incf_ext_flash_address_0x20 d'2'
heinrichsweikamp
parents:
diff changeset
704 ; call ext_flash_byte_read_plus_0x20 ; Read information type
heinrichsweikamp
parents:
diff changeset
705 ; call ext_flash_byte_read_plus_0x20 ; Read information Length
heinrichsweikamp
parents:
diff changeset
706 call ext_flash_byte_read_plus_0x20 ; Read information Divisor
heinrichsweikamp
parents:
diff changeset
707 movff temp1,divisor_decoplan ; Store divisor
heinrichsweikamp
parents:
diff changeset
708 ; Divisor CNS
heinrichsweikamp
parents:
diff changeset
709 incf_ext_flash_address_0x20 d'2'
heinrichsweikamp
parents:
diff changeset
710 ; call ext_flash_byte_read_plus_0x20 ; Read information type
heinrichsweikamp
parents:
diff changeset
711 ; call ext_flash_byte_read_plus_0x20 ; Read information Length
heinrichsweikamp
parents:
diff changeset
712 call ext_flash_byte_read_plus_0x20 ; Read information Divisor
heinrichsweikamp
parents:
diff changeset
713 movff temp1,divisor_cns ; Store divisor
heinrichsweikamp
parents:
diff changeset
714 ; Divisor Tank data
heinrichsweikamp
parents:
diff changeset
715 incf_ext_flash_address_0x20 d'2'
heinrichsweikamp
parents:
diff changeset
716 ; call ext_flash_byte_read_plus_0x20 ; Read information type
heinrichsweikamp
parents:
diff changeset
717 ; call ext_flash_byte_read_plus_0x20 ; Read information Length
heinrichsweikamp
parents:
diff changeset
718 call ext_flash_byte_read_plus_0x20 ; Read information Divisor
heinrichsweikamp
parents:
diff changeset
719 movff temp1,divisor_tank ; Store divisor
heinrichsweikamp
parents:
diff changeset
720
heinrichsweikamp
parents:
diff changeset
721 ; Start Profile display
heinrichsweikamp
parents:
diff changeset
722 movlw color_deepblue
heinrichsweikamp
parents:
diff changeset
723 call TFT_set_color ; Make this configurable?
heinrichsweikamp
parents:
diff changeset
724 ; Draw a frame around profile area
heinrichsweikamp
parents:
diff changeset
725 WIN_FRAME_COLOR16 profile_top-1,profile_top+profile_height_pixels+1,profile_left-1,profile_left+profile_width_pixels+1
heinrichsweikamp
parents:
diff changeset
726
heinrichsweikamp
parents:
diff changeset
727 movlw profile_top
heinrichsweikamp
parents:
diff changeset
728 movff WREG,win_top
heinrichsweikamp
parents:
diff changeset
729 movlw profile_left
heinrichsweikamp
parents:
diff changeset
730 movff WREG,win_leftx2 ; Left border (0-159)
heinrichsweikamp
parents:
diff changeset
731 movlw d'1'
heinrichsweikamp
parents:
diff changeset
732 movff WREG,win_height
heinrichsweikamp
parents:
diff changeset
733 movlw profile_width_pixels+.1
heinrichsweikamp
parents:
diff changeset
734 movff WREG,win_width ; Right border (0-159)
heinrichsweikamp
parents:
diff changeset
735 bra display_profile2f ; No 0m line
heinrichsweikamp
parents:
diff changeset
736 display_profile2e:
heinrichsweikamp
parents:
diff changeset
737 call TFT_box ; Inputs: win_top, win_leftx2, win_height, win_width, win_color1, win_color2
heinrichsweikamp
parents:
diff changeset
738 display_profile2f:
heinrichsweikamp
parents:
diff changeset
739 movff win_top,WREG ; Get row
heinrichsweikamp
parents:
diff changeset
740 addwf x_scale+0,W ; Add line interval distance to win_top
heinrichsweikamp
parents:
diff changeset
741 tstfsz x_scale+1 ; >255?
heinrichsweikamp
parents:
diff changeset
742 movlw d'255' ; Yes, make win_top>239 -> Abort here
heinrichsweikamp
parents:
diff changeset
743 btfsc STATUS,C ; A Cary from the addwf above?
heinrichsweikamp
parents:
diff changeset
744 movlw d'255' ; Yes, make win_top>239 -> Abort here
heinrichsweikamp
parents:
diff changeset
745 movff WREG,win_top ; Result in win_top again
heinrichsweikamp
parents:
diff changeset
746 movff win_top,lo ; Get win_top in Bank1...
heinrichsweikamp
parents:
diff changeset
747 movlw profile_top+profile_height_pixels+.1 ; Limit
heinrichsweikamp
parents:
diff changeset
748 cpfsgt lo ; >239?
heinrichsweikamp
parents:
diff changeset
749 bra display_profile2e ; No, draw another line
heinrichsweikamp
parents:
diff changeset
750
heinrichsweikamp
parents:
diff changeset
751 clrf timeout_counter2 ; here: used as counter for depth readings
heinrichsweikamp
parents:
diff changeset
752 movlw profile_width_pixels+profile_left-.1
heinrichsweikamp
parents:
diff changeset
753 movwf ignore_digits ; here: used as counter for x-pixels
heinrichsweikamp
parents:
diff changeset
754 bcf end_of_profile ; clear flag
heinrichsweikamp
parents:
diff changeset
755 movlw profile_left
heinrichsweikamp
parents:
diff changeset
756 movwf logbook_pixel_x_pos ; here: used as colum x2 (Start at Colum 5)
heinrichsweikamp
parents:
diff changeset
757 movlw profile_top ; Zero-m row
heinrichsweikamp
parents:
diff changeset
758 movwf apnoe_mins ; here: used for fill between rows
heinrichsweikamp
parents:
diff changeset
759 movwf logbook_last_tp ; Initialise for Tp° curve too.
heinrichsweikamp
parents:
diff changeset
760
heinrichsweikamp
parents:
diff changeset
761 movlw LOW(-.100) ; Initialize max tp° to -10.0 °C.
heinrichsweikamp
parents:
diff changeset
762 movwf logbook_max_tp+0
heinrichsweikamp
parents:
diff changeset
763 movlw HIGH 0xFFFF & (-.100)
heinrichsweikamp
parents:
diff changeset
764 movwf logbook_max_tp+1
heinrichsweikamp
parents:
diff changeset
765
heinrichsweikamp
parents:
diff changeset
766 setf logbook_cur_tp+0 ; Initialize Tp°, before the first recorded point.
heinrichsweikamp
parents:
diff changeset
767 setf logbook_cur_tp+1
heinrichsweikamp
parents:
diff changeset
768 clrf logbook_last_tp ; Also reset previous Y for Tp°
heinrichsweikamp
parents:
diff changeset
769 clrf logbook_ceiling ; Ceiling = 0, correct value for no ceiling.
heinrichsweikamp
parents:
diff changeset
770
heinrichsweikamp
parents:
diff changeset
771 INIT_PIXEL_WROTE logbook_pixel_x_pos ; pixel x2 (Also sets standard Color!)
heinrichsweikamp
parents:
diff changeset
772
heinrichsweikamp
parents:
diff changeset
773 profile_display_loop:
heinrichsweikamp
parents:
diff changeset
774 movff profile_temp+0,profile_temp2+0
heinrichsweikamp
parents:
diff changeset
775 movff profile_temp+1,profile_temp2+1 ; 16Bit x-scaler
heinrichsweikamp
parents:
diff changeset
776 incf profile_temp2+1,F
heinrichsweikamp
parents:
diff changeset
777 tstfsz profile_temp2+0 ; Must not be Zero
heinrichsweikamp
parents:
diff changeset
778 bra profile_display_loop2 ; Not Zero!
heinrichsweikamp
parents:
diff changeset
779 incf profile_temp2+0,F ; Zero, Increase!
heinrichsweikamp
parents:
diff changeset
780
heinrichsweikamp
parents:
diff changeset
781 profile_display_loop2:
heinrichsweikamp
parents:
diff changeset
782 rcall profile_view_get_depth ; reads depth, temp and profile data
heinrichsweikamp
parents:
diff changeset
783
heinrichsweikamp
parents:
diff changeset
784 btfsc end_of_profile ; end-of profile reached?
heinrichsweikamp
parents:
diff changeset
785 bra profile_display_loop_done ; Yes, skip all remaining pixels
heinrichsweikamp
parents:
diff changeset
786
heinrichsweikamp
parents:
diff changeset
787
heinrichsweikamp
parents:
diff changeset
788 ;---- Draw Ceiling curve, if any ---------------------------------------------
heinrichsweikamp
parents:
diff changeset
789 movf divisor_deco,W
heinrichsweikamp
parents:
diff changeset
790 bz profile_display_skip_deco
heinrichsweikamp
parents:
diff changeset
791
heinrichsweikamp
parents:
diff changeset
792 movf logbook_ceiling,W ; Any deco ceiling ?
heinrichsweikamp
parents:
diff changeset
793 bz profile_display_skip_deco
heinrichsweikamp
parents:
diff changeset
794
heinrichsweikamp
parents:
diff changeset
795 mullw .100 ; Yes: convert to mbar
heinrichsweikamp
parents:
diff changeset
796 movff PRODL,sub_a+0
heinrichsweikamp
parents:
diff changeset
797 movff PRODH,sub_a+1
heinrichsweikamp
parents:
diff changeset
798 movff logbook_cur_depth+0,sub_b+0 ; Compare with UNSIGNED current depth (16bits)
heinrichsweikamp
parents:
diff changeset
799 movff logbook_cur_depth+1,sub_b+1
heinrichsweikamp
parents:
diff changeset
800 call subU16 ; set (or not) neg_flag
heinrichsweikamp
parents:
diff changeset
801
heinrichsweikamp
parents:
diff changeset
802 movlw color_dark_green ; Dark green if Ok,
heinrichsweikamp
parents:
diff changeset
803 btfss neg_flag
heinrichsweikamp
parents:
diff changeset
804 movlw color_dark_red ; Or dark red if ceiling overflown.
heinrichsweikamp
parents:
diff changeset
805 call TFT_set_color
heinrichsweikamp
parents:
diff changeset
806
heinrichsweikamp
parents:
diff changeset
807 movff PRODL,xA+0
heinrichsweikamp
parents:
diff changeset
808 movff PRODH,xA+1
heinrichsweikamp
parents:
diff changeset
809 movff y_scale+0,xB+0 ; devide pressure in mbar/quant for row offsett
heinrichsweikamp
parents:
diff changeset
810 movff y_scale+1,xB+1
heinrichsweikamp
parents:
diff changeset
811 call div16x16 ; xA/xB=xC
heinrichsweikamp
parents:
diff changeset
812
heinrichsweikamp
parents:
diff changeset
813 movlw profile_top+.1 ; Starts right after the top greenish line.
heinrichsweikamp
parents:
diff changeset
814 movff WREG,win_top
heinrichsweikamp
parents:
diff changeset
815 movff logbook_pixel_x_pos,win_leftx2 ; Left border (0-159)
heinrichsweikamp
parents:
diff changeset
816 movff xC+0,win_height
heinrichsweikamp
parents:
diff changeset
817 call half_vertical_line ; Inputs: win_top, win_leftx2, win_height, win_color1, win_color2
heinrichsweikamp
parents:
diff changeset
818
heinrichsweikamp
parents:
diff changeset
819 profile_display_skip_deco:
heinrichsweikamp
parents:
diff changeset
820 ;---- Draw Tp° curve, if any ---------------------------------------------
heinrichsweikamp
parents:
diff changeset
821 movf divisor_temperature,W
heinrichsweikamp
parents:
diff changeset
822 bz profile_display_skip_temp
heinrichsweikamp
parents:
diff changeset
823
heinrichsweikamp
parents:
diff changeset
824 movf logbook_cur_tp+0,W ; Did we had already a valid Tp°C record ?
heinrichsweikamp
parents:
diff changeset
825 andwf logbook_cur_tp+1,W
heinrichsweikamp
parents:
diff changeset
826 incf WREG
heinrichsweikamp
parents:
diff changeset
827 bz profile_display_skip_temp ; No: just skip drawing.
heinrichsweikamp
parents:
diff changeset
828
heinrichsweikamp
parents:
diff changeset
829 movlw LOW(((profile_height_pixels-.10)*.256)/.370) ; fixed tp° scale: (-2 .. +35°C * scale256 )/153pix
heinrichsweikamp
parents:
diff changeset
830 movwf xB+0
heinrichsweikamp
parents:
diff changeset
831 movlw HIGH(((profile_height_pixels-.10)*.256)/.370)
heinrichsweikamp
parents:
diff changeset
832 movwf xB+1
heinrichsweikamp
parents:
diff changeset
833
heinrichsweikamp
parents:
diff changeset
834 movf logbook_cur_tp+0,W ; Current Tp° - (-2.0°C) == Tp° + 20.
heinrichsweikamp
parents:
diff changeset
835 addlw LOW(.20) ; Low byte.
heinrichsweikamp
parents:
diff changeset
836 movwf xA+0
heinrichsweikamp
parents:
diff changeset
837 movf logbook_cur_tp+1,W
heinrichsweikamp
parents:
diff changeset
838 btfsc STATUS,C ; Propagate carry, if any
heinrichsweikamp
parents:
diff changeset
839 incf WREG
heinrichsweikamp
parents:
diff changeset
840 movwf xA+1
heinrichsweikamp
parents:
diff changeset
841 call mult16x16 ; xA*xB=xC
heinrichsweikamp
parents:
diff changeset
842
heinrichsweikamp
parents:
diff changeset
843 ; scale: divide by 256, ie. take just high byte.
heinrichsweikamp
parents:
diff changeset
844 movf xC+1,W
heinrichsweikamp
parents:
diff changeset
845 sublw profile_top+profile_height_pixels-.10 ; Upside-down: Y = .75 + (.153 - result)
heinrichsweikamp
parents:
diff changeset
846 movwf xC+0
heinrichsweikamp
parents:
diff changeset
847
heinrichsweikamp
parents:
diff changeset
848 ; Check limits
heinrichsweikamp
parents:
diff changeset
849 movlw profile_top
heinrichsweikamp
parents:
diff changeset
850 movwf xC+1
heinrichsweikamp
parents:
diff changeset
851 cpfsgt xC+0
heinrichsweikamp
parents:
diff changeset
852 movff xC+1,xC+0
heinrichsweikamp
parents:
diff changeset
853
heinrichsweikamp
parents:
diff changeset
854 movlw color_orange
heinrichsweikamp
parents:
diff changeset
855 call TFT_set_color
heinrichsweikamp
parents:
diff changeset
856
heinrichsweikamp
parents:
diff changeset
857 movf logbook_last_tp,W ; do we have a valid previous value ?
heinrichsweikamp
parents:
diff changeset
858 bz profile_display_temp_1 ; No: skip the vertical line.
heinrichsweikamp
parents:
diff changeset
859 movwf xC+1
heinrichsweikamp
parents:
diff changeset
860 call profile_display_fill ; In this column between this row (xC+0) and the last row (xC+1)
heinrichsweikamp
parents:
diff changeset
861 profile_display_temp_1:
heinrichsweikamp
parents:
diff changeset
862 movff xC+0,logbook_last_tp
heinrichsweikamp
parents:
diff changeset
863 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; Set col(0..159) x row (0..239), put a current color pixel.
heinrichsweikamp
parents:
diff changeset
864
heinrichsweikamp
parents:
diff changeset
865 profile_display_skip_temp:
heinrichsweikamp
parents:
diff changeset
866 ;---- Draw depth curve ---------------------------------------------------
heinrichsweikamp
parents:
diff changeset
867 movff y_scale+0,xB+0 ; devide pressure in mbar/quant for row offsett
heinrichsweikamp
parents:
diff changeset
868 movff y_scale+1,xB+1
heinrichsweikamp
parents:
diff changeset
869 movff logbook_cur_depth+0,xA+0
heinrichsweikamp
parents:
diff changeset
870 movff logbook_cur_depth+1,xA+1
heinrichsweikamp
parents:
diff changeset
871 call div16x16 ; xA/xB=xC
heinrichsweikamp
parents:
diff changeset
872 movlw profile_top
heinrichsweikamp
parents:
diff changeset
873 addwf xC+0,F ; add 75 pixel offset to result
heinrichsweikamp
parents:
diff changeset
874
heinrichsweikamp
parents:
diff changeset
875 btfsc STATUS,C ; Ignore potential profile errors
heinrichsweikamp
parents:
diff changeset
876 movff apnoe_mins,xC+0
heinrichsweikamp
parents:
diff changeset
877
heinrichsweikamp
parents:
diff changeset
878 rcall profile_display_color ; Back to normal profile color.
heinrichsweikamp
parents:
diff changeset
879
heinrichsweikamp
parents:
diff changeset
880 movff apnoe_mins,xC+1
heinrichsweikamp
parents:
diff changeset
881 call profile_display_fill ; In this column between this row (xC+0) and the last row (xC+1)
heinrichsweikamp
parents:
diff changeset
882 movff xC+0,apnoe_mins ; Store last row for fill routine
heinrichsweikamp
parents:
diff changeset
883
heinrichsweikamp
parents:
diff changeset
884 PIXEL_WRITE logbook_pixel_x_pos,xC+0 ; Set col(0..159) x row (0..239), put a std color pixel.
heinrichsweikamp
parents:
diff changeset
885 incf logbook_pixel_x_pos,F ; Next row
heinrichsweikamp
parents:
diff changeset
886
heinrichsweikamp
parents:
diff changeset
887 ;---- Draw CNS curve, if any ---------------------------------------------
heinrichsweikamp
parents:
diff changeset
888 movf divisor_cns,W
heinrichsweikamp
parents:
diff changeset
889 bz profile_display_skip_cns
heinrichsweikamp
parents:
diff changeset
890 ;
heinrichsweikamp
parents:
diff changeset
891 ; TODO HERE
heinrichsweikamp
parents:
diff changeset
892 ;
heinrichsweikamp
parents:
diff changeset
893 profile_display_skip_cns:
heinrichsweikamp
parents:
diff changeset
894
heinrichsweikamp
parents:
diff changeset
895 ;---- Draw GF curve, if any ----------------------------------------------
heinrichsweikamp
parents:
diff changeset
896 movf divisor_gf,W
heinrichsweikamp
parents:
diff changeset
897 bz profile_display_skip_gf
heinrichsweikamp
parents:
diff changeset
898 ;
heinrichsweikamp
parents:
diff changeset
899 ; TODO HERE
heinrichsweikamp
parents:
diff changeset
900 ;
heinrichsweikamp
parents:
diff changeset
901 profile_display_skip_gf:
heinrichsweikamp
parents:
diff changeset
902
heinrichsweikamp
parents:
diff changeset
903 ;---- All curves done.
heinrichsweikamp
parents:
diff changeset
904
heinrichsweikamp
parents:
diff changeset
905 profile_display_skip_loop1: ; skips readings!
heinrichsweikamp
parents:
diff changeset
906 dcfsnz profile_temp2+0,F
heinrichsweikamp
parents:
diff changeset
907 bra profile_display_loop3 ; check 16bit....
heinrichsweikamp
parents:
diff changeset
908
heinrichsweikamp
parents:
diff changeset
909 rcall profile_view_get_depth ; reads depth, temp and profile data
heinrichsweikamp
parents:
diff changeset
910 bra profile_display_skip_loop1
heinrichsweikamp
parents:
diff changeset
911
heinrichsweikamp
parents:
diff changeset
912 profile_display_loop3:
heinrichsweikamp
parents:
diff changeset
913 decfsz profile_temp2+1,F ; 16 bit x-scaler test
heinrichsweikamp
parents:
diff changeset
914 bra profile_display_skip_loop1 ; skips readings!
heinrichsweikamp
parents:
diff changeset
915
heinrichsweikamp
parents:
diff changeset
916 decfsz ignore_digits,F ; counts drawn x-pixels to zero
heinrichsweikamp
parents:
diff changeset
917 bra profile_display_loop ; Not ready yet
heinrichsweikamp
parents:
diff changeset
918 ; Done.
heinrichsweikamp
parents:
diff changeset
919
heinrichsweikamp
parents:
diff changeset
920 display_profile_no_profile: ; No profile available for this dive!
heinrichsweikamp
parents:
diff changeset
921
heinrichsweikamp
parents:
diff changeset
922 profile_display_loop_done:
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
923 btfss is_bailout ; Bailout during the dive?
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
924 bra profile_display_loop_done_nobail ; No
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
925 ; Yes, show "Bailout"
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
926 movlw color_pink
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
927 call TFT_set_color
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
928 WIN_TINY logbook_bailout_column,logbook_bailout_row
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
929 STRCPY_TEXT_PRINT tDiveBailout ; Bailout
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
930 profile_display_loop_done_nobail:
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
931 btfss gas6_changed ; Gas6
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
932 bra profile_display_loop_done_nogas6 ; No
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
933 ; Yes, show "Gas 6!"
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
934 movlw color_pink
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
935 call TFT_set_color
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
936 WIN_TINY logbook_bailout_column,logbook_bailout_row-.15
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
937 STRCPY_TEXT tGas ; Gas
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
938 STRCAT_PRINT " 6!"
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
939
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
940 profile_display_loop_done_nogas6:
0
heinrichsweikamp
parents:
diff changeset
941 decf divesecs,F ;-1
heinrichsweikamp
parents:
diff changeset
942 read_int_eeprom .2
heinrichsweikamp
parents:
diff changeset
943 movf EEDATA,W
heinrichsweikamp
parents:
diff changeset
944 bcf STATUS,C
heinrichsweikamp
parents:
diff changeset
945 subfwb divesecs,W ; max. dives (low value) - divesecs
heinrichsweikamp
parents:
diff changeset
946 movwf lo ; result
heinrichsweikamp
parents:
diff changeset
947 incf divesecs,F ;+1
heinrichsweikamp
parents:
diff changeset
948 ; Set ext_flash_address:3 to TOC entry of this dive
heinrichsweikamp
parents:
diff changeset
949 ; 1st: 200000h-200FFFh -> lo=0
heinrichsweikamp
parents:
diff changeset
950 ; 2nd: 201000h-201FFFh -> lo=1
heinrichsweikamp
parents:
diff changeset
951 ; 3rd: 202000h-202FFFh -> lo=2
heinrichsweikamp
parents:
diff changeset
952 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...)
heinrichsweikamp
parents:
diff changeset
953 clrf ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
954 clrf ext_flash_address+1
heinrichsweikamp
parents:
diff changeset
955 movlw 0x20
heinrichsweikamp
parents:
diff changeset
956 movwf ext_flash_address+2
heinrichsweikamp
parents:
diff changeset
957 movlw .16
heinrichsweikamp
parents:
diff changeset
958 mulwf lo ; lo*16 = offset to 0x2000 (up:hi)
heinrichsweikamp
parents:
diff changeset
959 movf PRODL,W
heinrichsweikamp
parents:
diff changeset
960 addwf ext_flash_address+1,F
heinrichsweikamp
parents:
diff changeset
961 movf PRODH,W
heinrichsweikamp
parents:
diff changeset
962 addwfc ext_flash_address+2,F
heinrichsweikamp
parents:
diff changeset
963 ; pointer at the first 0xFA of header
heinrichsweikamp
parents:
diff changeset
964
heinrichsweikamp
parents:
diff changeset
965 movlw .2 ; negative offset
heinrichsweikamp
parents:
diff changeset
966 addwf logbook_last_tp,W
heinrichsweikamp
parents:
diff changeset
967 movff WREG,win_top ; Line below temp
heinrichsweikamp
parents:
diff changeset
968 movff logbook_pixel_x_pos,lo
heinrichsweikamp
parents:
diff changeset
969 movlw .130
heinrichsweikamp
parents:
diff changeset
970 cpfslt lo ; limit left border to 130
heinrichsweikamp
parents:
diff changeset
971 movwf lo
heinrichsweikamp
parents:
diff changeset
972 movff lo,win_leftx2
heinrichsweikamp
parents:
diff changeset
973 WIN_FONT FT_TINY
heinrichsweikamp
parents:
diff changeset
974 movlw color_orange ; Use same color as tp° curve
heinrichsweikamp
parents:
diff changeset
975 call TFT_set_color
heinrichsweikamp
parents:
diff changeset
976
heinrichsweikamp
parents:
diff changeset
977 movff logbook_min_tp+0,lo
heinrichsweikamp
parents:
diff changeset
978 movff logbook_min_tp+1,hi
heinrichsweikamp
parents:
diff changeset
979 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
980
heinrichsweikamp
parents:
diff changeset
981 TSTOSS opt_units ; 0=°C, 1=°F
heinrichsweikamp
parents:
diff changeset
982 bra logbook_show_temp_metric
heinrichsweikamp
parents:
diff changeset
983 ;logbook_show_temp_imperial:
heinrichsweikamp
parents:
diff changeset
984 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
heinrichsweikamp
parents:
diff changeset
985 call convert_celsius_to_fahrenheit ; convert value in lo:hi from celsius to fahrenheit
heinrichsweikamp
parents:
diff changeset
986 lfsr FSR2,buffer ; Overwrite "-"
heinrichsweikamp
parents:
diff changeset
987 bsf ignore_digit5 ; Full degrees only
heinrichsweikamp
parents:
diff changeset
988 output_16
heinrichsweikamp
parents:
diff changeset
989 bcf ignore_digit5
heinrichsweikamp
parents:
diff changeset
990 STRCAT_TEXT_PRINT tLogTunitF
heinrichsweikamp
parents:
diff changeset
991 bra logbook_show_temp_common
heinrichsweikamp
parents:
diff changeset
992
heinrichsweikamp
parents:
diff changeset
993 logbook_show_temp_metric:
heinrichsweikamp
parents:
diff changeset
994 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
heinrichsweikamp
parents:
diff changeset
995 movlw d'3'
heinrichsweikamp
parents:
diff changeset
996 movwf ignore_digits
heinrichsweikamp
parents:
diff changeset
997 bsf leftbind
heinrichsweikamp
parents:
diff changeset
998 output_16dp d'2' ; temperature
heinrichsweikamp
parents:
diff changeset
999 STRCAT_TEXT_PRINT tLogTunitC
heinrichsweikamp
parents:
diff changeset
1000
heinrichsweikamp
parents:
diff changeset
1001 logbook_show_temp_common:
50
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 25
diff changeset
1002 bcf leftbind
ec4d8503ec45 NEW: user-selectable color schemes
heinrichsweikamp
parents: 25
diff changeset
1003 call TFT_standard_color
0
heinrichsweikamp
parents:
diff changeset
1004
heinrichsweikamp
parents:
diff changeset
1005 ; Get pointer to Gaslist
heinrichsweikamp
parents:
diff changeset
1006 LOG_POINT_TO log_gas1
heinrichsweikamp
parents:
diff changeset
1007
heinrichsweikamp
parents:
diff changeset
1008 movlw color_white ; Color for Gas 1
heinrichsweikamp
parents:
diff changeset
1009 call TFT_set_color ; Set Color...
heinrichsweikamp
parents:
diff changeset
1010 bsf leftbind
heinrichsweikamp
parents:
diff changeset
1011 WIN_TINY log_gas_column1, log_gas_row
heinrichsweikamp
parents:
diff changeset
1012 rcall log_show_gas_common
heinrichsweikamp
parents:
diff changeset
1013
heinrichsweikamp
parents:
diff changeset
1014 movlw color_green ; Color for Gas 2
heinrichsweikamp
parents:
diff changeset
1015 call TFT_set_color ; Set Color...
heinrichsweikamp
parents:
diff changeset
1016 WIN_TINY log_gas_column2, log_gas_row
heinrichsweikamp
parents:
diff changeset
1017 rcall log_show_gas_common
heinrichsweikamp
parents:
diff changeset
1018
heinrichsweikamp
parents:
diff changeset
1019 movlw color_red ; Color for Gas 3
heinrichsweikamp
parents:
diff changeset
1020 call TFT_set_color ; Set Color...
heinrichsweikamp
parents:
diff changeset
1021 WIN_TINY log_gas_column3, log_gas_row
heinrichsweikamp
parents:
diff changeset
1022 rcall log_show_gas_common
heinrichsweikamp
parents:
diff changeset
1023
heinrichsweikamp
parents:
diff changeset
1024 movlw color_yellow ; Color for Gas 4
heinrichsweikamp
parents:
diff changeset
1025 call TFT_set_color ; Set Color...
heinrichsweikamp
parents:
diff changeset
1026 WIN_TINY log_gas_column4, log_gas_row
heinrichsweikamp
parents:
diff changeset
1027 rcall log_show_gas_common
heinrichsweikamp
parents:
diff changeset
1028
heinrichsweikamp
parents:
diff changeset
1029 movlw color_cyan ; Color for Gas 5
heinrichsweikamp
parents:
diff changeset
1030 call TFT_set_color ; Set Color...
heinrichsweikamp
parents:
diff changeset
1031 WIN_TINY log_gas_column5, log_gas_row
heinrichsweikamp
parents:
diff changeset
1032 rcall log_show_gas_common
heinrichsweikamp
parents:
diff changeset
1033
heinrichsweikamp
parents:
diff changeset
1034 rcall logbook_preloop_tasks ; Clear some flags and set to Speed_eco
heinrichsweikamp
parents:
diff changeset
1035 display_profile_loop:
heinrichsweikamp
parents:
diff changeset
1036 btfsc switch_left ; SET/MENU?
heinrichsweikamp
parents:
diff changeset
1037 bra logbook_page2 ; Show more information
heinrichsweikamp
parents:
diff changeset
1038 btfsc switch_right ; ENTER?
heinrichsweikamp
parents:
diff changeset
1039 bra exit_profileview ; back to list
heinrichsweikamp
parents:
diff changeset
1040
heinrichsweikamp
parents:
diff changeset
1041 rcall log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second
heinrichsweikamp
parents:
diff changeset
1042 btfsc sleepmode ; Timeout?
heinrichsweikamp
parents:
diff changeset
1043 bra exit_profileview ; back to list
heinrichsweikamp
parents:
diff changeset
1044 bra display_profile_loop ; wait for something to do
heinrichsweikamp
parents:
diff changeset
1045
heinrichsweikamp
parents:
diff changeset
1046 global log_screendump_and_onesecond
heinrichsweikamp
parents:
diff changeset
1047 log_screendump_and_onesecond: ; Check if we need to make a screenshot and check for new second
heinrichsweikamp
parents:
diff changeset
1048 btfsc onesecupdate
heinrichsweikamp
parents:
diff changeset
1049 call timeout_surfmode ; Timeout
heinrichsweikamp
parents:
diff changeset
1050 btfsc onesecupdate
heinrichsweikamp
parents:
diff changeset
1051 call set_dive_modes ; Check, if divemode must be entered
heinrichsweikamp
parents:
diff changeset
1052 bcf onesecupdate ; one second update
heinrichsweikamp
parents:
diff changeset
1053 btfsc divemode
heinrichsweikamp
parents:
diff changeset
1054 goto restart ; Enter Divemode if required
heinrichsweikamp
parents:
diff changeset
1055
heinrichsweikamp
parents:
diff changeset
1056 btfsc enable_screen_dumps ; =1: Ignore vin_usb, wait for "l" command (Screen dump)
heinrichsweikamp
parents:
diff changeset
1057 bra log_screendump_and_onesecond2
heinrichsweikamp
parents:
diff changeset
1058 btfsc vusb_in ; USB plugged in?
heinrichsweikamp
parents:
diff changeset
1059 goto comm_mode ; Start COMM mode
heinrichsweikamp
parents:
diff changeset
1060 return
heinrichsweikamp
parents:
diff changeset
1061 log_screendump_and_onesecond2:
heinrichsweikamp
parents:
diff changeset
1062 btfss vusb_in ; USB (still) plugged in?
heinrichsweikamp
parents:
diff changeset
1063 bcf enable_screen_dumps ; No, clear flag
heinrichsweikamp
parents:
diff changeset
1064 call rs232_get_byte
heinrichsweikamp
parents:
diff changeset
1065 btfsc rs232_recieve_overflow
heinrichsweikamp
parents:
diff changeset
1066 return
heinrichsweikamp
parents:
diff changeset
1067 movlw "l"
heinrichsweikamp
parents:
diff changeset
1068 cpfseq RCREG1
heinrichsweikamp
parents:
diff changeset
1069 return
heinrichsweikamp
parents:
diff changeset
1070 call TFT_dump_screen ; Dump the screen contents
heinrichsweikamp
parents:
diff changeset
1071 return
heinrichsweikamp
parents:
diff changeset
1072
heinrichsweikamp
parents:
diff changeset
1073 log_show_gas_common:
heinrichsweikamp
parents:
diff changeset
1074 extern customview_show_mix
heinrichsweikamp
parents:
diff changeset
1075 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
1076 call ext_flash_byte_read_plus ; Gas2 current O2
heinrichsweikamp
parents:
diff changeset
1077 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1078 call ext_flash_byte_read_plus ; Gas2 current He
heinrichsweikamp
parents:
diff changeset
1079 movff temp1,hi
heinrichsweikamp
parents:
diff changeset
1080 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2
heinrichsweikamp
parents:
diff changeset
1081 STRCAT_PRINT ""
heinrichsweikamp
parents:
diff changeset
1082 call ext_flash_byte_read_plus ; Gas2 change depth
heinrichsweikamp
parents:
diff changeset
1083 call ext_flash_byte_read_plus ; Gas2 Type
heinrichsweikamp
parents:
diff changeset
1084 return
heinrichsweikamp
parents:
diff changeset
1085
heinrichsweikamp
parents:
diff changeset
1086 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
1087 profile_display_color:
heinrichsweikamp
parents:
diff changeset
1088 movff average_depth_hold_total+3,active_gas ; Restore gas color.
heinrichsweikamp
parents:
diff changeset
1089 movlw color_white ; Default color
heinrichsweikamp
parents:
diff changeset
1090 dcfsnz active_gas,F
heinrichsweikamp
parents:
diff changeset
1091 movlw color_white ; Color for Gas 1
heinrichsweikamp
parents:
diff changeset
1092 dcfsnz active_gas,F
heinrichsweikamp
parents:
diff changeset
1093 movlw color_green ; Color for Gas 2
heinrichsweikamp
parents:
diff changeset
1094 dcfsnz active_gas,F
heinrichsweikamp
parents:
diff changeset
1095 movlw color_red ; Color for Gas 3
heinrichsweikamp
parents:
diff changeset
1096 dcfsnz active_gas,F
heinrichsweikamp
parents:
diff changeset
1097 movlw color_yellow ; Color for Gas 4
heinrichsweikamp
parents:
diff changeset
1098 dcfsnz active_gas,F
heinrichsweikamp
parents:
diff changeset
1099 movlw color_cyan ; Color for Gas 5
heinrichsweikamp
parents:
diff changeset
1100 dcfsnz active_gas,F
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1101 movlw color_pink ; Color for Gas 6
0
heinrichsweikamp
parents:
diff changeset
1102 goto TFT_set_color ; Set Color...
heinrichsweikamp
parents:
diff changeset
1103
heinrichsweikamp
parents:
diff changeset
1104 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
1105 ; Draw a vertical line between xC+1 and xC+0, at current X position.
heinrichsweikamp
parents:
diff changeset
1106 ;
heinrichsweikamp
parents:
diff changeset
1107 ; Note: should keep xC+0
heinrichsweikamp
parents:
diff changeset
1108 ; Note: ascending or descending !
heinrichsweikamp
parents:
diff changeset
1109 ;
heinrichsweikamp
parents:
diff changeset
1110 profile_display_fill:
heinrichsweikamp
parents:
diff changeset
1111 ; First, check if xC+0>apnoe_mins or xC+0<aponoe_mins
heinrichsweikamp
parents:
diff changeset
1112 movf xC+0,W
heinrichsweikamp
parents:
diff changeset
1113 cpfseq xC+1 ; xC+0 = apone_mins?
heinrichsweikamp
parents:
diff changeset
1114 bra profile_display_fill2 ; No!
heinrichsweikamp
parents:
diff changeset
1115 return
heinrichsweikamp
parents:
diff changeset
1116
heinrichsweikamp
parents:
diff changeset
1117 profile_display_fill2:
heinrichsweikamp
parents:
diff changeset
1118 ; Make sure to init X position.
heinrichsweikamp
parents:
diff changeset
1119 movf logbook_pixel_x_pos,W
heinrichsweikamp
parents:
diff changeset
1120 mullw 2
heinrichsweikamp
parents:
diff changeset
1121 decf PRODL,F
heinrichsweikamp
parents:
diff changeset
1122 movlw 0
heinrichsweikamp
parents:
diff changeset
1123 subwfb PRODH,F
heinrichsweikamp
parents:
diff changeset
1124 call pixel_write_col320
heinrichsweikamp
parents:
diff changeset
1125
heinrichsweikamp
parents:
diff changeset
1126 movf xC+0,W
heinrichsweikamp
parents:
diff changeset
1127 cpfsgt xC+1 ; apnoe_mins>xC+0?
heinrichsweikamp
parents:
diff changeset
1128 bra profile_display_fill_up ; Yes!
heinrichsweikamp
parents:
diff changeset
1129
heinrichsweikamp
parents:
diff changeset
1130 profile_display_fill_down2: ; Loop
heinrichsweikamp
parents:
diff changeset
1131 decf xC+1,F
heinrichsweikamp
parents:
diff changeset
1132
heinrichsweikamp
parents:
diff changeset
1133 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239)
heinrichsweikamp
parents:
diff changeset
1134
heinrichsweikamp
parents:
diff changeset
1135 movf xC+0,W
heinrichsweikamp
parents:
diff changeset
1136 cpfseq xC+1 ; Loop until xC+1=xC+0
heinrichsweikamp
parents:
diff changeset
1137 bra profile_display_fill_down2
heinrichsweikamp
parents:
diff changeset
1138 return ; apnoe_mins and xC+0 are untouched
heinrichsweikamp
parents:
diff changeset
1139
heinrichsweikamp
parents:
diff changeset
1140 profile_display_fill_up: ; Fill upwards from xC+0 to apone_mins!
heinrichsweikamp
parents:
diff changeset
1141 incf xC+1,F
heinrichsweikamp
parents:
diff changeset
1142
heinrichsweikamp
parents:
diff changeset
1143 HALF_PIXEL_WRITE xC+1 ; Updates just row (0..239)
heinrichsweikamp
parents:
diff changeset
1144
heinrichsweikamp
parents:
diff changeset
1145 movf xC+0,W
heinrichsweikamp
parents:
diff changeset
1146 cpfseq xC+1 ; Loop until xC+1=apnoe_mins
heinrichsweikamp
parents:
diff changeset
1147 bra profile_display_fill_up
heinrichsweikamp
parents:
diff changeset
1148 return ; apnoe_mins and xC+0 are untouched
heinrichsweikamp
parents:
diff changeset
1149
heinrichsweikamp
parents:
diff changeset
1150 ;=============================================================================
heinrichsweikamp
parents:
diff changeset
1151
heinrichsweikamp
parents:
diff changeset
1152
heinrichsweikamp
parents:
diff changeset
1153 profile_view_get_depth:
heinrichsweikamp
parents:
diff changeset
1154 incf logbook_sample_counter+0,F
heinrichsweikamp
parents:
diff changeset
1155 movlw d'0'
heinrichsweikamp
parents:
diff changeset
1156 addwfc logbook_sample_counter+1,F ; Count read pixels
heinrichsweikamp
parents:
diff changeset
1157
heinrichsweikamp
parents:
diff changeset
1158 movf logbook_sample_counter+0,W
heinrichsweikamp
parents:
diff changeset
1159 cpfseq average_depth_hold_total+0
heinrichsweikamp
parents:
diff changeset
1160 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue
heinrichsweikamp
parents:
diff changeset
1161 movf logbook_sample_counter+1,W
heinrichsweikamp
parents:
diff changeset
1162 cpfseq average_depth_hold_total+1
heinrichsweikamp
parents:
diff changeset
1163 bra profile_view_get_depth_no_line ; no need to draw a 10min line, continue
heinrichsweikamp
parents:
diff changeset
1164 ; draw a new 10min line here...
heinrichsweikamp
parents:
diff changeset
1165 clrf logbook_sample_counter+0
heinrichsweikamp
parents:
diff changeset
1166 clrf logbook_sample_counter+1 ; clear counting registers for next line
heinrichsweikamp
parents:
diff changeset
1167
heinrichsweikamp
parents:
diff changeset
1168 ; Vertical lines...
heinrichsweikamp
parents:
diff changeset
1169 movlw color_deepblue
heinrichsweikamp
parents:
diff changeset
1170 call TFT_set_color ; Make this configurable?
heinrichsweikamp
parents:
diff changeset
1171 movlw profile_top+.1
heinrichsweikamp
parents:
diff changeset
1172 movff WREG,win_top
heinrichsweikamp
parents:
diff changeset
1173 incf logbook_pixel_x_pos,W ; draw one line to right to make sure it's the background of the profile
heinrichsweikamp
parents:
diff changeset
1174 movff WREG,win_leftx2 ; Left border (0-159)
heinrichsweikamp
parents:
diff changeset
1175 movlw profile_height_pixels
heinrichsweikamp
parents:
diff changeset
1176 movff WREG,win_height
heinrichsweikamp
parents:
diff changeset
1177 movlw profile_height_pixels
heinrichsweikamp
parents:
diff changeset
1178 movff WREG,win_width ; "Window" height
heinrichsweikamp
parents:
diff changeset
1179 call half_horizontal_line ; Inputs: win_top, win_leftx2, win_width, win_color1, win_color2
heinrichsweikamp
parents:
diff changeset
1180
heinrichsweikamp
parents:
diff changeset
1181 profile_view_get_depth_no_line:
heinrichsweikamp
parents:
diff changeset
1182 call ext_flash_byte_read_plus_0x20 ; read depth first
heinrichsweikamp
parents:
diff changeset
1183 movff temp1,logbook_cur_depth+0 ; low value
heinrichsweikamp
parents:
diff changeset
1184 call ext_flash_byte_read_plus_0x20 ; read depth first
heinrichsweikamp
parents:
diff changeset
1185 movff temp1,logbook_cur_depth+1 ; high value
heinrichsweikamp
parents:
diff changeset
1186 call ext_flash_byte_read_plus_0x20 ; read Profile Flag Byte
heinrichsweikamp
parents:
diff changeset
1187 movff temp1,timeout_counter2 ; Read Profile Flag Byte
heinrichsweikamp
parents:
diff changeset
1188
heinrichsweikamp
parents:
diff changeset
1189 bcf event_occured ; clear flag
heinrichsweikamp
parents:
diff changeset
1190 btfsc timeout_counter2,7
heinrichsweikamp
parents:
diff changeset
1191 bsf event_occured ; We also have an Event byte!
heinrichsweikamp
parents:
diff changeset
1192 bcf timeout_counter2,7 ; Clear Event Byte Flag (If any)
heinrichsweikamp
parents:
diff changeset
1193 ; timeout_counter2 now holds the number of additional bytes to ignore (0-127)
heinrichsweikamp
parents:
diff changeset
1194 movlw 0xFD ; end of profile bytes?
heinrichsweikamp
parents:
diff changeset
1195 cpfseq logbook_cur_depth+0
heinrichsweikamp
parents:
diff changeset
1196 bra profile_view_get_depth_new1 ; no 1st. 0xFD
heinrichsweikamp
parents:
diff changeset
1197 cpfseq logbook_cur_depth+1
heinrichsweikamp
parents:
diff changeset
1198 bra profile_view_get_depth_new1 ; no 2nd. 0xFD
heinrichsweikamp
parents:
diff changeset
1199 bsf end_of_profile ; End found! Set Flag! Skip remaining pixels!
heinrichsweikamp
parents:
diff changeset
1200 return
heinrichsweikamp
parents:
diff changeset
1201
heinrichsweikamp
parents:
diff changeset
1202 profile_view_get_depth_new1:
heinrichsweikamp
parents:
diff changeset
1203 btfsc event_occured ; Was there an event attached to this sample?
heinrichsweikamp
parents:
diff changeset
1204 rcall profile_view_get_depth_new2 ; Yes, get information about this event
heinrichsweikamp
parents:
diff changeset
1205
heinrichsweikamp
parents:
diff changeset
1206 ;---- Read Tp°, if any AND divisor reached AND bytes available -----------
heinrichsweikamp
parents:
diff changeset
1207 movf divisor_temperature,W ; Is Tp° divisor null ?
heinrichsweikamp
parents:
diff changeset
1208 bz profile_view_get_depth_no_tp; Yes: no Tp° curve.
heinrichsweikamp
parents:
diff changeset
1209 decf count_temperature,F ; Decrement tp° counter
heinrichsweikamp
parents:
diff changeset
1210 bnz profile_view_get_depth_no_tp; No temperature this time
heinrichsweikamp
parents:
diff changeset
1211
heinrichsweikamp
parents:
diff changeset
1212 call ext_flash_byte_read_plus_0x20 ; Tp° low
heinrichsweikamp
parents:
diff changeset
1213 decf timeout_counter2,F
heinrichsweikamp
parents:
diff changeset
1214 movff temp1,logbook_cur_tp+0
heinrichsweikamp
parents:
diff changeset
1215 call ext_flash_byte_read_plus_0x20 ; Tp° high
heinrichsweikamp
parents:
diff changeset
1216 decf timeout_counter2,F
heinrichsweikamp
parents:
diff changeset
1217 movff temp1,logbook_cur_tp+1
heinrichsweikamp
parents:
diff changeset
1218 movff divisor_temperature,count_temperature ; Restart counter.
heinrichsweikamp
parents:
diff changeset
1219
heinrichsweikamp
parents:
diff changeset
1220 ; Compute Tp° max on the fly...
heinrichsweikamp
parents:
diff changeset
1221 movff logbook_cur_tp+0,sub_a+0 ; Compare cur_tp > max_tp ?
heinrichsweikamp
parents:
diff changeset
1222 movff logbook_cur_tp+1,sub_a+1
heinrichsweikamp
parents:
diff changeset
1223 movff logbook_max_tp+0,sub_b+0
heinrichsweikamp
parents:
diff changeset
1224 movff logbook_max_tp+1,sub_b+1
heinrichsweikamp
parents:
diff changeset
1225 call sub16 ; SIGNED sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
1226 btfsc neg_flag
heinrichsweikamp
parents:
diff changeset
1227 bra profile_view_get_depth_no_tp
heinrichsweikamp
parents:
diff changeset
1228
heinrichsweikamp
parents:
diff changeset
1229 movff logbook_cur_tp+0,logbook_max_tp+0
heinrichsweikamp
parents:
diff changeset
1230 movff logbook_cur_tp+1,logbook_max_tp+1
heinrichsweikamp
parents:
diff changeset
1231
heinrichsweikamp
parents:
diff changeset
1232 ;---- Read deco, if any AND divisor=0 AND bytes available ----------------
heinrichsweikamp
parents:
diff changeset
1233 profile_view_get_depth_no_tp:
heinrichsweikamp
parents:
diff changeset
1234 movf divisor_deco,W
heinrichsweikamp
parents:
diff changeset
1235 bz profile_view_get_depth_no_deco
heinrichsweikamp
parents:
diff changeset
1236 decf count_deco,F
heinrichsweikamp
parents:
diff changeset
1237 bnz profile_view_get_depth_no_deco
heinrichsweikamp
parents:
diff changeset
1238
heinrichsweikamp
parents:
diff changeset
1239 call ext_flash_byte_read_plus_0x20
heinrichsweikamp
parents:
diff changeset
1240 decf timeout_counter2,F
heinrichsweikamp
parents:
diff changeset
1241 movff temp1,logbook_ceiling
heinrichsweikamp
parents:
diff changeset
1242 movff divisor_deco,count_deco ; Restart counter.
heinrichsweikamp
parents:
diff changeset
1243
heinrichsweikamp
parents:
diff changeset
1244 ;---- Read GF, if any AND divisor=0 AND bytes available ------------------
heinrichsweikamp
parents:
diff changeset
1245 profile_view_get_depth_no_deco:
heinrichsweikamp
parents:
diff changeset
1246 movf timeout_counter2,W ; No more extra bytes ?
heinrichsweikamp
parents:
diff changeset
1247 btfsc STATUS,Z
heinrichsweikamp
parents:
diff changeset
1248 return ; No: done.
heinrichsweikamp
parents:
diff changeset
1249
heinrichsweikamp
parents:
diff changeset
1250 ; Then skip remaining bytes...
heinrichsweikamp
parents:
diff changeset
1251 movf timeout_counter2,W ; number of additional bytes to ignore (0-127)
heinrichsweikamp
parents:
diff changeset
1252 call incf_ext_flash_address0_0x20; increases bytes in ext_flash_address:3 with 0x200000 bank switching
heinrichsweikamp
parents:
diff changeset
1253 return
heinrichsweikamp
parents:
diff changeset
1254
heinrichsweikamp
parents:
diff changeset
1255 profile_view_get_depth_new2:
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1256 clrf EventByte
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1257 clrf EventByte2 ; Clear EventBytes
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1258 call ext_flash_byte_read_plus_0x20 ; Read Event byte
0
heinrichsweikamp
parents:
diff changeset
1259 movff temp1,EventByte ; store EventByte
heinrichsweikamp
parents:
diff changeset
1260 decf timeout_counter2,F ; reduce counter
98
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 89
diff changeset
1261
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 89
diff changeset
1262 btfss EventByte,7 ; Another Event byte?
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 89
diff changeset
1263 bra profile_no_second_eventbyte ; No
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 89
diff changeset
1264 call ext_flash_byte_read_plus_0x20; Read Event byte2
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 89
diff changeset
1265 movff temp1,EventByte2 ; store EventByte2
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 89
diff changeset
1266 decf timeout_counter2,F ; reduce counter
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 89
diff changeset
1267 bcf EventByte,7 ; Clear flag
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 89
diff changeset
1268
24b3fd59e61f add event "bailout" in profile
heinrichsweikamp
parents: 89
diff changeset
1269 profile_no_second_eventbyte:
0
heinrichsweikamp
parents:
diff changeset
1270 ; Check Event flags in the EventByte
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1271 btfsc EventByte2,0 ; Bailout?
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1272 bra logbook_event2 ; Yes!
0
heinrichsweikamp
parents:
diff changeset
1273 btfsc EventByte,4 ; Manual Gas Changed?
heinrichsweikamp
parents:
diff changeset
1274 bra logbook_event1 ; Yes!
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1275 btfsc EventByte,6 ; Setpoint Change?
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1276 bra logbook_event3 ; Yes!
0
heinrichsweikamp
parents:
diff changeset
1277 btfss EventByte,5 ; Stored Gas Changed?
heinrichsweikamp
parents:
diff changeset
1278 return ; No, return
heinrichsweikamp
parents:
diff changeset
1279 ; Stored Gas changed!
heinrichsweikamp
parents:
diff changeset
1280 call ext_flash_byte_read_plus_0x20 ; Read Gas#
heinrichsweikamp
parents:
diff changeset
1281 decf timeout_counter2,F ; reduce counter
heinrichsweikamp
parents:
diff changeset
1282 movff temp1,average_depth_hold_total+3
heinrichsweikamp
parents:
diff changeset
1283 rcall profile_display_color ; Change profile color according to gas number
heinrichsweikamp
parents:
diff changeset
1284 return
heinrichsweikamp
parents:
diff changeset
1285
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1286 logbook_event1: ; Gas6 changed
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1287 bsf gas6_changed
0
heinrichsweikamp
parents:
diff changeset
1288 movlw 6 ; Just color backup to 6
heinrichsweikamp
parents:
diff changeset
1289 movwf average_depth_hold_total+3
heinrichsweikamp
parents:
diff changeset
1290 rcall profile_display_color ; Back to normal profile color.
heinrichsweikamp
parents:
diff changeset
1291 return ;(The two bytes indicating the manual gas change will be ignored in the standard "ignore loop" above...)
heinrichsweikamp
parents:
diff changeset
1292
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1293 logbook_event2: ; Bailout
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1294 bsf is_bailout ; Set flag
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1295 movff average_depth_hold_total+3,total_divetime_seconds+0 ; Backup last gas color in case we return to CCR
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1296 movlw 6 ; Use Gas6 color
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1297 movwf average_depth_hold_total+3
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1298 rcall profile_display_color ; Back to normal profile color.
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1299 return ;(The two bytes indicating the bailout gas selected will be ignored in the standard "ignore loop" above...)
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1300
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1301 logbook_event3: ; Setpoint change
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1302 btfss is_bailout ; Are we in bailout?
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1303 return ; No, return
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1304 ; We were in bailout before, restore profile color
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1305 movff total_divetime_seconds+0,average_depth_hold_total+3 ; Restore color
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1306 rcall profile_display_color ; Back to normal profile color.
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1307 return
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1308
0
heinrichsweikamp
parents:
diff changeset
1309 exit_profileview:
heinrichsweikamp
parents:
diff changeset
1310 call speed_fastest
heinrichsweikamp
parents:
diff changeset
1311 bcf sleepmode
heinrichsweikamp
parents:
diff changeset
1312 clrf timeout_counter2 ; restore all registers to build same page again
heinrichsweikamp
parents:
diff changeset
1313 movff divemins_backup,divemins+0
heinrichsweikamp
parents:
diff changeset
1314 movff logbook_divenumber_temp, logbook_divenumber
heinrichsweikamp
parents:
diff changeset
1315 movff logbook_max_dive_counter_temp,logbook_max_dive_counter
heinrichsweikamp
parents:
diff changeset
1316 incf logbook_max_dive_counter,F
heinrichsweikamp
parents:
diff changeset
1317 decf logbook_divenumber,F
heinrichsweikamp
parents:
diff changeset
1318 bcf all_dives_shown
heinrichsweikamp
parents:
diff changeset
1319 clrf menupos3 ; here: used row on current page
heinrichsweikamp
parents:
diff changeset
1320 movlw logbook_row_number
heinrichsweikamp
parents:
diff changeset
1321 movwf menupos ; here: active row on current page
heinrichsweikamp
parents:
diff changeset
1322 clrf CCP1CON ; stop PWM
heinrichsweikamp
parents:
diff changeset
1323 bcf PORTC,2 ; Pull PWM out to GND
heinrichsweikamp
parents:
diff changeset
1324 call TFT_ClearScreen ; clear details/profile
heinrichsweikamp
parents:
diff changeset
1325 goto logbook2 ; start search
heinrichsweikamp
parents:
diff changeset
1326
heinrichsweikamp
parents:
diff changeset
1327 next_logbook2:
heinrichsweikamp
parents:
diff changeset
1328 btfsc all_dives_shown ; all shown
heinrichsweikamp
parents:
diff changeset
1329 goto logbook ; all reset
heinrichsweikamp
parents:
diff changeset
1330 clrf menupos3
heinrichsweikamp
parents:
diff changeset
1331 movlw logbook_row_number
heinrichsweikamp
parents:
diff changeset
1332 movwf menupos
heinrichsweikamp
parents:
diff changeset
1333 incf logbook_page_number,F ; start new screen
heinrichsweikamp
parents:
diff changeset
1334 clrf CCP1CON ; stop PWM
heinrichsweikamp
parents:
diff changeset
1335 bcf PORTC,2 ; Pull PWM out to GND
heinrichsweikamp
parents:
diff changeset
1336 call TFT_ClearScreen
heinrichsweikamp
parents:
diff changeset
1337 goto logbook2 ; start search
heinrichsweikamp
parents:
diff changeset
1338
heinrichsweikamp
parents:
diff changeset
1339 next_logbook3:
heinrichsweikamp
parents:
diff changeset
1340 incf menupos,F ; +1
heinrichsweikamp
parents:
diff changeset
1341 movlw logbook_row_number+.2
heinrichsweikamp
parents:
diff changeset
1342 cpfsgt menupos ; =logbook_row_number+.3?
heinrichsweikamp
parents:
diff changeset
1343 bra next_logbook3a ; No
heinrichsweikamp
parents:
diff changeset
1344 movlw .1
heinrichsweikamp
parents:
diff changeset
1345 movwf menupos
heinrichsweikamp
parents:
diff changeset
1346 bra next_logbook3b
heinrichsweikamp
parents:
diff changeset
1347
heinrichsweikamp
parents:
diff changeset
1348 next_logbook3a:
heinrichsweikamp
parents:
diff changeset
1349 incf menupos3,W ; last entry in current page +1
heinrichsweikamp
parents:
diff changeset
1350 cpfseq menupos ; same as cursor pos.?
heinrichsweikamp
parents:
diff changeset
1351 bra next_logbook3b ; No
heinrichsweikamp
parents:
diff changeset
1352 movlw logbook_row_number+.1 ; Yes, ...
heinrichsweikamp
parents:
diff changeset
1353 movwf menupos ; ... jump directly to "next page" if page is not full
heinrichsweikamp
parents:
diff changeset
1354
heinrichsweikamp
parents:
diff changeset
1355 movlw logbook_row_number
heinrichsweikamp
parents:
diff changeset
1356 cpfseq menupos3 ; Last dive was row logbook_row_number?
heinrichsweikamp
parents:
diff changeset
1357 bsf all_dives_shown ; No, set flag to load first page again (full reset)
heinrichsweikamp
parents:
diff changeset
1358
heinrichsweikamp
parents:
diff changeset
1359 next_logbook3b:
heinrichsweikamp
parents:
diff changeset
1360 clrf timeout_counter2
heinrichsweikamp
parents:
diff changeset
1361 call TFT_logbook_cursor
heinrichsweikamp
parents:
diff changeset
1362
heinrichsweikamp
parents:
diff changeset
1363 bcf switch_left
heinrichsweikamp
parents:
diff changeset
1364 goto logbook_loop
heinrichsweikamp
parents:
diff changeset
1365
heinrichsweikamp
parents:
diff changeset
1366 display_listdive:
heinrichsweikamp
parents:
diff changeset
1367 bsf logbook_page_not_empty ; Page not empty
heinrichsweikamp
parents:
diff changeset
1368 incf menupos3,F
heinrichsweikamp
parents:
diff changeset
1369
heinrichsweikamp
parents:
diff changeset
1370 bsf leftbind
heinrichsweikamp
parents:
diff changeset
1371 WIN_FONT FT_SMALL
heinrichsweikamp
parents:
diff changeset
1372 WIN_LEFT logbook_list_left
heinrichsweikamp
parents:
diff changeset
1373
heinrichsweikamp
parents:
diff changeset
1374 decf menupos3,W ; -1 into wreg
heinrichsweikamp
parents:
diff changeset
1375 mullw logbook_row_offset
heinrichsweikamp
parents:
diff changeset
1376 movff PRODL,win_top
heinrichsweikamp
parents:
diff changeset
1377
heinrichsweikamp
parents:
diff changeset
1378 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
1379 movff logbook_divenumber,lo
heinrichsweikamp
parents:
diff changeset
1380 output_8 ; # of dive
heinrichsweikamp
parents:
diff changeset
1381 PUTC ' '
heinrichsweikamp
parents:
diff changeset
1382 LOG_POINT_TO log_date+1 ; Point to month
heinrichsweikamp
parents:
diff changeset
1383 call ext_flash_byte_read_plus
heinrichsweikamp
parents:
diff changeset
1384 movff temp1,lo ; read month
heinrichsweikamp
parents:
diff changeset
1385
heinrichsweikamp
parents:
diff changeset
1386 display_listdive2:
heinrichsweikamp
parents:
diff changeset
1387 movff lo,convert_value_temp+0 ; Month (in lo, see above)
heinrichsweikamp
parents:
diff changeset
1388 call ext_flash_byte_read_plus ; Day
heinrichsweikamp
parents:
diff changeset
1389 movff temp1,convert_value_temp+1
heinrichsweikamp
parents:
diff changeset
1390 call TFT_convert_date_short ; converts into "DD/MM" or "MM/DD" or "MM/DD" into buffer
heinrichsweikamp
parents:
diff changeset
1391 PUTC ' '
heinrichsweikamp
parents:
diff changeset
1392
heinrichsweikamp
parents:
diff changeset
1393 LOG_POINT_TO log_max_depth ; Point to max. depth
heinrichsweikamp
parents:
diff changeset
1394 call ext_flash_byte_read_plus ; max. Depth
heinrichsweikamp
parents:
diff changeset
1395 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1396 call ext_flash_byte_read_plus
heinrichsweikamp
parents:
diff changeset
1397 movff temp1,hi
heinrichsweikamp
parents:
diff changeset
1398
heinrichsweikamp
parents:
diff changeset
1399 TSTOSS opt_units ; 0=Meters, 1=Feets
heinrichsweikamp
parents:
diff changeset
1400 bra display_listdive2_metric
heinrichsweikamp
parents:
diff changeset
1401 ;display_listdive2_imperial:
heinrichsweikamp
parents:
diff changeset
1402 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
heinrichsweikamp
parents:
diff changeset
1403 PUTC ' '
25
f65d070a5b76 fix imperial units in logbook
heinrichsweikamp
parents: 0
diff changeset
1404 bcf leftbind
f65d070a5b76 fix imperial units in logbook
heinrichsweikamp
parents: 0
diff changeset
1405 output_16_3
0
heinrichsweikamp
parents:
diff changeset
1406 STRCAT_TEXT tFeets1
heinrichsweikamp
parents:
diff changeset
1407 bra display_listdive3
heinrichsweikamp
parents:
diff changeset
1408
heinrichsweikamp
parents:
diff changeset
1409 display_listdive2_metric:
heinrichsweikamp
parents:
diff changeset
1410 bsf ignore_digit5 ; no cm...
heinrichsweikamp
parents:
diff changeset
1411 movlw d'1' ; +1
heinrichsweikamp
parents:
diff changeset
1412 movff WREG,ignore_digits ; no 1000m
heinrichsweikamp
parents:
diff changeset
1413 bcf leftbind
heinrichsweikamp
parents:
diff changeset
1414 output_16dp .3 ; xxx.y
heinrichsweikamp
parents:
diff changeset
1415 STRCAT_TEXT tMeters
heinrichsweikamp
parents:
diff changeset
1416 PUTC ' '
heinrichsweikamp
parents:
diff changeset
1417
heinrichsweikamp
parents:
diff changeset
1418 display_listdive3:
heinrichsweikamp
parents:
diff changeset
1419 call ext_flash_byte_read_plus
heinrichsweikamp
parents:
diff changeset
1420 movff temp1,lo ; read divetime minutes
heinrichsweikamp
parents:
diff changeset
1421 call ext_flash_byte_read_plus
heinrichsweikamp
parents:
diff changeset
1422 movff temp1,hi
heinrichsweikamp
parents:
diff changeset
1423 output_16_3 ; Divetime minutes (0-999min)
heinrichsweikamp
parents:
diff changeset
1424 STRCAT_TEXT_PRINT tMinutes ; Display header-row in list
heinrichsweikamp
parents:
diff changeset
1425 return
heinrichsweikamp
parents:
diff changeset
1426
heinrichsweikamp
parents:
diff changeset
1427 logbook_show_divenumber:
heinrichsweikamp
parents:
diff changeset
1428 call do_logoffset_common_read ; Read into lo:hi
heinrichsweikamp
parents:
diff changeset
1429 tstfsz lo ; lo=0?
heinrichsweikamp
parents:
diff changeset
1430 bra logbook_show_divenumber2 ; No, adjust offset
heinrichsweikamp
parents:
diff changeset
1431 tstfsz hi ; hi=0?
heinrichsweikamp
parents:
diff changeset
1432 bra logbook_show_divenumber2 ; No, adjust offset
heinrichsweikamp
parents:
diff changeset
1433 movff divesecs,lo ; lo=0 and hi=0 -> skip Offset routine
heinrichsweikamp
parents:
diff changeset
1434 bra logbook_show_divenumber3 ; Display now
heinrichsweikamp
parents:
diff changeset
1435
heinrichsweikamp
parents:
diff changeset
1436 logbook_show_divenumber2:
heinrichsweikamp
parents:
diff changeset
1437 movlw d'1'
heinrichsweikamp
parents:
diff changeset
1438 addwf lo,F
heinrichsweikamp
parents:
diff changeset
1439 movlw d'0'
heinrichsweikamp
parents:
diff changeset
1440 addwfc hi,F ; hi:lo = hi:lo + 1
heinrichsweikamp
parents:
diff changeset
1441 movff lo,sub_a+0
heinrichsweikamp
parents:
diff changeset
1442 movff hi,sub_a+1
heinrichsweikamp
parents:
diff changeset
1443 movff divesecs,sub_b+0
heinrichsweikamp
parents:
diff changeset
1444 clrf sub_b+1
heinrichsweikamp
parents:
diff changeset
1445 call subU16 ; sub_c = sub_a - sub_b
heinrichsweikamp
parents:
diff changeset
1446 movff sub_c+0,lo
heinrichsweikamp
parents:
diff changeset
1447 movff sub_c+1,hi
heinrichsweikamp
parents:
diff changeset
1448
heinrichsweikamp
parents:
diff changeset
1449 logbook_show_divenumber3:
heinrichsweikamp
parents:
diff changeset
1450 WIN_MEDIUM logbook_divenumer_column, logbook_divenumer_row
heinrichsweikamp
parents:
diff changeset
1451 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
1452 bsf leftbind
heinrichsweikamp
parents:
diff changeset
1453 output_16 ; # of dive in logbook
heinrichsweikamp
parents:
diff changeset
1454 bcf leftbind
heinrichsweikamp
parents:
diff changeset
1455 STRCAT_PRINT ""
heinrichsweikamp
parents:
diff changeset
1456 return
heinrichsweikamp
parents:
diff changeset
1457
heinrichsweikamp
parents:
diff changeset
1458
heinrichsweikamp
parents:
diff changeset
1459 logbook_page2: ; Show more info
heinrichsweikamp
parents:
diff changeset
1460 call speed_fastest
heinrichsweikamp
parents:
diff changeset
1461 clrf CCP1CON ; stop PWM
heinrichsweikamp
parents:
diff changeset
1462 bcf PORTC,2 ; Pull PWM out to GND
heinrichsweikamp
parents:
diff changeset
1463 call TFT_ClearScreen ; Clear screen
heinrichsweikamp
parents:
diff changeset
1464
heinrichsweikamp
parents:
diff changeset
1465 ; Set ext_flash pointer to "#divesecs-oldest" dive
heinrichsweikamp
parents:
diff changeset
1466 ; compute read_int_eeprom .2 - divesecs
heinrichsweikamp
parents:
diff changeset
1467 ; Read required header data for profile display
heinrichsweikamp
parents:
diff changeset
1468 ; look in header for pointer to begin of diveprofile (Byte 2-4)
heinrichsweikamp
parents:
diff changeset
1469 ; Set pointer (ext_flash_log_pointer:3) to this address, start drawing
heinrichsweikamp
parents:
diff changeset
1470
heinrichsweikamp
parents:
diff changeset
1471 decf divesecs,F ;-1
heinrichsweikamp
parents:
diff changeset
1472 read_int_eeprom .2
heinrichsweikamp
parents:
diff changeset
1473 movf EEDATA,W
heinrichsweikamp
parents:
diff changeset
1474 bcf STATUS,C
heinrichsweikamp
parents:
diff changeset
1475 subfwb divesecs,W ; max. dives (low value) - divesecs
heinrichsweikamp
parents:
diff changeset
1476 movwf lo ; result
heinrichsweikamp
parents:
diff changeset
1477 incf divesecs,F ;+1
heinrichsweikamp
parents:
diff changeset
1478 ; Set ext_flash_address:3 to TOC entry of this dive
heinrichsweikamp
parents:
diff changeset
1479 ; 1st: 200000h-200FFFh -> lo=0
heinrichsweikamp
parents:
diff changeset
1480 ; 2nd: 201000h-201FFFh -> lo=1
heinrichsweikamp
parents:
diff changeset
1481 ; 3rd: 202000h-202FFFh -> lo=2
heinrichsweikamp
parents:
diff changeset
1482 ; 256: 2FF000h-2FFFFFh -> lo=255 (And hi>0...)
heinrichsweikamp
parents:
diff changeset
1483 clrf ext_flash_address+0
heinrichsweikamp
parents:
diff changeset
1484 clrf ext_flash_address+1
heinrichsweikamp
parents:
diff changeset
1485 movlw 0x20
heinrichsweikamp
parents:
diff changeset
1486 movwf ext_flash_address+2
heinrichsweikamp
parents:
diff changeset
1487 movlw .16
heinrichsweikamp
parents:
diff changeset
1488 mulwf lo ; lo*16 = offset to 0x2000 (up:hi)
heinrichsweikamp
parents:
diff changeset
1489 movf PRODL,W
heinrichsweikamp
parents:
diff changeset
1490 addwf ext_flash_address+1,F
heinrichsweikamp
parents:
diff changeset
1491 movf PRODH,W
heinrichsweikamp
parents:
diff changeset
1492 addwfc ext_flash_address+2,F
heinrichsweikamp
parents:
diff changeset
1493 ; pointer at the first 0xFA of header
heinrichsweikamp
parents:
diff changeset
1494 call logbook_show_divenumber ; Show the dive number in medium font
heinrichsweikamp
parents:
diff changeset
1495
heinrichsweikamp
parents:
diff changeset
1496
heinrichsweikamp
parents:
diff changeset
1497 LOG_POINT_TO log_surface_press
heinrichsweikamp
parents:
diff changeset
1498 ; surface pressure in mbar
heinrichsweikamp
parents:
diff changeset
1499 call ext_flash_byte_read_plus ; read surface pressure
heinrichsweikamp
parents:
diff changeset
1500 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1501 call ext_flash_byte_read_plus ; read surface pressure
heinrichsweikamp
parents:
diff changeset
1502 movff temp1,hi
heinrichsweikamp
parents:
diff changeset
1503 WIN_TINY MBAR_column,MBAR_row
heinrichsweikamp
parents:
diff changeset
1504 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
1505 bsf leftbind
heinrichsweikamp
parents:
diff changeset
1506 output_16 ; Air pressure before dive
heinrichsweikamp
parents:
diff changeset
1507 STRCAT_TEXT_PRINT tMBAR
heinrichsweikamp
parents:
diff changeset
1508
89
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 66
diff changeset
1509 ; OC/CC Gas List
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 66
diff changeset
1510 LOG_POINT_TO log_divemode
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 66
diff changeset
1511 call ext_flash_byte_read_plus ; 0=OC, 1=CC, 2=Gauge, 3=Apnea into temp1
0
heinrichsweikamp
parents:
diff changeset
1512 WIN_TINY log2_title_column,log2_title_row1
heinrichsweikamp
parents:
diff changeset
1513 WIN_COLOR color_greenish
89
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 66
diff changeset
1514 movlw .1
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 66
diff changeset
1515 cpfseq temp1 ;=CC?
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 66
diff changeset
1516 bra logbook_gaslist_oc
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 66
diff changeset
1517 STRCPY_TEXT_PRINT tGaslistCC
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 66
diff changeset
1518 bra logbook_gaslist_common
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 66
diff changeset
1519 logbook_gaslist_oc:
0
heinrichsweikamp
parents:
diff changeset
1520 STRCPY_TEXT_PRINT tGaslist
89
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 66
diff changeset
1521 logbook_gaslist_common:
c34516c99ca8 BUGFIX: No average depth for end-of-dive portion (<1m)
heinrichsweikamp
parents: 66
diff changeset
1522 LOG_POINT_TO log_gas1
0
heinrichsweikamp
parents:
diff changeset
1523 WIN_FRAME_STD log2_title_row1-2, log2_gas_row5+.15, log2_title_column-2, .159 ; Top, Bottom, Left, Right
heinrichsweikamp
parents:
diff changeset
1524 bcf leftbind
heinrichsweikamp
parents:
diff changeset
1525 movlw color_white ; Color for Gas 1
heinrichsweikamp
parents:
diff changeset
1526 call TFT_set_color ; Set Color...
heinrichsweikamp
parents:
diff changeset
1527 WIN_TINY log2_gas_column, log2_gas_row1
heinrichsweikamp
parents:
diff changeset
1528 rcall log_show_gas_common2
heinrichsweikamp
parents:
diff changeset
1529 movlw color_green ; Color for Gas 2
heinrichsweikamp
parents:
diff changeset
1530 call TFT_set_color ; Set Color...
heinrichsweikamp
parents:
diff changeset
1531 WIN_TINY log2_gas_column, log2_gas_row2
heinrichsweikamp
parents:
diff changeset
1532 rcall log_show_gas_common2
heinrichsweikamp
parents:
diff changeset
1533 movlw color_red ; Color for Gas 3
heinrichsweikamp
parents:
diff changeset
1534 call TFT_set_color ; Set Color...
heinrichsweikamp
parents:
diff changeset
1535 WIN_TINY log2_gas_column, log2_gas_row3
heinrichsweikamp
parents:
diff changeset
1536 rcall log_show_gas_common2
heinrichsweikamp
parents:
diff changeset
1537 movlw color_yellow ; Color for Gas 4
heinrichsweikamp
parents:
diff changeset
1538 call TFT_set_color ; Set Color...
heinrichsweikamp
parents:
diff changeset
1539 WIN_TINY log2_gas_column, log2_gas_row4
heinrichsweikamp
parents:
diff changeset
1540 rcall log_show_gas_common2
heinrichsweikamp
parents:
diff changeset
1541 movlw color_cyan ; Color for Gas 5
heinrichsweikamp
parents:
diff changeset
1542 call TFT_set_color ; Set Color...
heinrichsweikamp
parents:
diff changeset
1543 WIN_TINY log2_gas_column, log2_gas_row5
heinrichsweikamp
parents:
diff changeset
1544 rcall log_show_gas_common2
heinrichsweikamp
parents:
diff changeset
1545
heinrichsweikamp
parents:
diff changeset
1546 ; Firmware
heinrichsweikamp
parents:
diff changeset
1547 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
1548 WIN_TINY log2_firmware_column,log2_firmware_row
heinrichsweikamp
parents:
diff changeset
1549 STRCPY_TEXT tFirmware
heinrichsweikamp
parents:
diff changeset
1550 call ext_flash_byte_read_plus ; read firmware xx
heinrichsweikamp
parents:
diff changeset
1551 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1552 bsf leftbind
heinrichsweikamp
parents:
diff changeset
1553 output_8
heinrichsweikamp
parents:
diff changeset
1554 PUTC "."
heinrichsweikamp
parents:
diff changeset
1555 call ext_flash_byte_read_plus ; read firmware yy
heinrichsweikamp
parents:
diff changeset
1556 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1557 output_99x
heinrichsweikamp
parents:
diff changeset
1558 STRCAT_PRINT ""
heinrichsweikamp
parents:
diff changeset
1559
heinrichsweikamp
parents:
diff changeset
1560 ; Battery
heinrichsweikamp
parents:
diff changeset
1561 WIN_TINY log2_battery_column,log2_battery_row
heinrichsweikamp
parents:
diff changeset
1562 STRCPY "Batt:"
heinrichsweikamp
parents:
diff changeset
1563 call ext_flash_byte_read_plus ; read battery low
heinrichsweikamp
parents:
diff changeset
1564 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1565 call ext_flash_byte_read_plus ; read battery high
heinrichsweikamp
parents:
diff changeset
1566 movff temp1,hi
heinrichsweikamp
parents:
diff changeset
1567 output_16dp .2
heinrichsweikamp
parents:
diff changeset
1568 STRCAT_PRINT "V"
heinrichsweikamp
parents:
diff changeset
1569
heinrichsweikamp
parents:
diff changeset
1570 ; Setpoint list
heinrichsweikamp
parents:
diff changeset
1571 LOG_POINT_TO log_sp1
heinrichsweikamp
parents:
diff changeset
1572 WIN_TINY log2_title_column,log2_title_sp_row
heinrichsweikamp
parents:
diff changeset
1573 WIN_COLOR color_greenish
heinrichsweikamp
parents:
diff changeset
1574 STRCPY_TEXT_PRINT tFixedSetpoints
heinrichsweikamp
parents:
diff changeset
1575 WIN_FRAME_STD log2_title_sp_row-2, log2_sp_row5+.15, log2_title_column-2, .159 ; Top, Bottom, Left, Right
heinrichsweikamp
parents:
diff changeset
1576 WIN_TINY log2_gas_column, log2_sp_row1
heinrichsweikamp
parents:
diff changeset
1577 rcall log_show_sp_common
heinrichsweikamp
parents:
diff changeset
1578 WIN_TINY log2_gas_column, log2_sp_row2
heinrichsweikamp
parents:
diff changeset
1579 rcall log_show_sp_common
heinrichsweikamp
parents:
diff changeset
1580 WIN_TINY log2_gas_column, log2_sp_row3
heinrichsweikamp
parents:
diff changeset
1581 rcall log_show_sp_common
heinrichsweikamp
parents:
diff changeset
1582 WIN_TINY log2_gas_column, log2_sp_row4
heinrichsweikamp
parents:
diff changeset
1583 rcall log_show_sp_common
heinrichsweikamp
parents:
diff changeset
1584 WIN_TINY log2_gas_column, log2_sp_row5
heinrichsweikamp
parents:
diff changeset
1585 rcall log_show_sp_common
heinrichsweikamp
parents:
diff changeset
1586
heinrichsweikamp
parents:
diff changeset
1587 ; Salinity
heinrichsweikamp
parents:
diff changeset
1588 WIN_TINY log2_salinity_column,log2_salinity_row
heinrichsweikamp
parents:
diff changeset
1589 STRCPY_TEXT tDvSalinity
heinrichsweikamp
parents:
diff changeset
1590 bsf leftbind
heinrichsweikamp
parents:
diff changeset
1591 call ext_flash_byte_read_plus ; read salinity
heinrichsweikamp
parents:
diff changeset
1592 movff temp1,lo
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1593 movff temp1,total_divetime_seconds+1 ; backup for average depth display
0
heinrichsweikamp
parents:
diff changeset
1594 output_8
heinrichsweikamp
parents:
diff changeset
1595 STRCAT_PRINT "%"
heinrichsweikamp
parents:
diff changeset
1596
heinrichsweikamp
parents:
diff changeset
1597 ; CNS
heinrichsweikamp
parents:
diff changeset
1598 LOG_POINT_TO log_cns_start
heinrichsweikamp
parents:
diff changeset
1599 WIN_TINY log2_cns_column,log2_cns_row
heinrichsweikamp
parents:
diff changeset
1600 STRCPY_TEXT tCNS2
heinrichsweikamp
parents:
diff changeset
1601 call ext_flash_byte_read_plus ; read cns low
heinrichsweikamp
parents:
diff changeset
1602 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1603 call ext_flash_byte_read_plus ; read cns high
heinrichsweikamp
parents:
diff changeset
1604 movff temp1,hi
heinrichsweikamp
parents:
diff changeset
1605 output_16
heinrichsweikamp
parents:
diff changeset
1606 LOG_POINT_TO log_cns_end
heinrichsweikamp
parents:
diff changeset
1607 STRCAT "->"
heinrichsweikamp
parents:
diff changeset
1608 call ext_flash_byte_read_plus ; read CNS low
heinrichsweikamp
parents:
diff changeset
1609 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1610 call ext_flash_byte_read_plus ; read CNS high
heinrichsweikamp
parents:
diff changeset
1611 movff temp1,hi
heinrichsweikamp
parents:
diff changeset
1612 output_16
heinrichsweikamp
parents:
diff changeset
1613 STRCAT_PRINT "%"
heinrichsweikamp
parents:
diff changeset
1614
heinrichsweikamp
parents:
diff changeset
1615 ; Average depth
heinrichsweikamp
parents:
diff changeset
1616 WIN_TINY log2_avr_column,log2_avr_row
heinrichsweikamp
parents:
diff changeset
1617 STRCPY_TEXT tAVR
heinrichsweikamp
parents:
diff changeset
1618 call ext_flash_byte_read_plus ; read avr low
heinrichsweikamp
parents:
diff changeset
1619 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1620 call ext_flash_byte_read_plus ; read avr high
heinrichsweikamp
parents:
diff changeset
1621 movff temp1,hi
99
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1622
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1623 movf total_divetime_seconds+1,W ; salinity for this dive
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1624 call adjust_depth_with_salinity_log ; computes salinity setting (FROM WREG!) into lo:hi [mbar]
87cc1adfe4da show event "bailout" in the internal logbook
heinrichsweikamp
parents: 98
diff changeset
1625
0
heinrichsweikamp
parents:
diff changeset
1626 output_16dp .3
heinrichsweikamp
parents:
diff changeset
1627 STRCAT_PRINT "m"
heinrichsweikamp
parents:
diff changeset
1628
heinrichsweikamp
parents:
diff changeset
1629 ; Deco model
heinrichsweikamp
parents:
diff changeset
1630 LOG_POINT_TO log_decomodel
heinrichsweikamp
parents:
diff changeset
1631 WIN_TINY log2_decomodel_column,log2_decomodel_row
heinrichsweikamp
parents:
diff changeset
1632 STRCPY_TEXT tDkMode
heinrichsweikamp
parents:
diff changeset
1633 call ext_flash_byte_read_plus ; read deco model
heinrichsweikamp
parents:
diff changeset
1634 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1635 decfsz temp1,F
heinrichsweikamp
parents:
diff changeset
1636 bra logbook_decomodel1
heinrichsweikamp
parents:
diff changeset
1637 ; Deco model GF Version
heinrichsweikamp
parents:
diff changeset
1638 STRCAT_TEXT_PRINT tZHL16GF
heinrichsweikamp
parents:
diff changeset
1639 LOG_POINT_TO log_gf_lo
heinrichsweikamp
parents:
diff changeset
1640 WIN_TINY log2_decomodel2_column,log2_decomodel2_row
heinrichsweikamp
parents:
diff changeset
1641 STRCPY_TEXT tGF_low
heinrichsweikamp
parents:
diff changeset
1642 call ext_flash_byte_read_plus ; Read GF lo
heinrichsweikamp
parents:
diff changeset
1643 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1644 output_8
heinrichsweikamp
parents:
diff changeset
1645 STRCAT_PRINT "%"
heinrichsweikamp
parents:
diff changeset
1646 WIN_TINY log2_decomodel3_column,log2_decomodel3_row
heinrichsweikamp
parents:
diff changeset
1647 STRCPY_TEXT tGF_high
heinrichsweikamp
parents:
diff changeset
1648 call ext_flash_byte_read_plus ; Read GF hi
heinrichsweikamp
parents:
diff changeset
1649 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1650 output_8
heinrichsweikamp
parents:
diff changeset
1651 STRCAT_PRINT "%"
heinrichsweikamp
parents:
diff changeset
1652 bra logbook_decomodel2
heinrichsweikamp
parents:
diff changeset
1653 logbook_decomodel1:
heinrichsweikamp
parents:
diff changeset
1654 ; Deco model NON-GF Version
heinrichsweikamp
parents:
diff changeset
1655 STRCAT_TEXT_PRINT tZHL16
heinrichsweikamp
parents:
diff changeset
1656 LOG_POINT_TO log_sat_mult
heinrichsweikamp
parents:
diff changeset
1657 WIN_TINY log2_decomodel2_column,log2_decomodel2_row
heinrichsweikamp
parents:
diff changeset
1658 STRCPY_TEXT tSaturationMult
heinrichsweikamp
parents:
diff changeset
1659 call ext_flash_byte_read_plus ; Read sat_mult
heinrichsweikamp
parents:
diff changeset
1660 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1661 output_8
heinrichsweikamp
parents:
diff changeset
1662 STRCAT_PRINT "%"
heinrichsweikamp
parents:
diff changeset
1663 WIN_TINY log2_decomodel3_column,log2_decomodel3_row
heinrichsweikamp
parents:
diff changeset
1664 STRCPY_TEXT tDesaturationMult
heinrichsweikamp
parents:
diff changeset
1665 call ext_flash_byte_read_plus ; Read desat_mult
heinrichsweikamp
parents:
diff changeset
1666 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1667 output_8
heinrichsweikamp
parents:
diff changeset
1668 STRCAT_PRINT "%"
heinrichsweikamp
parents:
diff changeset
1669 logbook_decomodel2:
heinrichsweikamp
parents:
diff changeset
1670 ; Dive mode
heinrichsweikamp
parents:
diff changeset
1671 LOG_POINT_TO log_divemode
heinrichsweikamp
parents:
diff changeset
1672 WIN_TINY log2_divemode_column,log2_divemode_row
heinrichsweikamp
parents:
diff changeset
1673 STRCPY_TEXT tDvMode
heinrichsweikamp
parents:
diff changeset
1674 call ext_flash_byte_read_plus ; Read divemode
heinrichsweikamp
parents:
diff changeset
1675 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1676 call TFT_display_decotype_surface1 ; "strcat_print"s divemode (OC, CC, APNEA or GAUGE)
heinrichsweikamp
parents:
diff changeset
1677
heinrichsweikamp
parents:
diff changeset
1678 ; Last deco
heinrichsweikamp
parents:
diff changeset
1679 LOG_POINT_TO log_last_stop
heinrichsweikamp
parents:
diff changeset
1680 WIN_TINY log2_lastdeco_column,log2_lastdeco_row
heinrichsweikamp
parents:
diff changeset
1681 STRCPY_TEXT tLastDecostop
heinrichsweikamp
parents:
diff changeset
1682 call ext_flash_byte_read_plus ; Read last stop
heinrichsweikamp
parents:
diff changeset
1683 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1684 output_8
heinrichsweikamp
parents:
diff changeset
1685 STRCAT_PRINT "m"
heinrichsweikamp
parents:
diff changeset
1686
heinrichsweikamp
parents:
diff changeset
1687 ; A frame around the details
heinrichsweikamp
parents:
diff changeset
1688 WIN_TINY log2_lastdeco_column,log2_salinity_row-.16
heinrichsweikamp
parents:
diff changeset
1689 WIN_COLOR color_greenish
heinrichsweikamp
parents:
diff changeset
1690 STRCPY_TEXT_PRINT tLogbook
heinrichsweikamp
parents:
diff changeset
1691 WIN_FRAME_STD log2_salinity_row-.18, MBAR_row+.15, 0, .85 ; Top, Bottom, Left, Right
heinrichsweikamp
parents:
diff changeset
1692
heinrichsweikamp
parents:
diff changeset
1693 rcall logbook_preloop_tasks ; Clear some flags and set to Speed_eco
heinrichsweikamp
parents:
diff changeset
1694 display_details_loop:
heinrichsweikamp
parents:
diff changeset
1695 btfsc switch_left ; SET/MENU?
heinrichsweikamp
parents:
diff changeset
1696 goto display_profile2 ; Show the profile view again
heinrichsweikamp
parents:
diff changeset
1697 btfsc switch_right ; ENTER?
heinrichsweikamp
parents:
diff changeset
1698 bra exit_profileview ; back to list
heinrichsweikamp
parents:
diff changeset
1699 rcall log_screendump_and_onesecond ; Check if we need to make a screenshot and check for new second
heinrichsweikamp
parents:
diff changeset
1700 btfsc sleepmode ; Timeout?
heinrichsweikamp
parents:
diff changeset
1701 bra exit_profileview ; back to list
heinrichsweikamp
parents:
diff changeset
1702
heinrichsweikamp
parents:
diff changeset
1703 bra display_details_loop ; wait for something to do
heinrichsweikamp
parents:
diff changeset
1704
heinrichsweikamp
parents:
diff changeset
1705 global logbook_preloop_tasks
heinrichsweikamp
parents:
diff changeset
1706 logbook_preloop_tasks:
heinrichsweikamp
parents:
diff changeset
1707 movlw CCP1CON_VALUE ; See ostc3.inc
heinrichsweikamp
parents:
diff changeset
1708 movwf CCP1CON ; Power-on backlight
heinrichsweikamp
parents:
diff changeset
1709 call TFT_standard_color
heinrichsweikamp
parents:
diff changeset
1710 bcf sleepmode ; clear some flags
heinrichsweikamp
parents:
diff changeset
1711 bcf switch_right
heinrichsweikamp
parents:
diff changeset
1712 bcf switch_left
heinrichsweikamp
parents:
diff changeset
1713 clrf timeout_counter2
heinrichsweikamp
parents:
diff changeset
1714 call speed_normal
heinrichsweikamp
parents:
diff changeset
1715 return
heinrichsweikamp
parents:
diff changeset
1716
heinrichsweikamp
parents:
diff changeset
1717 log_show_sp_common:
heinrichsweikamp
parents:
diff changeset
1718 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
1719 call ext_flash_byte_read_plus ; Read setpoint
heinrichsweikamp
parents:
diff changeset
1720 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1721 clrf hi
heinrichsweikamp
parents:
diff changeset
1722 bsf leftbind
heinrichsweikamp
parents:
diff changeset
1723 output_16dp d'3'
heinrichsweikamp
parents:
diff changeset
1724 bcf leftbind
heinrichsweikamp
parents:
diff changeset
1725 STRCAT_TEXT tbar
heinrichsweikamp
parents:
diff changeset
1726 PUTC " "
heinrichsweikamp
parents:
diff changeset
1727 call ext_flash_byte_read_plus ; change depth
heinrichsweikamp
parents:
diff changeset
1728 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1729
heinrichsweikamp
parents:
diff changeset
1730 TSTOSS opt_units ; 0=Meters, 1=Feets
heinrichsweikamp
parents:
diff changeset
1731 bra log_show_sp_common_metric
heinrichsweikamp
parents:
diff changeset
1732 movf lo,W
heinrichsweikamp
parents:
diff changeset
1733 mullw .100 ; convert meters to mbar
heinrichsweikamp
parents:
diff changeset
1734 movff PRODL,lo
heinrichsweikamp
parents:
diff changeset
1735 movff PRODH,hi
heinrichsweikamp
parents:
diff changeset
1736 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
heinrichsweikamp
parents:
diff changeset
1737 output_16
heinrichsweikamp
parents:
diff changeset
1738 STRCAT_TEXT tFeets ; "ft"
heinrichsweikamp
parents:
diff changeset
1739 bra log_show_sp_common_common
heinrichsweikamp
parents:
diff changeset
1740 log_show_sp_common_metric:
heinrichsweikamp
parents:
diff changeset
1741 output_8
heinrichsweikamp
parents:
diff changeset
1742 STRCAT_TEXT tMeters ; "m"
heinrichsweikamp
parents:
diff changeset
1743 log_show_sp_common_common:
heinrichsweikamp
parents:
diff changeset
1744 STRCAT_PRINT ""
heinrichsweikamp
parents:
diff changeset
1745 return
heinrichsweikamp
parents:
diff changeset
1746
heinrichsweikamp
parents:
diff changeset
1747 log_show_gas_common2: ; as log_show_gas_common but with change depth
heinrichsweikamp
parents:
diff changeset
1748 lfsr FSR2,buffer
heinrichsweikamp
parents:
diff changeset
1749 call ext_flash_byte_read_plus ; current O2
heinrichsweikamp
parents:
diff changeset
1750 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1751 call ext_flash_byte_read_plus ; current He
heinrichsweikamp
parents:
diff changeset
1752 movff temp1,hi
heinrichsweikamp
parents:
diff changeset
1753 call customview_show_mix ; Put "Nxlo", "Txlo/hi", "Air" or "O2" into Postinc2
heinrichsweikamp
parents:
diff changeset
1754 call ext_flash_byte_read_plus ; change depth
heinrichsweikamp
parents:
diff changeset
1755 movff temp1,lo
heinrichsweikamp
parents:
diff changeset
1756
heinrichsweikamp
parents:
diff changeset
1757 TSTOSS opt_units ; 0=Meters, 1=Feets
heinrichsweikamp
parents:
diff changeset
1758 bra log_show_gas_common2_metric
heinrichsweikamp
parents:
diff changeset
1759 movf lo,W
heinrichsweikamp
parents:
diff changeset
1760 mullw .100 ; convert meters to mbar
heinrichsweikamp
parents:
diff changeset
1761 movff PRODL,lo
heinrichsweikamp
parents:
diff changeset
1762 movff PRODH,hi
heinrichsweikamp
parents:
diff changeset
1763 call convert_mbar_to_feet ; convert value in lo:hi from mbar to feet
heinrichsweikamp
parents:
diff changeset
1764 output_16
heinrichsweikamp
parents:
diff changeset
1765 STRCAT_TEXT tFeets ; "ft"
heinrichsweikamp
parents:
diff changeset
1766 bra log_show_gas_common2_common
heinrichsweikamp
parents:
diff changeset
1767 log_show_gas_common2_metric:
heinrichsweikamp
parents:
diff changeset
1768 output_8
heinrichsweikamp
parents:
diff changeset
1769 STRCAT_TEXT tMeters ; "m"
heinrichsweikamp
parents:
diff changeset
1770 log_show_gas_common2_common:
heinrichsweikamp
parents:
diff changeset
1771 bcf leftbind
heinrichsweikamp
parents:
diff changeset
1772 call ext_flash_byte_read_plus ; Gas Type
heinrichsweikamp
parents:
diff changeset
1773 STRCAT_PRINT ""
heinrichsweikamp
parents:
diff changeset
1774 return
heinrichsweikamp
parents:
diff changeset
1775
heinrichsweikamp
parents:
diff changeset
1776 END