toio.cube.api.sensor module¶
- class toio.cube.api.sensor.RequestMotionDetection[source]¶
Bases:
CubeCommand
Motion information request command
References
https://toio.github.io/toio-spec/en/docs/ble_sensor#requesting-motion-detection-information
- class toio.cube.api.sensor.PostureDataType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
- Euler = 1¶
- Quaternions = 2¶
- HighPrecisionEuler = 3¶
- class toio.cube.api.sensor.RequestPostureAngleDetection(data_type: PostureDataType)[source]¶
Bases:
CubeCommand
Posture angle information request command
References
- __init__(data_type: PostureDataType)[source]¶
- class toio.cube.api.sensor.RequestMagneticSensor[source]¶
Bases:
CubeCommand
Magnetic sensor information request command
References
- class toio.cube.api.sensor.Posture(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]¶
Bases:
IntEnum
Orientation of the cube.
- Unknown = 0¶
- Top = 1¶
- Bottom = 2¶
- Rear = 3¶
- Front = 4¶
- Right = 5¶
- Left = 6¶
- class toio.cube.api.sensor.MotionDetectionData(payload: bytearray)[source]¶
Bases:
CubeResponse
Information on the cube’s motion detection.
- horizontal¶
Horizontal detection
- Type:
bool
- collision¶
Collision detection
- Type:
bool
- double_tap¶
Double-tap detection
- Type:
bool
- shake¶
Shake detection (0:no shake, 1:Level1 - 10:Level10)
- Type:
int
- Reference:
https://toio.github.io/toio-spec/en/docs/ble_sensor/#obtaining-motion-detection-information
- class toio.cube.api.sensor.PostureAngleEulerData(payload: bytearray)[source]¶
Bases:
CubeResponse
Information of posture angle (Euler angle)
- roll¶
Roll (X axis)
- Type:
int
- pitch¶
Pitch (Y axis)
- Type:
int
- yaw¶
Yaw (Z axis)
- Type:
int
References
- class toio.cube.api.sensor.PostureAngleQuaternionsData(payload: bytearray)[source]¶
Bases:
CubeResponse
PostureAngleQuaternionData
Information of posture angle (Quaternion)
- w¶
- Type:
float
- x¶
- Type:
float
- y¶
- Type:
float
- z¶
- Type:
float
References
- class toio.cube.api.sensor.PostureAngleHighPrecisionEulerData(payload: bytearray)[source]¶
Bases:
CubeResponse
Information of high precision posture angle (Euler angle)
- roll¶
Roll (X axis)
- Type:
float
- pitch¶
Pitch (Y axis)
- Type:
float
- yaw¶
Yaw (Z axis)
- Type:
float
References
- class toio.cube.api.sensor.MagneticSensorData(payload: bytearray)[source]¶
Bases:
CubeResponse
Information of magnetic sensor
- state¶
Magnet state
- Type:
int
- strength¶
Magnetic force strength
- Type:
int
- x¶
Magnetic force direction (X axis)
- Type:
int
- y¶
Magnetic force direction (Y axis)
- Type:
int
- z¶
Magnetic force direction (Z axis)
- Type:
int
References
https://toio.github.io/toio-spec/en/docs/ble_magnetic_sensor/#obtaining-magnetic-sensor-information-
- toio.cube.api.sensor.SensorResponseType¶
Response types of Sensor characteristic
alias of
Union
[MotionDetectionData
,PostureAngleEulerData
,PostureAngleQuaternionsData
,PostureAngleHighPrecisionEulerData
,MagneticSensorData
]
- class toio.cube.api.sensor.Sensor(interface: CubeInterface, device: Any)[source]¶
Bases:
CubeCharacteristic
Sensor information characteristic
References
- static is_my_data(payload: bytearray) MotionDetectionData | PostureAngleEulerData | PostureAngleQuaternionsData | PostureAngleHighPrecisionEulerData | MagneticSensorData | None [source]¶
If payload is my characteristic response, this function returns CubeResponse object. Otherwise, it returns None.
- Parameters:
payload (GattReadData) – received data from the cube.
- __init__(interface: CubeInterface, device: Any)[source]¶
- async read() MotionDetectionData | PostureAngleEulerData | PostureAngleQuaternionsData | PostureAngleHighPrecisionEulerData | MagneticSensorData | None [source]¶
Read sensor information response
- Returns:
One of SensorInformationData or None (None returns when read fails)
- async request_posture_angle_information(data_type: PostureDataType) None [source]¶
Send posture angle information request command