-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
246 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Autogenerated file. | ||
from .client import PlanarPositionClient # type: ignore |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# Autogenerated file. Do not edit. | ||
from jacdac.bus import Bus, SensorClient | ||
from .constants import * | ||
from typing import Optional, Tuple | ||
|
||
|
||
class PlanarPositionClient(SensorClient): | ||
""" | ||
A sensor that repors 2D position, typically an optical mouse tracking sensor. | ||
* | ||
* The sensor starts at an arbitrary origin (0,0) and reports the distance from that origin. | ||
* | ||
* The `streaming_interval` is respected when the position is changing. When the position is not changing, the streaming interval may be throttled to `500ms`. | ||
Implements a client for the `Planar position <https://microsoft.github.io/jacdac-docs/services/planarposition>`_ service. | ||
""" | ||
|
||
def __init__(self, bus: Bus, role: str, *, missing_position_value: Optional[Tuple[float, float]] = None) -> None: | ||
super().__init__(bus, JD_SERVICE_CLASS_PLANAR_POSITION, JD_PLANAR_POSITION_PACK_FORMATS, role) | ||
self.missing_position_value = missing_position_value | ||
|
||
@property | ||
def position(self) -> Optional[Tuple[float, float]]: | ||
""" | ||
The current position of the sensor., x: mm,y: mm | ||
""" | ||
self.refresh_reading() | ||
return self.register(JD_PLANAR_POSITION_REG_POSITION).value(self.missing_position_value) | ||
|
||
@property | ||
def variant(self) -> Optional[PlanarPositionVariant]: | ||
""" | ||
(Optional) Specifies the type of physical sensor., | ||
""" | ||
return self.register(JD_PLANAR_POSITION_REG_VARIANT).value() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Autogenerated constants for Planar position service | ||
from enum import IntEnum | ||
from jacdac.constants import * | ||
from jacdac.system.constants import * | ||
JD_SERVICE_CLASS_PLANAR_POSITION = const(0x1dc37f55) | ||
|
||
|
||
class PlanarPositionVariant(IntEnum): | ||
OPTICAL_MOUSE_POSITION = const(0x1) | ||
|
||
|
||
JD_PLANAR_POSITION_REG_POSITION = const(JD_REG_READING) | ||
JD_PLANAR_POSITION_REG_VARIANT = const(JD_REG_VARIANT) | ||
JD_PLANAR_POSITION_PACK_FORMATS = { | ||
JD_PLANAR_POSITION_REG_POSITION: "i22.10 i22.10", | ||
JD_PLANAR_POSITION_REG_VARIANT: "u8" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters