comparison src/tft_outputs.asm @ 239:6c4ad243cb44

CNANGE: aGF pair has same range then normal GF pair Work on graphic compass
author heinrichsweikamp
date Sun, 01 Mar 2015 21:10:14 +0100
parents e2ea74646127
children 5968af2839a4
comparison
equal deleted inserted replaced
238:49512af55afc 239:6c4ad243cb44
178 movff hi,xB+0 178 movff hi,xB+0
179 clrf xB+1 179 clrf xB+1
180 call mult16x16 ; lo * p_amb/10 180 call mult16x16 ; lo * p_amb/10
181 ; Check if ppO2>6,55bar 181 ; Check if ppO2>6,55bar
182 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? 182 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar?
183 bra TFT_color_code_warn ; Yes, warn in warning color 183 bra TFT_warnings_color ; Yes, warn in warning color
184 ; Check if ppO2>3,30bar 184 ; Check if ppO2>3,30bar
185 btfsc xC+1,7 185 btfsc xC+1,7
186 bra TFT_color_code_warn ; Yes, warn in warning color 186 bra TFT_warnings_color ; Yes, warn in warning color
187 187
188 ; Check for low ppo2 188 ; Check for low ppo2
189 movff xC+0,sub_a+0 189 movff xC+0,sub_a+0
190 movff xC+1,sub_a+1 190 movff xC+1,sub_a+1
191 movff opt_ppO2_min,WREG 191 movff opt_ppO2_min,WREG
192 mullw d'100' ; opt_ppO2_min*100 192 mullw d'100' ; opt_ppO2_min*100
193 movff PRODL,sub_b+0 193 movff PRODL,sub_b+0
194 movff PRODH,sub_b+1 194 movff PRODH,sub_b+1
195 call subU16 195 call subU16
196 btfsc neg_flag 196 btfsc neg_flag
197 bra TFT_color_code_warn ; too low -> Warning Color! 197 bra TFT_warnings_color ; too low -> Warning Color!
198 198
199 ; Check for high ppo2 199 ; Check for high ppo2
200 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode 200 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode
201 mullw d'100' ; opt_ppO2_max*100 201 mullw d'100' ; opt_ppO2_max*100
202 movff PRODL,sub_b+0 202 movff PRODL,sub_b+0
203 movff PRODH,sub_b+1 203 movff PRODH,sub_b+1
204 call subU16 ; sub_c = sub_a - sub_b 204 call subU16 ; sub_c = sub_a - sub_b
205 btfss neg_flag 205 btfss neg_flag
206 bra TFT_color_code_warn ; too high -> Warning Color! 206 bra TFT_warnings_color ; too high -> Warning Color!
207 return
208
209 TFT_color_code_warn:
210 call TFT_warnings_color
211 return 207 return
212 208
213 TFT_color_code_ceiling: 209 TFT_color_code_ceiling:
214 SAFE_2BYTE_COPY rel_pressure, lo 210 SAFE_2BYTE_COPY rel_pressure, lo
215 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar] 211 call adjust_depth_with_salinity ; computes salinity setting into lo:hi [mbar]
222 clrf xB+1 ; Devide/100 -> xC+0 = Depth in m 218 clrf xB+1 ; Devide/100 -> xC+0 = Depth in m
223 call div16x16 ; xA/xB=xC with xA as remainder 219 call div16x16 ; xA/xB=xC with xA as remainder
224 movf xC+0,W ; Depth in m 220 movf xC+0,W ; Depth in m
225 subwf lo,W 221 subwf lo,W
226 btfsc STATUS,C 222 btfsc STATUS,C
227 bra TFT_color_code_warn ; Set to warning color 223 bra TFT_warnings_color ; Set to warning color
228 call TFT_standard_color 224 call TFT_standard_color
229 return 225 return
230 226
231 TFT_color_code_depth: 227 TFT_color_code_depth:
232 movff hi,hi_temp 228 movff hi,hi_temp
243 movff hi,sub_b+1 239 movff hi,sub_b+1
244 movff hi_temp,hi 240 movff hi_temp,hi
245 movff lo_temp,lo ; Restore hi, lo 241 movff lo_temp,lo ; Restore hi, lo
246 call subU16 ; sub_c = sub_a - sub_b 242 call subU16 ; sub_c = sub_a - sub_b
247 btfss neg_flag 243 btfss neg_flag
248 bra TFT_color_code_warn ; Set to warning color 244 bra TFT_warnings_color ; Set to warning color
249 call TFT_standard_color 245 call TFT_standard_color
250 return 246 return
251 247
252 TFT_color_code_cns: 248 TFT_color_code_cns:
253 movff int_O_CNS_fraction+1,lo ; copy into bank1 249 movff int_O_CNS_fraction+1,lo ; copy into bank1
254 tstfsz lo ; >255% ? 250 tstfsz lo ; >255% ?
255 bra TFT_color_code_warn ; Yes 251 bra TFT_warnings_color ; Yes
256 movff int_O_CNS_fraction+0,lo 252 movff int_O_CNS_fraction+0,lo
257 movlw color_code_cns_high ; CNS Warn [%] 253 movlw color_code_cns_high ; CNS Warn [%]
258 subwf lo,W 254 subwf lo,W
259 btfsc STATUS,C 255 btfsc STATUS,C
260 bra TFT_color_code_warn ; Set to warning color 256 bra TFT_warnings_color ; Set to warning color
261 call TFT_standard_color 257 call TFT_standard_color
262 return 258 return
263 259
264 TFT_color_code_gf: 260 TFT_color_code_gf:
265 movff char_O_gradient_factor,lo ; gradient factor 261 movff char_O_gradient_factor,lo ; gradient factor
266 movlw color_code_gf_warn_high ; GF Warn [%] 262 movlw color_code_gf_warn_high ; GF Warn [%]
267 subwf lo,W 263 subwf lo,W
268 btfsc STATUS,C 264 btfsc STATUS,C
269 bra TFT_color_code_warn ; Set to warning color 265 bra TFT_warnings_color ; Set to warning color
270 call TFT_standard_color 266 call TFT_standard_color
271 return 267 return
272 268
273 TFT_color_code_ppo2: 269 TFT_color_code_ppo2:
274 ; Check if ppO2>6,55bar 270 ; Check if ppO2>6,55bar
275 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar? 271 tstfsz xC+2 ; char_I_O2_ratio * p_amb/10 > 65536, ppO2>6,55bar?
276 bra TFT_color_code_warn ; Yes, warn in warning color 272 bra TFT_warnings_color ; Yes, warn in warning color
277 ; Check if ppO2>3,30bar 273 ; Check if ppO2>3,30bar
278 btfsc xC+1,7 274 btfsc xC+1,7
279 bra TFT_color_code_warn ; Yes, warn in warning color 275 bra TFT_warnings_color ; Yes, warn in warning color
280 276
281 movff xC+0,sub_a+0 277 movff xC+0,sub_a+0
282 movff xC+1,sub_a+1 278 movff xC+1,sub_a+1
283 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode 279 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode
284 mullw d'100' 280 mullw d'100'
285 movff PRODL,sub_b+0 281 movff PRODL,sub_b+0
286 movff PRODH,sub_b+1 282 movff PRODH,sub_b+1
287 call subU16 ; sub_c = sub_a - sub_b 283 call subU16 ; sub_c = sub_a - sub_b
288 btfss neg_flag 284 btfss neg_flag
289 bra TFT_color_code_warn ; Set to warning color 285 bra TFT_warnings_color ; Set to warning color
290 286
291 movff xC+0,sub_a+0 287 movff xC+0,sub_a+0
292 movff xC+1,sub_a+1 288 movff xC+1,sub_a+1
293 movff opt_ppO2_min,WREG ; PPO2 min for Sensors and color coding in divemode 289 movff opt_ppO2_min,WREG ; PPO2 min for Sensors and color coding in divemode
294 mullw d'100' 290 mullw d'100'
295 movff PRODL,sub_b+0 291 movff PRODL,sub_b+0
296 movff PRODH,sub_b+1 292 movff PRODH,sub_b+1
297 call subU16 ; sub_c = sub_a - sub_b 293 call subU16 ; sub_c = sub_a - sub_b
298 btfsc neg_flag 294 btfsc neg_flag
299 bra TFT_color_code_warn ; Set to warning color 295 bra TFT_warnings_color ; Set to warning color
300 call TFT_standard_color 296 call TFT_standard_color
301 return 297 return
302 298
303 TFT_color_code_velocity: 299 TFT_color_code_velocity:
304 btfss neg_flag ; Ignore for descent! 300 btfss neg_flag ; Ignore for descent!
305 bra TFT_color_code_velocity1 ; Skip check! 301 bra TFT_color_code_velocity1 ; Skip check!
306 movff divA+0,lo 302 movff divA+0,lo
307 movlw color_code_velocity_warn_high ; Velocity warn [m/min] 303 movlw color_code_velocity_warn_high ; Velocity warn [m/min]
308 subwf lo,W 304 subwf lo,W
309 btfsc STATUS,C 305 btfsc STATUS,C
310 bra TFT_color_code_warn ; Set to warning color 306 bra TFT_warnings_color ; Set to warning color
311 TFT_color_code_velocity1: 307 TFT_color_code_velocity1:
312 call TFT_standard_color 308 call TFT_standard_color
313 return 309 return
314 310
315 TFT_color_code_ppo2_hud: ; With ppO2 [cbar] in lo 311 TFT_color_code_ppo2_hud: ; With ppO2 [cbar] in lo
316 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode 312 movff opt_ppO2_max,WREG ; PPO2 Max for MOD calculation and color coding in divemode
317 cpfsgt lo ; lo > opt_ppO2_max? 313 cpfsgt lo ; lo > opt_ppO2_max?
318 bra TFT_color_code_ppo2_hud1; No 314 bra TFT_color_code_ppo2_hud1; No
319 bra TFT_color_code_warn ; Yes 315 bra TFT_warnings_color ; Yes
320 TFT_color_code_ppo2_hud1: 316 TFT_color_code_ppo2_hud1:
321 movff opt_ppO2_min,WREG ; PPO2 min for Sensors and color coding in divemode 317 movff opt_ppO2_min,WREG ; PPO2 min for Sensors and color coding in divemode
322 cpfslt lo ; lo < opt_ppO2_min? 318 cpfslt lo ; lo < opt_ppO2_min?
323 bra TFT_color_code_ppo2_hud2; No 319 bra TFT_color_code_ppo2_hud2; No
324 bra TFT_color_code_warn ; Yes 320 bra TFT_warnings_color ; Yes
325 TFT_color_code_ppo2_hud2: 321 TFT_color_code_ppo2_hud2:
326 call TFT_standard_color 322 call TFT_standard_color
327 return 323 return
328 324
329 TFT_color_code_battery: ; With battery percent in lo 325 TFT_color_code_battery: ; With battery percent in lo
330 movlw color_code_battery_low 326 movlw color_code_battery_low
331 cpfsgt lo ; lo < color_code_battery_low ? 327 cpfsgt lo ; lo < color_code_battery_low ?
332 bra TFT_color_code_warn ; No 328 bra TFT_warnings_color ; No
333 call TFT_standard_color 329 call TFT_standard_color
334 return 330 return
335 331
336 ; **************************************************************************** 332 ; ****************************************************************************
337 333
1425 STRCPY_TEXT_PRINT tHeading ; Heading: 1421 STRCPY_TEXT_PRINT tHeading ; Heading:
1426 return 1422 return
1427 1423
1428 global TFT_dive_compass_mask 1424 global TFT_dive_compass_mask
1429 TFT_dive_compass_mask: 1425 TFT_dive_compass_mask:
1430 WIN_TINY dive_compass_mask_column,dive_compass_mask_row 1426 WIN_BOX_STD dive_compass_graph_row-.3,dive_compass_graph_row,(dive_compass_graph_left+dive_compass_graph_right)/.2-.2,(dive_compass_graph_left+dive_compass_graph_right)/.2+.2
1431 call TFT_divemask_color 1427 WIN_FRAME_STD dive_compass_graph_row, dive_compass_graph_row+dive_compass_graph_height,dive_compass_graph_left-.1,dive_compass_graph_right-.1
1432 STRCPY_TEXT_PRINT tHeading ; Heading: 1428 return
1433 return 1429
1430 ; WIN_TINY dive_compass_mask_column,dive_compass_mask_row
1431 ; call TFT_divemask_color
1432 ; STRCPY_TEXT_PRINT tHeading ; Heading:
1433 ; return
1434 1434
1435 1435
1436 global TFT_surface_compass_heading 1436 global TFT_surface_compass_heading
1437 TFT_surface_compass_heading: 1437 TFT_surface_compass_heading:
1438 rcall compass_heading_common 1438 rcall compass_heading_common
1485 movff buffer+3,buffer+1 1485 movff buffer+3,buffer+1
1486 movff buffer+4,buffer+2 1486 movff buffer+4,buffer+2
1487 lfsr FSR2,buffer+3 1487 lfsr FSR2,buffer+3
1488 STRCAT "° " 1488 STRCAT "° "
1489 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 1489 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2
1490 STRCAT_PRINT " " 1490 clrf WREG
1491 movff WREG,buffer+.7 ; limit to 7 chars
1492 STRCAT_PRINT ""
1491 return 1493 return
1492 1494
1493 global TFT_dive_compass_heading 1495 global TFT_dive_compass_heading
1494 TFT_dive_compass_heading: 1496 TFT_dive_compass_heading:
1495 rcall compass_heading_common 1497 rcall compass_heading_common
1498
1499 ; Graphic output
1500 movff compass_heading_shown+0,lo
1501 movff compass_heading_shown+1,hi
1502 bcf STATUS,C
1503 rrcf hi,F
1504 rrcf lo,F ; /2 -> heading 0-179 in lo
1505
1506 ; Debug
1507 WIN_TINY .0,.71
1508 output_8
1509 STRCAT_PRINT " "
1510 ; Debug
1511
1512 ; With 60° shown, left border is heading-30° or lo - 15
1513 movlw .15
1514 subwf lo,W
1515 btfss STATUS,C ; <0?
1516 addlw .180 ; Yes, adjust value
1517 movwf lo ; lo has now left border of graphic in 0-179
1518
1519 ; Debug
1520 WIN_TINY .0,.85
1521 output_8
1522 STRCAT_PRINT " "
1523 ; Debug
1524
1525 ; Draw marks (left border of graphic is in lo)
1526 ; WIN_BOX_BLACK dive_compass_graph_row+.1,dive_compass_graph_row+dive_compass_graph_height-.1,dive_compass_graph_left,dive_compass_graph_right-.2
1527 ; WIN_FRAME_STD dive_compass_graph_row, dive_compass_graph_row+dive_compass_graph_height,dive_compass_graph_left-.1,dive_compass_graph_right-.1
1528 movlw dive_compass_graph_row+.1
1529 movff WREG,win_top
1530 movlw dive_compass_graph_height-.1
1531 movff WREG,win_height
1532
1533 ; lo is 0-179, draw first mark at full 10°
1534 incf lo,F ; +1
1535 setf hi ; =255
1536 TFT_compass_graph1:
1537 lfsr FSR2,buffer
1538 incf hi,F
1539 decf lo,F
1540 output_8
1541 movlw "0"
1542 movwf up ; Digit "0"
1543 movff buffer+2,WREG
1544 cpfseq up ; Last digit = 0?
1545 bra TFT_compass_graph1b ; No
1546 bra TFT_compass_graph1a ; Yes
1547 TFT_compass_graph1b:
1548 movlw "5"
1549 movwf up ; Digit "5"
1550 movff buffer+2,WREG
1551 cpfseq up ; Last digit = 5?
1552 bra TFT_compass_graph1 ; No
1553
1554 TFT_compass_graph1a:
1555 ; Yes setup PROD for the first mark
1556 movlw .5
1557 mulwf hi
1558 movlw dive_compass_graph_leftx2
1559 addwf PRODL,F
1560 movlw .0
1561 addwfc PRODH,F ; add left offset
1562
1563 movlw .11 ; amount of marks (-1)
1564 movwf up
1565 TFT_compass_graph2:
1566 movff PRODL,lo
1567 movff PRODH,hi ; Backup
1568 rcall TFT_compass_graph3 ; Write one mark
1569 movff lo,PRODL
1570 movff hi,PRODH ; Restore
1571 movlw .25 ; Spacing in pixels
1572 addwf PRODL,F
1573 movlw .0
1574 addwfc PRODH,F
1575 decfsz up,F
1576 bra TFT_compass_graph2
1577
1578 rcall TFT_compass_graph4 ; Write one mark without black space
1579
1580 ; Text output
1496 WIN_STD dive_compass_head_column,dive_compass_head_row 1581 WIN_STD dive_compass_head_column,dive_compass_head_row
1497 call TFT_standard_color 1582 call TFT_standard_color
1498 rcall TFT_surface_compass_heading_com ; Show "000° N" 1583 rcall TFT_surface_compass_heading_com ; Show "000° N"
1499 TFT_dive_compass_heading3: 1584
1500 return ; No graphical output (yet) 1585 return ; Done.
1501 1586
1502 movff compass_heading+0,sub_a+0 1587
1503 movff compass_heading+1,sub_a+1 1588 TFT_compass_graph3:
1504 movlw .45 1589 rcall TFT_compass_graph4 ; Mark
1505 movwf sub_b+0 1590 movff lo,PRODL
1506 clrf sub_b+1 1591 movff hi,PRODH ; Restore
1507 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) 1592
1508 btfss neg_flag ; Result <0? 1593 ; black space
1509 bra TFT_dive_compass_heading_graph1 ; No 1594 clrf WREG
1510 ; Yes 1595 movff WREG,win_color1
1511 movlw LOW .360 1596 movff WREG,win_color2 ; Set to black
1512 movwf sub_a+0 1597 movlw dive_compass_graph_width+.1
1513 movlw HIGH .360 1598 addwf PRODL,F
1514 movwf sub_a+1 1599 movlw .0
1515 movff sub_c+0,sub_b+0 1600 addwfc PRODH,F
1516 movff sub_c+1,sub_b+1 1601 movlw .20 ; Spacing in pixels
1517 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values)
1518
1519 TFT_dive_compass_heading_graph1:
1520 WIN_SMALL dive_compass_head_column+.70,dive_compass_head_row
1521 movff sub_c+0,lo
1522 movff sub_c+1,hi
1523 call TFT_standard_color
1524 bsf leftbind
1525 output_16
1526 bcf leftbind
1527 STRCAT_PRINT " "
1528
1529 ; Draw marks (left border of graphic is in lo)
1530 movlw b'00011111'
1531 andwf lo,F ; Get lowest 5bits of heading
1532 movlw d'30'
1533 cpfslt lo
1534 movwf lo ; Limit to 30
1535 rlncf lo,F ; x2
1536 ; marks parameters
1537 WIN_BOX_BLACK dive_compass_graph_row,dive_compass_graph_row+dive_compass_graph_height,.0,.159
1538 call TFT_standard_color
1539 WIN_SMALL .77,dive_compass_graph_row ; Center of screen
1540 STRCPY_PRINT "^"
1541 call TFT_divemask_color
1542 movlw dive_compass_graph_row
1543 movff WREG,win_top
1544 movlw dive_compass_graph_height
1545 movff WREG,win_height
1546 movlw dive_compass_graph_width
1547 movff WREG,win_width+0 1602 movff WREG,win_width+0
1548 clrf win_width+1
1549 ; marks draw loop
1550 movlw .6
1551 movwf hi ; amount of marks (max.)
1552 clrf lo_temp
1553 TFT_dive_compass_heading_graph2:
1554 movlw LOW .319
1555 movwf sub_a+0
1556 movlw HIGH .319
1557 movwf sub_a+1
1558 movff lo,sub_b+0
1559 movff lo_temp,sub_b+1
1560 call subU16
1561 btfsc neg_flag
1562 bra TFT_dive_compass_heading_graph3 ; Abort when negative
1563 movff sub_c+0,PRODL
1564 movff sub_c+1,PRODH
1565 call TFT_box_write_16bit_win_left ; With column in PRODL:PRODH 1603 call TFT_box_write_16bit_win_left ; With column in PRODL:PRODH
1566 ;---- Define Window ------------------------------------------------------
1567 movf win_width,W 1604 movf win_width,W
1568 bcf STATUS,C 1605 bcf STATUS,C
1569 rlcf WREG 1606 rlcf WREG
1570 movwf win_width+0 1607 movwf win_width+0
1571 movlw 0 1608 movlw 0
1572 rlcf WREG 1609 rlcf WREG
1573 movwf win_width+1 1610 movwf win_width+1
1574 call TFT_box_16bit_win_left 1611 call TFT_box_16bit_win_left ; Fill window
1575 movlw .56 ; 60 px. space 1612 return
1576 addwf lo,F 1613
1577 movlw .0 1614 TFT_compass_graph4:
1578 addwfc lo_temp,F 1615 call TFT_divemask_color
1579 ; movlw .160 1616 ;---- Define Window ------------------------------------------------------
1580 ; cpfslt lo 1617 movlw dive_compass_graph_width
1581 ; bra TFT_dive_compass_heading_graph3 ; Abort 1618 movff WREG,win_width+0
1582 decfsz hi,F 1619 clrf win_width+1
1583 bra TFT_dive_compass_heading_graph2 1620 call TFT_box_write_16bit_win_left ; With column in PRODL:PRODH
1584 TFT_dive_compass_heading_graph3: 1621 movf win_width,W
1585 return 1622 bcf STATUS,C
1623 rlcf WREG
1624 movwf win_width+0
1625 movlw 0
1626 rlcf WREG
1627 movwf win_width+1
1628 call TFT_box_16bit_win_left ; Fill window
1629 return
1630
1586 1631
1587 tft_compass_cardinal: 1632 tft_compass_cardinal:
1588 btfsc hi,0 ; Heading >255°? 1633 btfsc hi,0 ; Heading >255°?
1589 bra tft_compass_cardinal2 ; Yes must be W, NW or N 1634 bra tft_compass_cardinal2 ; Yes must be W, NW or N
1590 ; No, Must be W, SW, S, SE, E, NE or N 1635 ; No, Must be W, SW, S, SE, E, NE or N
1621 bra tft_compass_cardinal_W 1666 bra tft_compass_cardinal_W
1622 movlw .82 1667 movlw .82
1623 subwf lo,W 1668 subwf lo,W
1624 btfss STATUS,C 1669 btfss STATUS,C
1625 bra tft_compass_cardinal_NW 1670 bra tft_compass_cardinal_NW
1626 bra tft_compass_cardinal_N 1671 ; bra tft_compass_cardinal_N
1627
1628 tft_compass_cardinal_N: 1672 tft_compass_cardinal_N:
1629 STRCAT_TEXT tN 1673 STRCAT_TEXT tN
1630 return 1674 return
1631 tft_compass_cardinal_NE: 1675 tft_compass_cardinal_NE:
1632 STRCAT_TEXT tNE 1676 STRCAT_TEXT tNE