A lightweight identifier for one Sifteo cube. More...
#include <sifteo/cube.h>
Public Member Functions | |
Byte3 | accel () const |
Return the physical accelerometer state, as a signed byte-vector. More... | |
float | batteryLevel () const |
Get this cube's battery level. More... | |
_SYSCubeIDVector | bit () const |
Return the _SYSCubeIDVector bit associated with this ID. More... | |
CubeID () | |
Default constructor. By default, a CubeID is initialized to a special Undefined value. This value can be tested for with the isDefined() predicate. | |
CubeID (_SYSCubeID sys) | |
Initialize a CubeID with a concrete slot value. Slots are numbered from 0 to NUM_SLOTS - 1. | |
void | detachMotionBuffer () const |
Detach any motion buffer which was previously attached to this cube. More... | |
void | detachVideoBuffer () const |
Detach any video buffer which was previously attached to this cube. More... | |
uint64_t | hwID () const |
Return the cube's unique 64-bit hardware ID. This ID uniquely identifies the cube that this slot is paired with. More... | |
bool | isDefined () const |
Is this a CubeID that was initialized with a valid slot number, and not one that was initialized as undefined? | |
bool | isTouching () const |
Is this cube being touched right now? Return the current state of the touch sensor. | |
operator _SYSCubeID () const | |
Implicit conversion to _SYSCubeID, for use in low-level system calls. | |
void | unpair () const |
Remove the persistent pairing association between this cube and the current Base. More... | |
Static Public Attributes | |
static const _SYSCubeID | NUM_SLOTS = _SYS_NUM_CUBE_SLOTS |
The maximum number of distinct CubeIDs. | |
static const _SYSCubeID | UNDEFINED = _SYS_CUBE_ID_INVALID |
A reserved ID, used to mark undefined CubeIDs. | |
A lightweight identifier for one Sifteo cube.
This is a small unsigned integer which refers to a "cube slot", a collection of resources that the operating system maintains for each cube or potential cube.
CubeID objects can be used as accessors for state that is stored in this "cube slot", and as mutators to change the state of the slot. Use a CubeID to read sensor state from a cube, to connect a new cube, or as a parameter for other APIs which need to tell cubes apart.
|
inline |
Return the physical accelerometer state, as a signed byte-vector.
All components are signed bytes, ranging from -128 to 127, with a full scale range of 2G. +X is to the right, +Y is toward the bottom of the screen, and +Z points "into" the screen.
A vector of (0, 0, 0) is considered free-fall. A cube lying flat on the table will have X and Y coordinates near zero, and a positive Z coordinate near 64. An upside-down cube would have a negative Z coordinate near -64.
|
inline |
Get this cube's battery level.
The battery level has already been converted into a "fuel gauge" representation, with 0.0f representing a qualitatively dead battery and 1.0f representing a totally new battery.
A reading of exactly zero will only result when the battery level is not yet known. It takes the cube about a second to measure its own battery level, so if you're talking to a cube that has just been turned on and connected, the first measurement may not yet be available.
To get the battery level for the base unit, call System::batteryLevel().
|
inline |
Return the _SYSCubeIDVector bit associated with this ID.
These bits are used for some system calls, and they can be used to quickly describe a set of cubes.
|
inline |
Detach any motion buffer which was previously attached to this cube.
After this point, we'll refrain from capturing high-frequency motion data from this cube. The latest motion sample will still be available from accel().
|
inline |
Detach any video buffer which was previously attached to this cube.
After this point, we'll refrain from sending any video updates to this cube. The cube will retain its existing screen contents.
Waits for all cubes to finish rendering before detaching.
|
inline |
Return the cube's unique 64-bit hardware ID. This ID uniquely identifies the cube that this slot is paired with.
The system caches these IDs, so usually this function will return nearly instantly. However, if the HWID is not yet known, this may block while we wait on a radio round-trip to discover the HWID.
|
inline |
Remove the persistent pairing association between this cube and the current Base.
This cube will also be shutdown and disconnected.
Sifteo SDK v1.1.0 (see all versions)
Last updated Tue Dec 23 2014, by Doxygen