v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
Public Types | Static Public Member Functions | List of all members
Sifteo::System Class Reference

Global operations that apply to the system as a whole. More...

#include <sifteo/system.h>

Public Types

enum  HardwareVersion { HardwareNone = _SYS_HW_VERSION_NONE, HardwareGen2 = _SYS_HW_VERSION_GEN_2, HardwareGen2_5 = _SYS_HW_VERSION_GEN_2_5 }
 

Static Public Member Functions

static void abort ()
 Exit with a fault, for fatal error handling. More...
 
static float batteryLevel ()
 Get the system's battery level. More...
 
static void exit ()
 Leave the game immediately. More...
 
static void finish ()
 Wait for any previous paint() to finish. More...
 
static uint8_t hardwareVersion ()
 Returns the hardware revision for the Sifteo base this application is running on. More...
 
static bool isDebug ()
 Is this a debug build? More...
 
static bool isSimDebug ()
 Is this a debug build running in simulation? More...
 
static void keepAwake ()
 Prevent the system from shutting down due to inactivity. More...
 
static uint32_t osVersion ()
 Returns the system's operating system version. More...
 
static void paint ()
 Draw the next frame. More...
 
static void paintUnlimited ()
 Draw the next frame, without an upper limit on frame rate. More...
 
static void setCubeRange (unsigned minimum, unsigned maximum)
 Set the range of cubes supported. More...
 
static void setCubeRange (unsigned count)
 Helper to specify a cube range with identical minimum and maximum counts.
 
static void shutdown (bool now=false)
 Shut down the system. More...
 
static void yield ()
 Temporarily give up control of the CPU. More...
 

Detailed Description

Global operations that apply to the system as a whole.

Member Function Documentation

static void Sifteo::System::abort ( )
inlinestatic

Exit with a fault, for fatal error handling.

This is the same kind of fatal error that occurs when an ASSERT() fails.

static float Sifteo::System::batteryLevel ( )
inlinestatic

Get the system'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. This is only relevant to code which can run very soon after the system boots.

To get the battery level for a single cube, call CubeID::batteryLevel().

static void Sifteo::System::exit ( )
inlinestatic

Leave the game immediately.

Returns control back to the main menu. Equivalent to returning from main().

static void Sifteo::System::finish ( )
inlinestatic

Wait for any previous paint() to finish.

This is analogous to glFinish() in OpenGL. It doesn't enqueue any new rendering, but the caller has a strong guarantee that all existing rendering has completed by the time this function returns.

This function must be used if you're changing VRAM after rendering a frame, and you must make absolutely sure that this change doesn't affect the current frame. For example, if you're making a sharp transition from one video mode to a totally different one.

Typically you should call finish() before an event that changes the video mode or the BG1 mask.

Don't overuse finish(), especially not if you're concerned with frame rate. Normally it's desirable to be working on building the next frame while the cubes are still busy rendering the previous one.

Unlike paint() and yield(), finish does not dispatch Sifteo::Events handler functions.

static uint8_t Sifteo::System::hardwareVersion ( )
inlinestatic

Returns the hardware revision for the Sifteo base this application is running on.

Note
early OS versions do not support the _SYS_version() syscall - HardwareVersion::HardwareNone is returned in this case.
See also
HardwareVersion
static bool Sifteo::System::isDebug ( )
inlinestatic

Is this a debug build?

Returns 'true' if slinky was invoked with '-g', or false otherwise.

static bool Sifteo::System::isSimDebug ( )
inlinestatic

Is this a debug build running in simulation?

Returns 'true' if slinky was invoked with '-g' and we're running in siftulator rather than on real hardware. Returns false otherwise.

Release builds cannot detect being run in Siftulator in this manner. On release buids, this function always returns false.

static void Sifteo::System::keepAwake ( )
inlinestatic

Prevent the system from shutting down due to inactivity.

By default, the system shuts down automatically after 10 minutes of inactivity - no touch or neighbor events. If an app wants to keep running, and does not expect to generate any neighbor or touch events during normal operation, keepAwake() resets the timeout countdown.

static uint32_t Sifteo::System::osVersion ( )
inlinestatic

Returns the system's operating system version.

The version is a numeric value of the form 0xMMNNPP (MM = major, NN = minor, PP = patch).

For example, if your application is running on a system at version 1.5.10, the value from osVersion() will be 0x010510.

Note
early OS versions do not support the _SYS_version() syscall - _SYS_OS_VERSION_NONE is returned in this case.
static void Sifteo::System::paint ( )
inlinestatic

Draw the next frame.

Draws simultaneously on all enabled and connected cubes.

This function includes flow control. If the game is rendering faster than the cubes are, this function automatically yields to keep the game's frame rate in sync with the cube frame rate.

This function can very cheaply determine whether any changes in fact occurred on a cube. If nothing changed, we won't redraw that cube. If no cubes need drawing, this function yields for the duration of one frame.

Handlers registered with Sifteo::Events may be dispatched immediately prior to returning from paint().

static void Sifteo::System::paintUnlimited ( )
inlinestatic

Draw the next frame, without an upper limit on frame rate.

Normally paint() includes various forms of throttling which prevent the game from rendering faster than the LCD can display frames, or faster than the cube can keep up. Because of this, a normal paint() includes two phases: waiting for time to paint, then triggering a paint on all cubes.

This variant of paint() skips the former step. We immediately trigger a render on all cubes, without regard to putting any explicit upper limits on the rate at which we're completing frames.

Handlers registered with Sifteo::Events may be dispatched immediately prior to returning from paintUnlimited().

static void Sifteo::System::setCubeRange ( unsigned  minimum,
unsigned  maximum 
)
inlinestatic

Set the range of cubes supported.

When the number of cubes connected to the system drops below minimum, the system pauses execution until the requisite number of cubes are connected, or the user decides to quit.

When the number of cubes connected to the system is greater than maximum, extra cubes will not be reported as connected to userspace. NOTE: the behavior for cubes in this limbo state has not been fully specified.

In many cases, it is not required to call setCubeRange() explicitly - including a call to Metadata::cubeRange() is sufficient to set the default cube range for the app. During execution, setCubeRange() can be used to dynamically configure the number of cubes.

Note
Calling setCubeRange() when the number of cubes connected to the system is below the new minimum will trigger a pause immediately until the required cubes are connected.
static void Sifteo::System::shutdown ( bool  now = false)
inlinestatic

Shut down the system.

This initiates a shutdown sequence. By default, this will pause the game and present the system's standard shutdown UI. If shutdown is cancelled, this function returns. Otherwise, the base shuts down immediately and this function will not return.

Games may elect to use this to shut down during periods of inactivity, such as if the user leaves a menu idle for a while.

If the 'now' flag is true, the UI is bypassed and we shut down immediately.

static void Sifteo::System::yield ( )
inlinestatic

Temporarily give up control of the CPU.

During a yield(), event callbacks may run. If the system as a whole has nothing better to do, the CPU will be put into a lower-power mode until some kind of event occurs.

yield() may return at any time, including immediately after it's called. There is no guarantee that any particular event will have occurred before it returns.

Handlers registered with Sifteo::Events may be dispatched immediately prior to returning from yield().


The documentation for this class was generated from the following file: