Merged official boilerplates to get working settings

This commit is contained in:
Warwick New 2026-06-25 12:45:16 +01:00
parent 1e9c24262b
commit 8b8d9f73d0
5 changed files with 115 additions and 139 deletions

38
package-lock.json generated
View file

@ -1,21 +1,21 @@
{
"name": "eatordonteat",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "eatordonteat",
"version": "1.0.0",
"dependencies": {
"@rebble/clay": "^1.0.10"
}
},
"node_modules/@rebble/clay": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/@rebble/clay/-/clay-1.0.10.tgz",
"integrity": "sha512-84EL9J6egrnWk/FzqCxRa9/vqO4fx7SBxdttthLEpBro+FVqUg+rMlqOzT8+zl4PkBQKAWdnqHwlHaS4heiXKg==",
"license": "MIT"
}
}
"name": "eatordonteat",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "eatordonteat",
"version": "1.0.0",
"dependencies": {
"@rebble/clay": "^1.0.10"
}
},
"node_modules/@rebble/clay": {
"version": "1.0.10",
"resolved": "https://registry.npmjs.org/@rebble/clay/-/clay-1.0.10.tgz",
"integrity": "sha512-84EL9J6egrnWk/FzqCxRa9/vqO4fx7SBxdttthLEpBro+FVqUg+rMlqOzT8+zl4PkBQKAWdnqHwlHaS4heiXKg==",
"license": "MIT"
}
}
}

View file

@ -1,36 +1,39 @@
{
"name": "eatordonteat",
"author": "MakeAwesomeHappen",
"version": "1.0.0",
"keywords": [
"pebble-app"
],
"private": true,
"dependencies": {
"@rebble/clay": "^1.0.10"
},
"pebble": {
"displayName": "Eat / Don't Eat watchface",
"uuid": "34fbfd25-b227-49fd-9c90-7f71b9731131",
"sdkVersion": "3",
"enableMultiJS": true,
"targetPlatforms": [
"aplite",
"basalt",
"chalk",
"diorite",
"emery",
"flint",
"gabbro"
],
"watchapp": {
"watchface": true
},
"messageKeys": [
"dummy"
],
"resources": {
"media": []
}
}
"name": "eatordonteat",
"author": "MakeAwesomeHappen",
"version": "1.0.0",
"keywords": [
"pebble-app"
],
"private": true,
"dependencies": {
"@rebble/clay": "^1.0.10"
},
"pebble": {
"displayName": "Eat / Don't Eat watchface",
"uuid": "34fbfd25-b227-49fd-9c90-7f71b9731131",
"sdkVersion": "3",
"enableMultiJS": true,
"targetPlatforms": [
"aplite",
"basalt",
"chalk",
"diorite",
"emery",
"flint",
"gabbro"
],
"watchapp": {
"watchface": true
},
"messageKeys": [
"BackgroundColor",
"ForegroundColor",
"SecondTick",
"Animations"
],
"resources": {
"media": []
}
}
}

View file

@ -1,86 +0,0 @@
#include <pebble.h>
static Window *s_main_window;
static TextLayer *s_time_layer;
static TextLayer *s_date_layer;
static void update_time() {
// Get a tm structure
time_t temp = time(NULL);
struct tm *tick_time = localtime(&temp);
// Write the current hours and minutes into a buffer
static char s_time_buffer[8];
strftime(s_time_buffer, sizeof(s_time_buffer),
clock_is_24h_style() ? "%H:%M" : "%I:%M", tick_time);
// Display this time on the TextLayer
text_layer_set_text(s_time_layer, s_time_buffer);
// Write the current date into a buffer
static char s_date_buffer[16];
strftime(s_date_buffer, sizeof(s_date_buffer), "%a %b %d", tick_time);
// Display the date
text_layer_set_text(s_date_layer, s_date_buffer);
}
static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
update_time();
}
static void main_window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
GRect bounds = layer_get_bounds(window_layer);
// Create the time TextLayer
s_time_layer =
text_layer_create(GRect(0, PBL_IF_ROUND_ELSE(58, 52), bounds.size.w, 50));
text_layer_set_background_color(s_time_layer, GColorClear);
text_layer_set_text_color(s_time_layer, GColorWhite);
text_layer_set_font(s_time_layer,
fonts_get_system_font(FONT_KEY_BITHAM_42_BOLD));
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));
// Create the date TextLayer
s_date_layer = text_layer_create(
GRect(0, PBL_IF_ROUND_ELSE(110, 104), bounds.size.w, 30));
text_layer_set_background_color(s_date_layer, GColorClear);
text_layer_set_text_color(s_date_layer, GColorWhite);
text_layer_set_font(s_date_layer,
fonts_get_system_font(FONT_KEY_GOTHIC_24_BOLD));
text_layer_set_text_alignment(s_date_layer, GTextAlignmentCenter);
// Add to Window
layer_add_child(window_layer, text_layer_get_layer(s_date_layer));
}
static void main_window_unload(Window *window) {
text_layer_destroy(s_date_layer);
text_layer_destroy(s_time_layer);
}
static void init() {
s_main_window = window_create();
window_set_background_color(s_main_window, GColorBlack);
window_set_window_handlers(
s_main_window,
(WindowHandlers){.load = main_window_load, .unload = main_window_unload});
window_stack_push(s_main_window, true);
update_time();
tick_timer_service_subscribe(MINUTE_UNIT, tick_handler);
}
static void deinit() { window_destroy(s_main_window); }
int main(void) {
init();
app_event_loop();
deinit();
}

56
src/pkjs/config.js Normal file
View file

@ -0,0 +1,56 @@
module.exports = [
{
"type": "heading",
"defaultValue": "App Configuration"
},
{
"type": "text",
"defaultValue": "Here is some introductory text."
},
{
"type": "section",
"items": [
{
"type": "heading",
"defaultValue": "Colors"
},
{
"type": "color",
"messageKey": "BackgroundColor",
"defaultValue": "0x000000",
"label": "Background Color"
},
{
"type": "color",
"messageKey": "ForegroundColor",
"defaultValue": "0xFFFFFF",
"label": "Foreground Color"
}
]
},
{
"type": "section",
"items": [
{
"type": "heading",
"defaultValue": "More Settings"
},
{
"type": "toggle",
"messageKey": "SecondTick",
"label": "Enable Seconds",
"defaultValue": false
},
{
"type": "toggle",
"messageKey": "Animations",
"label": "Enable Animations",
"defaultValue": false
}
]
},
{
"type": "submit",
"defaultValue": "Save Settings"
}
];

3
src/pkjs/index.js Normal file
View file

@ -0,0 +1,3 @@
var Clay = require('@rebble/clay');
var clayConfig = require('./config');
var clay = new Clay(clayConfig);