Low-level FFI bindings for Pebble (watch) SDK 4.3.
I recommend using the high-level wrapper in pebble-skip
instead, since it provides almost the same functionality with full memory safety and with very little overhead.
The Pebble SDK isn't automatically included, but you can build a statically linked library and the use the official toolchain to link and package the watch app. See here for an example.
This crate is still heavily work in progress, so expect frequent breaking changes and missing functionality before 0.1. If you'd like me to prioritise a specific API, please file a feature request on GitHub.
Please use cargo-edit to always add the latest version of this library:
cargo add pebble-sys
#![no_std]
use pebble_sys::{
foundation::app::app_event_loop,
standard_c::memory::{c_str, void},
user_interface::{
window::number_window::{
number_window_create, number_window_get_window_mut, number_window_set_value,
NumberWindowCallbacks,
},
window_stack::window_stack_push,
},
};
#[no_mangle]
pub extern "C" fn main() -> i32 {
static mut CONTEXT: () = ();
unsafe {
let label = &*("miles to see you\0" as *const _ as *const c_str);
let number_window = number_window_create(
label,
NumberWindowCallbacks {
incremented: None,
decremented: None,
selected: None,
},
&mut *(&mut CONTEXT as *mut _ as *mut void),
)
.unwrap();
number_window_set_value(number_window, 10_000);
let window = number_window_get_window_mut(number_window);
window_stack_push(window, true);
app_event_loop();
0
}
}
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
pebble-sys
strictly follows Semantic Versioning 2.0.0 with the following exceptions:
- The minor version will not reset to 0 on major version changes (except for v1).
Consider it the global feature level. - The patch version will not reset to 0 on major or minor version changes (except for v0.1 and v1).
Consider it the global patch level.
This includes the Rust version requirement specified above.
Earlier Rust versions may be compatible, but this can change with minor or patch releases.
Which versions are affected by features and patches can be determined from the respective headings in CHANGELOG.md.