v1.0.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
system.h
1 /* -*- mode: C; c-basic-offset: 4; intent-tabs-mode: nil -*-
2  *
3  * This file is part of the public interface to the Sifteo SDK.
4  * Copyright <c> 2012 Sifteo, Inc. All rights reserved.
5  */
6 
7 #pragma once
8 #ifdef NOT_USERSPACE
9 # error This is a userspace-only header, not allowed by the current build.
10 #endif
11 
12 #include <sifteo/abi.h>
13 #include <sifteo/macros.h>
14 
15 namespace Sifteo {
16 
29 class System {
30  public:
31 
39  static void exit() {
40  _SYS_exit();
41  }
42 
49  static void abort() {
50  _SYS_abort();
51  }
52 
68  static void yield() {
69  _SYS_yield();
70  }
71 
90  static void paint() {
91  _SYS_paint();
92  }
93 
111  static void paintUnlimited() {
112  _SYS_paintUnlimited();
113  }
114 
141  static void finish() {
142  _SYS_finish();
143  }
144 
150  static bool isDebug() {
151  return _SYS_lti_isDebug();
152  }
153 
163  static bool isSimDebug()
164  {
165  unsigned flag = 0;
166  SCRIPT_FMT(LUA, "Runtime():poke(%p, 1)", &flag);
167  return flag;
168  }
169 
183  static float batteryLevel() {
184  return _SYS_sysBatteryLevel() / float(_SYS_BATTERY_MAX);
185  }
186 
200  static void shutdown(bool now = false) {
201  return _SYS_shutdown(now ? 0 : _SYS_SHUTDOWN_WITH_UI);
202  }
203 
212  static void keepAwake() {
213  _SYS_keepAwake();
214  }
215 
236  static void setCubeRange(unsigned minimum, unsigned maximum) {
237  _SYS_setCubeRange(minimum, maximum);
238  }
239 
243  static void setCubeRange(unsigned count) {
244  _SYS_setCubeRange(count, count);
245  }
246 
258  static uint32_t osVersion() {
259 
260  if ((_SYS_getFeatures() & _SYS_FEATURE_SYS_VERSION) != 0) {
261  return _SYS_version() & _SYS_OS_VERSION_MASK;
262  }
263 
264  return _SYS_OS_VERSION_NONE;
265  }
266 
274  static uint8_t hardwareVersion() {
275 
276  if ((_SYS_getFeatures() & _SYS_FEATURE_SYS_VERSION) != 0) {
277  return _SYS_version() >> _SYS_HW_VERSION_SHIFT;
278  }
279 
280  return _SYS_HW_VERSION_NONE;
281  }
282 };
283 
288 } // namespace Sifteo