Mercurial > public > hwos_code
comparison src/tft_outputs.asm @ 256:5b4ef0b9090d
place compass display code into compass_ops.asm
author | heinrichsweikamp |
---|---|
date | Mon, 23 Mar 2015 18:02:40 +0100 |
parents | ad62dff7739a |
children | e1cd6848863d |
comparison
equal
deleted
inserted
replaced
255:ad62dff7739a | 256:5b4ef0b9090d |
---|---|
1295 movlw surf_warning_length ; No, use surface string length | 1295 movlw surf_warning_length ; No, use surface string length |
1296 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) | 1296 call TFT_fillup_with_spaces ; Fillup FSR2 with spaces (Total string length in #WREG) |
1297 STRCAT_PRINT "" | 1297 STRCAT_PRINT "" |
1298 return | 1298 return |
1299 | 1299 |
1300 global TFT_compass_fast | |
1301 TFT_compass_fast: | |
1302 WIN_TINY .20,.50 | |
1303 STRCPY "X:" | |
1304 movff compass_DX+0,lo | |
1305 movff compass_DX+1,hi | |
1306 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1307 output_16 | |
1308 STRCAT " Y:" | |
1309 movff compass_DY+0,lo | |
1310 movff compass_DY+1,hi | |
1311 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1312 output_16 | |
1313 STRCAT " Z:" | |
1314 movff compass_DZ+0,lo | |
1315 movff compass_DZ+1,hi | |
1316 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1317 output_16 | |
1318 STRCAT_PRINT " " | |
1319 return | |
1320 | |
1321 global TFT_show_timeout_testmode | |
1322 TFT_show_timeout_testmode: ; With timeout in WREG... | |
1323 movwf hi | |
1324 WIN_TINY .20,.68 | |
1325 STRCPY "T:" | |
1326 movf timeout_counter2,W ; current timeout | |
1327 subwf hi,W ; subtract from timeout value | |
1328 addlw .1 ; +1 | |
1329 movwf lo | |
1330 bsf leftbind | |
1331 output_8 ; Display timeout | |
1332 bcf leftbind | |
1333 STRCAT_PRINT "s " | |
1334 return | |
1335 | |
1336 | |
1337 global TFT_compass_show_gain | |
1338 TFT_compass_show_gain: ; Show the current compass gain | |
1339 movff opt_compass_gain,lo ; 0-7 (230LSB/Gauss to 1370LSB/Gaus) | |
1340 tstfsz lo | |
1341 return ; Do not show unless gain=0 | |
1342 WIN_TINY .20,.86 | |
1343 STRCPY_TEXT tCompassGain | |
1344 movff opt_compass_gain,lo ; 0-7 (230LSB/Gauss to 1370LSB/Gaus) | |
1345 bsf leftbind | |
1346 output_8 | |
1347 bcf leftbind | |
1348 STRCAT_PRINT "!" | |
1349 return | |
1350 | |
1351 global TFT_surface_decosettings ; Show all deco settings | 1300 global TFT_surface_decosettings ; Show all deco settings |
1352 TFT_surface_decosettings: | 1301 TFT_surface_decosettings: |
1353 ; Deco Mode | 1302 ; Deco Mode |
1354 call TFT_standard_color | 1303 call TFT_standard_color |
1355 movff char_I_deco_model,WREG | 1304 movff char_I_deco_model,WREG |
1403 movff opt_salinity,lo | 1352 movff opt_salinity,lo |
1404 output_8 | 1353 output_8 |
1405 bcf leftbind | 1354 bcf leftbind |
1406 STRCAT_TEXT_PRINT tPercent | 1355 STRCAT_TEXT_PRINT tPercent |
1407 return ; Done. | 1356 return ; Done. |
1408 | |
1409 global TFT_surface_compass_mask | |
1410 TFT_surface_compass_mask: | |
1411 WIN_SMALL surf_compass_mask_column,surf_compass_mask_row | |
1412 call TFT_standard_color | |
1413 STRCPY_TEXT_PRINT tHeading ; Heading: | |
1414 return | |
1415 | |
1416 global TFT_dive_compass_mask | |
1417 TFT_dive_compass_mask: | |
1418 WIN_FRAME_STD dive_compass_graph_row, dive_compass_graph_row+dive_compass_graph_height, .0, .159 | |
1419 return | |
1420 | |
1421 global TFT_surface_compass_heading | |
1422 TFT_surface_compass_heading: | |
1423 rcall compass_heading_common | |
1424 WIN_STD surf_compass_head_column,surf_compass_head_row | |
1425 call TFT_standard_color | |
1426 TFT_surface_compass_heading_com: ; Show "000° N" | |
1427 movff compass_heading+0,lo | |
1428 movff compass_heading+1,hi | |
1429 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1430 | |
1431 ; Shown and actual identical? | |
1432 movff compass_heading_shown+0,WREG | |
1433 cpfseq lo | |
1434 bra TFT_surface_compass_heading_com1 ; Not equal | |
1435 movff compass_heading_shown+1,WREG | |
1436 cpfseq hi | |
1437 bra TFT_surface_compass_heading_com1 ; Not equal | |
1438 bra TFT_surface_compass_heading_com3 ; equal, skip smoothing | |
1439 | |
1440 TFT_surface_compass_heading_com1: | |
1441 movff lo,sub_a+0 | |
1442 movff hi,sub_a+1 | |
1443 movff compass_heading_shown+0,sub_b+0 | |
1444 movff compass_heading_shown+1,sub_b+1 | |
1445 call subU16 | |
1446 btfsc neg_flag | |
1447 bra TFT_surface_compass_heading_com2 ; shown > actual | |
1448 ; shown < actual | |
1449 banksel compass_heading_shown | |
1450 infsnz compass_heading_shown+0,F | |
1451 incf compass_heading_shown+1,F ; +1 | |
1452 bra TFT_surface_compass_heading_com3 | |
1453 | |
1454 TFT_surface_compass_heading_com2: | |
1455 banksel compass_heading_shown | |
1456 movlw d'1' | |
1457 subwf compass_heading_shown+0,F | |
1458 movlw d'0' | |
1459 subwfb compass_heading_shown+1,F ; -1 | |
1460 | |
1461 TFT_surface_compass_heading_com3: | |
1462 banksel common | |
1463 movff compass_heading_shown+0,lo | |
1464 movff compass_heading_shown+1,hi | |
1465 bsf leftbind | |
1466 output_16dp .2 ; Result is "0.000" | |
1467 bcf leftbind | |
1468 ; rearrange figures to "000" | |
1469 movff buffer+2,buffer+0 | |
1470 movff buffer+3,buffer+1 | |
1471 movff buffer+4,buffer+2 | |
1472 lfsr FSR2,buffer+3 | |
1473 STRCAT "° " | |
1474 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 | |
1475 clrf WREG | |
1476 movff WREG,buffer+.7 ; limit to 7 chars | |
1477 STRCAT_PRINT "" | |
1478 return | |
1479 | |
1480 global TFT_dive_compass_heading | |
1481 TFT_dive_compass_heading: | |
1482 rcall compass_heading_common | |
1483 ; ; ToDo - these are for development only, hardcoding the bearing position | |
1484 ; ; 244° : SW - W | |
1485 ; movlw low(d'244') | |
1486 ; movff WREG,compass_bearing+0 | |
1487 ; movlw high(d'244') | |
1488 ; movff WREG,compass_bearing+1 | |
1489 | |
1490 movff compass_heading_shown+0,xA+0 | |
1491 movff compass_heading_shown+1,xA+1 | |
1492 ; xRD and xRDlft | |
1493 ; 1. 160° viewing angle: +360 offset if xA<=292; for non-negative scale | |
1494 movlw high(d'292') | |
1495 movff WREG,sub_a+1 | |
1496 movlw low(d'292') | |
1497 movff WREG,sub_a+0 | |
1498 movff xA+1,sub_b+1 | |
1499 movff xA+0,sub_b+0 | |
1500 call subU16 ; sub_c = sub_a - sub_b | |
1501 btfsc neg_flag ; xA>292 | |
1502 bra TFT_dive_compass_heading_1 ;yes | |
1503 ; no, xA<=292 | |
1504 movlw high(d'360') | |
1505 addwf xA+1,1 | |
1506 movlw low(d'360') | |
1507 addwf xA+0,1 | |
1508 btfsc STATUS,C | |
1509 incf xA+1 | |
1510 TFT_dive_compass_heading_1: | |
1511 ; 2. -80: left pixel offset from the center | |
1512 movlw low( d'80' ) | |
1513 subwf xA+0,1 | |
1514 btfss STATUS,C | |
1515 decf xA+1 | |
1516 ; 3. save it to xRD | |
1517 movff xA+0,xRD+0 | |
1518 movff xA+1,xRD+1 | |
1519 ; 4. add 160 (display px width) | |
1520 movlw high(d'160') | |
1521 addwf xA+1,1 | |
1522 movlw low(d'160') | |
1523 addwf xA+0,1 | |
1524 btfsc STATUS,C | |
1525 incf xA+1 | |
1526 ; 5. save it to xRDr | |
1527 movff xA+0,xRDr+0 | |
1528 movff xA+1,xRDr+1 | |
1529 | |
1530 ; ; Bearing ? | |
1531 ; ; We can skip this xRD180 calculation if no bearing is set | |
1532 ; bcf compass_bearing_set | |
1533 ; movff compass_bearing+0,sub_a+0 | |
1534 ; movff compass_bearing+1,sub_a+1 | |
1535 ; movlw d'0' | |
1536 ; cpfseq sub_a+1 | |
1537 ; bra TFT_dive_compass_bearing ; something set, calculate xRD180 | |
1538 ; movlw d'0' | |
1539 ; cpfseq sub_a+0 | |
1540 ; bra TFT_dive_compass_bearing ; something set, calculate xRD180 | |
1541 ; bra TFT_dive_compass_ruler ; no value in the bearing, skip calc | |
1542 ; | |
1543 ;TFT_dive_compass_bearing: | |
1544 ; bsf compass_bearing_set | |
1545 | |
1546 btfss compass_bearing_set | |
1547 bra TFT_dive_compass_ruler ; no value in the bearing, skip calc | |
1548 | |
1549 ; we have bearing set, we will need xRD180 calculated | |
1550 ; xRD180 is xRDr-180 | |
1551 movff xRDr+1,sub_a+1 | |
1552 movff xRDr+0,sub_a+0 | |
1553 movlw high(d'180') | |
1554 movff WREG,sub_b+1 | |
1555 movlw low(d'180') | |
1556 movff WREG,sub_b+0 | |
1557 call subU16 ; sub_c = sub_a - sub_b | |
1558 movff sub_c+1,xRD180+1 | |
1559 movff sub_c+0,xRD180+0 | |
1560 | |
1561 ; get the bearing virtual display offset, store it to divA | |
1562 movff compass_bearing+0,xA+0 | |
1563 movff compass_bearing+1,xA+1 | |
1564 ; divA =IF (U10>292;U10;U10+360) | |
1565 movlw high(d'292') | |
1566 movff WREG,sub_a+1 | |
1567 movlw low(d'292') | |
1568 movff WREG,sub_a+0 | |
1569 movff xA+1,sub_b+1 | |
1570 movff xA+0,sub_b+0 | |
1571 call subU16 ; sub_c = sub_a - sub_b | |
1572 btfsc neg_flag ; xA>292 | |
1573 bra TFT_dive_compass_bearing_1 ;yes | |
1574 ; no, xA<=292 | |
1575 movlw high(d'360') | |
1576 addwf xA+1,1 | |
1577 movlw low(d'360') | |
1578 addwf xA+0,1 | |
1579 btfsc STATUS,C | |
1580 incf xA+1 | |
1581 ; save it for the direction (<< or >>) calculation | |
1582 movff xA+1,divA+1 | |
1583 movff xA+0,divA+0 | |
1584 | |
1585 TFT_dive_compass_bearing_1: | |
1586 ; calculate bearing position and visibility (ahead or behind) | |
1587 bcf compass_bearing_vis ; default is not-visibly | |
1588 bcf compass_bearing_ahd ; default is behind | |
1589 ; check if it's ahead | |
1590 ; load the bearing offset into sub_a | |
1591 movff divA+1,sub_a+1 | |
1592 movff divA+0,sub_a+0 | |
1593 ; load the display offset back to sub_b | |
1594 movff xRD+0,sub_b+0 | |
1595 movff xRD+1,sub_b+1 | |
1596 rcall TFT_dive_compass_bearing_ap | |
1597 ;test if we found it | |
1598 btfsc compass_bearing_vis | |
1599 bra TFT_dive_compass_bearing_dir | |
1600 | |
1601 ; check if it's ahead with a furr turn | |
1602 ; load the bearing offset into sub_a | |
1603 movff divA+1,sub_a+1 | |
1604 movff divA+0,sub_a+0 | |
1605 ; load the display offset back to sub_b | |
1606 movff xRD+0,sub_b+0 | |
1607 movff xRD+1,sub_b+1 | |
1608 movlw high(d'360') | |
1609 addwf sub_b+1,1 | |
1610 movlw low(d'360') | |
1611 addwf sub_b+0,1 | |
1612 btfsc STATUS,C | |
1613 incf sub_b+1 | |
1614 rcall TFT_dive_compass_bearing_ap | |
1615 ;test if we found it | |
1616 btfsc compass_bearing_vis | |
1617 bra TFT_dive_compass_bearing_dir | |
1618 | |
1619 ; marker is not ahead of us, check if it's behind us | |
1620 ; use the (160 - (xRD180 - xCM)) formula to see if it's on the display | |
1621 ; load the display offset back to sub_a | |
1622 movff xRD180+0,sub_a+0 | |
1623 movff xRD180+1,sub_a+1 | |
1624 ; load the marker's offset into sub_b | |
1625 movff divA+0,sub_b+0 | |
1626 movff divA+1,sub_b+1 | |
1627 rcall TFT_dive_compass_bearing_bp | |
1628 ;test if we found it | |
1629 btfsc compass_bearing_vis | |
1630 bra TFT_dive_compass_bearing_dir | |
1631 | |
1632 ;check if it's behind with the lower turn | |
1633 movff xRD180+0,sub_a+0 | |
1634 movff xRD180+1,sub_a+1 | |
1635 movlw high(d'360') | |
1636 addwf sub_a+1,1 | |
1637 movlw low(d'360') | |
1638 addwf sub_a+0,1 | |
1639 btfsc STATUS,C | |
1640 incf sub_a+1 | |
1641 ; load the marker's offset into sub_b | |
1642 movff divA+0,sub_b+0 | |
1643 movff divA+1,sub_b+1 | |
1644 rcall TFT_dive_compass_bearing_bp | |
1645 ;test if we found it | |
1646 btfsc compass_bearing_vis | |
1647 bra TFT_dive_compass_bearing_dir | |
1648 | |
1649 ; check if it's behind with the upper turn | |
1650 movff divA+1,sub_b+1 | |
1651 movff divA+0,sub_b+0 | |
1652 movlw high(d'360') | |
1653 addwf sub_b+1,1 | |
1654 movlw low(d'360') | |
1655 addwf sub_b+0,1 | |
1656 btfsc STATUS,C | |
1657 incf sub_b+1 | |
1658 rcall TFT_dive_compass_bearing_bp | |
1659 bra TFT_dive_compass_bearing_dir | |
1660 | |
1661 TFT_dive_compass_bearing_ap: | |
1662 ; xCM received in sub_a | |
1663 ; xRD received in sub_b | |
1664 ; 1/a. check if it's viewable from the left side | |
1665 call subU16 ; sub_c = sub_a - sub_b | |
1666 btfsc neg_flag ; xRD>divA | |
1667 return ;no, | |
1668 ; yes, store the RO=RP-RD for drawing | |
1669 movff sub_c+0,xC+0 | |
1670 movff sub_c+1,xC+1 | |
1671 ; 1/b. check if it's viewable from the right side? | |
1672 movlw d'2' ; avoid thin mess on the side of the display | |
1673 addwf sub_a+0,1 | |
1674 btfsc STATUS, C | |
1675 incf sub_a+1 | |
1676 ; load the display offset right side into sub_b | |
1677 movlw high(d'160') | |
1678 addwf sub_b+1,1 | |
1679 movlw low(d'160') | |
1680 addwf sub_b+0,1 | |
1681 btfsc STATUS,C | |
1682 incf sub_b+1 | |
1683 call subU16 ; sub_c = sub_a - sub_b | |
1684 btfss neg_flag ; xRDr>xA(+2) | |
1685 return ; no, | |
1686 ; print the bearing lines on the screen | |
1687 movff xC+0,xCM | |
1688 bsf compass_bearing_vis ; set visible | |
1689 bsf compass_bearing_ahd ; set ahead | |
1690 return ; done, | |
1691 | |
1692 TFT_dive_compass_bearing_bp: | |
1693 ; use the (160 - (xRD180 - xCM)) formula to see if it's on the display | |
1694 ; the marker's offset received in sub_b | |
1695 ; the xRD180 display offset received in sub_a | |
1696 ; xRD180 - xCM | |
1697 call subU16 ; sub_c = sub_a - sub_b | |
1698 btfsc neg_flag ; CM>xRD180 | |
1699 return ; no, not on screen | |
1700 ; 160 - (X) | |
1701 movlw high(d'160') | |
1702 movff WREG,sub_a+1 | |
1703 movlw low(d'160') | |
1704 movff WREG,sub_a+0 | |
1705 movff sub_c+1,sub_b+1 | |
1706 movff sub_c+0,sub_b+0 | |
1707 call subU16 ; sub_c = sub_a - sub_b | |
1708 btfsc neg_flag ; X>160 | |
1709 return ; no, not on screen | |
1710 ; check if not overflow - this sounds a double check... | |
1711 movlw d'1' | |
1712 cpfslt sub_c+1 | |
1713 return ; high set, >160 | |
1714 movlw d'160' | |
1715 cpfslt sub_c+0 | |
1716 return ; low >160 | |
1717 ; print the bearing lines on the screen | |
1718 movff sub_c+0,xCM | |
1719 bsf compass_bearing_vis | |
1720 return ; done | |
1721 | |
1722 TFT_dive_compass_bearing_dir: | |
1723 ; check if bearing to heading, and calculate the direction | |
1724 bcf compass_bearing_eq | |
1725 btfss compass_bearing_vis | |
1726 bra TFT_dive_compass_bearing_lr | |
1727 btfss compass_bearing_ahd | |
1728 bra TFT_dive_compass_bearing_lr | |
1729 movff xCM,xA+0 | |
1730 movlw d'80' | |
1731 cpfseq xA+0 | |
1732 bra TFT_dive_compass_bearing_lr | |
1733 bsf compass_bearing_eq | |
1734 bra TFT_dive_compass_ruler ; bearing points to heading, no signs are required, go to the ruler | |
1735 | |
1736 TFT_dive_compass_bearing_lr: | |
1737 ; 1. calculate whether bearing is to left or to right | |
1738 bsf compass_bearing_lft ; to the left by default | |
1739 ; get the bearing offset back | |
1740 movff divA+1,xA+1 | |
1741 movff divA+0,xA+0 | |
1742 ; xC: save center value to compare the direction to front value | |
1743 movff xA+1,xC+1 | |
1744 movff xA+0,xC+0 | |
1745 ; xB: we need the left side for comparism... left = -180 | |
1746 movff xA+1,sub_a+1 | |
1747 movff xA+0,sub_a+0 | |
1748 movlw high(d'180') | |
1749 movff WREG,sub_b+1 | |
1750 movlw low(d'180') | |
1751 movff WREG,sub_b+0 | |
1752 call subU16 ; sub_c = sub_a - sub_b | |
1753 movff sub_c+1,xB+1 ; xB has the left side of the 180° distance center | |
1754 movff sub_c+0,xB+0 | |
1755 ; xA = IF(xRD>(xC+100);xRD-280;xRD+80) | |
1756 movff xC+1,sub_a+1 | |
1757 movff xC+0,sub_a+0 | |
1758 movlw d'100' | |
1759 addwf sub_a+0,1 | |
1760 btfsc STATUS,C | |
1761 incf sub_a+1 | |
1762 movff xRD+1,sub_b+1 | |
1763 movff xRD+0,sub_b+0 | |
1764 call subU16 ; sub_c = sub_a - sub_b | |
1765 btfsc neg_flag ; xRD>xC+100 | |
1766 bra TFT_dive_compass_bearing_lr_2 ; yes, xA=xRD-280 | |
1767 ; no, xA = xRD+80 | |
1768 movff xRD+1,xA+1 | |
1769 movff xRD+0,xA+0 | |
1770 movlw d'80' | |
1771 addwf xA+0,1 | |
1772 btfsc STATUS,C | |
1773 incf xA+1 | |
1774 bra TFT_dive_compass_bearing_lr_c | |
1775 | |
1776 TFT_dive_compass_bearing_lr_2: | |
1777 ; xA=xRD-280 | |
1778 movff xRD+1,sub_a+1 | |
1779 movff xRD+0,sub_a+0 | |
1780 movlw high(d'280') | |
1781 movff WREG,sub_b+1 | |
1782 movlw low(d'280') | |
1783 movff WREG,sub_b+0 | |
1784 call subU16 ; sub_c = sub_a - sub_b | |
1785 movff sub_c+1,xA+1 | |
1786 movff sub_c+0,xA+0 | |
1787 ;bra TFT_dive_compass_bearing_lr_c | |
1788 | |
1789 TFT_dive_compass_bearing_lr_c: | |
1790 ; xB < xA < xC => right, otherwise left (default) | |
1791 movff xA+1,sub_b+1 | |
1792 movff xA+0,sub_b+0 | |
1793 movff xB+1,sub_a+1 | |
1794 movff xB+0,sub_a+0 | |
1795 call subU16 ; sub_c = sub_a - sub_b | |
1796 btfss neg_flag ; xA>xB ? | |
1797 bra TFT_dive_compass_ruler ; No, xB >= xA, keep default left | |
1798 movff xA+1,sub_a+1 | |
1799 movff xA+0,sub_a+0 | |
1800 movff xC+1,sub_b+1 | |
1801 movff xC+0,sub_b+0 | |
1802 call subU16 ; sub_c = sub_a - sub_b | |
1803 btfss neg_flag ; xC>xA ? | |
1804 bra TFT_dive_compass_ruler ; No, xA >= xC, keep default left | |
1805 bcf compass_bearing_lft | |
1806 | |
1807 TFT_dive_compass_ruler: | |
1808 ; calculate mod15 for the ticks | |
1809 movff xRD+0,xA+0 | |
1810 movff xRD+1,xA+1 | |
1811 movlw d'15' | |
1812 movwf xB+0 | |
1813 clrf xB+1 | |
1814 call div16x16 ;xA/xB=xC with xA+0 as remainder | |
1815 ; check xA+0, it has the remainder | |
1816 movlw d'0' | |
1817 cpfsgt xA+0 ; mod15 > 0 | |
1818 bra TFT_dive_compass_ruler_1 ; no, RM = 0 | |
1819 ; yes RM = 15 - RDmod15 | |
1820 movlw d'15' | |
1821 subfwb xA+0,1 | |
1822 TFT_dive_compass_ruler_1: | |
1823 ; xA+0 holds the RM, store it to 'lo' | |
1824 movff xA+0,lo | |
1825 ; init DD to zero, store it to 'hi' | |
1826 movlw d'0' | |
1827 movff WREG,hi | |
1828 | |
1829 TFT_dive_compass_ruler_loop: | |
1830 ; 1. check if we run of from the display | |
1831 movlw d'160' ; Looks like 160 works because TFT_box limits the dispay | |
1832 cpfslt lo,1 | |
1833 bra TFT_dive_compass_ruler_lend ; xRM >= W | |
1834 ; 2. Clear the tick area from DD to RM - in segments to avoid blinking | |
1835 ; don't do a clear if we are at 0 (zero) otherwise it will blink | |
1836 ; because of the width underflow | |
1837 movlw d'0' | |
1838 cpfsgt lo,1 | |
1839 bra TFT_dive_compass_ruler_loop_zz | |
1840 rcall TFT_dive_compass_clr_ruler | |
1841 TFT_dive_compass_ruler_loop_zz: | |
1842 ; 3. Draw the markers @ RM | |
1843 rcall TFT_dive_compass_ruler_print | |
1844 ; 4. If D<82 and RM>79: means we put something over the center line | |
1845 ; redraw the center line | |
1846 movlw d'82' | |
1847 cpfslt hi,1 | |
1848 bra TFT_dive_compass_ruler_loop_zz2 | |
1849 movlw d'79' | |
1850 cpfsgt lo,1 | |
1851 bra TFT_dive_compass_ruler_loop_zz2 | |
1852 rcall TFT_dive_compass_c_mk | |
1853 TFT_dive_compass_ruler_loop_zz2: | |
1854 ; 5. set D = RM + 2 : position after the 2px tick | |
1855 movff lo,hi | |
1856 movlw d'2' | |
1857 addwf hi,1 | |
1858 ; 6. set RM = RM + 15 : position to the next tick | |
1859 movlw d'15' | |
1860 addwf lo,1 | |
1861 ; 7. loop | |
1862 bra TFT_dive_compass_ruler_loop | |
1863 | |
1864 TFT_dive_compass_ruler_lend: ; loop end | |
1865 ; 8. clear the rest of the tick area if D<160 | |
1866 movlw d'160' | |
1867 cpfslt hi,1 | |
1868 bra TFT_dive_compass_ruler_lend2 ; D >= W | |
1869 ; 9. position left to end of display to clear the remaining area | |
1870 movlw d'160' | |
1871 movwf lo | |
1872 ; 10. clear it | |
1873 rcall TFT_dive_compass_clr_ruler | |
1874 | |
1875 TFT_dive_compass_ruler_lend2: | |
1876 rcall TFT_dive_compass_c_mk | |
1877 ; done with the compass ruler, put the labels on the screen | |
1878 ; get the RD abck to sub_b | |
1879 movff xRD+0,sub_b+0 | |
1880 movff xRD+1,sub_b+1 | |
1881 ; hi stores the display position | |
1882 movlw d'0' | |
1883 movwf hi | |
1884 ; lo stores the last item's display position | |
1885 movlw d'0' | |
1886 movwf lo | |
1887 bcf print_compass_label | |
1888 | |
1889 movlw d'14' | |
1890 movwf up ; up stores the width of hte label | |
1891 movlw low( d'219' ) ; position of the label | |
1892 movwf sub_a+0 | |
1893 movlw high( d'219' ) | |
1894 movwf sub_a+1 | |
1895 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
1896 btfss print_compass_label ; Yes? | |
1897 bra dcr_1 | |
1898 STRCPY_TEXT_PRINT tSW ; yes - print it | |
1899 dcr_1: | |
1900 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
1901 | |
1902 movlw d'7' | |
1903 movwf up ; up stores the width of hte label | |
1904 movlw low( d'267' ) ; position of the label | |
1905 movwf sub_a+0 | |
1906 movlw high( d'267' ) | |
1907 movwf sub_a+1 | |
1908 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
1909 btfss print_compass_label ; Yes? | |
1910 bra dcr_2 | |
1911 STRCPY_TEXT_PRINT tW ; yes - print it | |
1912 dcr_2: | |
1913 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
1914 | |
1915 movlw d'14' | |
1916 movwf up ; up stores the width of hte label | |
1917 movlw low( d'309' ) ; position of the label | |
1918 movwf sub_a+0 | |
1919 movlw high( d'309' ) | |
1920 movwf sub_a+1 | |
1921 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
1922 btfss print_compass_label ; Yes? | |
1923 bra dcr_3 | |
1924 STRCPY_TEXT_PRINT tNW ; yes - print it | |
1925 dcr_3: | |
1926 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
1927 | |
1928 movlw d'6' | |
1929 movwf up ; up stores the width of hte label | |
1930 movlw low( d'358' ) ; position of the label | |
1931 movwf sub_a+0 | |
1932 movlw high( d'358' ) | |
1933 movwf sub_a+1 | |
1934 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
1935 btfss print_compass_label ; Yes? | |
1936 bra dcr_4 | |
1937 STRCPY_TEXT_PRINT tN ; yes - print it | |
1938 dcr_4: | |
1939 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
1940 | |
1941 movlw d'13' | |
1942 movwf up ; up stores the width of hte label | |
1943 movlw low( d'399' ) ; position of the label | |
1944 movwf sub_a+0 | |
1945 movlw high( d'399' ) | |
1946 movwf sub_a+1 | |
1947 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
1948 btfss print_compass_label ; Yes? | |
1949 bra dcr_5 | |
1950 STRCPY_TEXT_PRINT tNE ; yes - print it | |
1951 dcr_5: | |
1952 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
1953 | |
1954 movlw d'6' | |
1955 movwf up ; up stores the width of hte label | |
1956 movlw low( d'448' ) ; position of the label | |
1957 movwf sub_a+0 | |
1958 movlw high( d'448' ) | |
1959 movwf sub_a+1 | |
1960 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
1961 btfss print_compass_label ; Yes? | |
1962 bra dcr_6 | |
1963 STRCPY_TEXT_PRINT tE ; yes - print it | |
1964 dcr_6: | |
1965 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
1966 | |
1967 movlw d'13' | |
1968 movwf up ; up stores the width of hte label | |
1969 movlw low( d'489' ) ; position of the label | |
1970 movwf sub_a+0 | |
1971 movlw high( d'489' ) | |
1972 movwf sub_a+1 | |
1973 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
1974 btfss print_compass_label ; Yes? | |
1975 bra dcr_7 | |
1976 STRCPY_TEXT_PRINT tSE ; yes - print it | |
1977 dcr_7: | |
1978 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
1979 | |
1980 movlw d'6' | |
1981 movwf up ; up stores the width of hte label | |
1982 movlw low( d'538' ) ; position of the label | |
1983 movwf sub_a+0 | |
1984 movlw high( d'538' ) | |
1985 movwf sub_a+1 | |
1986 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
1987 btfss print_compass_label ; Yes? | |
1988 bra dcr_8 | |
1989 STRCPY_TEXT_PRINT tS ; yes - print it | |
1990 dcr_8: | |
1991 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
1992 | |
1993 movlw d'14' | |
1994 movwf up ; up stores the width of hte label | |
1995 movlw low( d'579' ) ; position of the label | |
1996 movwf sub_a+0 | |
1997 movlw high( d'579' ) | |
1998 movwf sub_a+1 | |
1999 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
2000 btfss print_compass_label ; Yes? | |
2001 bra dcr_9 | |
2002 STRCPY_TEXT_PRINT tSW ; yes - print it | |
2003 dcr_9: | |
2004 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
2005 | |
2006 movlw d'7' | |
2007 movwf up ; up stores the width of hte label | |
2008 movlw low( d'627' ) ; position of the label | |
2009 movwf sub_a+0 | |
2010 movlw high( d'627' ) | |
2011 movwf sub_a+1 | |
2012 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
2013 btfss print_compass_label ; Yes? | |
2014 bra dcr_10 | |
2015 STRCPY_TEXT_PRINT tW ; yes - print it | |
2016 dcr_10: | |
2017 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
2018 | |
2019 movlw d'14' | |
2020 movwf up ; up stores the width of hte label | |
2021 movlw low( d'669' ) ; position of the label | |
2022 movwf sub_a+0 | |
2023 movlw high( d'669' ) | |
2024 movwf sub_a+1 | |
2025 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
2026 btfss print_compass_label ; Yes? | |
2027 bra dcr_11 | |
2028 STRCPY_TEXT_PRINT tNW ; yes - print it | |
2029 dcr_11: | |
2030 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
2031 | |
2032 movlw d'6' | |
2033 movwf up ; up stores the width of hte label | |
2034 movlw low( d'718' ) ; position of the label | |
2035 movwf sub_a+0 | |
2036 movlw high( d'718' ) | |
2037 movwf sub_a+1 | |
2038 rcall TFT_dive_compass_label_proc ; check if the label should be on screen | |
2039 btfss print_compass_label ; Yes? | |
2040 bra dcr_12 | |
2041 STRCPY_TEXT_PRINT tN ; yes - print it | |
2042 dcr_12: | |
2043 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
2044 | |
2045 TFT_dive_compass_label_end: | |
2046 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
2047 ; restore lo and hi for the final cleanup | |
2048 movff xLO,lo | |
2049 movff xHI,hi | |
2050 ; clear the rest of the SQ area if there are more space | |
2051 movlw d'160' | |
2052 cpfslt hi | |
2053 bra TFT_dive_compass_label_end2 ; D >= 160, no more space | |
2054 ; position left to end of display to clear the remaining area | |
2055 movlw d'160' | |
2056 movff WREG,lo | |
2057 ; clear it | |
2058 rcall TFT_dive_compass_clr_label | |
2059 TFT_dive_compass_label_end2: | |
2060 rcall TFT_dive_compass_c_mk ; check if label is on the center line or the marker | |
2061 ; do we have bearing set? | |
2062 btfsc compass_bearing_set | |
2063 bra TFT_dive_compass_dir_text ; bearing_set=1 - go and print the dir (<< or >>) | |
2064 rcall TFT_dive_compass_dir_lclr ; no, clear the area (e.g. we had but removed) | |
2065 rcall TFT_dive_compass_dir_rclr | |
2066 bra TFT_dive_compass_text | |
2067 | |
2068 TFT_dive_compass_dir_text: | |
2069 ; bearing set, but does it point to heading? | |
2070 btfss compass_bearing_eq | |
2071 bra TFT_dive_compass_dir_text_2 ; bearing != heading - go and print the dir | |
2072 rcall TFT_dive_compass_dir_lclr ; bearing = heading, no need for direction markers | |
2073 rcall TFT_dive_compass_dir_rclr | |
2074 bra TFT_dive_compass_text | |
2075 | |
2076 TFT_dive_compass_dir_text_2: | |
2077 btfsc compass_bearing_lft | |
2078 bra TFT_dive_compass_dir_ldir ; bearing_lft=1, print the left marker | |
2079 ;TFT_dive_compass_text_rdir: | |
2080 movlw color_green | |
2081 call TFT_set_color | |
2082 WIN_SMALL dive_compass_rdir_column,dive_compass_head_row | |
2083 STRCPY_PRINT ">>" | |
2084 ; do not forget to clear the left | |
2085 rcall TFT_dive_compass_dir_lclr | |
2086 bra TFT_dive_compass_text | |
2087 | |
2088 TFT_dive_compass_dir_ldir: | |
2089 movlw color_green | |
2090 call TFT_set_color | |
2091 WIN_SMALL dive_compass_ldir_column,dive_compass_head_row | |
2092 STRCPY_PRINT "<<" | |
2093 ; do not forget to clear the right | |
2094 rcall TFT_dive_compass_dir_rclr | |
2095 ;bra TFT_dive_compass_text | |
2096 | |
2097 TFT_dive_compass_text: | |
2098 ; Text output | |
2099 call TFT_standard_color | |
2100 WIN_SMALL dive_compass_head_column,dive_compass_head_row | |
2101 rcall TFT_surface_compass_heading_com ; Show "000° N" | |
2102 return | |
2103 | |
2104 TFT_dive_compass_dir_lclr: | |
2105 WIN_SMALL dive_compass_ldir_column,dive_compass_head_row | |
2106 STRCPY_PRINT " " | |
2107 return | |
2108 | |
2109 TFT_dive_compass_dir_rclr: | |
2110 WIN_SMALL dive_compass_rdir_column,dive_compass_head_row | |
2111 STRCPY_PRINT " " | |
2112 return | |
2113 | |
2114 TFT_dive_compass_label_proc: | |
2115 ; Input: | |
2116 ; xHI: DD - display'a current position | |
2117 ; xRD: RD - ruler display offset | |
2118 ; sub_a: RP - item's ruler display offset | |
2119 ; get the RD abck to sub_b | |
2120 movff xHI,hi | |
2121 bcf print_compass_label | |
2122 ; 1/a. check if it's viewable ? sub_a(RP) >= sub_b(RD) ? | |
2123 ; set the carry flag if sub_b(xRD) is equal to or greater than sub_a(xRP): | |
2124 movff xRD+0,sub_b+0 | |
2125 movff xRD+1,sub_b+1 | |
2126 call subU16 ; sub_c = sub_a - sub_b | |
2127 btfsc neg_flag ; >=0? | |
2128 return ; No | |
2129 ; store the RO=RP-RD for drawing | |
2130 movff sub_c+0,xC+0 | |
2131 movff sub_c+1,xC+1 | |
2132 | |
2133 ; 1/b. check if it's viewable ? sub_a(RP)+up(width) < sub_b(RD)+160 | |
2134 ; if already above, no need to process the rest of the labels | |
2135 ;movff up,WREG ; don't worry about the width, low level call prevents overload | |
2136 movlw d'2' ; .. but still avoid thin mess on the side of the display | |
2137 addwf sub_a+0,1 | |
2138 btfsc STATUS, C | |
2139 incf sub_a+1 | |
2140 | |
2141 movff xRDr+0,sub_b+0 | |
2142 movff xRDr+1,sub_b+1 | |
2143 call subU16 ; sub_c = sub_a - sub_b | |
2144 btfss neg_flag ; ? <0 | |
2145 bra TFT_dive_compass_label_end ; No | |
2146 | |
2147 ; 2. restore RO=RP-RD from 1/a. | |
2148 movff xC+0,lo | |
2149 | |
2150 ; 3. Clear the segment from DD(hi) to lo | |
2151 ; don't do a clear if we are at 0 (zero) otherwise it will blink | |
2152 ; ?because of the width underflow? | |
2153 movlw d'0' | |
2154 cpfsgt lo | |
2155 bra TFT_dive_compass_label_proc_p | |
2156 rcall TFT_dive_compass_clr_label | |
2157 TFT_dive_compass_label_proc_p: | |
2158 ; 4. print the SQ on the screen | |
2159 call TFT_standard_color | |
2160 bsf print_compass_label | |
2161 rcall TFT_dive_compass_label_print | |
2162 ; 6. retain the new display positions | |
2163 movff hi,divB ; old-hi will be used by the c_mk : clear+marker printing | |
2164 movff lo,hi | |
2165 movff up,WREG | |
2166 addwf hi,1 | |
2167 movff lo,xLO | |
2168 movff hi,xHI | |
2169 return | |
2170 | |
2171 TFT_dive_compass_label_print: | |
2172 movlw dive_compass_label_row | |
2173 movff WREG,win_top | |
2174 movff lo,win_leftx2 | |
2175 movlw FT_SMALL | |
2176 movff WREG,win_font | |
2177 return | |
2178 | |
2179 TFT_dive_compass_c_mk: | |
2180 ; Common task to draw center line and marker | |
2181 ; until a proper implementation make it simple: | |
2182 rcall TFT_dive_compass_mk | |
2183 rcall TFT_dive_compass_cline | |
2184 return | |
2185 | |
2186 TFT_dive_compass_mk: | |
2187 ; draw the bearing on the screen if visible and if we just put something over it | |
2188 btfss compass_bearing_set | |
2189 return ; bearing_set=0 nothing to display | |
2190 | |
2191 btfss compass_bearing_vis | |
2192 return ; bearing set but not visible | |
2193 | |
2194 ; save lo/hi from trashing | |
2195 movff lo,xA+0 | |
2196 movff hi,xA+1 | |
2197 | |
2198 ; did we just update the marker's position? | |
2199 ; DD.......DD | |
2200 ; CM+2>=DD(old) or CM-2<=DD | |
2201 ; ToDo | |
2202 | |
2203 btfss compass_bearing_ahd | |
2204 bra TFT_dive_compass_mk_rear | |
2205 ;TFT_dive_compass_mk_front: | |
2206 clrf lo | |
2207 movff xCM,lo | |
2208 bsf print_compass_label ; set=green marker | |
2209 rcall TFT_dive_compass_mk_print | |
2210 bcf print_compass_label | |
2211 bra TFT_dive_compass_mk_end | |
2212 | |
2213 TFT_dive_compass_mk_rear: | |
2214 clrf lo | |
2215 movff xCM,lo | |
2216 bcf print_compass_label ; set=red marker | |
2217 rcall TFT_dive_compass_mk_print | |
2218 | |
2219 TFT_dive_compass_mk_end: | |
2220 movff xA+0,lo | |
2221 movff xA+1,hi | |
2222 return | |
2223 | |
2224 TFT_dive_compass_mk_print: | |
2225 movlw d'1' | |
2226 cpfsgt lo | |
2227 bra TFT_dive_compass_mk_print_2 ; lo<1, skip the first line | |
2228 movlw d'2' | |
2229 subwf lo,0 | |
2230 movff WREG,win_leftx2 | |
2231 rcall TFT_dive_compass_mk_print_3 | |
2232 TFT_dive_compass_mk_print_2: | |
2233 movlw d'2' | |
2234 addwf lo,0 | |
2235 movff WREG,win_leftx2 | |
2236 rcall TFT_dive_compass_mk_print_3 | |
2237 return | |
2238 TFT_dive_compass_mk_print_3: | |
2239 movlw dive_compass_label_row | |
2240 movff WREG,win_top | |
2241 movlw dive_compass_label_height-.2 | |
2242 movff WREG,win_height | |
2243 movlw d'2' | |
2244 movff WREG,win_width | |
2245 movlw d'2' | |
2246 movff WREG,win_bargraph | |
2247 movlw color_green | |
2248 btfss print_compass_label | |
2249 movlw color_red | |
2250 call TFT_set_color | |
2251 call TFT_box | |
2252 return | |
2253 | |
2254 TFT_dive_compass_clr_label: | |
2255 movlw dive_compass_label_row-.2 ; set top & height | |
2256 movff WREG,win_top | |
2257 movlw dive_compass_label_height+.2 | |
2258 movff WREG,win_height | |
2259 rcall TFT_dive_compass_clear | |
2260 return | |
2261 | |
2262 TFT_dive_compass_clr_ruler: | |
2263 ; top tick | |
2264 movlw dive_compass_tick_top_top ; set top & height | |
2265 movff WREG,win_top | |
2266 movlw dive_compass_tick_height | |
2267 movff WREG,win_height | |
2268 rcall TFT_dive_compass_clear | |
2269 ;bottom tick | |
2270 movlw dive_compass_tick_bot_top ; set top & height | |
2271 movff WREG,win_top | |
2272 movlw dive_compass_tick_height | |
2273 movff WREG,win_height | |
2274 rcall TFT_dive_compass_clear | |
2275 return | |
2276 | |
2277 TFT_dive_compass_clear: | |
2278 ; we receive RM in lo and DD in hi | |
2279 ; calculate width = RM-D | |
2280 movff hi,WREG | |
2281 subwf lo,0 | |
2282 movff WREG,win_width ; RM-DD | |
2283 movff WREG,win_bargraph | |
2284 movff hi,win_leftx2 | |
2285 movlw color_black | |
2286 call TFT_set_color | |
2287 call TFT_box | |
2288 return | |
2289 | |
2290 TFT_dive_compass_ruler_print: | |
2291 ; we receive RM in lo and DD in hi | |
2292 movlw dive_compass_tick_top_top | |
2293 movff WREG,win_top | |
2294 movlw dive_compass_tick_height | |
2295 movff WREG,win_height | |
2296 movlw d'2' | |
2297 movff WREG,win_width | |
2298 movlw d'2' | |
2299 movff WREG,win_bargraph | |
2300 movff lo,win_leftx2 ; 0..159 | |
2301 call TFT_standard_color | |
2302 call TFT_box | |
2303 movlw dive_compass_tick_bot_top | |
2304 movff WREG,win_top | |
2305 movlw dive_compass_tick_height | |
2306 movff WREG,win_height | |
2307 call TFT_standard_color | |
2308 call TFT_box | |
2309 return | |
2310 | |
2311 TFT_dive_compass_cline: | |
2312 movlw color_yellow | |
2313 WIN_BOX_COLOR dive_compass_tick_top_top,dive_compass_tick_bot_bot,.80,.81 | |
2314 return | |
2315 | |
2316 tft_compass_cardinal: | |
2317 btfsc hi,0 ; Heading >255°? | |
2318 bra tft_compass_cardinal2 ; Yes must be W, NW or N | |
2319 ; No, Must be W, SW, S, SE, E, NE or N | |
2320 movlw .23 | |
2321 subwf lo,W | |
2322 btfss STATUS,C | |
2323 bra tft_compass_cardinal_N | |
2324 movlw .68 | |
2325 subwf lo,W | |
2326 btfss STATUS,C | |
2327 bra tft_compass_cardinal_NE | |
2328 movlw .113 | |
2329 subwf lo,W | |
2330 btfss STATUS,C | |
2331 bra tft_compass_cardinal_E | |
2332 movlw .158 | |
2333 subwf lo,W | |
2334 btfss STATUS,C | |
2335 bra tft_compass_cardinal_SE | |
2336 movlw .203 | |
2337 subwf lo,W | |
2338 btfss STATUS,C | |
2339 bra tft_compass_cardinal_S | |
2340 movlw .248 | |
2341 subwf lo,W | |
2342 btfss STATUS,C | |
2343 bra tft_compass_cardinal_SW | |
2344 bra tft_compass_cardinal_W | |
2345 | |
2346 tft_compass_cardinal2: | |
2347 movlw .37 | |
2348 subwf lo,W | |
2349 btfss STATUS,C | |
2350 bra tft_compass_cardinal_W | |
2351 movlw .82 | |
2352 subwf lo,W | |
2353 btfss STATUS,C | |
2354 bra tft_compass_cardinal_NW | |
2355 ; bra tft_compass_cardinal_N | |
2356 tft_compass_cardinal_N: | |
2357 STRCAT_TEXT tN | |
2358 return | |
2359 tft_compass_cardinal_NE: | |
2360 STRCAT_TEXT tNE | |
2361 return | |
2362 tft_compass_cardinal_E: | |
2363 STRCAT_TEXT tE | |
2364 return | |
2365 tft_compass_cardinal_SE: | |
2366 STRCAT_TEXT tSE | |
2367 return | |
2368 tft_compass_cardinal_S: | |
2369 STRCAT_TEXT tS | |
2370 return | |
2371 tft_compass_cardinal_SW: | |
2372 STRCAT_TEXT tSW | |
2373 return | |
2374 tft_compass_cardinal_W: | |
2375 STRCAT_TEXT tW | |
2376 return | |
2377 tft_compass_cardinal_NW: | |
2378 STRCAT_TEXT tNW | |
2379 return | |
2380 | |
2381 compass_heading_common: | |
2382 call speed_normal | |
2383 movlw compass_averaging ; numbers of extra averaging | |
2384 movwf up | |
2385 compass_heading_common2: | |
2386 rcall TFT_get_compass | |
2387 decfsz up,F | |
2388 bra compass_heading_common2 | |
2389 extern compass | |
2390 call compass ; Do compass corrections. | |
2391 banksel common | |
2392 | |
2393 ; More then compass_fast_treshold? | |
2394 movff compass_heading_old+0,sub_a+0 | |
2395 movff compass_heading_old+1,sub_a+1 | |
2396 movff compass_heading+0,sub_b+0 | |
2397 movff compass_heading+1,sub_b+1 | |
2398 call sub16 | |
2399 btfss neg_flag ; <0? | |
2400 bra compass_heading_common3 ; No, test for threshold | |
2401 ; Yes, subtract the other way round | |
2402 movff compass_heading+0,sub_a+0 | |
2403 movff compass_heading+1,sub_a+1 | |
2404 movff compass_heading_old+0,sub_b+0 | |
2405 movff compass_heading_old+1,sub_b+1 | |
2406 call sub16 | |
2407 compass_heading_common3: | |
2408 movff compass_heading+0,compass_heading_old+0 ; copy new "old" | |
2409 movff compass_heading+1,compass_heading_old+1 | |
2410 | |
2411 bcf compass_fast_mode | |
2412 movlw compass_fast_treshold | |
2413 cpfslt sub_c+0 ; > compass_fast_treshold? | |
2414 bsf compass_fast_mode ; Yes! | |
2415 | |
2416 btfss compass_fast_mode ; In fast mode? | |
2417 return ; No. | |
2418 ; Yes. | |
2419 movff compass_heading+0,lo | |
2420 movff compass_heading+1,hi | |
2421 rcall TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
2422 movff lo,compass_heading_shown+0 | |
2423 movff hi,compass_heading_shown+1 | |
2424 return | |
2425 | |
2426 TFT_get_compass: | |
2427 call I2C_RX_compass ; Test Compass | |
2428 call I2C_RX_accelerometer ; Test Accelerometer | |
2429 extern compass_filter | |
2430 call compass_filter ; Filter Raw compass + accel readings. | |
2431 banksel common | |
2432 return | |
2433 | 1357 |
2434 global TFT_debug_output | 1358 global TFT_debug_output |
2435 TFT_debug_output: | 1359 TFT_debug_output: |
2436 return | 1360 return |
2437 WIN_TINY .80,.0 | 1361 WIN_TINY .80,.0 |