This is an example HTML forms configuration page.
``` -------------------------------- ### Building Nanopb Example with CMake (Bash) Source: https://github.com/google/pebble/blob/main/third_party/nanopb/examples/cmake_simple/README.txt This script demonstrates the process of building a nanopb example using CMake on a Linux system. It involves creating a build directory, running CMake, compiling the code using make, and then executing the resulting binary. The process assumes a CMake-compatible environment is already set up. ```bash mkdir build cd build/ cmake .. make ``` ```bash ./simple ``` -------------------------------- ### Installing Pebble App via Different Connection Methods Using Shell Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/tools-and-resources/pebble-tool.md Demonstrates how to install a Pebble app to a physical watch or emulator via multiple connection types: Wi-Fi phone IP, QEMU instance, local serial Bluetooth connection, and CloudPebble proxy. Each command shows the use of the `pebble install` command with flags specifying connection details. Dependencies include access to a Pebble watch or an emulator instance and proper phone or device configuration. Inputs include IP address, host and port, or serial device path. Outputs are app installations onto the target Pebble device or emulator. ```shell $ pebble install --phone IP ``` ```shell $ pebble install --qemu HOST:PORT ``` ```shell $ pebble install --serial SERIAL ``` ```shell $ pebble install --cloudpebble ``` -------------------------------- ### Install Latest SDK Using Pebble Tool Source: https://github.com/google/pebble/blob/main/devsite/source/sdk/download.md This command installs the latest available SDK version using the `pebble` tool. It assumes that the `pebble` tool is already installed and configured. The `latest` argument specifies that the newest available SDK should be installed. The output typically shows the download progress and installation status. ```bash $ pebble sdk install latest ``` -------------------------------- ### Installing pblconvert using pip Source: https://github.com/google/pebble/blob/main/third_party/pbl/pblconvert/README.rst This snippet demonstrates how to install the pblconvert tool using pip. It utilizes the 'pip install .' command to install the tool from the current directory. This assumes that the project has a setup.py file configured correctly. The installation makes the tool available for use in the user's environment. ```Bash $ pip install . ``` -------------------------------- ### Initializing Setup and Loop Functions Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/smartstraps/talking-to-pebble.md Defines the standard `setup()` and `loop()` functions, which are the main components of an Arduino sketch. The `setup()` function is used to initialize the serial communication and other configurations, and the `loop()` function runs repeatedly to handle the main program logic. ```c++ void setup() { } void loop() { } ``` -------------------------------- ### Creating New Rocky.js Project via CLI Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/rocky-js/rocky-js-overview.md This snippet provides an example of creating a new Rocky.js project using the Pebble SDK command-line interface. It requires the Pebble SDK to be installed and properly configured. ```text $ pebble new-project --rocky projectname ``` -------------------------------- ### Initializing PebbleKit in Swift Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/migration/pebblekit-ios-3.md This Swift code snippet demonstrates the basic initialization of PebbleKit in a Swift project. It sets the appUUID and delegate, and then starts the central manager. ```Swift func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { let pebbleCentral = PBPebbleCentral.defaultCentral() pebbleCentral.appUUID = PBGolfUUID pebbleCentral.delegate = self pebbleCentral.run() return true } ``` -------------------------------- ### Opening Configuration URL (PebbleKit JS) Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/user-interfaces/app-configuration-static.md This JavaScript code snippet, within a `showConfiguration` event listener, opens the developer's custom configuration HTML page using `Pebble.openURL()`. Requires the PebbleKit JS library to be included in the project. ```JavaScript Pebble.addEventListener('showConfiguration', function() { var url = 'http://example.com/config.html'; Pebble.openURL(url); }); ``` -------------------------------- ### Initializing PebbleKit JS & Handling Events Source: https://github.com/google/pebble/blob/main/devsite/source/tutorials/watchface-tutorial/part3.md This JavaScript snippet demonstrates the basic setup for PebbleKit JS. It includes event listeners for the 'ready' and 'appmessage' events, providing a starting point for watchface functionality. It requires PebbleKit JS library and a Pebble watch. ```JavaScript // Listen for when the watchface is opened Pebble.addEventListener('ready', function(e) { console.log('PebbleKit JS ready!'); } ); // Listen for when an AppMessage is received Pebble.addEventListener('appmessage', function(e) { console.log('AppMessage received!'); } ); ``` -------------------------------- ### Setting PATH Environment Variable Source: https://github.com/google/pebble/blob/main/third_party/jerryscript/targets/esp8266/docs/ESP-PREREQUISITES.md Adds the crosstool-NG build directory to the PATH environment variable. This allows the system to find the compiled Xtensa toolchain. Requires editing a shell configuration file such as .profile or .bashrc. ```bash PATH=$PWD/builds/xtensa-lx106-elf/bin:$PATH ``` -------------------------------- ### Video Feature YAML Example Source: https://github.com/google/pebble/blob/main/devsite/README.md This YAML code defines a video feature for the landing page's slideshow. It specifies the title, target URL, background image, video URL (hosted on S3), button text and colors, and duration. This sets up a landing page video element. ```yaml - title: Send a Smile with Android Actionable Notifications url: /blog/2014/12/19/Leverage-Android-Actionable-Notifications/ background_image: /images/landing-page/actionable-notifications.png video: url: https://s3.amazonaws.com/developer.getpebble.com/videos/actionable-notifications.mp4 button_text: Learn how to supercharge Your Android Apps button_fg: white button_bg: green duration: 5000 ``` -------------------------------- ### Installing with Emulator Source: https://github.com/google/pebble/blob/main/devsite/source/_posts/2015-12-01-A-New-Pebble-Tool.md This snippet illustrates how to install an application using the emulator while specifying a particular SDK version using the `--sdk` flag. This allows developers to install on a specific SDK version, useful when using different SDK versions in build and install commands. ```text katharine@kbrmbp ~> pebble install --emulator basalt --sdk 3.7 ``` -------------------------------- ### Installing pbl using pip Source: https://github.com/google/pebble/blob/main/third_party/pbl/pbl/README.md This command installs the `pbl` tool from a Git repository using pip. The `git+ssh://...` specifies the Git repository's SSH URL. The installation is required to use the `pbl` tool. There are no specific dependencies mentioned other than pip and git. This will install the `pbl` tool and make it available for use. ```shell pip install git+ssh://git@github.com/pebble/pbl.git ``` -------------------------------- ### Install Pebble SDK with Homebrew Source: https://github.com/google/pebble/blob/main/devsite/source/sdk/download.md This command installs the Pebble SDK using Homebrew. The command first updates the package lists and then installs the pebble-sdk package. This is used when the user has not previously installed the Pebble SDK with Homebrew. The `brew` command is used to manage packages. ```bash $ brew update && brew install pebble/pebble-sdk/pebble-sdk ``` -------------------------------- ### Creating a Directory for Pebble Tools - Bash Source: https://github.com/google/pebble/blob/main/devsite/source/_includes/sdk/steps_install_sdk.md This snippet creates a directory to host all Pebble tools. It uses the `mkdir` command followed by the directory path specified by `site.data.sdk.path`. This directory is where the Pebble SDK will be extracted. ```Bash mkdir {{ site.data.sdk.path }} ``` -------------------------------- ### Pebble SDK 2.x App Initialization (C) Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/migration/migration-guide.md Shows the simplified app initialization in Pebble SDK 2.x using `main()`, directly calling `handle_init()` and `handle_deinit()`. This is a revised approach compared to the SDK 1.x method. ```c int main(void) { handle_init(); app_event_loop(); handle_deinit(); } ``` -------------------------------- ### Installing Pebble Clay Package Source: https://github.com/google/pebble/blob/main/devsite/source/_posts/2016-06-24-introducing-clay.md This code snippet demonstrates how to install the Clay module via the Pebble Packages command-line tool or by adding the dependency to your CloudPebble project. It is a prerequisite for using the Clay configuration framework in a Pebble app. It specifies the command to install the package with SDK and how to add the dependency for CloudPebble. ```bash $ pebble package install pebble-clay ``` -------------------------------- ### Markdown Emoji Example Source: https://github.com/google/pebble/blob/main/devsite/docs/markdown.md This snippet demonstrates the use of emoji in Markdown using the colon syntax. It shows an example of how to include an emoji in text. ```markdown If you're a beginner Pebble developer, you should use :cloud:Pebble ``` -------------------------------- ### Markdown Table Example Source: https://github.com/google/pebble/blob/main/devsite/docs/markdown.md This snippet provides an example of a Markdown table using the PHP Markdown Extra syntax. It shows the basic structure of a table with headers and content cells. ```markdown | First Header | Second Header | | ------------- | ------------- | | Content Cell | Content Cell | | Content Cell | Content Cell | ``` -------------------------------- ### Pebble SDK 1.x App Initialization (C) Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/migration/migration-guide.md Shows the app initialization in Pebble SDK 1.x using `pbl_main()` and `PebbleAppHandlers`. This is contrasted with the SDK 2.x approach in another snippet. ```c void pbl_main(void *params) { PebbleAppHandlers handlers = { .init_handler = &handle_init }; app_event_loop(params, &handlers); } ``` -------------------------------- ### Installing and Launching Pebble App with GDB Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/debugging/debugging-with-gdb.md This snippet demonstrates the commands to install a Pebble app into the emulator and then launch it under the GDB debugger. Requires the Pebble Tool to be installed and configured. The output shows the GDB prompt, indicating readiness for debugging commands. ```text $ pebble install --emulator basalt $ pebble gdb --emulator basalt ``` -------------------------------- ### Building and Installing with Pebble Tool - Shell Source: https://github.com/google/pebble/blob/main/devsite/source/_posts/2016-05-16-Pebble-JS-Round.md This shell snippet shows the command to build and install a Pebble project on the Chalk emulator. The `pebble clean` command is used to remove all generated files, then `pebble build && pebble install --emulator=chalk --logs` builds the project and installs it on the Chalk emulator. ```Shell > pebble clean > pebble build && pebble install --emulator=chalk --logs ``` -------------------------------- ### JerryScript Simple Run Example (C) Source: https://github.com/google/pebble/blob/main/third_party/jerryscript/docs/02.API-REFERENCE.md Demonstrates a simple execution of JavaScript code within JerryScript. Shows how to use jerry_run_simple to execute a short script. No dependencies besides the JerryScript library. Prints \"Hello, World!\" to the console. ```C { const jerry_char_t *script = \"print ('Hello, World!');\"; jerry_run_simple (script, strlen ((const char *) script), JERRY_INIT_EMPTY); } ``` -------------------------------- ### Installing pip and virtualenv with Bash Source: https://github.com/google/pebble/blob/main/devsite/source/_includes/sdk/steps_python.md This snippet demonstrates installing pip and virtualenv on macOS using easy_install or on Linux using apt-get. These tools are prerequisites for managing Python dependencies needed by Pebble SDK. 'pip' enables Python package management, while 'virtualenv' is required for isolated environment setup. ```bash sudo easy_install pip sudo pip install virtualenv ``` ```bash sudo apt-get install python-pip python2.7-dev sudo pip install virtualenv ``` -------------------------------- ### Pebble SDK 2.0 Build Process (C) Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/migration/migration-guide.md Illustrates the simplified build process using the `pebble build` command. This snippet shows the output of the build process, including memory usage information. Requires the Pebble SDK 2.0 and a correctly configured project. ```bash $ pebble build ... Memory usage: ============= Total app footprint in RAM: 801 bytes / ~24kb Free RAM available (heap): 23775 bytes [12\/13] inject-metadata: build\/pebble-app.raw.bin build\/app_resources.pbpack.data -> build\/pebble-app.bin [13\/13] helloworld.pbw: build\/pebble-app.bin build\/app_resources.pbpack -> build\/helloworld.pbw ... 'build' finished successfully (0.562s) ``` -------------------------------- ### Output of Global Object Method Example (Bash) Source: https://github.com/google/pebble/blob/main/third_party/jerryscript/docs/03.API-EXAMPLE.md Shows the expected console output generated when the JerryScript engine executes the JavaScript script in the first C example, which calls the native `MyObject.myFunc()` method. ```Bash Hello World ``` -------------------------------- ### JavaScript Code Block Example Source: https://github.com/google/pebble/blob/main/devsite/docs/markdown.md This snippet provides a basic example of a JavaScript code block within Markdown. It demonstrates the use of triple backticks to denote a code block and the specification of the language for syntax highlighting. Click to copy functionality is enabled by default. ```javascript var foo = 'bar'; ``` -------------------------------- ### Client Execution and Directory Listing Request Source: https://github.com/google/pebble/blob/main/third_party/nanopb/examples/network_server/README.txt Executes the compiled client, passing the directory `/bin` as an argument. The client connects to the server and requests a listing of the specified directory. The server responds with the file listing. ```Bash ./client /bin ``` -------------------------------- ### FreeRTOS Task Function: Get Stack Start Address (C) Source: https://github.com/google/pebble/blob/main/devsite/source/_posts/2014-10-10-FreeRTOS-Modifications-From-Pebble-v2.md This function retrieves the starting memory address of a task's stack space. It's useful for implementing routines that check available stack space to prevent stack overflow errors. ```C uintptr_t ulTaskGetStackStart( xTaskHandle xTask ); ``` -------------------------------- ### Installing Clay - CLI Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/user-interfaces/app-configuration.md This code snippet shows how to install the pebble-clay package using the Pebble command-line interface (CLI). This command must be executed within the project folder. ```text $ pebble package install pebble-clay ``` -------------------------------- ### Setting Up Express Server - JavaScript Source: https://github.com/google/pebble/blob/main/devsite/source/_posts/2015-03-20-Getting-Started-With-Timeline.md This code sets up a basic Express server. It imports the necessary modules (Express and the pebble-api module). The server listens on port 5000 or the environment's PORT. A route for the root ('/') is defined to return a 'Hello, world!' message. Dependencies are Express and pebble-api. ```javascript var express = require('express'); var request = require('request'); var Timeline = require('pebble-api'); var app = express(); app.set('port', (process.env.PORT || 5000)); var timeline = new Timeline(); app.get('/', function(req, res) { res.send('Hello, world!'); }); // start the webserver var server = app.listen(app.get('port'), function () { console.log('Package Tracker server listening on port %s', app.get('port')); }); ``` -------------------------------- ### Set and Get Native Handle on JerryScript Object in C Source: https://github.com/google/pebble/blob/main/third_party/jerryscript/docs/02.API-REFERENCE.md This example, also shown for `jerry_get_object_native_handle`, demonstrates associating a native handle (`handle_set`) with a JerryScript object (`object`) using `jerry_set_object_native_handle` and then retrieving it using `jerry_get_object_native_handle`. It illustrates the basic usage of setting and getting handles. ```C { jerry_value_t object; uintptr_t handle_set; ... // receive or construct object and handle_set value jerry_set_object_native_handle (object, handle_set, NULL); ... uintptr_t handle_get; bool is_there_associated_handle = jerry_get_object_native_handle (object, &handle_get); } ``` -------------------------------- ### Pebble Timeline Pin Pushing: Python Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/pebble-timeline/timeline-libraries.md This Python code utilizes the `pypebbleapi` library to send shared pins to the Pebble timeline. It requires installing the library via pip. The example creates a pin with an ID and date, and sends it to specified topics using the `send_shared_pin` method. Error handling is not explicitly shown in this example. ```python from pypebbleapi import Timeline, Pin import datetime timeline = Timeline(my_api_key) my_pin = Pin(id='123', datetime.date.today().isoformat()) timeline.send_shared_pin(['a_topic', 'another_topic'], my_pin) ``` -------------------------------- ### Setting up MenuLayer in C Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/user-interfaces/layers.md This snippet sets up a `MenuLayer` by creating it, configuring click event handling, and assigning the defined callback functions. It enables the user to interact with the menu using up/down and select buttons. The created menu layer is then added to the window. ```C // Create the MenuLayer s_menu_layer = menu_layer_create(bounds); // Let it receive click events menu_layer_set_click_config_onto_window(s_menu_layer, window); // Set the callbacks for behavior and rendering menu_layer_set_callbacks(s_menu_layer, NULL, (MenuLayerCallbacks) { .get_num_rows = get_num_rows_callback, .draw_row = draw_row_callback, .get_cell_height = get_cell_height_callback, .select_click = select_callback, }); // Add to the Window layer_add_child(root_layer, menu_layer_get_layer(s_menu_layer)); ``` -------------------------------- ### Extracting the Pebble SDK - Bash Source: https://github.com/google/pebble/blob/main/devsite/source/_includes/sdk/steps_install_sdk.md This snippet extracts the downloaded Pebble SDK using the `tar` command. It navigates to the directory where the SDK was downloaded and then executes the extraction. The specific file name to extract changes depending on the operating system (macOS or Linux 64-bit). ```Bash cd {{ site.data.sdk.path }} tar -jxf ~/Downloads/pebble-sdk-{{ site.data.sdk.pebble_tool.version }}-{% if include.mac %}mac{% else %}linux64{% endif %}.tar.bz2 ``` -------------------------------- ### Getting message size Source: https://github.com/google/pebble/blob/main/third_party/nanopb/docs/concepts.md This snippet demonstrates how to calculate the encoded size of a message without actually storing the encoded data. It uses a zeroed-out pb_ostream_t stream to encode a Person message. ```C Person myperson = ...; pb_ostream_t sizestream = {0}; pb_encode(&sizestream, Person_fields, &myperson); printf("Encoded size is %d\n", sizestream.bytes_written); ``` -------------------------------- ### Initializing PBPebbleCentral and Handling Onboarding (Objective-C) Source: https://github.com/google/pebble/blob/main/devsite/source/_guides/migration/pebblekit-ios-3.md This code shows how to initialize `PBPebbleCentral` and conditionally run it based on user onboarding status. It demonstrates deferred execution of `[[PBPebbleCentral defaultCentral] run]` to avoid immediate Bluetooth permission prompts and provides a better user experience. ```Objective-C // MyAppDelegate.m - Set up PBPebbleCentral and run if the user has already // performed onboarding - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { [PBPebbleCentral defaultCentral].delegate = self; [PBPebbleCentral defaultCentral].appUUID = myAppUUID; if ([MySettings sharedSettings].userDidPerformOnboarding) { [[PBPebbleCentral defaultCentral] run]; } } ``` ```Objective-C // MyOnboarding.m - Once the pop-up has been accepted, begin PBPebbleCentral - (IBAction)didTapGrantBluetoothPermissionButton:(id)sender { [MySettings sharedSettings].userDidPerformOnboarding = YES; [[PBPebbleCentral defaultCentral] run]; // will trigger pop-up } ``` -------------------------------- ### Install Latest Beta SDK Source: https://github.com/google/pebble/blob/main/devsite/source/sdk/download.md This command installs the latest beta SDK available after setting the channel to beta with `pebble sdk set-channel beta`. This retrieves the latest available beta version. This allows the user to access and test the latest features that are not included in the stable releases of Pebble SDK. ```bash $ pebble sdk install latest ``` -------------------------------- ### Markdown SDK Documentation Links Source: https://github.com/google/pebble/blob/main/devsite/docs/markdown.md This snippet explains how to create links to sections within the SDK documentation using double backticks. It shows examples of creating inline links and links within text. ```markdown This will link to the ``window_create`` documentation. You should check out the page on [Events](``event services``) ``` -------------------------------- ### Liquid Alert Tags in Markdown Source: https://github.com/google/pebble/blob/main/devsite/docs/markdown.md This snippet shows how to use Liquid tags to create alerts with different levels of importance ('important' and 'notice'). It provides examples for both alert types and demonstrates how to specify the alert level. ```liquid {% alert important %} PebbleKit JS and PebbleKit Android/iOS may **not** be used in conjunction. {% endalert %} {% alert notice %} This API is currently in the beta stage, and may be changed before final release. {% endalert %} ``` -------------------------------- ### Initializing Simple Pebble App Source: https://github.com/google/pebble/blob/main/devsite/source/tutorials/advanced/vector-animations.md This code snippet provides the basic structure for a Pebble app, creating a window and defining the necessary load and unload functions. It initializes the app and pushes a blank window onto the stack. ```c #include