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