Mercurial > public > hwos_code
comparison src/tft_outputs.asm @ 83:eb72c8865f47
Test with graphic compass
author | heinrichsweikamp |
---|---|
date | Mon, 17 Mar 2014 23:48:30 +0100 |
parents | a5ea132770db |
children | 45a420beb534 |
comparison
equal
deleted
inserted
replaced
82:0653dd581c26 | 83:eb72c8865f47 |
---|---|
1589 STRCPY_TEXT_PRINT tHeading ; Heading: | 1589 STRCPY_TEXT_PRINT tHeading ; Heading: |
1590 return | 1590 return |
1591 | 1591 |
1592 global TFT_dive_compass_mask | 1592 global TFT_dive_compass_mask |
1593 TFT_dive_compass_mask: | 1593 TFT_dive_compass_mask: |
1594 WIN_TINY dive_compass_mask_column,dive_compass_mask_row | 1594 ; WIN_TINY dive_compass_mask_column,dive_compass_mask_row |
1595 call TFT_divemask_color | 1595 ; call TFT_divemask_color |
1596 STRCPY_TEXT_PRINT tHeading ; Heading: | 1596 ; STRCPY_TEXT_PRINT tHeading ; Heading: |
1597 return | 1597 return |
1598 | 1598 |
1599 | 1599 |
1600 global TFT_surface_compass_heading | 1600 global TFT_surface_compass_heading |
1601 TFT_surface_compass_heading: | 1601 TFT_surface_compass_heading: |
1609 return | 1609 return |
1610 TFT_surface_compass_heading2: | 1610 TFT_surface_compass_heading2: |
1611 WIN_STD surf_compass_head_column,surf_compass_head_row | 1611 WIN_STD surf_compass_head_column,surf_compass_head_row |
1612 call TFT_standard_color | 1612 call TFT_standard_color |
1613 lfsr FSR2,buffer | 1613 lfsr FSR2,buffer |
1614 ; movff compass_heading+0,lo | |
1615 ; movff compass_heading+1,hi | |
1616 ; call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | |
1617 ; output_8 | |
1618 ; PUTC " " | |
1619 ; movff hi,lo | |
1620 ; output_8 | |
1621 ; PUTC " " | |
1622 movff compass_heading+0,lo | 1614 movff compass_heading+0,lo |
1623 movff compass_heading+1,hi | 1615 movff compass_heading+1,hi |
1624 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required | 1616 call TFT_convert_signed_16bit ; converts lo:hi into signed-short and adds '-' to POSTINC2 if required |
1625 bsf leftbind | 1617 bsf leftbind |
1626 output_16 | 1618 output_16 |
1637 bra TFT_dive_compass_heading2 ; Yes | 1629 bra TFT_dive_compass_heading2 ; Yes |
1638 ; No, update 1/second max. | 1630 ; No, update 1/second max. |
1639 movff sensor_state_counter,lo | 1631 movff sensor_state_counter,lo |
1640 movlw .6 | 1632 movlw .6 |
1641 cpfsgt lo | 1633 cpfsgt lo |
1642 return | 1634 bra TFT_dive_compass_heading3 ; But update graph always in fast mode |
1643 TFT_dive_compass_heading2: | 1635 TFT_dive_compass_heading2: |
1644 WIN_STD dive_compass_head_column,dive_compass_head_row | 1636 WIN_STD dive_compass_head_column,dive_compass_head_row |
1645 call TFT_standard_color | 1637 call TFT_standard_color |
1646 lfsr FSR2,buffer | 1638 lfsr FSR2,buffer |
1647 movff compass_heading+0,lo | 1639 movff compass_heading+0,lo |
1651 output_16 | 1643 output_16 |
1652 bcf leftbind | 1644 bcf leftbind |
1653 STRCAT "° " | 1645 STRCAT "° " |
1654 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 | 1646 rcall tft_compass_cardinal ; Add cardinal and ordinal to POSTINC2 |
1655 STRCAT_PRINT " " | 1647 STRCAT_PRINT " " |
1648 TFT_dive_compass_heading3: | |
1649 movff compass_heading+0,sub_a+0 | |
1650 movff compass_heading+1,sub_a+1 | |
1651 movlw .45 | |
1652 movwf sub_b+0 | |
1653 clrf sub_b+1 | |
1654 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) | |
1655 btfss neg_flag ; Result <0? | |
1656 bra TFT_dive_compass_heading_graph1 ; No | |
1657 ; Yes | |
1658 movlw LOW .360 | |
1659 movwf sub_a+0 | |
1660 movlw HIGH .360 | |
1661 movwf sub_a+1 | |
1662 movff sub_c+0,sub_b+0 | |
1663 movff sub_c+1,sub_b+1 | |
1664 call subU16 ; sub_c = sub_a - sub_b (with UNSIGNED values) | |
1665 | |
1666 TFT_dive_compass_heading_graph1: | |
1667 WIN_SMALL dive_compass_head_column+.70,dive_compass_head_row | |
1668 movff sub_c+0,lo | |
1669 movff sub_c+1,hi | |
1670 call TFT_standard_color | |
1671 lfsr FSR2,buffer | |
1672 bsf leftbind | |
1673 output_16 | |
1674 bcf leftbind | |
1675 STRCAT_PRINT " " | |
1676 | |
1677 ; Draw marks (left border of graphic is in lo) | |
1678 movlw b'00011111' | |
1679 andwf lo,F ; Get lowest 5bits of heading | |
1680 movlw d'30' | |
1681 cpfslt lo | |
1682 movwf lo ; Limit to 30 | |
1683 rlncf lo,F ; x2 | |
1684 ; marks parameters | |
1685 WIN_BOX_BLACK dive_compass_graph_row,dive_compass_graph_row+dive_compass_graph_height,.0,.159 | |
1686 call TFT_standard_color | |
1687 WIN_SMALL .77,dive_compass_graph_row ; Center of screen | |
1688 STRCPY_PRINT "^" | |
1689 call TFT_divemask_color | |
1690 movlw dive_compass_graph_row | |
1691 movff WREG,win_top | |
1692 movlw dive_compass_graph_height | |
1693 movff WREG,win_height | |
1694 movlw dive_compass_graph_width | |
1695 movff WREG,win_width+0 | |
1696 clrf win_width+1 | |
1697 ; marks draw loop | |
1698 movlw .6 | |
1699 movwf hi ; amount of marks (max.) | |
1700 clrf lo_temp | |
1701 TFT_dive_compass_heading_graph2: | |
1702 movlw LOW .319 | |
1703 movwf sub_a+0 | |
1704 movlw HIGH .319 | |
1705 movwf sub_a+1 | |
1706 movff lo,sub_b+0 | |
1707 movff lo_temp,sub_b+1 | |
1708 call subU16 | |
1709 btfsc neg_flag | |
1710 bra TFT_dive_compass_heading_graph3 ; Abort when negative | |
1711 movff sub_c+0,PRODL | |
1712 movff sub_c+1,PRODH | |
1713 call TFT_box_write_16bit_win_left ; With column in PRODL:PRODH | |
1714 ;---- Define Window ------------------------------------------------------ | |
1715 movf win_width,W | |
1716 bcf STATUS,C | |
1717 rlcf WREG | |
1718 movwf win_width+0 | |
1719 movlw 0 | |
1720 rlcf WREG | |
1721 movwf win_width+1 | |
1722 call TFT_box_16bit_win_left | |
1723 movlw .56 ; 60 px. space | |
1724 addwf lo,F | |
1725 movlw .0 | |
1726 addwfc lo_temp,F | |
1727 ; movlw .160 | |
1728 ; cpfslt lo | |
1729 ; bra TFT_dive_compass_heading_graph3 ; Abort | |
1730 decfsz hi,F | |
1731 bra TFT_dive_compass_heading_graph2 | |
1732 TFT_dive_compass_heading_graph3: | |
1656 return | 1733 return |
1657 | 1734 |
1658 tft_compass_cardinal: | 1735 tft_compass_cardinal: |
1659 btfsc hi,0 ; Heading >255°? | 1736 btfsc hi,0 ; Heading >255°? |
1660 bra tft_compass_cardinal2 ; Yes must be W, NW or N | 1737 bra tft_compass_cardinal2 ; Yes must be W, NW or N |