toio package¶
Subpackages¶
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
Module contents¶
- 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: ~toio.device_interface.CubeInterface | None = None, name: str | None = None, scanner: ~typing.Type[~toio.device_interface.ScannerInterface] = <class 'toio.scanner.ble.UniversalBleScanner'>, scanner_args: ~typing.Sequence[~typing.Any] = ())[source]
Bases:
CubeInterface
Access to toio Core Cube
Note
self.protocol_version is set after connecting to the cube.
self.protocol_version and self.max_retry_to_get_protocol_version is supported since v1.1.0.
basic scan function is supported since v1.1.0.
When Toio is initialized with no arguments, the scan() function can search for a cubes. scan() can be followed by a call to the connect() function to connect to multiple cubes.
If you initialize ToioCoreCube with a CubeInfo or a CubeInterface, you can connect to specified cube by calling the connect() function. In this case, the scan() function does not work.
ToioCoreCube is an asynchronous context manager. When ‘async with’ is used, ‘__aenter__’ handles the process up to connection, and ‘__aexit__’ handles the disconnection.
- interface
control interface (e.g. BleCube)
- Type:
- name
cube name (optional)
- Type:
str
- api
API class
- Type:
ToioCoreCubeLowLevelAPI
- protocol_version
protocol version of the cube
- Type:
Optional[ProtocolVersion]
- max_retry_to_get_protocol_version
number of retries to get protocol version
- Type:
int
- SUPPORTED_MAJOR_VERSION: int = 2
- SUPPORTED_MINOR_VERSION: int = 4
- static create(initializer: CubeInterface | CubeInfo | Sequence) ToioCoreCube [source]
Supported toio.py versions: v1.1.0 or later
Create a ToioCoreCube instance from a CubeInterface or CubeInfo
- Parameters:
initializer (CubeInitializer) – initializer
- Return type:
Optional[ToioCoreCube]
- static create_cubes(initializers: Iterable[CubeInterface | CubeInfo]) List[ToioCoreCube] [source]
Supported toio.py versions: v1.1.0 or later
Create a ToioCoreCube instance list from a CubeInterface or CubeInfo list
- Parameters:
initializers (Iterable[CubeInitializer]) – initializers
- Return type:
List[ToioCoreCube]
- __init__(interface: ~toio.device_interface.CubeInterface | None = None, name: str | None = None, scanner: ~typing.Type[~toio.device_interface.ScannerInterface] = <class 'toio.scanner.ble.UniversalBleScanner'>, scanner_args: ~typing.Sequence[~typing.Any] = ())[source]
- async scan()[source]
- async connect() bool [source]
- async disconnect() bool [source]
- async read(char_uuid: UUID) bytearray [source]
- async write(char_uuid: UUID, data: bytes | bytearray | memoryview, response: bool = False)[source]
- async register_notification_handler(char_uuid: UUID, notification_handler: Callable[[BleakGATTCharacteristic, bytearray], None | Awaitable[None]]) bool [source]
- async unregister_notification_handler(char_uuid: UUID) bool [source]
- is_connect() bool [source]
Implemented in v1.1.0 or later
get current connection state
- class toio.MultipleToioCoreCubes(cubes: int | ~typing.List[~toio.device_interface.CubeInfo], names: ~typing.Sequence[str] | None = None, scanner: ~typing.Type[~toio.device_interface.ScannerInterface] = <class 'toio.scanner.ble.UniversalBleScanner'>, scanner_args: ~typing.Sequence[~typing.Any] = ())[source]
Bases:
object
Multiple cube control class
This class is a wrapper to control multiple cubes easier.
When MultipleToioCoreCubes is initialized with an integer, the scan() function can search for a specified number of cubes. scan() can be followed by a call to the connect() function to connect to multiple cubes.
If you initialize MultipleToioCoreCubes with a list of CubeInfo, you can connect to multiple cubes by calling the connect() function. In this case, the scan() function does not work.
MultipleToioCoreCubes is an asynchronous context manager. When ‘async with’ is used, ‘__aenter__’ handles the process up to connection, and ‘__aexit__’ handles the disconnection.
Access to each cubes
Each cube can be accessed by the number.
>>> async with MultipleToioCoreCubes(2) as cubes: >>> cubes[0].api....() >>> cubes[1].api....()
Each cube can be accessd by ‘for’ also.
>>> async with MultipleToioCoreCubes(2) as cubes: >>> for c in cubes: >>> c.api....()
When ‘names’ is specified, cubes has each name and can be accessed with specified name.
>>> # accessing by cube name property >>> async with MultipleToioCoreCubes(2, "alpha", "beta") as cubes: >>> cubes.alpha.api....() >>> cubes.beta.api....()
>>> # accessing cubes using the cube interface obtained by name >>> async with MultipleToioCoreCubes(2, "alpha", "beta") as cubes: >>> alpha = cubes.named("alpha") >>> beta = cubes.named("beta") >>> alpha.api....() >>> beta.api....()
- OPERATION_INTERVAL: float = 0.5
- __init__(cubes: int | ~typing.List[~toio.device_interface.CubeInfo], names: ~typing.Sequence[str] | None = None, scanner: ~typing.Type[~toio.device_interface.ScannerInterface] = <class 'toio.scanner.ble.UniversalBleScanner'>, scanner_args: ~typing.Sequence[~typing.Any] = ())[source]
Initialize MultipleCubes
- Parameters:
cubes (Union[int, List[CubeInfo]]) – number of cubes to be scanned, or list of cubes to be handled
names (Optional[Sequence[str]]) – sequence of names of cubes
scanner (Type[ScannerInterface]) – scanner interface (default is UniversalBleScanner)
scanner_args (Sequence[Any]) – arguments given to the scanner.scan() function
- async scan()[source]
scan cubes
If MultipleCubes is initialized with integer number, this function performs to scan the number of cubes.
- async connect()[source]
connect to multiple cubes
cubes are connected at MultipleToioCoreCubes.OPERATION_INTERVAL second interval.
- async disconnect()[source]
disconnect to multiple cubes
cubes are disconnected at MultipleToioCoreCubes.OPERATION_INTERVAL second interval.
- named(name: str) ToioCoreCube [source]
get the cube specified by the name
- Parameters:
name (str) – name
- Return type:
ToioCoreCube
- Exceptions:
ValueError: the cube specified is not found
- class toio.NotificationHandlerInfo(func: Callable[[bytearray], None] | Callable[[bytearray], Awaitable[None]] | Callable[[bytearray, Any], None] | Callable[[bytearray, Any], Awaitable[None]], device: Any, interface: CubeInterface, misc: Any = None)[source]
Bases:
object
Information of registered notification handler function.
- NotificationHandlerInfo includes several type of information:
Unique data given at registration (misc)
Information about the device that received the notification (device, interface)
Information used for internal use (rest of properties)
- __init__(func: Callable[[bytearray], None] | Callable[[bytearray], Awaitable[None]] | Callable[[bytearray, Any], None] | Callable[[bytearray, Any], Awaitable[None]], device: Any, interface: CubeInterface, misc: Any = None)[source]
__init__.
- Parameters:
func (NotificationHandlerTypes) – notification handler function
device (NotificationReceivedDevice) – device to be notified
interface (CubeInterface) – interface of device
misc (Any) – user data
- property misc: Any
User data given when the notification handler function is registered.
- property device: Any
The device that received the notification.
- property interface: CubeInterface
The interface of the device that received the notification. (equal to device.interface)
- property is_async: bool
Whether the notification handler function is async or sync. (for internal use)
- property num_of_args: int
Number of arguments received by the registered notification handler function. (for internal use)
- get_notified_cube() ToioCoreCube [source]
Return self.device as ToioCoreCube
- class toio.ToioCoreCubeLowLevelAPI(interface: CubeInterface, root_device: Any)[source]
Bases:
object
Control APIs This class has control APIs for each characteristic.
- 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, root_device: Any)[source]
- property version: str
- 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: CubeInterface, device: Any)[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: CubeInterface, device: Any)[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, device: Any)[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, device: Any)[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
- HighPrecisionEuler = 3
- 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, device: Any)[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 | ResponseConnectionIntervalRequest | ResponseGettingRequestedConnectionInterval | ResponseGettingCurrentConnectionInterval | 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) 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-
- async request_to_change_connection_interval(min_interval: int, max_interval: int) None [source]
Request the connected central device to change the connection interval.
Note
If central device can not accept the requested connection interval value, one of the following occurs: - Bluetooth connection is disconnected. - Another connection interval value is set that can be accepted by the central device.
max_interval must be greater than or equal to min_interval. (except the value is 0xFFFF)
- Parameters:
min_interval (int) – min_interval, from 6 to 3200, or 0xFFFF (0xFFFF means “to be determined by central”)
max_interval (int) – max_interval, from 6 to 3200, or 0xFFFF (0xFFFF means “to be determined by central”)
References
https://toio.github.io/toio-spec/en/docs/ble_configuration#request-to-change-connection-interval-
- async get_requested_connection_interval() None [source]
Get requested connection interval value.
References
- async get_current_connection_interval() None [source]
Get current connection interval value.
References
- 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, device: Any)[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, device: Any)[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
- static from_int(duration_ms: int, r: int, g: int, b: int) IndicatorParam [source]
- flatten()[source]
- __init__(duration_ms: int, color: Color) None
- class toio.Indicator(interface: CubeInterface, device: Any)[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, device: Any)[source]
- async turn_on(param: IndicatorParam | Sequence[int]) None [source]
Send indicator turn on / off command
- Parameters:
param (Union[IndicatorParam, Sequence[int]]) – 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: Sequence[IndicatorParam] | Sequence[Sequence[int]]) None [source]
Send repeated indicator turning on / off command
- Parameters:
repeat (int) – Number of repetitions
param_list (Union[Sequence[IndicatorParam], Sequence[Sequence[int]]]) – 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
- static from_int(x: int = 0, y: int = 0, angle: int = 0, rotation_option: int = 0) TargetPosition [source]
- 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, device: Any)[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, device: Any)[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 | int, speed: Speed | Sequence[int], target: TargetPosition | Sequence[int]) 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 | int, speed: Speed | Sequence[int], mode: WriteMode | int, target_list: Sequence[TargetPosition] | Sequence[Sequence[int]]) None [source]
Send multiple target specified motor control command
- Parameters:
timeout (int) – Timeout [s] (Note: not [ms])
movement_type (Union[MovementType, int]) – Movement type
speed (Union[Speed, Sequence[int]]) – Speed parameter
mode (Union[WriteMode, int]) – Write mode
target_list (List[Union[TargetPosition, Sequence[int]]]) – Target parameter list
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 | int, cube_direction: AccelerationDirection | int, priority: AccelerationPriority | int, 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 (Union[AccelerationRotation, int]) – Rotational direction when the cube is changing orientation.
cube_direction (Union[AccelerationDirection, int]) – Direction the cube travels.
priority (Union[AccelerationPriority, int]) – 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
- HighPrecisionEuler = 3
- 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:
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.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
- 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, 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_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, device: Any)[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, device: Any)[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[MidiNote] | Tuple[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 from_int(x: int = 0, y: int = 0, angle: int = 0)[source]
- 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
- static from_int(x_top_left: int = 0, y_top_left: int = 0, x_bottom_right: int = 0, y_bottom_right: int = 0, name: str | None = None)[source]
- __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'))