This commit is contained in:
pelikhan 2021-12-08 15:56:42 -08:00
Родитель e7d7fe8615
Коммит 8f8fe6d157
44 изменённых файлов: 115 добавлений и 179 удалений

Просмотреть файл

@ -26,7 +26,7 @@ class BarometerClient(SensorClient):
@property
def pressure_error(self) -> Optional[float]:
"""
The real pressure is between `pressure - pressure_error` and `pressure + pressure_error`., _: hPa
(Optional) The real pressure is between `pressure - pressure_error` and `pressure + pressure_error`., _: hPa
"""
return self.register(JD_BAROMETER_REG_PRESSURE_ERROR).value()

Просмотреть файл

@ -18,7 +18,7 @@ class ButtonClientBase(SensorClient):
@property
def pressure(self) -> Optional[float]:
"""
Indicates the pressure state of the button, where ``0`` is open., _: /
Indicates the pressure state of the button, where `0` is open., _: /
"""
self.refresh_reading()
return self.register(JD_BUTTON_REG_PRESSURE).float_value(self.missing_pressure_value, 100)
@ -26,7 +26,7 @@ class ButtonClientBase(SensorClient):
@property
def analog(self) -> Optional[bool]:
"""
(Optional) Indicates if the button provides analog ``pressure`` readings.,
(Optional) Indicates if the button provides analog `pressure` readings.,
"""
return self.register(JD_BUTTON_REG_ANALOG).bool_value()

Просмотреть файл

@ -6,7 +6,7 @@ from typing import Optional
class CharacterScreenClient(Client):
"""
A screen that displays characters.
A screen that displays characters, typically a LCD/OLED character screen.
Implements a client for the `Character Screen <https://microsoft.github.io/jacdac-docs/services/characterscreen>`_ service.
"""
@ -73,15 +73,3 @@ class CharacterScreenClient(Client):
return self.register(JD_CHARACTER_SCREEN_REG_COLUMNS).value()
def set_line(self, index: int, message: str) -> None:
"""
Overrides the content of a single line at a 0-based index.
"""
self.send_cmd_packed(JD_CHARACTER_SCREEN_CMD_SET_LINE, index, message)
def clear(self, ) -> None:
"""
Clears all text from the display.
"""
self.send_cmd_packed(JD_CHARACTER_SCREEN_CMD_CLEAR, )

Просмотреть файл

@ -22,14 +22,11 @@ JD_CHARACTER_SCREEN_REG_VARIANT = const(JD_REG_VARIANT)
JD_CHARACTER_SCREEN_REG_TEXT_DIRECTION = const(0x82)
JD_CHARACTER_SCREEN_REG_ROWS = const(0x180)
JD_CHARACTER_SCREEN_REG_COLUMNS = const(0x181)
JD_CHARACTER_SCREEN_CMD_SET_LINE = const(0x80)
JD_CHARACTER_SCREEN_CMD_CLEAR = const(0x81)
JD_CHARACTER_SCREEN_PACK_FORMATS = {
JD_CHARACTER_SCREEN_REG_MESSAGE: "s",
JD_CHARACTER_SCREEN_REG_BRIGHTNESS: "u0.8",
JD_CHARACTER_SCREEN_REG_BRIGHTNESS: "u0.16",
JD_CHARACTER_SCREEN_REG_VARIANT: "u8",
JD_CHARACTER_SCREEN_REG_TEXT_DIRECTION: "u8",
JD_CHARACTER_SCREEN_REG_ROWS: "u8",
JD_CHARACTER_SCREEN_REG_COLUMNS: "u8",
JD_CHARACTER_SCREEN_CMD_SET_LINE: "u16 s"
JD_CHARACTER_SCREEN_REG_COLUMNS: "u8"
}

Просмотреть файл

@ -23,6 +23,13 @@ class DistanceClient(SensorClient):
self.refresh_reading()
return self.register(JD_DISTANCE_REG_DISTANCE).value(self.missing_distance_value)
@property
def distance_error(self) -> Optional[float]:
"""
(Optional) Absolute error on the reading value., _: m
"""
return self.register(JD_DISTANCE_REG_DISTANCE_ERROR).value()
@property
def min_range(self) -> Optional[float]:
"""

Просмотреть файл

@ -13,11 +13,13 @@ class DistanceVariant(IntEnum):
JD_DISTANCE_REG_DISTANCE = const(JD_REG_READING)
JD_DISTANCE_REG_DISTANCE_ERROR = const(JD_REG_READING_ERROR)
JD_DISTANCE_REG_MIN_RANGE = const(JD_REG_MIN_READING)
JD_DISTANCE_REG_MAX_RANGE = const(JD_REG_MAX_READING)
JD_DISTANCE_REG_VARIANT = const(JD_REG_VARIANT)
JD_DISTANCE_PACK_FORMATS = {
JD_DISTANCE_REG_DISTANCE: "u16.16",
JD_DISTANCE_REG_DISTANCE_ERROR: "u16.16",
JD_DISTANCE_REG_MIN_RANGE: "u16.16",
JD_DISTANCE_REG_MAX_RANGE: "u16.16",
JD_DISTANCE_REG_VARIANT: "u8"

Просмотреть файл

@ -18,7 +18,7 @@ class DmxClient(Client):
@property
def enabled(self) -> Optional[bool]:
"""
Determines if the DMX bridge is active,
Determines if the DMX bridge is active.,
"""
return self.register(JD_DMX_REG_ENABLED).bool_value()

Просмотреть файл

@ -26,7 +26,7 @@ class ECO2Client(SensorClient):
@property
def e_CO2_error(self) -> Optional[float]:
"""
Error on the reading value., _: ppm
(Optional) Error on the reading value., _: ppm
"""
return self.register(JD_E_CO2_REG_E_CO2_ERROR).value()

Просмотреть файл

@ -24,10 +24,17 @@ class FlexClient(SensorClient):
return self.register(JD_FLEX_REG_BENDING).float_value(self.missing_bending_value, 100)
@property
def variant(self) -> Optional[FlexVariant]:
def bending_error(self) -> Optional[float]:
"""
(Optional) Specifies the physical layout of the flex sensor.,
(Optional) Absolute error on the reading value., _: /
"""
return self.register(JD_FLEX_REG_VARIANT).value()
return self.register(JD_FLEX_REG_BENDING_ERROR).float_value(100)
@property
def length(self) -> Optional[int]:
"""
(Optional) Length of the flex sensor, _: mm
"""
return self.register(JD_FLEX_REG_LENGTH).value()

Просмотреть файл

@ -1,18 +1,12 @@
# Autogenerated constants for Flex service
from enum import IntEnum
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_FLEX = const(0x1f47c6c6)
class FlexVariant(IntEnum):
LINEAR22INCH = const(0x1)
LINEAR45INCH = const(0x2)
JD_FLEX_REG_BENDING = const(JD_REG_READING)
JD_FLEX_REG_VARIANT = const(JD_REG_VARIANT)
JD_FLEX_REG_BENDING_ERROR = const(JD_REG_READING_ERROR)
JD_FLEX_REG_LENGTH = const(0x180)
JD_FLEX_PACK_FORMATS = {
JD_FLEX_REG_BENDING: "u0.16",
JD_FLEX_REG_VARIANT: "u8"
JD_FLEX_REG_BENDING_ERROR: "u0.16",
JD_FLEX_REG_LENGTH: "u16"
}

Просмотреть файл

@ -19,8 +19,8 @@ class HidMouseClient(Client):
def set_button(self, buttons: HidMouseButton, event: HidMouseButtonEvent) -> None:
"""
Sets the up/down state of one or more buttons.
A ``Click`` is the same as ``Down`` followed by ``Up`` after 100ms.
A ``DoubleClick`` is two clicks with ``150ms`` gap between them (that is, ``100ms`` first click, ``150ms`` gap, ``100ms`` second click).
A `Click` is the same as `Down` followed by `Up` after 100ms.
A `DoubleClick` is two clicks with `150ms` gap between them (that is, `100ms` first click, `150ms` gap, `100ms` second click).
"""
self.send_cmd_packed(JD_HID_MOUSE_CMD_SET_BUTTON, buttons, event)

Просмотреть файл

@ -26,7 +26,7 @@ class HumidityClient(SensorClient):
@property
def humidity_error(self) -> Optional[float]:
"""
The real humidity is between `humidity - humidity_error` and `humidity + humidity_error`., _: %RH
(Optional) The real humidity is between `humidity - humidity_error` and `humidity + humidity_error`., _: %RH
"""
return self.register(JD_HUMIDITY_REG_HUMIDITY_ERROR).value()

Просмотреть файл

@ -8,28 +8,28 @@ class IlluminanceClient(SensorClient):
"""
Detects the amount of light falling onto a given surface area.
*
* Note that this is different from *luminance*, the amount of light that passes through, emits from, or reflects off an object.
* Note that this is different from _luminance_, the amount of light that passes through, emits from, or reflects off an object.
Implements a client for the `Illuminance <https://microsoft.github.io/jacdac-docs/services/illuminance>`_ service.
"""
def __init__(self, bus: Bus, role: str, *, missing_light_value: float = None) -> None:
def __init__(self, bus: Bus, role: str, *, missing_illuminance_value: float = None) -> None:
super().__init__(bus, JD_SERVICE_CLASS_ILLUMINANCE, JD_ILLUMINANCE_PACK_FORMATS, role)
self.missing_light_value = missing_light_value
self.missing_illuminance_value = missing_illuminance_value
@property
def light(self) -> Optional[float]:
def illuminance(self) -> Optional[float]:
"""
The amount of illuminance, as lumens per square metre., _: lux
"""
self.refresh_reading()
return self.register(JD_ILLUMINANCE_REG_LIGHT).value(self.missing_light_value)
return self.register(JD_ILLUMINANCE_REG_ILLUMINANCE).value(self.missing_illuminance_value)
@property
def light_error(self) -> Optional[float]:
def illuminance_error(self) -> Optional[float]:
"""
(Optional) Error on the reported sensor value., _: lux
"""
return self.register(JD_ILLUMINANCE_REG_LIGHT_ERROR).value()
return self.register(JD_ILLUMINANCE_REG_ILLUMINANCE_ERROR).value()

Просмотреть файл

@ -2,9 +2,9 @@
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_ILLUMINANCE = const(0x1e6ecaf2)
JD_ILLUMINANCE_REG_LIGHT = const(JD_REG_READING)
JD_ILLUMINANCE_REG_LIGHT_ERROR = const(JD_REG_READING_ERROR)
JD_ILLUMINANCE_REG_ILLUMINANCE = const(JD_REG_READING)
JD_ILLUMINANCE_REG_ILLUMINANCE_ERROR = const(JD_REG_READING_ERROR)
JD_ILLUMINANCE_PACK_FORMATS = {
JD_ILLUMINANCE_REG_LIGHT: "u22.10",
JD_ILLUMINANCE_REG_LIGHT_ERROR: "u22.10"
JD_ILLUMINANCE_REG_ILLUMINANCE: "u22.10",
JD_ILLUMINANCE_REG_ILLUMINANCE_ERROR: "u22.10"
}

Просмотреть файл

@ -1,5 +1,5 @@
# Autogenerated file. Do not edit.
from jacdac.bus import Bus, Client, EventHandlerFn, UnsubscribeFn
from jacdac.bus import Bus, Client
from .constants import *
from typing import Optional
@ -19,7 +19,7 @@ class LightBulbClient(Client):
def brightness(self) -> Optional[float]:
"""
Indicates the brightness of the light bulb. Zero means completely off and 0xffff means completely on.
For non-dimmeable lights, the value should be clamp to 0xffff for any non-zero value., _: /
For non-dimmable lights, the value should be clamp to 0xffff for any non-zero value., _: /
"""
return self.register(JD_LIGHT_BULB_REG_BRIGHTNESS).float_value(100)
@ -29,22 +29,10 @@ class LightBulbClient(Client):
@property
def dimmeable(self) -> Optional[bool]:
def dimmable(self) -> Optional[bool]:
"""
(Optional) Indicates if the light supports dimming.,
"""
return self.register(JD_LIGHT_BULB_REG_DIMMEABLE).bool_value()
def on_on(self, handler: EventHandlerFn) -> UnsubscribeFn:
"""
Emitted when the light brightness is greater than 0.
"""
return self.on_event(JD_LIGHT_BULB_EV_ON, handler)
def on_off(self, handler: EventHandlerFn) -> UnsubscribeFn:
"""
Emitted when the light is completely off with brightness to 0.
"""
return self.on_event(JD_LIGHT_BULB_EV_OFF, handler)
return self.register(JD_LIGHT_BULB_REG_DIMMABLE).bool_value()

Просмотреть файл

@ -3,10 +3,8 @@ from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_LIGHT_BULB = const(0x1cab054c)
JD_LIGHT_BULB_REG_BRIGHTNESS = const(JD_REG_INTENSITY)
JD_LIGHT_BULB_REG_DIMMEABLE = const(0x180)
JD_LIGHT_BULB_EV_ON = const(JD_EV_ACTIVE)
JD_LIGHT_BULB_EV_OFF = const(JD_EV_INACTIVE)
JD_LIGHT_BULB_REG_DIMMABLE = const(0x180)
JD_LIGHT_BULB_PACK_FORMATS = {
JD_LIGHT_BULB_REG_BRIGHTNESS: "u0.16",
JD_LIGHT_BULB_REG_DIMMEABLE: "u8"
JD_LIGHT_BULB_REG_DIMMABLE: "u8"
}

Просмотреть файл

@ -23,6 +23,13 @@ class LightLevelClient(SensorClient):
self.refresh_reading()
return self.register(JD_LIGHT_LEVEL_REG_LIGHT_LEVEL).float_value(self.missing_light_level_value, 100)
@property
def light_level_error(self) -> Optional[float]:
"""
(Optional) Absolute estimated error of the reading value, _: /
"""
return self.register(JD_LIGHT_LEVEL_REG_LIGHT_LEVEL_ERROR).float_value(100)
@property
def variant(self) -> Optional[LightLevelVariant]:
"""

Просмотреть файл

@ -12,8 +12,10 @@ class LightLevelVariant(IntEnum):
JD_LIGHT_LEVEL_REG_LIGHT_LEVEL = const(JD_REG_READING)
JD_LIGHT_LEVEL_REG_LIGHT_LEVEL_ERROR = const(JD_REG_READING_ERROR)
JD_LIGHT_LEVEL_REG_VARIANT = const(JD_REG_VARIANT)
JD_LIGHT_LEVEL_PACK_FORMATS = {
JD_LIGHT_LEVEL_REG_LIGHT_LEVEL: "u0.16",
JD_LIGHT_LEVEL_REG_LIGHT_LEVEL_ERROR: "u0.16",
JD_LIGHT_LEVEL_REG_VARIANT: "u8"
}

Просмотреть файл

@ -27,7 +27,7 @@ class MagnetometerClient(SensorClient):
@property
def forces_error(self) -> Optional[int]:
"""
(Optional) Error on the readings., _: nT
(Optional) Absolute estimated error on the readings., _: nT
"""
return self.register(JD_MAGNETOMETER_REG_FORCES_ERROR).value()

Просмотреть файл

@ -6,7 +6,7 @@ from typing import Optional
class MotorClient(Client):
"""
A bi-directional DC motor.
A DC motor.
Implements a client for the `Motor <https://microsoft.github.io/jacdac-docs/services/motor>`_ service.
"""
@ -56,4 +56,11 @@ class MotorClient(Client):
"""
return self.register(JD_MOTOR_REG_LOAD_SPEED).value()
@property
def reversible(self) -> Optional[bool]:
"""
(Optional) Indicates if the motor can run backwards.,
"""
return self.register(JD_MOTOR_REG_REVERSIBLE).bool_value()

Просмотреть файл

@ -6,9 +6,11 @@ JD_MOTOR_REG_DUTY = const(JD_REG_VALUE)
JD_MOTOR_REG_ENABLED = const(JD_REG_INTENSITY)
JD_MOTOR_REG_LOAD_TORQUE = const(0x180)
JD_MOTOR_REG_LOAD_SPEED = const(0x181)
JD_MOTOR_REG_REVERSIBLE = const(0x182)
JD_MOTOR_PACK_FORMATS = {
JD_MOTOR_REG_DUTY: "i1.15",
JD_MOTOR_REG_ENABLED: "u8",
JD_MOTOR_REG_LOAD_TORQUE: "u16.16",
JD_MOTOR_REG_LOAD_SPEED: "u16.16"
JD_MOTOR_REG_LOAD_SPEED: "u16.16",
JD_MOTOR_REG_REVERSIBLE: "u8"
}

Просмотреть файл

@ -19,9 +19,9 @@ class RealTimeClockClient(SensorClient):
def local_time(self) -> Optional[Tuple[int, int, int, int, int, int, int]]:
"""
Current time in 24h representation.
* ``day_of_month`` is day of the month, starting at ``1``
* ``day_of_week`` is day of the week, starting at ``1`` as monday
Default streaming period is 1 second.,
- `day_of_month` is day of the month, starting at `1`
- `day_of_week` is day of the week, starting at `1` as monday. Default streaming period is 1 second.,
"""
self.refresh_reading()
return self.register(JD_REAL_TIME_CLOCK_REG_LOCAL_TIME).value(self.missing_local_time_value)
@ -29,7 +29,7 @@ class RealTimeClockClient(SensorClient):
@property
def drift(self) -> Optional[float]:
"""
(Optional) Time drift since the last call to the ``set_time`` command., _: s
(Optional) Time drift since the last call to the `set_time` command., _: s
"""
return self.register(JD_REAL_TIME_CLOCK_REG_DRIFT).value()

Просмотреть файл

@ -1,5 +1,5 @@
# Autogenerated file. Do not edit.
from jacdac.bus import Bus, SensorClient, EventHandlerFn, UnsubscribeFn
from jacdac.bus import Bus, SensorClient
from .constants import *
from typing import Optional
@ -30,16 +30,4 @@ class ReflectedLightClient(SensorClient):
"""
return self.register(JD_REFLECTED_LIGHT_REG_VARIANT).value()
def on_dark(self, handler: EventHandlerFn) -> UnsubscribeFn:
"""
The sensor detected a transition from light to dark
"""
return self.on_event(JD_REFLECTED_LIGHT_EV_DARK, handler)
def on_light(self, handler: EventHandlerFn) -> UnsubscribeFn:
"""
The sensor detected a transition from dark to light
"""
return self.on_event(JD_REFLECTED_LIGHT_EV_LIGHT, handler)

Просмотреть файл

@ -12,8 +12,6 @@ class ReflectedLightVariant(IntEnum):
JD_REFLECTED_LIGHT_REG_BRIGHTNESS = const(JD_REG_READING)
JD_REFLECTED_LIGHT_REG_VARIANT = const(JD_REG_VARIANT)
JD_REFLECTED_LIGHT_EV_DARK = const(JD_EV_INACTIVE)
JD_REFLECTED_LIGHT_EV_LIGHT = const(JD_EV_ACTIVE)
JD_REFLECTED_LIGHT_PACK_FORMATS = {
JD_REFLECTED_LIGHT_REG_BRIGHTNESS: "u0.16",
JD_REFLECTED_LIGHT_REG_VARIANT: "u8"

Просмотреть файл

@ -1,5 +1,5 @@
# Autogenerated file. Do not edit.
from jacdac.bus import Bus, Client, EventHandlerFn, UnsubscribeFn
from jacdac.bus import Bus, Client
from .constants import *
from typing import Optional
@ -41,18 +41,4 @@ class RelayClient(Client):
"""
return self.register(JD_RELAY_REG_MAX_SWITCHING_CURRENT).value()
def on_active(self, handler: EventHandlerFn) -> UnsubscribeFn:
"""
Emitted when relay goes from `inactive` to `active` state.
Normally open (NO) relays close the circuit when activated.
"""
return self.on_event(JD_RELAY_EV_ACTIVE, handler)
def on_inactive(self, handler: EventHandlerFn) -> UnsubscribeFn:
"""
Emitted when relay goes from `active` to `inactive` state.
Normally closed (NC) relays open the circuit when activated.
"""
return self.on_event(JD_RELAY_EV_INACTIVE, handler)

Просмотреть файл

@ -14,8 +14,6 @@ class RelayVariant(IntEnum):
JD_RELAY_REG_CLOSED = const(JD_REG_INTENSITY)
JD_RELAY_REG_VARIANT = const(JD_REG_VARIANT)
JD_RELAY_REG_MAX_SWITCHING_CURRENT = const(0x180)
JD_RELAY_EV_ACTIVE = const(JD_EV_ACTIVE)
JD_RELAY_EV_INACTIVE = const(JD_EV_INACTIVE)
JD_RELAY_PACK_FORMATS = {
JD_RELAY_REG_CLOSED: "u8",
JD_RELAY_REG_VARIANT: "u8",

Просмотреть файл

@ -8,7 +8,7 @@ class RngClient(Client):
"""
Generates random numbers using entropy sourced from physical processes.
*
* This typically uses a cryptographical pseudo-random number generator (for example [Fortuna](https://en.wikipedia.org/wiki/Fortuna_(PRNG))),
* This typically uses a cryptographical pseudo-random number generator (for example [Fortuna](<https://en.wikipedia.org/wiki/Fortuna_(PRNG)>)),
* which is periodically re-seeded with entropy coming from some hardware source.
Implements a client for the `Random Number Generator <https://microsoft.github.io/jacdac-docs/services/rng>`_ service.

Просмотреть файл

@ -20,8 +20,8 @@ class SevenSegmentDisplayClient(Client):
"""
Each byte encodes the display status of a digit using,
where bit 0 encodes segment `A`, bit 1 encodes segments `B`, ..., bit 6 encodes segments `G`, and bit 7 encodes the decimal point (if present).
If incoming ``digits`` data is smaller than `digit_count`, the remaining digits will be cleared.
Thus, sending an empty ``digits`` payload clears the screen.
If incoming `digits` data is smaller than `digit_count`, the remaining digits will be cleared.
Thus, sending an empty `digits` payload clears the screen.
```text
- A -
@ -43,7 +43,7 @@ class SevenSegmentDisplayClient(Client):
@property
def brightness(self) -> Optional[float]:
"""
Controls the brightness of the LEDs. ``0`` means off., _: /
Controls the brightness of the LEDs. `0` means off., _: /
"""
return self.register(JD_SEVEN_SEGMENT_DISPLAY_REG_BRIGHTNESS).float_value(100)

Просмотреть файл

@ -18,7 +18,7 @@ class SoilMoistureClient(SensorClient):
@property
def moisture(self) -> Optional[float]:
"""
Indicates the wetness of the soil, from ``dry`` to ``wet``., _: /
Indicates the wetness of the soil, from `dry` to `wet`., _: /
"""
self.refresh_reading()
return self.register(JD_SOIL_MOISTURE_REG_MOISTURE).float_value(self.missing_moisture_value, 100)

Просмотреть файл

@ -35,36 +35,6 @@ class SoundLevelClient(SensorClient):
self.register(JD_SOUND_LEVEL_REG_ENABLED).set_values(value)
@property
def min_decibels(self) -> Optional[int]:
"""
(Optional) The minimum power value considered by the sensor.
If both ``min_decibels`` and ``max_decibels`` are supported,
the volume in deciment can be linearly interpolated between
``[min_decibels, max_decibels]``., _: dB
"""
return self.register(JD_SOUND_LEVEL_REG_MIN_DECIBELS).value()
@min_decibels.setter
def min_decibels(self, value: int) -> None:
self.register(JD_SOUND_LEVEL_REG_MIN_DECIBELS).set_values(value)
@property
def max_decibels(self) -> Optional[int]:
"""
(Optional) The maximum power value considered by the sensor.
If both ``min_decibels`` and ``max_decibels`` are supported,
the volume in deciment can be linearly interpolated between
``[min_decibels, max_decibels]``., _: dB
"""
return self.register(JD_SOUND_LEVEL_REG_MAX_DECIBELS).value()
@max_decibels.setter
def max_decibels(self, value: int) -> None:
self.register(JD_SOUND_LEVEL_REG_MAX_DECIBELS).set_values(value)
@property
def loud_threshold(self) -> Optional[float]:
"""

Просмотреть файл

@ -4,8 +4,6 @@ from jacdac.system.constants import *
JD_SERVICE_CLASS_SOUND_LEVEL = const(0x14ad1a5d)
JD_SOUND_LEVEL_REG_SOUND_LEVEL = const(JD_REG_READING)
JD_SOUND_LEVEL_REG_ENABLED = const(JD_REG_INTENSITY)
JD_SOUND_LEVEL_REG_MIN_DECIBELS = const(0x81)
JD_SOUND_LEVEL_REG_MAX_DECIBELS = const(0x82)
JD_SOUND_LEVEL_REG_LOUD_THRESHOLD = const(JD_REG_ACTIVE_THRESHOLD)
JD_SOUND_LEVEL_REG_QUIET_THRESHOLD = const(JD_REG_INACTIVE_THRESHOLD)
JD_SOUND_LEVEL_EV_LOUD = const(JD_EV_ACTIVE)
@ -13,8 +11,6 @@ JD_SOUND_LEVEL_EV_QUIET = const(JD_EV_INACTIVE)
JD_SOUND_LEVEL_PACK_FORMATS = {
JD_SOUND_LEVEL_REG_SOUND_LEVEL: "u0.16",
JD_SOUND_LEVEL_REG_ENABLED: "u8",
JD_SOUND_LEVEL_REG_MIN_DECIBELS: "i16",
JD_SOUND_LEVEL_REG_MAX_DECIBELS: "i16",
JD_SOUND_LEVEL_REG_LOUD_THRESHOLD: "u0.16",
JD_SOUND_LEVEL_REG_QUIET_THRESHOLD: "u0.16"
}

Просмотреть файл

@ -34,3 +34,9 @@ class SoundPlayerClient(Client):
"""
self.send_cmd_packed(JD_SOUND_PLAYER_CMD_PLAY, name)
def cancel(self, ) -> None:
"""
Cancel any sound playing.
"""
self.send_cmd_packed(JD_SOUND_PLAYER_CMD_CANCEL, )

Просмотреть файл

@ -4,7 +4,8 @@ from jacdac.system.constants import *
JD_SERVICE_CLASS_SOUND_PLAYER = const(0x1403d338)
JD_SOUND_PLAYER_REG_VOLUME = const(JD_REG_INTENSITY)
JD_SOUND_PLAYER_CMD_PLAY = const(0x80)
JD_SOUND_PLAYER_CMD_LIST_SOUNDS = const(0x81)
JD_SOUND_PLAYER_CMD_CANCEL = const(0x81)
JD_SOUND_PLAYER_CMD_LIST_SOUNDS = const(0x82)
JD_SOUND_PLAYER_PACK_FORMATS = {
JD_SOUND_PLAYER_REG_VOLUME: "u0.16",
JD_SOUND_PLAYER_CMD_PLAY: "s",

Просмотреть файл

@ -75,7 +75,7 @@ class SoundSpectrumClient(SensorClient):
def smoothing_time_constant(self) -> Optional[float]:
"""
The averaging constant with the last analysis frame.
If ``0`` is set, there is no averaging done, whereas a value of ``1`` means "overlap the previous and current buffer quite a lot while computing the value"., _: /
If `0` is set, there is no averaging done, whereas a value of `1` means "overlap the previous and current buffer quite a lot while computing the value"., _: /
"""
return self.register(JD_SOUND_SPECTRUM_REG_SMOOTHING_TIME_CONSTANT).float_value(100)

Просмотреть файл

@ -40,13 +40,13 @@ class SwitchClient(SensorClient):
def on_on(self, handler: EventHandlerFn) -> UnsubscribeFn:
"""
Emitted when switch goes from ``off`` to ``on``.
Emitted when switch goes from `off` to `on`.
"""
return self.on_event(JD_SWITCH_EV_ON, handler)
def on_off(self, handler: EventHandlerFn) -> UnsubscribeFn:
"""
Emitted when switch goes from ``on`` to ``off``.
Emitted when switch goes from `on` to `off`.
"""
return self.on_event(JD_SWITCH_EV_OFF, handler)

Просмотреть файл

@ -40,7 +40,7 @@ class ThermocoupleClient(SensorClient):
@property
def temperature_error(self) -> Optional[float]:
"""
The real temperature is between `temperature - temperature_error` and `temperature + temperature_error`., _: °C
(Optional) The real temperature is between `temperature - temperature_error` and `temperature + temperature_error`., _: °C
"""
return self.register(JD_THERMOCOUPLE_REG_TEMPERATURE_ERROR).value()

Просмотреть файл

@ -40,7 +40,7 @@ class ThermometerClient(SensorClient):
@property
def temperature_error(self) -> Optional[float]:
"""
The real temperature is between `temperature - temperature_error` and `temperature + temperature_error`., _: °C
(Optional) The real temperature is between `temperature - temperature_error` and `temperature + temperature_error`., _: °C
"""
return self.register(JD_THERMOMETER_REG_TEMPERATURE_ERROR).value()

Просмотреть файл

@ -1,13 +1,13 @@
# Autogenerated file. Do not edit.
from jacdac.bus import Bus, Client
from .constants import *
from typing import Optional
class VibrationMotorClient(Client):
"""
A vibration motor.
Implements a client for the `Vibration motor <https://microsoft.github.io/jacdac-docs/services/vibration>`_ service.
Implements a client for the `Vibration motor <https://microsoft.github.io/jacdac-docs/services/vibrationmotor>`_ service.
"""
@ -15,16 +15,4 @@ class VibrationMotorClient(Client):
super().__init__(bus, JD_SERVICE_CLASS_VIBRATION_MOTOR, JD_VIBRATION_MOTOR_PACK_FORMATS, role)
@property
def enabled(self) -> Optional[bool]:
"""
Determines if the vibration motor responds to vibrate commands.,
"""
return self.register(JD_VIBRATION_MOTOR_REG_ENABLED).bool_value()
@enabled.setter
def enabled(self, value: bool) -> None:
self.register(JD_VIBRATION_MOTOR_REG_ENABLED).set_values(value)

Просмотреть файл

@ -1,10 +1,7 @@
# Autogenerated constants for Vibration motor service
from jacdac.constants import *
from jacdac.system.constants import *
JD_SERVICE_CLASS_VIBRATION_MOTOR = const(0x183fc4a2)
JD_VIBRATION_MOTOR_REG_ENABLED = const(JD_REG_INTENSITY)
JD_VIBRATION_MOTOR_CMD_VIBRATE = const(0x80)
JD_VIBRATION_MOTOR_PACK_FORMATS = {
JD_VIBRATION_MOTOR_REG_ENABLED: "u8",
JD_VIBRATION_MOTOR_CMD_VIBRATE: "r: u8 u0.8"
}

Просмотреть файл

@ -23,6 +23,13 @@ class WaterLevelClient(SensorClient):
self.refresh_reading()
return self.register(JD_WATER_LEVEL_REG_LEVEL).float_value(self.missing_level_value, 100)
@property
def level_error(self) -> Optional[float]:
"""
(Optional) The error rage on the current reading, _: /
"""
return self.register(JD_WATER_LEVEL_REG_LEVEL_ERROR).float_value(100)
@property
def variant(self) -> Optional[WaterLevelVariant]:
"""

Просмотреть файл

@ -12,8 +12,10 @@ class WaterLevelVariant(IntEnum):
JD_WATER_LEVEL_REG_LEVEL = const(JD_REG_READING)
JD_WATER_LEVEL_REG_LEVEL_ERROR = const(JD_REG_READING_ERROR)
JD_WATER_LEVEL_REG_VARIANT = const(JD_REG_VARIANT)
JD_WATER_LEVEL_PACK_FORMATS = {
JD_WATER_LEVEL_REG_LEVEL: "u0.16",
JD_WATER_LEVEL_REG_LEVEL_ERROR: "u0.16",
JD_WATER_LEVEL_REG_VARIANT: "u8"
}

Просмотреть файл

@ -26,7 +26,7 @@ class WindSpeedClient(SensorClient):
@property
def wind_speed_error(self) -> Optional[float]:
"""
Error on the reading, _: m/s
(Optional) Error on the reading, _: m/s
"""
return self.register(JD_WIND_SPEED_REG_WIND_SPEED_ERROR).value()