Skip to content
This repository has been archived by the owner on Oct 18, 2022. It is now read-only.
/ pebble-sys Public archive

Low-level FFI bindings for Pebble (watch) SDK 4.3

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Tamschi/pebble-sys

pebble-sys

Lib.rs Crates.io Docs.rs

Rust nightly-2020-10-30 Build Status Crates.io - License

GitHub open issues open pull requests crev reviews

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.

Installation

Please use cargo-edit to always add the latest version of this library:

cargo add pebble-sys

Example

Aplite emulator screenshot: 'miles to see you' and 10000 in a number picker window

#![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
  }
}

License

Licensed under either of

at your option.

Contribution

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.

Versioning

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.

About

Low-level FFI bindings for Pebble (watch) SDK 4.3

Topics

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Code of conduct

Stars

Watchers

Forks

Languages