Import of the watch repository from Pebble

This commit is contained in:
Matthieu Jeanson 2024-12-12 16:43:03 -08:00 committed by Katharine Berry
commit 3b92768480
10334 changed files with 2564465 additions and 0 deletions

View file

@ -0,0 +1,3 @@
# Ignore build generated files
build

View file

@ -0,0 +1,22 @@
{
"uuid": "812b900e-53fb-463f-a7e5-691937328687",
"shortName": "gmtime_localtime_test",
"longName": "gmtime_localtime_test",
"companyName": "MakeAwesomeHappen",
"versionCode": 1,
"versionLabel": "1.0",
"watchapp": {
"watchface": false
},
"appKeys": {
"dummy": 0
},
"resources": {
"media": []
},
"targetPlatforms": [
"aplite",
"basalt"
],
"sdkVersion": "3"
}

View file

@ -0,0 +1,94 @@
/*
* 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 *window;
static TextLayer *time_layer;
static TextLayer *gmtime_layer;
static TextLayer *localtime_layer;
static void window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
time_t the_time = time(NULL);
// Time layer
static char time_buf[32];
snprintf(time_buf, 32, "time: %u", (unsigned) the_time);
time_layer = text_layer_create(GRect(0, 0, 144, 168));
text_layer_set_text(time_layer, time_buf);
text_layer_set_font(time_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
layer_add_child(window_layer, text_layer_get_layer(time_layer));
// Time layer
struct tm *gm_time = gmtime(&the_time);
static char gmtime_buf[32];
snprintf(gmtime_buf, 32, "gmtime: %d:%02d, is_dst: %d",
gm_time->tm_hour, gm_time->tm_min, gm_time->tm_isdst);
gmtime_layer = text_layer_create(GRect(0, 40, 144, 168));
text_layer_set_text(gmtime_layer, gmtime_buf);
text_layer_set_font(gmtime_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
layer_add_child(window_layer, text_layer_get_layer(gmtime_layer));
char gmtime_strftime_buf[32];
strftime(gmtime_strftime_buf, 32, "%z %Z", gm_time);
APP_LOG(APP_LOG_LEVEL_DEBUG, "gmtime: %s", gmtime_strftime_buf);
// Time layer
struct tm *lt_time = localtime(&the_time);
static char localtime_buf[32];
snprintf(localtime_buf, 32, "localtime: %d:%02d, is_dst: %d",
lt_time->tm_hour, lt_time->tm_min, lt_time->tm_isdst);
localtime_layer = text_layer_create(GRect(0, 96, 144, 168));
text_layer_set_text(localtime_layer, localtime_buf);
text_layer_set_font(localtime_layer, fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
layer_add_child(window_layer, text_layer_get_layer(localtime_layer));
char localtime_strftime_buf[32];
strftime(localtime_strftime_buf, 32, "%z %Z", lt_time);
APP_LOG(APP_LOG_LEVEL_DEBUG, "localtime: %s", localtime_strftime_buf);
}
static void window_unload(Window *window) {
text_layer_destroy(time_layer);
text_layer_destroy(gmtime_layer);
text_layer_destroy(localtime_layer);
}
static void init(void) {
window = window_create();
window_set_window_handlers(window, (WindowHandlers) {
.load = window_load,
.unload = window_unload,
});
const bool animated = true;
window_stack_push(window, animated);
}
static void deinit(void) {
window_destroy(window);
}
int main(void) {
init();
app_event_loop();
deinit();
}

View file

@ -0,0 +1,41 @@
#
# This file is the default set of rules to compile a Pebble project.
#
# Feel free to customize this to your needs.
#
import os.path
top = '.'
out = 'build'
def options(ctx):
ctx.load('pebble_sdk')
def configure(ctx):
ctx.load('pebble_sdk')
def build(ctx):
ctx.load('pebble_sdk')
build_worker = os.path.exists('worker_src')
binaries = []
for p in ctx.env.TARGET_PLATFORMS:
ctx.set_env(ctx.all_envs[p])
ctx.set_group(ctx.env.PLATFORM_NAME)
app_elf='{}/pebble-app.elf'.format(ctx.env.BUILD_DIR)
ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'),
target=app_elf)
if build_worker:
worker_elf='{}/pebble-worker.elf'.format(ctx.env.BUILD_DIR)
binaries.append({'platform': p, 'app_elf': app_elf, 'worker_elf': worker_elf})
ctx.pbl_worker(source=ctx.path.ant_glob('worker_src/**/*.c'),
target=worker_elf)
else:
binaries.append({'platform': p, 'app_elf': app_elf})
ctx.set_group('bundle')
ctx.pbl_bundle(binaries=binaries, js=ctx.path.ant_glob('src/js/**/*.js'))