mirror of
https://github.com/google/pebble.git
synced 2025-07-15 10:36:43 -04:00
Import of the watch repository from Pebble
This commit is contained in:
commit
3b92768480
10334 changed files with 2564465 additions and 0 deletions
3
src/apps/localtime_gmtime_test/.gitignore
vendored
Normal file
3
src/apps/localtime_gmtime_test/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
|
||||
# Ignore build generated files
|
||||
build
|
22
src/apps/localtime_gmtime_test/appinfo.json
Normal file
22
src/apps/localtime_gmtime_test/appinfo.json
Normal 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"
|
||||
}
|
94
src/apps/localtime_gmtime_test/src/localtime_gmtime_test.c
Normal file
94
src/apps/localtime_gmtime_test/src/localtime_gmtime_test.c
Normal 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();
|
||||
}
|
41
src/apps/localtime_gmtime_test/wscript
Normal file
41
src/apps/localtime_gmtime_test/wscript
Normal 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'))
|
Loading…
Add table
Add a link
Reference in a new issue