toio package¶
- class toio.ToioRelativeCoordinateSystem(origin: Point = Point(x=0, y=0))[source]
Bases:
CoordinateSystemABC
- to_native_angle(angle: int | float) int | float [source]
- to_native_x(x: int | float) int | float [source]
- to_native_y(y: int | float) int | float [source]
- from_native_angle(angle: int | float) int | float [source]
- from_native_x(x: int | float) int | float [source]
- from_native_y(y: int | float) int | float [source]
- class toio.VisualProgrammingCoordinateSystem(origin: Point = Point(x=0, y=0))[source]
Bases:
CoordinateSystemABC
- to_native_angle(angle: int | float) int | float [source]
- to_native_x(x: int | float) int | float [source]
- to_native_y(y: int | float) int | float [source]
- from_native_angle(angle: int | float) int | float [source]
- from_native_x(x: int | float) int | float [source]
- from_native_y(y: int | float) int | float [source]
- class toio.ToioCoreCube(interface: CubeInterface, name: str | None = None)[source]
Bases:
CubeInterface
Access to toio Core Cube
- interface
control interface (e.g. BleCube)
- Type:
- name
cube name (optional)
- Type:
str
- api
API class
- Type:
ToioCoreCubeLowLevelAPI
- __init__(interface: CubeInterface, name: str | None = None)[source]
- async connect() bool [source]
- async disconnect() bool [source]
- async read(uuid: UUID) bytearray [source]
- async write(uuid: UUID, data: bytes | bytearray | memoryview, response: bool = False)[source]
- async register_notification_handler(uuid: UUID, handler: Callable[[BleakGATTCharacteristic, bytearray], None | Awaitable[None]]) bool [source]
- async unregister_notification_handler(uuid: UUID) bool [source]
- class toio.ToioCoreCubeLowLevelAPI(interface: CubeInterface)[source]
Bases:
object
Control APIs This class has control APIs for each characteristic.
- version
Version of supported API
- Type:
str
- battery
Interface to battery characteristic
- Type:
api.Battery
- button
Interface to button characteristic
- Type:
api.Button
- configuration
Interface to configuration characteristic
- Type:
api.Configuration
- id_information
Interface to id information characteristic
- Type:
api.IdInformation
- indicator
Interface to indicator characteristic
- Type:
api.IdInformation
- motor
Interface to motor characteristic
- Type:
api.Motor
- sound
Interface to sound characteristic
- Type:
api.Sound
- __init__(interface: CubeInterface)[source]
- toio.BatteryResponseType
alias of
BatteryInformation
- class toio.BatteryInformation(payload: bytearray)[source]
Bases:
CubeResponse
Cube remaining battery level response
- battery_level
Battery level ( 0 <= battery_level <= 100)
- Type:
int
References
https://toio.github.io/toio-spec/en/docs/ble_battery#read-operations
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.Battery(interface)[source]
Bases:
CubeCharacteristic
Battery characteristic
References
https://toio.github.io/toio-spec/en/docs/ble_battery
- static is_my_data(payload: bytearray) BatteryInformation | 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)[source]
- async read() BatteryInformation | None [source]
Read the battery level
- Returns:
BatteryInformation or None (None returns when read fails)
References
https://toio.github.io/toio-spec/en/docs/ble_battery#read-operations
- toio.ButtonResponseType
alias of
ButtonInformation
- class toio.ButtonState(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Value of the state of cube button
- RELEASED = 0
- PRESSED = 128
- class toio.ButtonInformation(payload: bytearray)[source]
Bases:
CubeResponse
Cube button state response
- state
State of the cube button
- Type:
References
https://toio.github.io/toio-spec/en/docs/ble_button#read-operations
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.Button(interface: CubeInterface)[source]
Bases:
CubeCharacteristic
Button characteristic
References
https://toio.github.io/toio-spec/en/docs/ble_button
- static is_my_data(payload: bytearray) ButtonInformation | 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)[source]
- async read() ButtonInformation | None [source]
Read the state of button
- Returns:
ButtonInformation or None (None returns when read fails)
References
https://toio.github.io/toio-spec/en/docs/ble_button#read-operations
- class toio.NotificationCondition(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Notification conditions of ID notification
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#notification-conditions
- Always = 0
- ChangeDetection = 1
- Periodic = 255
- class toio.MagneticSensorFunction(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
- Disable = 0
- MagnetState = 1
- MagneticForce = 2
- class toio.MagneticSensorCondition(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
- Always = 0
- ChangeDetection = 1
- class toio.MotorSpeedInformationAcquisitionState(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
- Disable = 0
- Enable = 1
- class toio.PostureAngleDetectionType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
- Euler = 1
- Quaternions = 2
- class toio.PostureAngleDetectionCondition(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Notification condition of posture angle detection
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#notification-conditions-1
- Always = 0
- ChangeDetection = 1
- class toio.ProtocolVersion(payload: bytearray)[source]
Bases:
CubeResponse
Protocol version response
- version
version (UTF-8)
- Type:
str
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#obtaining-the-ble-protocol-version
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.ResponseIdNotificationSettings(payload: bytearray)[source]
Bases:
CubeResponse
ID notification setting response
- result
Result of the command
- Type:
bool
References
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.ResponseIdMissedNotificationSettings(payload: bytearray)[source]
Bases:
CubeResponse
ID missed notification setting response
- result
Result of the command
- Type:
bool
References
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.ResponseMagneticSensorSettings(payload: bytearray)[source]
Bases:
CubeResponse
Magnetic sensor setting response
- result
Result of the command
- Type:
bool
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#responses-to-magnetic-sensor-settings
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.ResponseMotorSpeedInformationAcquisitionSettings(payload: bytearray)[source]
Bases:
CubeResponse
Motor speed information setting response
- result
Result of the command
- Type:
bool
References
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.ResponsePostureAngleDetectionSettings(payload: bytearray)[source]
Bases:
CubeResponse
Posture angle detection setting response
- result
Result of the command
- Type:
bool
References
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.Configuration(interface: CubeInterface)[source]
Bases:
CubeCharacteristic
Configuration characteristic
References
https://toio.github.io/toio-spec/en/docs/ble_configuration
- static is_my_data(payload: bytearray) ProtocolVersion | ResponseIdNotificationSettings | ResponseIdMissedNotificationSettings | ResponseMagneticSensorSettings | ResponseMotorSpeedInformationAcquisitionSettings | ResponsePostureAngleDetectionSettings | 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) None [source]
- async request_protocol_version() None [source]
Send protocol version request command
This function DO NOT return response payload. Receive the result by notification.
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#requesting-the-ble-protocol-version
- async set_horizontal_detection_threshold(threshold: int) None [source]
Send horizontal detection threshold setting command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
threshold (int) – Threshold
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#horizontal-detection-threshold-settings
- async set_collision_detection_threshold(threshold: int) None [source]
Send collision detection threshold setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
threshold (int) – Threshold
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#collision-detection-threshold-settings
- async set_double_tap_detection_threshold(threshold: int) None [source]
Send double-tap detection threshold setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
threshold (int) – Threshold
References
- async set_id_notification(interval_ms: int, condition: NotificationCondition) None [source]
Send id information notification setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
interval_ms (int) – Notification interval [ms]
condition (NotificationCondition) – Condition
References
- async set_id_missed_notification(sensitivity_ms: int) None [source]
Send ID missed notification setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
sensitivity_ms (int) – Sensitivity [ms]
References
- async set_magnetic_sensor(function_type: MagneticSensorFunction, interval_ms: int, condition: MagneticSensorCondition) None [source]
Send magnetic sensor setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
function_type (MagneticSensorFunction) – Function type
interval_ms (int) – Notification interval [ms]
condition (MagneticSensorCondition) – Condition
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#magnetic-sensor-settings-
- async set_motor_speed_information_acquisition(state: MotorSpeedInformationAcquisitionState) None [source]
Send motor speed information acquisition setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
state (MotorSpeedInformationAcquisitionState) – state
References
- async set_posture_angle_detection(detection_type: PostureAngleDetectionType, interval_ms: int, condition: PostureAngleDetectionCondition) None [source]
Send posture angle setting request command
This function DO NOT return response payload. Receive the result by notification.
- Parameters:
detection_type (PostureAngleDetectionType) – Detection type
interval_ms (int) – Notification interval [ms]
condition (PostureAngleDetectionCondition) – Condition
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#posture-angle-detection-settings-
- class toio.PositionId(payload: bytearray)[source]
Bases:
CubeResponse
Position id information response
References
https://toio.github.io/toio-spec/en/docs/ble_id#position-id
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.StandardId(payload: bytearray)[source]
Bases:
CubeResponse
Standard id information response
References
https://toio.github.io/toio-spec/en/docs/ble_id#standard-id
- static is_myself(data: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.PositionIdMissed(payload: bytearray)[source]
Bases:
CubeResponse
Position id missed response
References
https://toio.github.io/toio-spec/en/docs/ble_id#position-id-missed
- static is_myself(data: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.StandardIdMissed(payload: bytearray)[source]
Bases:
CubeResponse
Standard id information response
References
https://toio.github.io/toio-spec/en/docs/ble_id#standard-id-missed
- static is_myself(data: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.IdInformation(interface: CubeInterface)[source]
Bases:
CubeCharacteristic
ID sensor characteristic
References
https://toio.github.io/toio-spec/en/docs/ble_id
- static is_my_data(payload: bytearray) PositionId | StandardId | PositionIdMissed | StandardIdMissed | 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)[source]
- async read() PositionId | StandardId | PositionIdMissed | StandardIdMissed | None [source]
Read id information response
- Returns:
One of IdInformationData or None (None returns when read fails)
- class toio.Color(r: int, g: int, b: int)[source]
Bases:
object
Indicator color in RGB
- r: int
R value (0 - 255)
- g: int
G value (0 - 255)
- b: int
B value (0 - 255)
- flatten()[source]
Return the tuple representation of this dataclass
- __init__(r: int, g: int, b: int) None
- class toio.IndicatorParam(duration_ms: int, color: Color)[source]
Bases:
object
Indicator color and lighting period
- duration_ms: int
- Duration of lighting:Any fraction less than 10ms will be truncated.0 - 9: no time limit10 - 2550: duration [ms]
- color: Color
- RGB value
- flatten()[source]
- __init__(duration_ms: int, color: Color) None
- class toio.Indicator(interface: CubeInterface)[source]
Bases:
CubeCharacteristic
Indicator characteristic
References
https://toio.github.io/toio-spec/en/docs/ble_light
- static is_my_data(_payload: bytearray) 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)[source]
- async turn_on(param: IndicatorParam) None [source]
Send indicator turn on / off command
- Parameters:
param – Indicator parameter
References
https://toio.github.io/toio-spec/en/docs/ble_light#repeated-turning-on-and-off-of-indicator
- async repeated_turn_on(repeat: int, param_list: list[toio.cube.api.indicator.IndicatorParam] | tuple[toio.cube.api.indicator.IndicatorParam, ...]) None [source]
Send repeated indicator turning on / off command
- Parameters:
repeat (int) – Number of repetitions
param_list (Union[list[IndicatorParam], tuple[IndicatorParam]]) – List of indicator parameters
References
https://toio.github.io/toio-spec/en/docs/ble_light#repeated-turning-on-and-off-of-indicator
- async turn_off_all() None [source]
Send all off command
References
https://toio.github.io/toio-spec/en/docs/ble_light#turn-off-all-indicators
- async turn_off(indicator_id: int) None [source]
Send off command
- Parameters:
indicator_id (int) – Indicator ID
References
https://toio.github.io/toio-spec/en/docs/ble_light#turn-off-a-specific-indicator
- class toio.MovementType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Movement type
References
https://toio.github.io/toio-spec/en/docs/ble_motor#movement-type
- Curve = 0
- CurveWithoutReverse = 1
- Linear = 2
- class toio.RotationOption(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Rotation Option
Angle of the cube at the target point
References
https://toio.github.io/toio-spec/en/docs/ble_motor#%CE%B8-angle-of-the-cube-at-the-target-point
- AbsoluteOptimal = 0
- AbsolutePositive = 1
- AbsoluteNegative = 2
- RelativePositive = 3
- RelativeNegative = 4
- WithoutRotation = 5
- SameAsAtWriting = 6
- class toio.TargetPosition(cube_location: CubeLocation, rotation_option: RotationOption = RotationOption.AbsoluteOptimal)[source]
Bases:
object
Target position parameter
- cube_location: CubeLocation
Target position of the cube
- rotation_option: RotationOption = 0
Rotation option
- flatten()[source]
- __init__(cube_location: CubeLocation, rotation_option: RotationOption = RotationOption.AbsoluteOptimal) None
- class toio.SpeedChangeType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Speed change type
References
https://toio.github.io/toio-spec/en/docs/ble_motor#motor-speed-change-types
- Constant = 0
- Acceleration = 1
- Deceleration = 2
- AccelerationAndDeceleration = 3
- class toio.Speed(max: int = 0, speed_change_type: SpeedChangeType = SpeedChangeType.Constant)[source]
Bases:
object
Speed parameter
- max: int = 0
Max speed
- speed_change_type: SpeedChangeType = 0
Speed change type
- flatten()[source]
- __init__(max: int = 0, speed_change_type: SpeedChangeType = SpeedChangeType.Constant) None
- class toio.WriteMode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Write mode of MotorControlMultipleTargets()
References
https://toio.github.io/toio-spec/en/docs/ble_motor#additional-write-operation-settings
- Overwrite = 0
- Append = 1
- class toio.AccelerationRotation(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Rotational direction when the cube is changing orientation
References
- Positive = 0
- Negative = 1
- class toio.AccelerationDirection(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Direction of cube travel
References
https://toio.github.io/toio-spec/en/docs/ble_motor/#direction-of-cube-travel
- Forward = 0
- Backward = 1
- class toio.AccelerationPriority(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Priority to the translational speed or the rotational velocity
References
https://toio.github.io/toio-spec/en/docs/ble_motor/#priority-designation
- TranslationalVelocity = 0
- RotationalVelocity = 1
- class toio.MotorResponseCode(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Response code of motor control APIs
References
https://toio.github.io/toio-spec/en/docs/ble_motor#response-content
- SUCCESS = 0
- ERROR_TIMEOUT = 1
- ERROR_ID_MISSED = 2
- ERROR_INVALID_PARAMETER = 3
- ERROR_INVALID_CUBE_STATE = 4
- SUCCESS_WITH_OVERWRITE = 5
- ERROR_NOT_SUPPORTED = 6
- ERROR_FAILED_TO_APPEND = 7
- class toio.ResponseMotorControlTarget(payload: bytearray)[source]
Bases:
CubeResponse
Target specified motor control response
- response_code
Response code
- Type:
References
https://toio.github.io/toio-spec/en/docs/ble_motor#responses-to-motor-control-with-target-specified
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.ResponseMotorControlMultipleTargets(payload: bytearray)[source]
Bases:
CubeResponse
Multiple target specified motor control response
- response_code
Response code
- Type:
References
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.ResponseMotorSpeed(payload: bytearray)[source]
Bases:
CubeResponse
Motor speed response
- left
motor speed (left)
- Type:
int
- right
motor speed (right)
- Type:
int
References
https://toio.github.io/toio-spec/en/docs/ble_motor#obtaining-motor-speed-information
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.Motor(interface: CubeInterface)[source]
Bases:
CubeCharacteristic
Motor characteristic
References
https://toio.github.io/toio-spec/en/docs/ble_motor
- static is_my_data(payload: bytearray) ResponseMotorControlTarget | ResponseMotorControlMultipleTargets | ResponseMotorSpeed | 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)[source]
- async motor_control(left: int, right: int, duration_ms: int | None = None) None [source]
Send motor control command
- Parameters:
left (int) – Motor speed (left)
right (int) – Motor speed (right)
duration_ms (Optional[int], optional) – Motor driving period [ms]. Defaults to None.
References
https://toio.github.io/toio-spec/en/docs/ble_motor#motor-control
- async motor_control_target(timeout: int, movement_type: MovementType, speed: Speed, target: TargetPosition) None [source]
Send target specified motor control command
- Parameters:
timeout (int) – Timeout [s] (Note: not [ms])
movement_type (MovementType) – Movement type
speed (Speed) – Speed parameter
target (TargetPosition) – Target parameter
References
https://toio.github.io/toio-spec/en/docs/ble_motor#motor-control-with-target-specified
- async motor_control_multiple_targets(timeout: int, movement_type: MovementType, speed: Speed, mode: WriteMode, target_list: list[toio.cube.api.motor.TargetPosition]) None [source]
Send multiple target specified motor control command
- Parameters:
timeout (int) – Timeout [s] (Note: not [ms])
movement_type (MovementType) – Movement type
speed (Speed) – Speed parameter
mode (WriteMode) – Write mode
target_list (list[TargetPosition]) – Target parameter
References
https://toio.github.io/toio-spec/en/docs/ble_motor#motor-control-with-multiple-targets-specified
- async motor_control_acceleration(translation: int, acceleration: int, rotation_velocity: int, rotation_direction: AccelerationRotation, cube_direction: AccelerationDirection, priority: AccelerationPriority, duration_ms: int) None [source]
Send acceleration specified motor control command
- Parameters:
translation (int) – Speed at which the cube moves in relation to the direction of travel.
acceleration (int) – Specify the increment (or decrement) in speed every 100 milliseconds.
rotation_velocity (int) – Rotational velocity when the cube is changing orientation.
rotation_direction (AccelerationRotation) – Rotational direction when the cube is changing orientation.
cube_direction (AccelerationDirection) – Direction the cube travels.
priority (AccelerationPriority) – Priority to the translational speed or the rotational velocity.
duration_ms (int) – Motor driving period [ms].
References
https://toio.github.io/toio-spec/en/docs/ble_motor/#motor-control-with-acceleration-specified
- class toio.PostureDataType(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
- Euler = 1
- Quaternions = 2
- class toio.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.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
- posture
Posture detection
- Type:
- 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
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.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:
nt
References
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.PostureAngleQuaternionsData(payload: bytearray)[source]
Bases:
CubeResponse
PostureAngleQuaternionData
Information of posture angle (Quaternion)
- w
- Type:
int
- x
- Type:
int
- y
- Type:
int
- z
- Type:
int
References
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- __str__() str [source]
Return str(self).
- class toio.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-
- static is_myself(payload: bytearray) bool [source]
If argument data is a byte representation of this class, this function converts the byte representation to an object and returns it.
- Parameters:
data (GattReadData) – received data from the cube.
- __init__(payload: bytearray)[source]
- class toio.Sensor(interface: CubeInterface)[source]
Bases:
CubeCharacteristic
Sensor information characteristic
References
- static is_my_data(payload: bytearray) MotionDetectionData | PostureAngleEulerData | PostureAngleQuaternionsData | 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)[source]
- async read() MotionDetectionData | PostureAngleEulerData | PostureAngleQuaternionsData | MagneticSensorData | None [source]
Read sensor information response
- Returns:
One of SensorInformationData or None (None returns when read fails)
- async request_motion_information() None [source]
Send motion information request command
- async request_posture_angle_information(data_type: PostureDataType) None [source]
Send posture angle information request command
- async request_magnetic_sensor_information() None [source]
Send magnetic sensor information request
- class toio.SoundId(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Sound effect ID
References
https://toio.github.io/toio-spec/en/docs/ble_sound#sound-effect-id
- Enter = 0
- Selected = 1
- Cancel = 2
- Cursor = 3
- MatIn = 4
- MatOut = 5
- Get1 = 6
- Get2 = 7
- Get3 = 8
- Effect1 = 9
- Effect2 = 10
- class toio.Note(value, names=<not given>, *values, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
IntEnum
Midi notes
References
https://toio.github.io/toio-spec/en/docs/ble_sound#midi-note-number-and-note-name
- C0 = 0
- CS0 = 1
- D0 = 2
- DS0 = 3
- E0 = 4
- F0 = 5
- FS0 = 6
- G0 = 7
- GS0 = 8
- A0 = 9
- AS0 = 10
- B0 = 11
- C1 = 12
- CS1 = 13
- D1 = 14
- DS1 = 15
- E1 = 16
- F1 = 17
- FS1 = 18
- G1 = 19
- GS1 = 20
- A1 = 21
- AS1 = 22
- B1 = 23
- C2 = 24
- CS2 = 25
- D2 = 26
- DS2 = 27
- E2 = 28
- F2 = 29
- FS2 = 30
- G2 = 31
- GS2 = 32
- A2 = 33
- AS2 = 34
- B2 = 35
- C3 = 36
- CS3 = 37
- D3 = 38
- DS3 = 39
- E3 = 40
- F3 = 41
- FS3 = 42
- G3 = 43
- GS3 = 44
- A3 = 45
- AS3 = 46
- B3 = 47
- C4 = 48
- CS4 = 49
- D4 = 50
- DS4 = 51
- E4 = 52
- F4 = 53
- FS4 = 54
- G4 = 55
- GS4 = 56
- A4 = 57
- AS4 = 58
- B4 = 59
- C5 = 60
- CS5 = 61
- D5 = 62
- DS5 = 63
- E5 = 64
- F5 = 65
- FS5 = 66
- G5 = 67
- GS5 = 68
- A5 = 69
- AS5 = 70
- B5 = 71
- C6 = 72
- CS6 = 73
- D6 = 74
- DS6 = 75
- E6 = 76
- F6 = 77
- FS6 = 78
- G6 = 79
- GS6 = 80
- A6 = 81
- AS6 = 82
- B6 = 83
- C7 = 84
- CS7 = 85
- D7 = 86
- DS7 = 87
- E7 = 88
- F7 = 89
- FS7 = 90
- G7 = 91
- GS7 = 92
- A7 = 93
- AS7 = 94
- B7 = 95
- C8 = 96
- CS8 = 97
- D8 = 98
- DS8 = 99
- E8 = 100
- F8 = 101
- FS8 = 102
- G8 = 103
- GS8 = 104
- A8 = 105
- AS8 = 106
- B8 = 107
- C9 = 108
- CS9 = 109
- D9 = 110
- DS9 = 111
- E9 = 112
- F9 = 113
- FS9 = 114
- G9 = 115
- GS9 = 116
- A9 = 117
- AS9 = 118
- B9 = 119
- C10 = 120
- CS10 = 121
- D10 = 122
- DS10 = 123
- E10 = 124
- F10 = 125
- FS10 = 126
- G10 = 127
- NO_SOUND = 128
- class toio.MidiNote(duration_ms: int, note: Note, volume: int)[source]
Bases:
object
Midi note
- duration_ms: int
- Duration of sounding note:Any fraction less than 10ms will be truncated.0 - 9: zero10 - 2550: duration [ms]
- note: Note
Midi note
- volume: int
- Volume:0: off1 - 255: max volume
- flatten()[source]
- __init__(duration_ms: int, note: Note, volume: int) None
- class toio.Sound(interface: CubeInterface)[source]
Bases:
CubeCharacteristic
Sound characteristic
References
https://toio.github.io/toio-spec/en/docs/ble_sound
- static is_my_data(_payload: bytearray) 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)[source]
- async play_sound_effect(sound_id: SoundId, volume: int)[source]
Send play sound effect command
- Parameters:
sound_id (SoundId) – Sound ID
volume (int) – Volume
- async play_midi(repeat: int, midi_notes: list[toio.cube.api.sound.MidiNote] | tuple[toio.cube.api.sound.MidiNote, ...])[source]
Send play midi note command
- async stop()[source]
Send sound stop command
- class toio.Point(x: int = 0, y: int = 0)[source]
Bases:
object
A point on 2 dimensions
- x: int = 0
- y: int = 0
- flatten()[source]
- __init__(x: int = 0, y: int = 0) None
- class toio.CubeLocation(point: Point, angle: int = 0)[source]
Bases:
object
A Position and angle of a cube on 2 dimensions
- point: Point
Point of a cube
- angle: int = 0
Angle of a cube (degree)
- static new() CubeLocation [source]
- get_boundary_point(target: CubeLocation) CubeLocation [source]
Obtains the point where a line passing through two points intersects the coordinate axis in the first quadrant.
- flatten()[source]
- __init__(point: Point, angle: int = 0) None
- class toio.MatRect(top_left: Point, bottom_right: Point, name: str | None = None)[source]
Bases:
object
A toio mat
- top_left: Point
Top-left point of a mat
- bottom_right: Point
Bottom-right point of a mat
- name: str | None = None
Mat name
- __str__() str [source]
Return str(self).
- flatten()[source]
- class toio.CoordinateSystemABC(origin: Point = Point(x=0, y=0))[source]
Bases:
object
- abstract to_native_angle(angle: int | float) int | float [source]
- abstract to_native_x(x: int | float) int | float [source]
- abstract to_native_y(y: int | float) int | float [source]
- abstract from_native_angle(angle: int | float) int | float [source]
- abstract from_native_x(x: int | float) int | float [source]
- abstract from_native_y(y: int | float) int | float [source]
- to_native_location(location: CubeLocation) CubeLocation [source]
- from_native_location(location: CubeLocation) CubeLocation [source]
- class toio.DefaultCoordinateSystem(origin: Point)[source]
Bases:
CoordinateSystemABC
Default coordinate system
No coordinate transformation No angle transformation
- to_native_angle(angle: int | float) int | float [source]
- to_native_x(x: int | float) int | float [source]
- to_native_y(y: int | float) int | float [source]
- from_native_angle(angle: int | float) int | float [source]
- from_native_x(x: int | float) int | float [source]
- from_native_y(y: int | float) int | float [source]
- class toio.RelativeCubeLocation(relative_location: CubeLocation, coordinate_system: CoordinateSystemABC)[source]
Bases:
object
Location of the cube in the relative coordinate system
- relative_location: CubeLocation
Relative location of a cube
- coordinate_system: CoordinateSystemABC
Coordinate system
- static new() RelativeCubeLocation [source]
Create new RelativeCubeLocation
- Returns:
new relative cube location instance
- Return type:
- to_absolute_point() Point [source]
Get the point of the cube on the absolute coordinate system
- Returns:
Point of the absolute coordinate system
- Return type:
- to_absolute_location() CubeLocation [source]
Get the location of the cube on the absolute coordinate system
- Returns:
CubeLocation of the absolute coordinate system
- Return type:
- from_absolute_point(abs_point: Point) Point [source]
Set the relative point from the absolute point
- Parameters:
abs_point (CubePoint) – Point on the absolute coordinate system
- Returns:
Point on the relative coordinate system
- Return type:
- from_absolute_location(abs_location: CubeLocation) CubeLocation [source]
Set the relative location from the absolute location
- Parameters:
abs_location (CubeLocation) – Location on the absolute coordinate system
- Returns:
Location on the relative coordinate system
- Return type:
- change_coordinate_system(new_coordinate_system: CoordinateSystemABC) None [source]
Change the coordinate system The location is updated to the coordinates in the new coordinate system
- __init__(relative_location: CubeLocation, coordinate_system: CoordinateSystemABC) None
- class toio.ToioMat[source]
Bases:
object
Definitions of official toio mats
- ToioCollectionMatRing = MatRect(top_left=Point(x=45, y=45), bottom_right=Point(x=455, y=455), name='Toio Collection (ring)')
- ToioCollectionMatColoredTiles = MatRect(top_left=Point(x=545, y=45), bottom_right=Point(x=955, y=455), name='Toio Collection (colored tiles)')
- PicotonsPlayMatFront = MatRect(top_left=Point(x=59, y=2088), bottom_right=Point(x=437, y=2285), name='Picotons (front)')
- PicotonsPlayMatBack = MatRect(top_left=Point(x=59, y=2303), bottom_right=Point(x=437, y=2499), name='Picotons (back)')
- PicotonsControlMat = MatRect(top_left=Point(x=764, y=2093), bottom_right=Point(x=953, y=2290), name='Picotons (control)')
- PicotonsAutoplayMat = MatRect(top_left=Point(x=554, y=2093), bottom_right=Point(x=742, y=2290), name='Picotons (auto play)')
- SimpleMat = MatRect(top_left=Point(x=98, y=142), bottom_right=Point(x=402, y=358), name='Simple mat')
- GesundroidMat = MatRect(top_left=Point(x=1050, y=45), bottom_right=Point(x=1460, y=455), name='Gesundroid')
- mats = (MatRect(top_left=Point(x=45, y=45), bottom_right=Point(x=455, y=455), name='Toio Collection (ring)'), MatRect(top_left=Point(x=545, y=45), bottom_right=Point(x=955, y=455), name='Toio Collection (colored tiles)'), MatRect(top_left=Point(x=59, y=2088), bottom_right=Point(x=437, y=2285), name='Picotons (front)'), MatRect(top_left=Point(x=59, y=2303), bottom_right=Point(x=437, y=2499), name='Picotons (back)'), MatRect(top_left=Point(x=764, y=2093), bottom_right=Point(x=953, y=2290), name='Picotons (control)'), MatRect(top_left=Point(x=554, y=2093), bottom_right=Point(x=742, y=2290), name='Picotons (auto play)'), MatRect(top_left=Point(x=98, y=142), bottom_right=Point(x=402, y=358), name='Simple mat'), MatRect(top_left=Point(x=1050, y=45), bottom_right=Point(x=1460, y=455), name='Gesundroid'))
Subpackages¶
- toio.cube package
- Subpackages
- toio.cube.api package
- Submodules
- toio.cube.api.base_class module
- toio.cube.api.battery module
- toio.cube.api.button module
- toio.cube.api.configuration module
RequestProtocolVersion
SetHorizontalDetectionThreshold
SetCollisionDetectionThreshold
SetDoubleTapDetectionTimeInterval
NotificationCondition
SetIdNotification
SetIdMissedNotification
MagneticSensorFunction
MagneticSensorCondition
SetMagneticSensor
MotorSpeedInformationAcquisitionState
SetMotorSpeedInformationAcquisition
PostureAngleDetectionType
PostureAngleDetectionCondition
SetPostureAngleDetection
ProtocolVersion
ResponseIdNotificationSettings
ResponseIdMissedNotificationSettings
ResponseMagneticSensorSettings
ResponseMotorSpeedInformationAcquisitionSettings
ResponsePostureAngleDetectionSettings
ConfigurationResponseType
Configuration
- toio.cube.api.id_information module
- toio.cube.api.indicator module
- toio.cube.api.motor module
MotorControl
MovementType
RotationOption
TargetPosition
SpeedChangeType
Speed
MotorControlTarget
WriteMode
MotorControlMultipleTargets
AccelerationRotation
AccelerationDirection
AccelerationPriority
MotorControlAcceleration
MotorResponseCode
ResponseMotorControlTarget
ResponseMotorControlMultipleTargets
ResponseMotorSpeed
MotorResponseType
Motor
- toio.cube.api.sensor module
- toio.cube.api.sound module
- Submodules
- toio.cube.api package
- Subpackages
- toio.device_interface package
- toio.scanner package
- toio.simple package
Direction
SimpleCube
SimpleCube.DEFAULT_ROTATION_OPTION
SimpleCube.DEFAULT_MOVEMENT_TYPE
SimpleCube.DEFAULT_TIMEOUT
SimpleCube.DEFAULT_ONE_STEP
SimpleCube.CELL_SIZE
SimpleCube.MONITORING_CYCLE
SimpleCube.search()
SimpleCube.__init__()
SimpleCube.disconnect()
SimpleCube.sleep()
SimpleCube.move()
SimpleCube.spin()
SimpleCube.run_motor()
SimpleCube.stop_motor()
SimpleCube.move_steps()
SimpleCube.turn()
SimpleCube.move_to()
SimpleCube.set_orientation()
SimpleCube.move_to_the_grid_cell()
SimpleCube.get_current_position()
SimpleCube.get_x()
SimpleCube.get_y()
SimpleCube.get_orientation()
SimpleCube.get_grid()
SimpleCube.get_grid_x()
SimpleCube.get_grid_y()
SimpleCube.is_on_the_gird_cell()
SimpleCube.is_touched()
SimpleCube.get_touched_card()
SimpleCube.get_cube_name()
SimpleCube.get_battery_level()
SimpleCube.get_3d_angle()
SimpleCube.get_posture()
SimpleCube.is_button_pressed()
SimpleCube.turn_on_cube_lamp()
SimpleCube.turn_off_cube_lamp()
SimpleCube.play_sound()
SimpleCube.stop_sound()
SimpleCube.is_magnet_in_contact()
Submodules¶
- toio.coordinate_systems module
ToioRelativeCoordinateSystem
ToioRelativeCoordinateSystem.__init__()
ToioRelativeCoordinateSystem.set_origin()
ToioRelativeCoordinateSystem.to_native_angle()
ToioRelativeCoordinateSystem.to_native_x()
ToioRelativeCoordinateSystem.to_native_y()
ToioRelativeCoordinateSystem.from_native_angle()
ToioRelativeCoordinateSystem.from_native_x()
ToioRelativeCoordinateSystem.from_native_y()
VisualProgrammingCoordinateSystem
VisualProgrammingCoordinateSystem.__init__()
VisualProgrammingCoordinateSystem.set_origin()
VisualProgrammingCoordinateSystem.to_native_angle()
VisualProgrammingCoordinateSystem.to_native_x()
VisualProgrammingCoordinateSystem.to_native_y()
VisualProgrammingCoordinateSystem.from_native_angle()
VisualProgrammingCoordinateSystem.from_native_x()
VisualProgrammingCoordinateSystem.from_native_y()
- toio.logger module
- toio.position module
Point
CubeLocation
MatRect
CoordinateSystemABC
CoordinateSystemABC.__init__()
CoordinateSystemABC.set_origin()
CoordinateSystemABC.to_native_angle()
CoordinateSystemABC.to_native_x()
CoordinateSystemABC.to_native_y()
CoordinateSystemABC.from_native_angle()
CoordinateSystemABC.from_native_x()
CoordinateSystemABC.from_native_y()
CoordinateSystemABC.to_native_point()
CoordinateSystemABC.to_native_location()
CoordinateSystemABC.from_native_point()
CoordinateSystemABC.from_native_location()
DefaultCoordinateSystem
DefaultCoordinateSystem.__init__()
DefaultCoordinateSystem.set_origin()
DefaultCoordinateSystem.to_native_angle()
DefaultCoordinateSystem.to_native_x()
DefaultCoordinateSystem.to_native_y()
DefaultCoordinateSystem.from_native_angle()
DefaultCoordinateSystem.from_native_x()
DefaultCoordinateSystem.from_native_y()
RelativeCubeLocation
RelativeCubeLocation.relative_location
RelativeCubeLocation.coordinate_system
RelativeCubeLocation.new()
RelativeCubeLocation.to_absolute_point()
RelativeCubeLocation.to_absolute_location()
RelativeCubeLocation.from_absolute_point()
RelativeCubeLocation.from_absolute_location()
RelativeCubeLocation.change_coordinate_system()
RelativeCubeLocation.__init__()
ToioMat
- toio.standard_id module
StandardIdCard
StandardIdCard.Typhoon
StandardIdCard.Rush
StandardIdCard.AutoTackle
StandardIdCard.Random
StandardIdCard.PoweredUpStrike
StandardIdCard.PoweredUpSlap
StandardIdCard.SideAttack
StandardIdCard.EasyMode
StandardIdCard.Left
StandardIdCard.Right
StandardIdCard.Forward
StandardIdCard.Back
StandardIdCard.Go
StandardIdCard.SkunkBlue
StandardIdCard.SkunkGreen
StandardIdCard.SkunkYellow
StandardIdCard.SkunkOrange
StandardIdCard.SkunkRed
StandardIdCard.SkunkBrown
StandardIdCard.SpeedUp
StandardIdCard.SlowDown
StandardIdCard.Wobble
StandardIdCard.Panic
StandardIdCard.Spin
StandardIdCard.Shock
StandardIdCard.CraftFighter
StandardIdCard.RhythmAndGo
StandardIdCard.SkunkChaser
StandardIdCard.FingerStrike
StandardIdCard.FingerStrikeForSinglePlayer
StandardIdCard.FreeMove
StandardIdCard.QuickSkunk2p
StandardIdCard.QuickSkunkCpu
StandardIdCard.KaijuBusters
StandardIdCard.WatchOutFree
StandardIdCard.WatchOut2p
StandardIdCard.WatchOutCpu
StandardIdCard.ColorMemory
StandardIdCard.LaserBeamChallenge
StandardIdCard.LaserBeamCreate
StandardIdCard.Baton
StandardIdCard.PullBack
StandardIdCard.Dash
StandardIdCard.DontDisturbNormal
StandardIdCard.DontDisturbRodeo
StandardIdCard.Answer
StandardIdCard.MusicSong1
StandardIdCard.MusicSong2
StandardIdCard.MusicSong3
StandardIdCard.MusicSong4
StandardIdCard.NUMBER_0
StandardIdCard.NUMBER_1
StandardIdCard.NUMBER_2
StandardIdCard.NUMBER_3
StandardIdCard.NUMBER_4
StandardIdCard.NUMBER_5
StandardIdCard.NUMBER_6
StandardIdCard.NUMBER_7
StandardIdCard.NUMBER_8
StandardIdCard.NUMBER_9
StandardIdCard.ALPHABET_A
StandardIdCard.ALPHABET_B
StandardIdCard.ALPHABET_C
StandardIdCard.ALPHABET_D
StandardIdCard.ALPHABET_E
StandardIdCard.ALPHABET_F
StandardIdCard.ALPHABET_G
StandardIdCard.ALPHABET_H
StandardIdCard.ALPHABET_I
StandardIdCard.ALPHABET_J
StandardIdCard.ALPHABET_K
StandardIdCard.ALPHABET_L
StandardIdCard.ALPHABET_M
StandardIdCard.ALPHABET_N
StandardIdCard.ALPHABET_O
StandardIdCard.ALPHABET_P
StandardIdCard.ALPHABET_Q
StandardIdCard.ALPHABET_R
StandardIdCard.ALPHABET_S
StandardIdCard.ALPHABET_T
StandardIdCard.ALPHABET_U
StandardIdCard.ALPHABET_V
StandardIdCard.ALPHABET_W
StandardIdCard.ALPHABET_X
StandardIdCard.ALPHABET_Y
StandardIdCard.ALPHABET_Z
StandardIdCard.MARK_Exclamation
StandardIdCard.MARK_Up
StandardIdCard.MARK_Question
StandardIdCard.MARK_Plus
StandardIdCard.MARK_Minus
StandardIdCard.MARK_Equal
StandardIdCard.MARK_Left
StandardIdCard.MARK_Down
StandardIdCard.MARK_Right
StandardIdCard.MARK_Multiplication
StandardIdCard.MARK_Division
StandardIdCard.MARK_Percent
- toio.toio_uuid module
- toio.utility module