Compare commits

..

2 Commits

Author SHA1 Message Date
c6454c5a5f Ignore build files 2025-12-31 15:27:26 +01:00
e56c5a9702 Initial watchface 2025-12-31 15:26:26 +01:00
5 changed files with 223 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
build
node_modules
.lock*

20
countdown_watchface/package-lock.json generated Normal file
View File

@@ -0,0 +1,20 @@
{
"name": "countdown_watchface",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "countdown_watchface",
"version": "1.0.0",
"dependencies": {
"pebble-effect-layer": "^1.2.0"
}
},
"node_modules/pebble-effect-layer": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/pebble-effect-layer/-/pebble-effect-layer-1.2.0.tgz",
"integrity": "sha512-AMbf4ooRCy/olsf3M5xOgILP+NSvfGlt12I0KAK0cD2F+dbx2gj24/xe9qINJVEhdfel624tP4jzjPJYMsR4Pw=="
}
}
}

View File

@@ -0,0 +1,34 @@
{
"name": "countdown_watchface",
"author": "Bas Grolleman",
"version": "1.0.0",
"keywords": [
"pebble-app"
],
"private": true,
"dependencies": {
"pebble-effect-layer": "^1.2.0"
},
"pebble": {
"displayName": "countdown_watchface",
"uuid": "769d0058-ae41-4e80-b41a-64d58e2ae3e0",
"sdkVersion": "3",
"enableMultiJS": true,
"targetPlatforms": [
"aplite",
"basalt",
"diorite",
"emery",
"flint"
],
"watchapp": {
"watchface": true
},
"messageKeys": [
"dummy"
],
"resources": {
"media": []
}
}
}

View File

@@ -0,0 +1,112 @@
#include <pebble.h>
#include <pebble-effect-layer/pebble-effect-layer.h>
static Window *s_main_window;
static TextLayer *s_time_layer;
static TextLayer *s_date_layer;
static TextLayer *s_cd_layer;
static EffectLayer *s_effect_layer;
static void main_window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_bounds(window_layer);
s_effect_layer = effect_layer_create(bounds);
effect_layer_add_effect(s_effect_layer, effect_invert, NULL);
layer_add_child(window_layer,effect_layer_get_layer(s_effect_layer));
s_time_layer = text_layer_create(
GRect(0, PBL_IF_ROUND_ELSE(58,52), bounds.size.w, 50)
);
// Improve the layout to be more like a watchface
text_layer_set_background_color(s_time_layer, GColorClear);
text_layer_set_text_color(s_time_layer, GColorWhite);
text_layer_set_text(s_time_layer, "00:00");
text_layer_set_font(s_time_layer, fonts_get_system_font(FONT_KEY_ROBOTO_BOLD_SUBSET_49));
text_layer_set_text_alignment(s_time_layer, GTextAlignmentCenter);
// Add it as a child layer to the Window's root layer
layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
s_date_layer = text_layer_create(
GRect(0, PBL_IF_ROUND_ELSE(108,102), bounds.size.w, 50)
);
// Improve the layout to be more like a watchface
text_layer_set_background_color(s_date_layer, GColorClear);
text_layer_set_text_color(s_date_layer, GColorWhite);
text_layer_set_text(s_date_layer, "Wed 1st Jan");
text_layer_set_font(s_date_layer, fonts_get_system_font(FONT_KEY_ROBOTO_CONDENSED_21));
text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter);
// Add it as a child layer to the Window's root layer
layer_add_child(window_layer, text_layer_get_layer(s_date_layer));
s_cd_layer = text_layer_create(
GRect(0, PBL_IF_ROUND_ELSE(18,12), bounds.size.w, 50)
);
// Improve the layout to be more like a watchface
text_layer_set_background_color(s_cd_layer, GColorClear);
text_layer_set_text_color(s_cd_layer, GColorWhite);
text_layer_set_text(s_cd_layer, "-----==========");
text_layer_set_font(s_cd_layer, fonts_get_system_font(FONT_KEY_GOTHIC_18));
text_layer_set_text_alignment(s_cd_layer, GTextAlignmentCenter);
// Add it as a child layer to the Window's root layer
layer_add_child(window_layer, text_layer_get_layer(s_cd_layer));
}
static void main_window_unload(Window *window) {
text_layer_destroy(s_time_layer);
text_layer_destroy(s_date_layer);
text_layer_destroy(s_cd_layer);
effect_layer_destroy(s_effect_layer);
}
static void update_time() {
time_t temp = time(NULL);
struct tm *tick_time = localtime(&temp);
static char s_buffer[8];
strftime(s_buffer, sizeof(s_buffer), clock_is_24h_style() ? "%H:%M" : "%I:%M", tick_time);
text_layer_set_text(s_time_layer, s_buffer);
static char d_buffer[12];
strftime(d_buffer, sizeof(d_buffer), "%a %d %b", tick_time);
text_layer_set_text(s_date_layer, d_buffer);
}
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
update_time();
}
static void init() {
s_main_window = window_create();
window_set_window_handlers(s_main_window, (WindowHandlers) {
.load = main_window_load,
.unload = main_window_unload
});
window_stack_push(s_main_window, true);
tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
update_time();
}
static void deinit() {
window_destroy(s_main_window);
}
int main(void) {
init();
app_event_loop();
deinit();
return 0;
}

View 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')