Struct playdate_rs::system::System

source ·
pub struct System { /* private fields */ }

Implementations§

source§

impl System

source

pub fn log_to_console(&self, msg: impl AsRef<str>)

Calls the log function.

source

pub fn error(&self, msg: impl AsRef<str>)

Calls the log function, outputting an error in red to the console, then pauses execution.

source

pub fn get_language(&self) -> Language

Returns the current language of the system.

source

pub fn get_current_time_milliseconds(&self) -> usize

Returns the number of milliseconds since…​some arbitrary point in time. This should present a consistent timebase while a game is running, but the counter will be disabled when the device is sleeping.

source

pub fn get_seconds_since_epoch(&self) -> (usize, usize)

Returns the number of seconds (and sets milliseconds if not NULL) elapsed since midnight (hour 0), January 1, 2000.

source

pub fn draw_fps(&self, x: i32, y: i32)

Calculates the current frames per second and draws that value at x, y.

source

pub fn get_button_state(&self) -> ButtonState

Returns bitmasks indicating which buttons are currently down. pushed and released reflect which buttons were pushed or released over the previous update cycle—at the nominal frame rate of 50 ms, fast button presses can be missed if you just poll the instantaneous state.

source

pub fn set_peripherals_enabled(&self, mask: Peripherals)

By default, the accelerometer is disabled to save (a small amount of) power. To use a peripheral, it must first be enabled via this function. Accelerometer data is not available until the next update cycle after it’s enabled.

source

pub fn get_accelerometer(&self) -> (f32, f32, f32)

Returns the last-read accelerometer data.

source

pub fn get_crank_angle(&self) -> f32

Returns the current position of the crank, in the range 0-360. Zero is pointing up, and the value increases as the crank moves clockwise, as viewed from the right side of the device.

source

pub fn get_crank_change(&self) -> f32

Returns the angle change of the crank since the last time this function was called. Negative values are anti-clockwise.

source

pub fn is_crank_docked(&self) -> bool

Returns 1 or 0 indicating whether or not the crank is folded into the unit.

source

pub fn set_crank_sounds_disabled(&self, flag: bool) -> bool

The function returns the previous value for this setting.

source

pub fn get_flipped(&self) -> bool

Returns 1 if the global “flipped” system setting is set, otherwise 0.

source

pub fn set_auto_lock_disabled(&self, disable: bool)

Disables or enables the 60 second auto lock feature. When called, the timer is reset to 60 seconds.

source

pub fn set_menu_image(&self, bitmap: &Bitmap, x_offset: i32)

A game can optionally provide an image to be displayed alongside the system menu. bitmap must be a 400x240 LCDBitmap. All important content should be in the left half of the image in an area 200 pixels wide, as the menu will obscure the rest. The right side of the image will be visible briefly as the menu animates in and out.

Optionally, a non-zero xoffset, can be provided. This must be a number between 0 and 200 and will cause the menu image to animate to a position offset left by xoffset pixels as the menu is animated in.

This function could be called in response to the kEventPause event in your implementation of eventHandler().

source

pub fn add_menu_item( &self, title: impl AsRef<str>, callback: PDMenuItemCallbackFunction ) -> MenuItem

title will be the title displayed by the menu item.

Adds a new menu item to the System Menu. When invoked by the user, this menu item will:

  1. Invoke your callback function.
  2. Hide the System Menu.
  3. Unpause your game and call eventHandler() with the kEventResume event.

Your game can then present an options interface to the player, or take other action, in whatever manner you choose.

source

pub fn add_checkmark_menu_item( &self, title: impl AsRef<str>, value: i32, callback: PDMenuItemCallbackFunction ) -> MenuItem

Adds a new menu item that can be checked or unchecked by the player.

title will be the title displayed by the menu item.

value should be 0 for unchecked, 1 for checked.

If this menu item is interacted with while the system menu is open, callback will be called when the menu is closed.

source

pub fn add_options_menu_item( &self, title: impl AsRef<str>, option_titles: &[&str], options_count: i32, callback: PDMenuItemCallbackFunction ) -> MenuItem

Adds a new menu item that allows the player to cycle through a set of options.

title will be the title displayed by the menu item.

options should be an array of strings representing the states this menu item can cycle through. Due to limited horizontal space, the option strings and title should be kept short for this type of menu item.

optionsCount should be the number of items contained in options.

If this menu item is interacted with while the system menu is open, callback will be called when the menu is closed.

source

pub fn remove_all_menu_items(&self)

Removes all custom menu items from the system menu.

source

pub fn get_reduce_flashing(&self) -> bool

Returns 1 if the global “reduce flashing” system setting is set, otherwise 0.

source

pub fn get_elapsed_time(&self) -> f32

Returns the number of seconds since playdate.resetElapsedTime() was called. The value is a floating-point number with microsecond accuracy.

source

pub fn reset_elapsed_time(&self)

Resets the high-resolution timer.

source

pub fn get_battery_percentage(&self) -> f32

Returns a value from 0-100 denoting the current level of battery charge. 0 = empty; 100 = full.

source

pub fn get_battery_voltage(&self) -> f32

Returns the battery’s current voltage level.

source

pub fn get_timezone_offset(&self) -> i32

Returns the system timezone offset from GMT, in seconds.

source

pub fn should_display_24_hour_time(&self) -> bool

Returns 1 if the user has set the 24-Hour Time preference in the Settings program.

source

pub fn convert_epoch_to_date_time(&self, epoch: u32) -> DateTime

Converts the given epoch time to a PDDateTime.

source

pub fn convert_date_time_to_epoch(&self, datetime: DateTime) -> u32

Converts the given PDDateTime to an epoch time.

source

pub fn clear_icache(&self)

Flush the CPU instruction cache, on the very unlikely chance you’re modifying instruction code on the fly. (If you don’t know what I’m talking about, you don’t need this. :smile:)

Auto Trait Implementations§

§

impl RefUnwindSafe for System

§

impl !Send for System

§

impl !Sync for System

§

impl Unpin for System

§

impl UnwindSafe for System

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.