diff --git a/src/system.rs b/src/system.rs index e4f8c6f..79489ff 100644 --- a/src/system.rs +++ b/src/system.rs @@ -5,6 +5,7 @@ use { use crankstart_sys::ctypes::c_int; pub use crankstart_sys::PDButtons; +use crankstart_sys::{PDDateTime, PDLanguage, PDPeripherals}; static mut SYSTEM: System = System(ptr::null_mut()); @@ -46,6 +47,18 @@ impl System { Ok((current, pushed, released)) } + pub fn set_peripherals_enabled(&self, peripherals: PDPeripherals) -> Result<(), Error> { + pd_func_caller!((*self.0).setPeripheralsEnabled, peripherals) + } + + pub fn get_accelerometer(&self) -> Result<(f32, f32, f32), Error> { + let mut outx = 0.0; + let mut outy = 0.0; + let mut outz = 0.0; + pd_func_caller!((*self.0).getAccelerometer, &mut outx, &mut outy, &mut outz)?; + Ok((outx, outy, outz)) + } + pub fn is_crank_docked(&self) -> Result { let docked: bool = pd_func_caller!((*self.0).isCrankDocked)? != 0; Ok(docked) @@ -117,15 +130,53 @@ impl System { Ok(pd_func_caller!((*self.0).getCurrentTimeMilliseconds)? as usize) } + pub fn get_timezone_offset(&self) -> Result { + pd_func_caller!((*self.0).getTimezoneOffset) + } + + pub fn convert_epoch_to_datetime(&self, epoch: u32) -> Result { + let mut datetime = PDDateTime::default(); + pd_func_caller!((*self.0).convertEpochToDateTime, epoch, &mut datetime)?; + Ok(datetime) + } + + pub fn convert_datetime_to_epoch(&self, datetime: &mut PDDateTime) -> Result { + Ok(pd_func_caller!((*self.0).convertDateTimeToEpoch, datetime)? as usize) + } + + pub fn should_display_24_hour_time(&self) -> Result { + Ok(pd_func_caller!((*self.0).shouldDisplay24HourTime)? != 0) + } + pub fn reset_elapsed_time(&self) -> Result<(), Error> { pd_func_caller!((*self.0).resetElapsedTime) } pub fn get_elapsed_time(&self) -> Result { - Ok(pd_func_caller!((*self.0).getElapsedTime)?) + pd_func_caller!((*self.0).getElapsedTime) + } + + pub fn get_flipped(&self) -> Result { + Ok(pd_func_caller!((*self.0).getFlipped)? != 0) + } + + pub fn get_reduced_flashing(&self) -> Result { + Ok(pd_func_caller!((*self.0).getReduceFlashing)? != 0) } pub fn draw_fps(&self, x: i32, y: i32) -> Result<(), Error> { pd_func_caller!((*self.0).drawFPS, x, y) } + + pub fn get_battery_percentage(&self) -> Result { + pd_func_caller!((*self.0).getBatteryPercentage) + } + + pub fn get_battery_voltage(&self) -> Result { + pd_func_caller!((*self.0).getBatteryVoltage) + } + + pub fn get_language(&self) -> Result { + pd_func_caller!((*self.0).getLanguage) + } }