mirror of
https://github.com/google/pebble.git
synced 2025-06-12 04:43:10 +00:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
21
sdk/defaults/app/index.js
Normal file
21
sdk/defaults/app/index.js
Normal file
|
@ -0,0 +1,21 @@
|
|||
/**
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
Pebble.addEventListener("ready",
|
||||
function(e) {
|
||||
console.log("Hello world! - Sent from your javascript application.");
|
||||
}
|
||||
);
|
76
sdk/defaults/app/main.c
Normal file
76
sdk/defaults/app/main.c
Normal file
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <pebble.h>
|
||||
|
||||
static Window *s_window;
|
||||
static TextLayer *s_text_layer;
|
||||
|
||||
static void prv_select_click_handler(ClickRecognizerRef recognizer, void *context) {
|
||||
text_layer_set_text(s_text_layer, "Select");
|
||||
}
|
||||
|
||||
static void prv_up_click_handler(ClickRecognizerRef recognizer, void *context) {
|
||||
text_layer_set_text(s_text_layer, "Up");
|
||||
}
|
||||
|
||||
static void prv_down_click_handler(ClickRecognizerRef recognizer, void *context) {
|
||||
text_layer_set_text(s_text_layer, "Down");
|
||||
}
|
||||
|
||||
static void prv_click_config_provider(void *context) {
|
||||
window_single_click_subscribe(BUTTON_ID_SELECT, prv_select_click_handler);
|
||||
window_single_click_subscribe(BUTTON_ID_UP, prv_up_click_handler);
|
||||
window_single_click_subscribe(BUTTON_ID_DOWN, prv_down_click_handler);
|
||||
}
|
||||
|
||||
static void prv_window_load(Window *window) {
|
||||
Layer *window_layer = window_get_root_layer(window);
|
||||
GRect bounds = layer_get_bounds(window_layer);
|
||||
|
||||
s_text_layer = text_layer_create(GRect(0, 72, bounds.size.w, 20));
|
||||
text_layer_set_text(s_text_layer, "Press a button");
|
||||
text_layer_set_text_alignment(s_text_layer, GTextAlignmentCenter);
|
||||
layer_add_child(window_layer, text_layer_get_layer(s_text_layer));
|
||||
}
|
||||
|
||||
static void prv_window_unload(Window *window) {
|
||||
text_layer_destroy(s_text_layer);
|
||||
}
|
||||
|
||||
static void prv_init(void) {
|
||||
s_window = window_create();
|
||||
window_set_click_config_provider(s_window, prv_click_config_provider);
|
||||
window_set_window_handlers(s_window, (WindowHandlers) {
|
||||
.load = prv_window_load,
|
||||
.unload = prv_window_unload,
|
||||
});
|
||||
const bool animated = true;
|
||||
window_stack_push(s_window, animated);
|
||||
}
|
||||
|
||||
static void prv_deinit(void) {
|
||||
window_destroy(s_window);
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
prv_init();
|
||||
|
||||
APP_LOG(APP_LOG_LEVEL_DEBUG, "Done initializing, pushed window: %p", s_window);
|
||||
|
||||
app_event_loop();
|
||||
prv_deinit();
|
||||
}
|
29
sdk/defaults/app/package.json
Normal file
29
sdk/defaults/app/package.json
Normal file
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "${project_name}",
|
||||
"author": "MakeAwesomeHappen",
|
||||
"version": "1.0.0",
|
||||
"keywords": ["pebble-app"],
|
||||
"private": true,
|
||||
"dependencies": {},
|
||||
"pebble": {
|
||||
"displayName": "${display_name}",
|
||||
"uuid": "${uuid}",
|
||||
"sdkVersion": "${sdk_version}",
|
||||
"enableMultiJS": true,
|
||||
"targetPlatforms": [
|
||||
"aplite",
|
||||
"basalt",
|
||||
"chalk",
|
||||
"diorite"
|
||||
],
|
||||
"watchapp": {
|
||||
"watchface": false
|
||||
},
|
||||
"messageKeys": [
|
||||
"dummy"
|
||||
],
|
||||
"resources": {
|
||||
"media": []
|
||||
}
|
||||
}
|
||||
}
|
21
sdk/defaults/app/simple.c
Normal file
21
sdk/defaults/app/simple.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <pebble.h>
|
||||
|
||||
int main(void) {
|
||||
app_event_loop();
|
||||
}
|
21
sdk/defaults/app/worker.c
Normal file
21
sdk/defaults/app/worker.c
Normal file
|
@ -0,0 +1,21 @@
|
|||
/*
|
||||
* Copyright 2024 Google LLC
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <pebble_worker.h>
|
||||
|
||||
int main(void) {
|
||||
worker_event_loop();
|
||||
}
|
54
sdk/defaults/app/wscript
Normal file
54
sdk/defaults/app/wscript
Normal file
|
@ -0,0 +1,54 @@
|
|||
#
|
||||
# This file is the default set of rules to compile a Pebble application.
|
||||
#
|
||||
# Feel free to customize this to your needs.
|
||||
#
|
||||
import os.path
|
||||
|
||||
top = '.'
|
||||
out = 'build'
|
||||
|
||||
|
||||
def options(ctx):
|
||||
ctx.load('pebble_sdk')
|
||||
|
||||
|
||||
def configure(ctx):
|
||||
"""
|
||||
This method is used to configure your build. ctx.load(`pebble_sdk`) automatically configures
|
||||
a build for each valid platform in `targetPlatforms`. Platform-specific configuration: add your
|
||||
change after calling ctx.load('pebble_sdk') and make sure to set the correct environment first.
|
||||
Universal configuration: add your change prior to calling ctx.load('pebble_sdk').
|
||||
"""
|
||||
ctx.load('pebble_sdk')
|
||||
|
||||
|
||||
def build(ctx):
|
||||
ctx.load('pebble_sdk')
|
||||
|
||||
build_worker = os.path.exists('worker_src')
|
||||
binaries = []
|
||||
|
||||
cached_env = ctx.env
|
||||
for platform in ctx.env.TARGET_PLATFORMS:
|
||||
ctx.env = ctx.all_envs[platform]
|
||||
ctx.set_group(ctx.env.PLATFORM_NAME)
|
||||
app_elf = '{}/pebble-app.elf'.format(ctx.env.BUILD_DIR)
|
||||
ctx.pbl_build(source=ctx.path.ant_glob('src/c/**/*.c'), target=app_elf, bin_type='app')
|
||||
|
||||
if build_worker:
|
||||
worker_elf = '{}/pebble-worker.elf'.format(ctx.env.BUILD_DIR)
|
||||
binaries.append({'platform': platform, 'app_elf': app_elf, 'worker_elf': worker_elf})
|
||||
ctx.pbl_build(source=ctx.path.ant_glob('worker_src/c/**/*.c'),
|
||||
target=worker_elf,
|
||||
bin_type='worker')
|
||||
else:
|
||||
binaries.append({'platform': platform, 'app_elf': app_elf})
|
||||
ctx.env = cached_env
|
||||
|
||||
ctx.set_group('bundle')
|
||||
ctx.pbl_bundle(binaries=binaries,
|
||||
js=ctx.path.ant_glob(['src/pkjs/**/*.js',
|
||||
'src/pkjs/**/*.json',
|
||||
'src/common/**/*.js']),
|
||||
js_entry_file='src/pkjs/index.js')
|
Loading…
Add table
Add a link
Reference in a new issue