Skip to content
Snippets Groups Projects
Select Git revision
  • 39a01e574664dafbbebe060f3476c24f5a4bbd89
  • main default protected
  • blm_dev_chan
  • release/1.4.0 protected
  • widgets_draw
  • return_of_melodic_demo
  • task_cleanup
  • mixer2
  • dx/fb-save-restore
  • dx/dldldld
  • fpletz/flake
  • dx/jacksense-headset-mic-only
  • release/1.3.0 protected
  • fil3s-limit-filesize
  • allow-reloading-sunmenu
  • wifi-json-error-handling
  • app_text_viewer
  • shoegaze-fps
  • media_has_video_has_audio
  • fil3s-media
  • more-accurate-battery
  • v1.4.0
  • v1.3.0
  • v1.2.0
  • v1.2.0+rc1
  • v1.1.1
  • v1.1.0
  • v1.1.0+rc1
  • v1.0.0
  • v1.0.0+rc6
  • v1.0.0+rc5
  • v1.0.0+rc4
  • v1.0.0+rc3
  • v1.0.0+rc2
  • v1.0.0+rc1
35 results

captouch.pyi

Blame
  • dos's avatar
    dos authored
    This makes it match the terminology used in other places
    ("petals" consisting of either 2 or 3 "pads").
    39a01e57
    History
    captouch.pyi 2.80 KiB
    from typing import Protocol, List, Tuple
    
    class CaptouchPetalPadsState(Protocol):
        """
        Current state of pads on a captouch petal.
    
        Not all petals have all pads. Top petals have a a base, cw and ccw pad.
        Bottom petals have a base and tip pad.
        """
    
        @property
        def tip(self) -> bool:
            """
            True if the petals's tip is currently touched.
            """
            ...
        @property
        def base(self) -> bool:
            """
            True if the petal's base is currently touched.
            """
            ...
        @property
        def cw(self) -> bool:
            """
            True if the petal's clockwise pad is currently touched.
            """
            ...
        @property
        def ccw(self) -> bool:
            """
            True if the petal's counter clockwise pad is currently touched.
            """
            ...
    
    class CaptouchPetalState(Protocol):
        @property
        def pressed(self) -> bool:
            """
            True if any of the petal's pads is currently touched.
            """
            ...
        @property
        def pressure(self) -> int:
            """
            How strongly the petal is currently being touched, in arbitrary units.
            """
            ...
        @property
        def top(self) -> bool:
            """
            True if this is a top petal.
            """
            ...
        @property
        def bottom(self) -> bool:
            """
            True if this is a bottom petal.
            """
            ...
        @property
        def pads(self) -> CaptouchPetalPadsState:
            """
            State of individual pads of the petal.
            """
            ...
        @property
        def position(seld) -> Tuple[int, int]:
            """
            Polar coordinates of touch on petal in the form of a (distance, angle)
            tuple.
    
            The units are arbitrary, but centered around (0, 0).
    
            An increase in distance means the touch is further away from the centre
            of the badge.
    
            An increase in angle means the touch is more clockwise.
            """
            ...
    
    class CaptouchState(Protocol):
        """
        State of captouch sensors, captured at some time.
        """
    
        @property
        def petals(self) -> List[CaptouchPetalState]:
            """
            State of individual petals.
    
            Contains 10 elements, with the zeroth element being the petal closest to
            the USB port. Then, every other petal in a clockwise direction.
    
            Petals 0, 2, 4, 6, 8 are Top petals.
    
            Petals 1, 3, 5, 7, 9 are Bottom petals.
            """
            ...
    
    def read() -> CaptouchState:
        """
        Reads current captouch state from hardware and returns a snapshot in time.
        """
        ...
    
    def calibration_active() -> bool:
        """
        Returns true if the captouch system is current recalibrating.
        """
        ...
    
    def calibration_request() -> None:
        """
        Attempts to start calibration of captouch controllers. No-op if a
        calibration is already active.
        """
        ...