comparison src/tft_outputs.asm @ 170:8bcb064b4fb8

CHANGE: Compass readout smoothed 1.53 beta release
author heinrichsweikamp
date Tue, 30 Sep 2014 10:35:47 +0200
parents afa31c815f24
children d097e10b383b
comparison
equal deleted inserted replaced
169:dcf3e08f31ac 170:8bcb064b4fb8
1349 1349
1350 1350
1351 global TFT_surface_compass_heading 1351 global TFT_surface_compass_heading
1352 TFT_surface_compass_heading: 1352 TFT_surface_compass_heading:
1353 rcall compass_heading_common 1353 rcall compass_heading_common
1354 btfsc compass_fast_mode ; In fast mode?
1355 bra TFT_surface_compass_heading2 ; Yes
1356 ; No, update 1/second max.
1357 movff sensor_state_counter,lo
1358 movlw .6
1359 cpfsgt lo
1360 return
1361 TFT_surface_compass_heading2:
1362 WIN_STD surf_compass_head_column,surf_compass_head_row 1354 WIN_STD surf_compass_head_column,surf_compass_head_row
1363 call TFT_standard_color 1355 call TFT_standard_color
1364 TFT_surface_compass_heading_com: ; Show "000° N" 1356 TFT_surface_compass_heading_com: ; Show "000° N"
1365 movff compass_heading+0,lo 1357 movff compass_heading+0,lo
1366 movff compass_heading+1,hi 1358 movff compass_heading+1,hi
1367 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required 1359 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
1360
1361 ; Shown and actual identical?
1362 movff compass_heading_shown+0,WREG
1363 cpfseq lo
1364 bra TFT_surface_compass_heading_com1 ; Not equal
1365 movff compass_heading_shown+1,WREG
1366 cpfseq hi
1367 bra TFT_surface_compass_heading_com1 ; Not equal
1368 bra TFT_surface_compass_heading_com3 ; equal, skip smoothing
1369
1370 TFT_surface_compass_heading_com1:
1371 movff lo,sub_a+0
1372 movff hi,sub_a+1
1373 movff compass_heading_shown+0,sub_b+0
1374 movff compass_heading_shown+1,sub_b+1
1375 call subU16
1376 btfsc neg_flag
1377 bra TFT_surface_compass_heading_com2 ; shown > actual
1378 ; shown < actual
1379 banksel compass_heading_shown
1380 infsnz compass_heading_shown+0,F
1381 incf compass_heading_shown+1,F ; +1
1382 bra TFT_surface_compass_heading_com3
1383
1384 TFT_surface_compass_heading_com2:
1385 banksel compass_heading_shown
1386 movlw d'1'
1387 subwf compass_heading_shown+0,F
1388 movlw d'0'
1389 subwfb compass_heading_shown+1,F ; -1
1390
1391 TFT_surface_compass_heading_com3:
1392 banksel common
1393 movff compass_heading_shown+0,lo
1394 movff compass_heading_shown+1,hi
1368 bsf leftbind 1395 bsf leftbind
1369 output_16dp .2 ; Result is "0.000" 1396 output_16dp .2 ; Result is "0.000"
1370 bcf leftbind 1397 bcf leftbind
1371 ; rearrange figures to "000" 1398 ; rearrange figures to "000"
1372 movff buffer+2,buffer+0 1399 movff buffer+2,buffer+0
1379 return 1406 return
1380 1407
1381 global TFT_dive_compass_heading 1408 global TFT_dive_compass_heading
1382 TFT_dive_compass_heading: 1409 TFT_dive_compass_heading:
1383 rcall compass_heading_common 1410 rcall compass_heading_common
1384 btfsc compass_fast_mode ; In fast mode?
1385 bra TFT_dive_compass_heading2 ; Yes
1386 ; No, update 1/second max.
1387 movff sensor_state_counter,lo
1388 movlw .6
1389 cpfsgt lo
1390 bra TFT_dive_compass_heading3 ; But update graph always in fast mode
1391 TFT_dive_compass_heading2:
1392 WIN_STD dive_compass_head_column,dive_compass_head_row 1411 WIN_STD dive_compass_head_column,dive_compass_head_row
1393 call TFT_standard_color 1412 call TFT_standard_color
1394 rcall TFT_surface_compass_heading_com ; Show "000° N" 1413 rcall TFT_surface_compass_heading_com ; Show "000° N"
1395 TFT_dive_compass_heading3: 1414 TFT_dive_compass_heading3:
1396 return ; No graphical output (yet) 1415 return ; No graphical output (yet)
1569 1588
1570 bcf compass_fast_mode 1589 bcf compass_fast_mode
1571 movlw compass_fast_treshold 1590 movlw compass_fast_treshold
1572 cpfslt sub_c+0 ; > compass_fast_treshold? 1591 cpfslt sub_c+0 ; > compass_fast_treshold?
1573 bsf compass_fast_mode ; Yes! 1592 bsf compass_fast_mode ; Yes!
1593
1594 btfss compass_fast_mode ; In fast mode?
1595 return ; No.
1596 ; Yes.
1597 movff compass_heading+0,lo
1598 movff compass_heading+1,hi
1599 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required
1600 movff lo,compass_heading_shown+0
1601 movff hi,compass_heading_shown+1
1574 return 1602 return
1575 1603
1576 TFT_get_compass: 1604 TFT_get_compass:
1577 call speed_normal 1605 call speed_normal
1578 call I2C_RX_compass ; Test Compass 1606 call I2C_RX_compass ; Test Compass