### GPath Creation and Drawing Example Source: https://developer.repebble.com/docs/c/struct_g_path.html This example demonstrates how to create a GPath, set its properties like rotation and translation, and then draw it as both filled and outlined shapes. ```APIDOC ## GPath Creation and Drawing Example ### Description This example demonstrates how to create a GPath, set its properties like rotation and translation, and then draw it as both filled and outlined shapes. ### Code ```c static GPath *s_my_path_ptr = NULL; static const GPathInfo BOLT_PATH_INFO = { .num_points = 6, .points = (GPoint []) {{21, 0}, {14, 26}, {28, 26}, {7, 60}, {14, 34}, {0, 34}} }; // .update_proc of my_layer: void my_layer_update_proc(Layer *my_layer, GContext* ctx) { // Fill the path: graphics_context_set_fill_color(ctx, GColorWhite); gpath_draw_filled(ctx, s_my_path_ptr); // Stroke the path: graphics_context_set_stroke_color(ctx, GColorBlack); gpath_draw_outline(ctx, s_my_path_ptr); } void setup_my_path(void) { s_my_path_ptr = gpath_create(&BOLT_PATH_INFO); // Rotate 15 degrees: gpath_rotate_to(s_my_path_ptr, TRIG_MAX_ANGLE / 360 * 15); // Translate by (5, 5): gpath_move_to(s_my_path_ptr, GPoint(5, 5)); } // For brevity, the setup of my_layer is not written out... ``` ``` -------------------------------- ### Example Usage Source: https://developer.repebble.com/docs/c/Foundation/App_Glance Demonstrates how to use `app_glance_reload` and `app_glance_add_slice` within a callback to update the application's glance. This example is conditional and does not run on PBL_PLATFORM_APLITE. ```APIDOC # App Glance API for the application to modify its "glance" i.e. app menu subtitle. Apps have the ability to show a temporary icon and subtitle in the app selection menu; this is known as a "glance". For example, the app might use it to display a preview of its current state such as the currently playing song or the number of pending notifications. The glance is loaded with a stack of AppGlanceSlice structs; only the latest slice is shown, and they are set to expire at a certain time to show the next slice in the stack. To update the glance with a stack of slices, you must define an AppGlanceReloadCallback and give it to app_glance_reload. The implementation of your AppGlanceReloadCallback should call app_glance_add_slice to add slices to the glance. The main window's unload handler is usually a good place to call app_glance_reload. PBL_PLATFORM_APLITE does not support App Glance. Example code: ``` #if !PBL_PLATFORM_APLITE static void glance_reload_callback(AppGlanceReloadSession *session, size_t limit, void *context) { AppGlanceSlice slice = { .expiration_time = APP_GLANCE_SLICE_NO_EXPIRATION, .layout.icon = APP_GLANCE_SLICE_DEFAULT_ICON, .layout.subtitle_template_string = "hello!", }; AppGlanceResult result = app_glance_add_slice(session, slice); if (result != APP_GLANCE_RESULT_SUCCESS){ APP_LOG(APP_LOG_LEVEL_ERROR, "app_glance_add_slice() returned %d", result); } } #endif // !PBL_PLATFORM_APLITE static void main_window_unload(Window *window) { #if !PBL_PLATFORM_APLITE app_glance_reload(glance_reload_callback, NULL); #endif // !PBL_PLATFORM_APLITE } ``` ``` -------------------------------- ### App Event Loop Setup Source: https://developer.repebble.com/docs/c/Foundation/App Configure and enter the main event loop for a Pebble C application. This function blocks until the app is ready to exit. Place this in your app's main() function after setup and before cleanup. ```c int main(void) { // do set up here // Enter the main event loop. This will block until the app is ready to exit. app_event_loop(); // do clean up here } ``` -------------------------------- ### launch_get_args Source: https://developer.repebble.com/docs/c/Foundation/Launch_Reason Get the argument passed to the app when it was launched. ```APIDOC ## launch_get_args ### Description Get the argument passed to the app when it was launched. ### Note Currently the only way to pass arguments to apps is by using an openWatchApp action on a pin. ### Signature uint32_t launch_get_args(void) ### Returns The argument passed to the app, or 0 if the app wasn't launched from a Launch App action ``` -------------------------------- ### dictation_session_start Source: https://developer.repebble.com/docs/c/Foundation/Dictation Starts a dictation session to begin transcribing speech. ```APIDOC ## dictation_session_start ### Description Starts a dictation session to begin transcribing speech. The session must have been previously created using `dictation_session_create`. ### Parameters #### session (DictationSession *) - The dictation session to start. #### language (const char *) - The language code for the speech recognition (e.g., "en-US"). ### Returns (bool) - True if the session started successfully, false otherwise. ``` -------------------------------- ### App Glance Example Source: https://developer.repebble.com/docs/c/struct_app_glance_slice_layout.html This example demonstrates how to use the App Glance API to add a slice to the glance. It includes a callback function `glance_reload_callback` that is triggered by `app_glance_reload` and adds a slice with a specific layout and expiration time. The `main_window_unload` function shows a common place to call `app_glance_reload`. ```APIDOC ## App Glance API Usage Example ### Description This example shows how to implement the App Glance API to display a temporary icon and subtitle in the app selection menu. It defines a callback function to add slices and demonstrates when to trigger the glance reload. ### Code ```c #if !PBL_PLATFORM_APLITE static void glance_reload_callback(AppGlanceReloadSession *session, size_t limit, void *context) { AppGlanceSlice slice = { .expiration_time = APP_GLANCE_SLICE_NO_EXPIRATION, .layout.icon = APP_GLANCE_SLICE_DEFAULT_ICON, .layout.subtitle_template_string = "hello!", }; AppGlanceResult result = app_glance_add_slice(session, slice); if (result != APP_GLANCE_RESULT_SUCCESS){ APP_LOG(APP_LOG_LEVEL_ERROR, "app_glance_add_slice() returned %d", result); } } #endif // !PBL_PLATFORM_APLITE static void main_window_unload(Window *window) { #if !PBL_PLATFORM_APLITE app_glance_reload(glance_reload_callback, NULL); #endif // !PBL_PLATFORM_APLITE } ``` ### Notes - The App Glance API is not supported on PBL_PLATFORM_APLITE. - `app_glance_add_slice` should only be called within an `AppGlanceReloadCallback`. - The `main_window_unload` handler is a typical location to call `app_glance_reload`. ``` -------------------------------- ### animation_get_duration Source: https://developer.repebble.com/docs/c/group___animation.html Gets the static duration of an animation from start to end (ignoring how much has already played, if any). ```APIDOC ## animation_get_duration ### Description Get the static duration of an animation from start to end (ignoring how much has already played, if any). ### Parameters #### Path Parameters - **animation** (Animation *) - Required - The animation for which to get the duration - **include_delay** (bool) - Required - if true, include the delay time - **include_play_count** (bool) - Required - if true, incorporate the play_count ### Returns the duration ``` -------------------------------- ### Rectangle Inset Examples Source: https://developer.repebble.com/docs/c/Graphics/Graphics_Types Demonstrates various ways to use grect_inset with GEdgeInsets for different inset scenarios. ```c GRect r_inset_all_sides = grect_inset(r, GEdgeInsets(10)); GRect r_inset_vertical_horizontal = grect_inset(r, GEdgeInsets(10, 20)); GRect r_expand_top_right_shrink_bottom_left = grect_inset(r, GEdgeInsets(-10, -10, 10, 10)); ``` -------------------------------- ### window_create Source: https://developer.repebble.com/docs/c/group___window.html Creates a new Window on the heap with default values for background color, root layer update procedure, click configuration provider, and window handlers. ```APIDOC ## window_create ### Description Creates a new Window on the heap and initializes it with default values. ### Returns A pointer to the window. `NULL` if the window could not be created. ### Code Example ```c Window *my_window = window_create(); ``` ``` -------------------------------- ### memset Source: https://developer.repebble.com/docs/c/Standard_C/Memory Sets n bytes to c starting at dest. This can be used to clear a memory region for example if c is 0. ```APIDOC ## memset ### Description Sets n bytes to c starting at dest. This can be used to clear a memory region for example if c is 0. ### Parameters #### Path Parameters - **dest** (void *) - Required - The pointer to the destination memory region - **c** (int) - Required - The integer used as an unsigned char to assign to each byte - **n** (size_t) - Required - The number of bytes to set. ``` -------------------------------- ### animation_get_implementation Source: https://developer.repebble.com/docs/c/struct_animation_implementation.html Gets the implementation of a custom animation. This function retrieves the structure containing the setup, update, and teardown function pointers for a given animation. ```APIDOC ## animation_get_implementation ### Description Gets the implementation of the custom animation. ### Parameters - **animation** (Animation *) - The animation for which to get the implementation. ### Returns - NULL if animation implementation has not been setup. - Returns a pointer to the AnimationImplementation structure. ``` -------------------------------- ### golfAppLaunch: Method Source: https://developer.repebble.com/docs/symbols Sends a command to launch the golf app on the specified watch. The result is returned asynchronously via a completion block. ```APIDOC ## golfAppLaunch: Method ### Description Sends a command to launch the golf app on the watch that the receiver represents. This method must be called from the main thread. ### Method Signature `- (void)golfAppLaunch:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))onSent;` ### Parameters * `onSent` (^(PBWatch *watch, NSError *__nullable error)) - Optional - The handler that will be called when the launch command has been sent or timed out (after 1.5 secs). `watch`: the recipient of the command. `error`: nil if the operation was successful, or else an NSError with more information on why it failed. ### Declared In `PBWatch+Golf.h` ``` -------------------------------- ### Initialize ActionBarLayer in Window Load Source: https://developer.repebble.com/docs/c/User_Interface/Layers/ActionBarLayer This snippet demonstrates the initial setup of the ActionBarLayer within a window's load handler. It covers creating the action bar, associating it with the window, setting a click configuration provider, and assigning icons. ```c ActionBarLayer *action_bar; // The implementation of my_next_click_handler and my_previous_click_handler // is omitted for the sake of brevity. See the Clicks reference docs. void click_config_provider(void *context) { window_single_click_subscribe(BUTTON_ID_DOWN, (ClickHandler) my_next_click_handler); window_single_click_subscribe(BUTTON_ID_UP, (ClickHandler) my_previous_click_handler); } void window_load(Window *window) { ... // Initialize the action bar: action_bar = action_bar_layer_create(); // Associate the action bar with the window: action_bar_layer_add_to_window(action_bar, window); // Set the click config provider: action_bar_layer_set_click_config_provider(action_bar, click_config_provider); // Set the icons: // The loading of the icons is omitted for brevity... See gbitmap_create_with_resource() action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_UP, my_icon_previous, true); action_bar_layer_set_icon_animated(action_bar, BUTTON_ID_DOWN, my_icon_next, true); } ``` -------------------------------- ### animation_get_duration Source: https://developer.repebble.com/docs/c/User_Interface/Animation Gets the static duration of an animation from start to end, ignoring how much has already played. Parameters include whether to include delay and play count. ```APIDOC ## animation_get_duration ### Description Get the static duration of an animation from start to end (ignoring how much has already played, if any). ### Parameters #### Path Parameters - **animation** (Animation *) - Required - The animation for which to get the duration - **include_delay** (bool) - Required - if true, include the delay time - **include_play_count** (bool) - Required - if true, incorporate the play_count ### Returns The static duration of the animation in milliseconds. ``` -------------------------------- ### Animation Handlers and Context Management Source: https://developer.repebble.com/docs/c/struct_animation_implementation.html Functions to set and get callbacks for an animation, allowing code execution at the start or end of an animation. Also manages the application-specific context passed to these callbacks. ```APIDOC ## animation_set_handlers ### Description Sets the callbacks for the animation. Often an application needs to run code at the start or at the end of an animation. Using this function is possible to register callback functions with an animation, that will get called at the start and end of the animation. ### Parameters - **animation** (Animation *) - The animation for which to set up the callbacks. - **callbacks** (AnimationHandlers) - The callbacks. - **context** (void *) - A pointer to application specific data, that will be passed as an argument by the animation subsystem when a callback is called. ### Returns - bool - true if successful, false on failure. ### Note Trying to set an attribute when an animation is immutable will return false (failure). An animation is immutable once it has been added to a sequence or spawn animation or has been scheduled. ## animation_get_context ### Description Gets the application-specific callback context of the animation. This `void` pointer is passed as an argument when the animation system calls AnimationHandlers callbacks. The context pointer can be set to point to any application specific data using animation_set_handlers(). ### Parameters - **animation** (Animation *) - The animation. ### Returns - void * - The application-specific callback context. ### See Also animation_set_handlers ``` -------------------------------- ### Initialize Window Click Configuration Provider Source: https://developer.repebble.com/docs/c/User_Interface/Clicks Associate a click configuration provider callback with the window during application initialization. ```c void app_init(void) { ... window_set_click_config_provider(&window, (ClickConfigProvider) config_provider); ... } ``` -------------------------------- ### Reading key/value pairs Source: https://developer.repebble.com/docs/c/Foundation/Dictionary This example shows how to iterate over the key/value pairs within a serialized dictionary buffer. It uses `dict_read_begin_from_buffer` to get the first tuple and `dict_read_next` to iterate through the remaining tuples, processing them based on their keys. ```APIDOC ## Reading key/value pairs ### Description To iterate over the key/value pairs in the dictionary that was created in the previous example code, you would do this: ### Method `dict_read_begin_from_buffer`, `dict_read_next` ### Parameters - `iter` (DictionaryIterator*): Pointer to the iterator to manage the reading process. - `buffer` (const uint8_t*): The buffer containing the serialized dictionary. - `size` (uint32_t): The size of the buffer. ### Request Example ```c Tuple *tuple = dict_read_begin_from_buffer(&iter, buffer, final_size); while (tuple) { switch (tuple->key) { case SOME_DATA_KEY: foo(tuple->value->data, tuple->length); break; case SOME_STRING_KEY: bar(tuple->value->cstring); break; } tuple = dict_read_next(&iter); } ``` ### Response - `tuple` (Tuple*): A pointer to the current tuple being read, or NULL if iteration is complete. - `tuple->key` (uint32_t): The key of the current tuple. - `tuple->value` (union*): A union containing the value of the current tuple (e.g., `data`, `cstring`). - `tuple->length` (uint32_t): The length of the value. ``` -------------------------------- ### Scroll Layer Get Content Indicator Source: https://developer.repebble.com/docs/c/struct_scroll_layer_callbacks.html Gets the ContentIndicator for a ScrollLayer. ```APIDOC ContentIndicator * scroll_layer_get_content_indicator(ScrollLayer * scroll_layer) ## Parameters - scroll_layer (ScrollLayer *) - The ScrollLayer for which to get the ContentIndicator. ## Returns A pointer to the ContentIndicator, or `NULL` upon failure. ``` -------------------------------- ### Create, Transform, and Draw a Path - Pebble C Source: https://developer.repebble.com/docs/c/Graphics/Drawing_Paths Demonstrates the creation of a GPath, applying rotation and translation, and then drawing it as both filled and outlined shapes. Ensure the GPath is created and configured before being used in an update_proc. ```c static GPath *s_my_path_ptr = NULL; static const GPathInfo BOLT_PATH_INFO = { .num_points = 6, .points = (GPoint []) {{21, 0}, {14, 26}, {28, 26}, {7, 60}, {14, 34}, {0, 34}} }; // .update_proc of my_layer: void my_layer_update_proc(Layer *my_layer, GContext* ctx) { // Fill the path: graphics_context_set_fill_color(ctx, GColorWhite); gpath_draw_filled(ctx, s_my_path_ptr); // Stroke the path: graphics_context_set_stroke_color(ctx, GColorBlack); gpath_draw_outline(ctx, s_my_path_ptr); } void setup_my_path(void) { s_my_path_ptr = gpath_create(&BOLT_PATH_INFO); // Rotate 15 degrees: gpath_rotate_to(s_my_path_ptr, TRIG_MAX_ANGLE / 360 * 15); // Translate by (5, 5): gpath_move_to(s_my_path_ptr, GPoint(5, 5)); } // For brevity, the setup of my_layer is not written out... ``` -------------------------------- ### Scroll Layer Get Shadow Hidden Source: https://developer.repebble.com/docs/c/struct_scroll_layer_callbacks.html Gets the visibility of the scroll layer shadow. ```APIDOC bool scroll_layer_get_shadow_hidden(const ScrollLayer * scroll_layer) ## Parameters - scroll_layer (const ScrollLayer *) - The scroll layer for which to get the visibility. ## Returns True if the shadow is hidden, false if it is not hidden. ``` -------------------------------- ### AnimationSetupImplementation Source: https://developer.repebble.com/docs/c/struct_animation_handlers.html Callback function to optionally prepare an animation for running. This is invoked when the animation is added to the scheduler. ```APIDOC typedef void(* AnimationSetupImplementation)(Animation *animation) Pointer to function that (optionally) prepares the animation for running. This callback is called when the animation is added to the scheduler. Parameters: animation (Animation *) - The animation that needs to be set up. ``` -------------------------------- ### animation_get_elapsed Source: https://developer.repebble.com/docs/c/group___animation.html Gets the current location in the animation. The animation must be scheduled to get the elapsed time. If it is not scheduled, this method will return false. ```APIDOC ## animation_get_elapsed ### Description Get the current location in the animation. ### Note The animation must be scheduled to get the elapsed time. If it is not schedule, this method will return false. ### Parameters #### Path Parameters - **animation** (Animation *) - Required - The animation for which to fetch the elapsed. - **elapsed_ms** (int32_t *) - Output - pointer to variable that will contain the elapsed time in milliseconds ### Returns true if successful, false on failure ``` -------------------------------- ### Begin New Path Source: https://developer.repebble.com/docs/rockyjs/CanvasRenderingContext2D Start a new path by clearing the list of sub-paths. Call this before defining a new shape. ```javascript ctx.beginPath(); ``` -------------------------------- ### animation_get_elapsed Source: https://developer.repebble.com/docs/c/User_Interface/Animation Gets the current location in the animation. The animation must be scheduled to get the elapsed time. Returns true if successful, false on failure. ```APIDOC ## animation_get_elapsed ### Description Get the current location in the animation. ### Parameters #### Path Parameters - **animation** (Animation *) - Required - The animation for which to fetch the elapsed. - **elapsed_ms** (int32_t *) - Output - pointer to variable that will contain the elapsed time in milliseconds ### Returns true if successful, false on failure ### Note The animation must be scheduled to get the elapsed time. If it is not schedule, this method will return false. ``` -------------------------------- ### GPath Creation and Drawing Example Source: https://developer.repebble.com/docs/c/group___path_drawing.html Demonstrates how to create, configure, and draw a GPath using the Pebble C API. This includes setting fill and stroke colors, rotating, and translating the path. ```APIDOC ## GPath Creation and Drawing Example ### Description This example shows the lifecycle of a `GPath` object, from creation using `gpath_create` with a `GPathInfo` structure, to configuration with `gpath_rotate_to` and `gpath_move_to`, and finally drawing it as both filled and outlined shapes using `gpath_draw_filled` and `gpath_draw_outline`. ### Code ```c static GPath *s_my_path_ptr = NULL; static const GPathInfo BOLT_PATH_INFO = { .num_points = 6, .points = (GPoint []) {{21, 0}, {14, 26}, {28, 26}, {7, 60}, {14, 34}, {0, 34}} }; // .update_proc of my_layer: void my_layer_update_proc(Layer *my_layer, GContext* ctx) { // Fill the path: graphics_context_set_fill_color(ctx, GColorWhite); gpath_draw_filled(ctx, s_my_path_ptr); // Stroke the path: graphics_context_set_stroke_color(ctx, GColorBlack); gpath_draw_outline(ctx, s_my_path_ptr); } void setup_my_path(void) { s_my_path_ptr = gpath_create(&BOLT_PATH_INFO); // Rotate 15 degrees: gpath_rotate_to(s_my_path_ptr, TRIG_MAX_ANGLE / 360 * 15); // Translate by (5, 5): gpath_move_to(s_my_path_ptr, GPoint(5, 5)); } // For brevity, the setup of my_layer is not written out... ``` ``` -------------------------------- ### Create, Log, and Finish Data Logging Session Source: https://developer.repebble.com/docs/c/Foundation/DataLogging Demonstrates creating a data logging session for 4-byte unsigned integers, logging multiple data blocks, and finishing the session. Ensure to close the session when no more data needs to be logged. ```c DataLoggingSessionRef logging_session = data_logging_create(0x1234, DATA_LOGGING_UINT, 4, false); // Fake creating some data and logging it to the session. uint32_t data[] = { 1, 2, 3}; data_logging_log(logging_session, &data, 3); // Fake creating more data and logging that as well. uint32_t data2[] = { 1, 2 }; data_logging_log(logging_session, &data, 2); // When we don't need to log anything else, we can close off the session. data_logging_finish(logging_session); ``` -------------------------------- ### Implement Long Click Start Handler Source: https://developer.repebble.com/docs/c/User_Interface/Clicks Implement the handler for the start of a long click event. This function is called when a button is held down for the specified duration. ```c void select_long_click_handler(ClickRecognizerRef recognizer, void *context) { ... called on long click start ... Window *window = (Window *)context; } ``` -------------------------------- ### Click Configuration Source: https://developer.repebble.com/docs/c/User_Interface/Clicks This section shows how to set up click configurations and handlers for different types of clicks. ```APIDOC ## Click Configuration ### Description Associate a click config provider callback with your window and then define button-specific configurations within that callback. ### Usage 1. **Initialize App**: Set the click config provider during application initialization. ```c void app_init(void) { // ... window_set_click_config_provider(&window, (ClickConfigProvider) config_provider); // ... } ``` 2. **Define Callback**: Implement the `config_provider` to subscribe to different click events. ```c void config_provider(Window *window) { // Single click / repeat-on-hold config: window_single_click_subscribe(BUTTON_ID_DOWN, down_single_click_handler); window_single_repeating_click_subscribe(BUTTON_ID_SELECT, 1000, select_single_click_handler); // Multi click config: window_multi_click_subscribe(BUTTON_ID_SELECT, 2, 10, 0, true, select_multi_click_handler); // Long click config: window_long_click_subscribe(BUTTON_ID_SELECT, 700, select_long_click_handler, select_long_click_release_handler); } ``` ### Handlers Implement the following handler functions for the subscribed click events: - **Single Click Handler**: Called on a single click. ```c void down_single_click_handler(ClickRecognizerRef recognizer, void *context) { // ... called on single click ... Window *window = (Window *)context; } ``` - **Repeating Single Click Handler**: Called on single click and repeatedly while held. ```c void select_single_click_handler(ClickRecognizerRef recognizer, void *context) { // ... called on single click, and every 1000ms of being held ... Window *window = (Window *)context; } ``` - **Multi-Click Handler**: Called for recognized multi-click patterns. ```c void select_multi_click_handler(ClickRecognizerRef recognizer, void *context) { // ... called for multi-clicks ... Window *window = (Window *)context; const uint16_t count = click_number_of_clicks_counted(recognizer); } ``` - **Long Click Handler**: Called when a long click begins. ```c void select_long_click_handler(ClickRecognizerRef recognizer, void *context) { // ... called on long click start ... Window *window = (Window *)context; } ``` - **Long Click Release Handler**: Called when a long click is released. ```c void select_long_click_release_handler(ClickRecognizerRef recognizer, void *context) { // ... called when long click is released ... Window *window = (Window *)context; } ``` ``` -------------------------------- ### sportsAppLaunch: Source: https://developer.repebble.com/docs/pebblekit-ios/Classes/PBWatch Sends a command to launch the sports app on the watch. This method must be called from the main thread. ```APIDOC ## sportsAppLaunch: ### Description Send a command to launch the sports app on the watch that the receiver represents. ### Method `- (void)sportsAppLaunch:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))_onSent_` ### Parameters #### onSent_ - The handler that will be called when the launch command has been sent or timed out (after 1.5 secs). - `watch`: the recipient of the command. - `error`: nil if the operation was successful, or else an NSError with more information on why it failed. ### Discussion Must be called from the main thread. ``` -------------------------------- ### number_window_get_value Source: https://developer.repebble.com/docs/symbols Gets the current value. ```APIDOC ## number_window_get_value ### Description Gets the current value. ### Method (Not specified, assumed C function call) ### Endpoint (Not applicable) ### Parameters (None specified) ### Request Example (Not applicable) ### Response (Current value, type not specified) ``` -------------------------------- ### gbitmap_get_format Source: https://developer.repebble.com/docs/c/group___graphics_types.html Get the GBitmapFormat for the GBitmap. ```APIDOC ## gbitmap_get_format ### Description Get the GBitmapFormat for the GBitmap. ### Parameters bitmap A pointer to the GBitmap to get the format ### Returns The format of the given GBitmap. ``` -------------------------------- ### Click Configuration and Handlers Source: https://developer.repebble.com/docs/c/group___clicks.html This section shows how to associate a click configuration provider with a window and define handlers for different click types. ```APIDOC ## Usage Example First associate a click config provider callback with your window: ```c void app_init(void) { ... window_set_click_config_provider(&window, (ClickConfigProvider) config_provider); ... } ``` Then in the callback, you set your desired configuration for each button: ```c void config_provider(Window *window) { // single click / repeat-on-hold config: window_single_click_subscribe(BUTTON_ID_DOWN, down_single_click_handler); window_single_repeating_click_subscribe(BUTTON_ID_SELECT, 1000, select_single_click_handler); // multi click config: window_multi_click_subscribe(BUTTON_ID_SELECT, 2, 10, 0, true, select_multi_click_handler); // long click config: window_long_click_subscribe(BUTTON_ID_SELECT, 700, select_long_click_handler, select_long_click_release_handler); } ``` Now you implement the handlers for each click you've subscribed to and set up: ```c void down_single_click_handler(ClickRecognizerRef recognizer, void *context) { ... called on single click ... Window *window = (Window *)context; } void select_single_click_handler(ClickRecognizerRef recognizer, void *context) { ... called on single click, and every 1000ms of being held ... Window *window = (Window *)context; } void select_multi_click_handler(ClickRecognizerRef recognizer, void *context) { ... called for multi-clicks ... Window *window = (Window *)context; const uint16_t count = click_number_of_clicks_counted(recognizer); } void select_long_click_handler(ClickRecognizerRef recognizer, void *context) { ... called on long click start ... Window *window = (Window *)context; } void select_long_click_release_handler(ClickRecognizerRef recognizer, void *context) { ... called when long click is released ... Window *window = (Window *)context; } ``` ``` -------------------------------- ### layer_get_hidden Source: https://developer.repebble.com/docs/c/User_Interface/Layers Gets the visibility of the layer. ```APIDOC ## layer_get_hidden ### Description Gets the visibility of the layer. ### Parameters - **layer** (const Layer *) - The layer for which to get the visibility. ### Returns True if the layer is hidden, false if it is not hidden. ``` -------------------------------- ### layer_get_bounds Source: https://developer.repebble.com/docs/c/User_Interface/Layers Gets the bounds of the layer. ```APIDOC ## layer_get_bounds ### Description Gets the bounds of the layer. ### Parameters #### Path Parameters - **layer** (const Layer *) - Required - The layer for which to get the bounds. ### Returns - GRect - The bounds of the layer. #### See Also - layer_set_bounds ``` -------------------------------- ### launch_reason Source: https://developer.repebble.com/docs/c/Foundation/Launch_Reason Provides the method used to launch the current application. ```APIDOC ## launch_reason ### Description Provides the method used to launch the current application. ### Signature AppLaunchReason launch_reason(void) ### Returns The method or reason the current application was launched ``` -------------------------------- ### number_window_create Source: https://developer.repebble.com/docs/symbols Creates a new NumberWindow on the heap and initalizes it with the default values. ```APIDOC ## number_window_create ### Description Creates a new NumberWindow on the heap and initalizes it with the default values. ### Method (Not specified, assumed C function call) ### Endpoint (Not applicable) ### Parameters (None specified) ### Request Example (Not applicable) ### Response (Not specified) ``` -------------------------------- ### watchDidDisconnect: Source: https://developer.repebble.com/docs/pebblekit-ios/Classes/Protocols/PBWatchDelegate.html Called when the watch gets disconnected. ```APIDOC ## watchDidDisconnect: ### Description Called when the watch gets disconnected. ### Method `- (void)watchDidDisconnect:(PBWatch *)_watch_` ### Parameters #### Parameters _watch_ The watch that was disconnected. ### Declared In `PBWatch.h` ``` -------------------------------- ### PBSemanticVersion Initialization Methods Source: https://developer.repebble.com/docs/symbols Methods for initializing PBSemanticVersion objects. ```APIDOC ## initWithVersionString: ### Description Returns a new instance by parsing the input. Expected format: major.minor.revision-sffix. Example: “2.0.1-rc2”. If a parsing error occurs, nil will be returned. ### Parameters - **versionString** (NSString *) - Expected format: major.minor.revision-sffix. ### Return Value A version or nil if some error happen. ### Declared In PBSemanticVersion.h ``` ```APIDOC ## initWithMajor:minor:revision:suffix: ### Description Returns a new instance by using the given components. ### Parameters - **major** (NSUInteger) - The version major number. - **minor** (NSUInteger) - The version minor number. - **revision** (NSUInteger) - The version revision number. - **suffix** (nullable NSString *) - The version suffix. Can be nil. ### Declared In PBSemanticVersion.h ``` -------------------------------- ### gbitmap_get_palette Source: https://developer.repebble.com/docs/c/group___graphics_types.html Get the palette for the given GBitmap. ```APIDOC ## gbitmap_get_palette ### Description Get the palette for the given GBitmap. ### Parameters bitmap A pointer to the GBitmap to get the palette from. ### Returns Pointer to a GColor array containing the palette colors. ``` -------------------------------- ### menu_layer_create Source: https://developer.repebble.com/docs/c/struct_menu_index.html Creates a new MenuLayer on the heap and initializes it with default values. Returns a pointer to the MenuLayer or NULL if creation fails. ```APIDOC ## menu_layer_create ### Description Creates a new MenuLayer on the heap and initalizes it with the default values. * Clips: `true` * Hidden: `false` * Content size: `frame.size` * Content offset: GPointZero * Callbacks: None (`NULL` for each one) * Callback context: `NULL` * After the relevant callbacks are called to populate the menu, the item at MenuIndex(0, 0) will be selected initially. ### Parameters #### Path Parameters * **frame** (GRect) - Required - The frame for the MenuLayer. ### Returns A pointer to the MenuLayer. `NULL` if the MenuLayer could not be created ``` -------------------------------- ### animation_get_implementation Source: https://developer.repebble.com/docs/c/User_Interface/Animation Gets the implementation of a custom animation. ```APIDOC ## animation_get_implementation ### Description Gets the implementation of the custom animation. ### Parameters #### Path Parameters - **animation** (Animation *) - The animation for which to get the implementation. ### Returns - const AnimationImplementation * - NULL if animation implementation has not been setup. ``` -------------------------------- ### appMessagesLaunch: Source: https://developer.repebble.com/docs/pebblekit-ios/Classes/PBWatch Sends a command to launch the watch application associated with the UUID set via `PBPebbleCentral setAppUUID:`. ```APIDOC ## appMessagesLaunch: ### Description Sends a command to launch the watch application with UUID as set using `[PBPebbleCentral setAppUUID:]`. ### Method - (void)appMessagesLaunch:(void ( ^ __nullable ) ( PBWatch *watch , NSError *__nullable error ))_onSent_ ### Parameters #### _onSent_ - The block that will be called after the launch command has been sent to the watch. - **watch** (PBWatch *) - The watch to which the command was sent. - **error** (NSError *__nullable) - If there was a problem, this will contain information about the underlying problem. See `PBErrorCode` for error codes. ### Discussion Must be called from the main thread. ``` -------------------------------- ### PBPebbleKitLogging.h Source: https://developer.repebble.com/docs/symbols Methods for configuring logging levels. ```APIDOC ## setLogLevel: ### Description Configures which events should be logged. Use `PBPebbleKitLogLevelOff` to disable all logging. ### Method `+ (void)setLogLevel:(PBPebbleKitLogLevel)logLevel` ### Parameters - **logLevel** (PBPebbleKitLogLevel) - One of the values in `PBPebbleKitLogLevel`, which will be the maximum level that will be logged. ### Declared In PBLog+Public.h ``` -------------------------------- ### animation_get_curve Source: https://developer.repebble.com/docs/c/User_Interface/Animation Gets the animation curve for the animation. ```APIDOC ## animation_get_curve ### Description Gets the animation curve for the animation. ### Parameters - **animation** (Animation *) - The animation for which to get the curve. ### Returns - AnimationCurve - The type of curve. ``` -------------------------------- ### GBitmap Format Source: https://developer.repebble.com/docs/c/Graphics/Graphics_Types Gets the GBitmapFormat for the GBitmap. ```APIDOC ## gbitmap_get_format ### Description Get the GBitmapFormat for the GBitmap. ### Parameters * **bitmap** (in) A pointer to the GBitmap to get the format ### Returns The format of the given GBitmap. ``` -------------------------------- ### Window Click Configuration Source: https://developer.repebble.com/docs/c/User_Interface/Window Functions for setting up click event handlers for a window. ```APIDOC ## window_set_click_config_provider ### Description Sets the click configuration provider callback function on the window. This will automatically setup the input handlers of the window as well to use the click recognizer subsystem. ### Parameters * **window** (Window *) - The window for which to set the click config provider. * **click_config_provider** (ClickConfigProvider) - The callback that will be called to configure the click recognizers with the window. ### See Also Clicks ClickConfigProvider ## window_set_click_config_provider_with_context ### Description Same as `window_set_click_config_provider()`, but will assign a custom context pointer (instead of the window pointer) that will be passed into the `ClickHandler` click event handlers. ``` -------------------------------- ### menu_layer_create Source: https://developer.repebble.com/docs/c/User_Interface/Layers/MenuLayer Creates a new MenuLayer on the heap and initializes it with default values. ```APIDOC ## menu_layer_create ### Description Creates a new MenuLayer on the heap and initalizes it with the default values. * Clips: `true` * Hidden: `false` * Content size: `frame.size` * Content offset: GPointZero * Callbacks: None (`NULL` for each one) * Callback context: `NULL` * After the relevant callbacks are called to populate the menu, the item at MenuIndex(0, 0) will be selected initially. ### Parameters * **frame** (GRect) - The frame for the MenuLayer. ### Returns A pointer to the MenuLayer. `NULL` if the MenuLayer could not be created ``` -------------------------------- ### status_bar_layer_get_foreground_color Source: https://developer.repebble.com/docs/c/User_Interface/Layers/StatusBarLayer Gets the foreground color of the StatusBarLayer. ```APIDOC ## status_bar_layer_get_foreground_color ### Description Gets foreground color of StatusBarLayer. ### Parameters - **status_bar_layer** (*const StatusBarLayer *) - The StatusBarLayer of which to get the color. ### Returns GColor of foreground color property. ``` -------------------------------- ### app_sync_init Source: https://developer.repebble.com/docs/c/group___app_sync.html Initializes an AppSync system with a specified buffer size and initial keys/values. The `tuple_changed_callback` is invoked asynchronously with initial values. ```APIDOC ## app_sync_init ### Description Initialized an AppSync system with specific buffer size and initial keys and values. The `callback.value_changed` callback will be called **asynchronously** with the initial keys and values, as to avoid duplicating code to update your app's UI. ##### Note Only updates for the keys specified in this initial array will be accepted by AppSync, updates for other keys that might come in will just be ignored. ### Parameters s The AppSync context to initialize buffer The buffer that AppSync should use buffer_size The size of the backing storage of the "current" dictionary. Use dict_calc_buffer_size_from_tuplets() to estimate the size you need. keys_and_initial_values An array of Tuplets with the initial keys and values. count The number of Tuplets in the `keys_and_initial_values` array. tuple_changed_callback The callback that will handle changed key/value pairs error_callback The callback that will handle errors context Pointer to app specific data that will get passed into calls to the callbacks ### Signature void app_sync_init(struct AppSync * s, uint8_t * buffer, const uint16_t buffer_size, const Tuplet *const keys_and_initial_values, const uint8_t count, AppSyncTupleChangedCallback tuple_changed_callback, AppSyncErrorCallback error_callback, void * context) ``` -------------------------------- ### status_bar_layer_get_background_color Source: https://developer.repebble.com/docs/c/User_Interface/Layers/StatusBarLayer Gets the background color of the StatusBarLayer. ```APIDOC ## status_bar_layer_get_background_color ### Description Gets background color of StatusBarLayer. ### Parameters - **status_bar_layer** (*const StatusBarLayer *) - The StatusBarLayer of which to get the color. ### Returns GColor of background color property. ``` -------------------------------- ### GDrawCommand Type Source: https://developer.repebble.com/docs/c/Graphics/Draw_Commands Get the type of a GDrawCommand. ```APIDOC ## gdraw_command_get_type ### Description Get the command type. ### Signature ```c GDrawCommandType gdraw_command_get_type(GDrawCommand * command) ``` ### Parameters * **command** (GDrawCommand *) - GDrawCommand from which to get the type ``` -------------------------------- ### sportsAppLaunch: Source: https://developer.repebble.com/docs/symbols Send a command to launch the sports app on the watch that the receiver represents. This method must be called from the main thread, and before sportsAppSetMetric:onSent: or sportsAppUpdate:onSent:. ```APIDOC ## sportsAppLaunch: ### Description Send a command to launch the sports app on the watch that the receiver represents. ### Method Objective-C method signature ### Parameters #### Path Parameters - **onSent** (void (^ __nullable )(PBWatch *watch, NSError *__nullable error)) - Required - The handler that will be called when the launch command has been sent or timed out (after 1.5 secs). ### Discussion Must be called from the main thread, and before sportsAppSetMetric:onSent: or sportsAppUpdate:onSent:. ``` -------------------------------- ### delegate Source: https://developer.repebble.com/docs/symbols Sets or gets the central’s delegate. ```APIDOC ## delegate ### Description The central’s delegate. ### Property @property (nonatomic, readwrite, weak) id __nullable delegate ### Declared In PBPebbleCentral.h ``` -------------------------------- ### app_sync_init Source: https://developer.repebble.com/docs/c/Foundation/AppSync Initializes an AppSync system with specific buffer size and initial keys and values. The `callback.value_changed` callback will be called asynchronously with the initial keys and values. ```APIDOC ## app_sync_init ### Description Initialized an AppSync system with specific buffer size and initial keys and values. The `callback.value_changed` callback will be called **asynchronously** with the initial keys and values, as to avoid duplicating code to update your app's UI. ##### Note Only updates for the keys specified in this initial array will be accepted by AppSync, updates for other keys that might come in will just be ignored. ### Parameters s The AppSync context to initialize buffer The buffer that AppSync should use buffer_size The size of the backing storage of the "current" dictionary. Use dict_calc_buffer_size_from_tuplets() to estimate the size you need. keys_and_initial_values An array of Tuplets with the initial keys and values. count The number of Tuplets in the `keys_and_initial_values` array. tuple_changed_callback The callback that will handle changed key/value pairs error_callback The callback that will handle errors context Pointer to app specific data that will get passed into calls to the callbacks ### Signature void app_sync_init(struct AppSync * s, uint8_t * buffer, const uint16_t buffer_size, const Tuplet *const keys_and_initial_values, const uint8_t count, AppSyncTupleChangedCallback tuple_changed_callback, AppSyncErrorCallback error_callback, void * context) ``` -------------------------------- ### Get Format Source: https://developer.repebble.com/docs/c/struct_g_bitmap_data_row_info.html Retrieves the pixel format of the GBitmap. ```APIDOC ## GBitmapFormat gbitmap_get_format(const GBitmap * bitmap) ### Description Get the GBitmapFormat for the GBitmap. ### Parameters - **bitmap** (const GBitmap *) A pointer to the GBitmap to get the format ### Returns The format of the given GBitmap. ``` -------------------------------- ### Create and Start Moddable XS VM (Alloy) Source: https://developer.repebble.com/docs/c/group___alloy.html Use `moddable_createMachine` to initialize and run a Moddable XS virtual machine for an Alloy application. Pass a `ModdableCreationRecord` for custom settings or NULL for defaults. ```c void moddable_createMachine(ModdableCreationRecord * creation) ``` -------------------------------- ### Load Resource Data (C) Source: https://developer.repebble.com/docs/c/Foundation/Resources Copies the entire content of a resource into a provided buffer. Ensure the buffer is large enough to hold the resource data to prevent overflows. ```c size_t resource_load(ResHandle h, uint8_t * buffer, size_t max_length); ```