Skip to content

Commit

Permalink
fix: updated constants
Browse files Browse the repository at this point in the history
  • Loading branch information
pelikhan committed Sep 7, 2022
1 parent cfcd25a commit 3e88928
Show file tree
Hide file tree
Showing 9 changed files with 246 additions and 3 deletions.
21 changes: 21 additions & 0 deletions jacdac/dc_current_measurement/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,25 @@ def measurement(self) -> Optional[float]:
self.refresh_reading()
return self.register(JD_DC_CURRENT_MEASUREMENT_REG_MEASUREMENT).value(self.missing_measurement_value)

@property
def measurement_error(self) -> Optional[float]:
"""
(Optional) Absolute error on the reading value., _: A
"""
return self.register(JD_DC_CURRENT_MEASUREMENT_REG_MEASUREMENT_ERROR).value()

@property
def min_measurement(self) -> Optional[float]:
"""
(Optional) Minimum measurable current, _: A
"""
return self.register(JD_DC_CURRENT_MEASUREMENT_REG_MIN_MEASUREMENT).value()

@property
def max_measurement(self) -> Optional[float]:
"""
(Optional) Maximum measurable current, _: A
"""
return self.register(JD_DC_CURRENT_MEASUREMENT_REG_MAX_MEASUREMENT).value()


8 changes: 7 additions & 1 deletion jacdac/dc_current_measurement/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@
JD_SERVICE_CLASS_DC_CURRENT_MEASUREMENT = const(0x1912c8ae)
JD_DC_CURRENT_MEASUREMENT_REG_MEASUREMENT_NAME = const(0x182)
JD_DC_CURRENT_MEASUREMENT_REG_MEASUREMENT = const(JD_REG_READING)
JD_DC_CURRENT_MEASUREMENT_REG_MEASUREMENT_ERROR = const(JD_REG_READING_ERROR)
JD_DC_CURRENT_MEASUREMENT_REG_MIN_MEASUREMENT = const(JD_REG_MIN_READING)
JD_DC_CURRENT_MEASUREMENT_REG_MAX_MEASUREMENT = const(JD_REG_MAX_READING)
JD_DC_CURRENT_MEASUREMENT_PACK_FORMATS = {
JD_DC_CURRENT_MEASUREMENT_REG_MEASUREMENT_NAME: "s",
JD_DC_CURRENT_MEASUREMENT_REG_MEASUREMENT: "f64"
JD_DC_CURRENT_MEASUREMENT_REG_MEASUREMENT: "f64",
JD_DC_CURRENT_MEASUREMENT_REG_MEASUREMENT_ERROR: "f64",
JD_DC_CURRENT_MEASUREMENT_REG_MIN_MEASUREMENT: "f64",
JD_DC_CURRENT_MEASUREMENT_REG_MAX_MEASUREMENT: "f64"
}
21 changes: 21 additions & 0 deletions jacdac/dc_voltage_measurement/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,25 @@ def measurement(self) -> Optional[float]:
self.refresh_reading()
return self.register(JD_DC_VOLTAGE_MEASUREMENT_REG_MEASUREMENT).value(self.missing_measurement_value)

@property
def measurement_error(self) -> Optional[float]:
"""
(Optional) Absolute error on the reading value., _: V
"""
return self.register(JD_DC_VOLTAGE_MEASUREMENT_REG_MEASUREMENT_ERROR).value()

@property
def min_measurement(self) -> Optional[float]:
"""
(Optional) Minimum measurable current, _: V
"""
return self.register(JD_DC_VOLTAGE_MEASUREMENT_REG_MIN_MEASUREMENT).value()

@property
def max_measurement(self) -> Optional[float]:
"""
(Optional) Maximum measurable current, _: V
"""
return self.register(JD_DC_VOLTAGE_MEASUREMENT_REG_MAX_MEASUREMENT).value()


8 changes: 7 additions & 1 deletion jacdac/dc_voltage_measurement/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,14 @@ class DcVoltageMeasurementVoltageMeasurementType(IntEnum):
JD_DC_VOLTAGE_MEASUREMENT_REG_MEASUREMENT_TYPE = const(0x181)
JD_DC_VOLTAGE_MEASUREMENT_REG_MEASUREMENT_NAME = const(0x182)
JD_DC_VOLTAGE_MEASUREMENT_REG_MEASUREMENT = const(JD_REG_READING)
JD_DC_VOLTAGE_MEASUREMENT_REG_MEASUREMENT_ERROR = const(JD_REG_READING_ERROR)
JD_DC_VOLTAGE_MEASUREMENT_REG_MIN_MEASUREMENT = const(JD_REG_MIN_READING)
JD_DC_VOLTAGE_MEASUREMENT_REG_MAX_MEASUREMENT = const(JD_REG_MAX_READING)
JD_DC_VOLTAGE_MEASUREMENT_PACK_FORMATS = {
JD_DC_VOLTAGE_MEASUREMENT_REG_MEASUREMENT_TYPE: "u8",
JD_DC_VOLTAGE_MEASUREMENT_REG_MEASUREMENT_NAME: "s",
JD_DC_VOLTAGE_MEASUREMENT_REG_MEASUREMENT: "f64"
JD_DC_VOLTAGE_MEASUREMENT_REG_MEASUREMENT: "f64",
JD_DC_VOLTAGE_MEASUREMENT_REG_MEASUREMENT_ERROR: "f64",
JD_DC_VOLTAGE_MEASUREMENT_REG_MIN_MEASUREMENT: "f64",
JD_DC_VOLTAGE_MEASUREMENT_REG_MAX_MEASUREMENT: "f64"
}
133 changes: 133 additions & 0 deletions jacdac/hid_keyboard/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,139 @@
JD_SERVICE_CLASS_HID_KEYBOARD = const(0x18b05b6a)


class HidKeyboardSelector(IntEnum):
NONE = const(0x0)
ERROR_ROLL_OVER = const(0x1)
POST_FAIL = const(0x2)
ERROR_UNDEFINED = const(0x3)
A = const(0x4)
B = const(0x5)
C = const(0x6)
D = const(0x7)
E = const(0x8)
F = const(0x9)
G = const(0xa)
H = const(0xb)
I = const(0xc)
J = const(0xd)
K = const(0xe)
L = const(0xf)
M = const(0x10)
N = const(0x11)
O = const(0x12)
P = const(0x13)
Q = const(0x14)
R = const(0x15)
S = const(0x16)
T = const(0x17)
U = const(0x18)
V = const(0x19)
W = const(0x1a)
X = const(0x1b)
Y = const(0x1c)
Z = const(0x1d)
_1 = const(0x1e)
_2 = const(0x1f)
_3 = const(0x20)
_4 = const(0x21)
_5 = const(0x22)
_6 = const(0x23)
_7 = const(0x24)
_8 = const(0x25)
_9 = const(0x26)
_0 = const(0x27)
RETURN = const(0x28)
ESCAPE = const(0x29)
BACKSPACE = const(0x2a)
TAB = const(0x2b)
SPACEBAR = const(0x2c)
MINUS = const(0x2d)
EQUALS = const(0x2e)
LEFT_SQUARE_BRACKET = const(0x2f)
RIGHT_SQUARE_BRACKET = const(0x30)
BACKSLASH = const(0x31)
NON_US_HASH = const(0x32)
SEMICOLON = const(0x33)
QUOTE = const(0x34)
GRAVE_ACCENT = const(0x35)
COMMA = const(0x36)
PERIOD = const(0x37)
SLASH = const(0x38)
CAPS_LOCK = const(0x39)
F1 = const(0x3a)
F2 = const(0x3b)
F3 = const(0x3c)
F4 = const(0x3d)
F5 = const(0x3e)
F6 = const(0x3f)
F7 = const(0x40)
F8 = const(0x41)
F9 = const(0x42)
F10 = const(0x43)
F11 = const(0x44)
F12 = const(0x45)
PRINT_SCREEN = const(0x46)
SCROLL_LOCK = const(0x47)
PAUSE = const(0x48)
INSERT = const(0x49)
HOME = const(0x4a)
PAGE_UP = const(0x4b)
DELETE = const(0x4c)
END = const(0x4d)
PAGE_DOWN = const(0x4e)
RIGHT_ARROW = const(0x4f)
LEFT_ARROW = const(0x50)
DOWN_ARROW = const(0x51)
UP_ARROW = const(0x52)
KEYPAD_NUM_LOCK = const(0x53)
KEYPAD_DIVIDE = const(0x54)
KEYPAD_MULTIPLY = const(0x55)
KEYPAD_ADD = const(0x56)
KEYPAD_SUBTRACE = const(0x57)
KEYPAD_RETURN = const(0x58)
KEYPAD1 = const(0x59)
KEYPAD2 = const(0x5a)
KEYPAD3 = const(0x5b)
KEYPAD4 = const(0x5c)
KEYPAD5 = const(0x5d)
KEYPAD6 = const(0x5e)
KEYPAD7 = const(0x5f)
KEYPAD8 = const(0x60)
KEYPAD9 = const(0x61)
KEYPAD0 = const(0x62)
KEYPAD_DECIMAL_POINT = const(0x63)
NON_US_BACKSLASH = const(0x64)
APPLICATION = const(0x65)
POWER = const(0x66)
KEYPAD_EQUALS = const(0x67)
F13 = const(0x68)
F14 = const(0x69)
F15 = const(0x6a)
F16 = const(0x6b)
F17 = const(0x6c)
F18 = const(0x6d)
F19 = const(0x6e)
F20 = const(0x6f)
F21 = const(0x70)
F22 = const(0x71)
F23 = const(0x72)
F24 = const(0x73)
EXECUTE = const(0x74)
HELP = const(0x75)
MENU = const(0x76)
SELECT = const(0x77)
STOP = const(0x78)
AGAIN = const(0x79)
UNDO = const(0x7a)
CUT = const(0x7b)
COPY = const(0x7c)
PASTE = const(0x7d)
FIND = const(0x7e)
MUTE = const(0x7f)
VOLUME_UP = const(0x80)
VOLUME_DOWN = const(0x81)


class HidKeyboardModifiers(IntEnum):
NONE = const(0x0)
LEFT_CONTROL = const(0x1)
Expand Down
2 changes: 2 additions & 0 deletions jacdac/planar_position/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Autogenerated file.
from .client import PlanarPositionClient # type: ignore
37 changes: 37 additions & 0 deletions jacdac/planar_position/client.py
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()


17 changes: 17 additions & 0 deletions jacdac/planar_position/constants.py
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"
}
2 changes: 1 addition & 1 deletion jacdac/usb_bridge/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class UsbBridgeClient(Client):
* These packets are not forwarded to the UART Jacdac line.
*
* Packets are sent over USB Serial (CDC).
* The host shall set the CDC to 2Mbaud 8N1
* The host shall set the CDC to 1Mbaud 8N1
* (even though in some cases the USB interface is connected directly to the MCU and line settings are
* ignored).
*
Expand Down

0 comments on commit 3e88928

Please sign in to comment.