Merged official boilerplates to get working settings
This commit is contained in:
parent
1e9c24262b
commit
8b8d9f73d0
5 changed files with 115 additions and 139 deletions
|
|
@ -27,7 +27,10 @@
|
||||||
"watchface": true
|
"watchface": true
|
||||||
},
|
},
|
||||||
"messageKeys": [
|
"messageKeys": [
|
||||||
"dummy"
|
"BackgroundColor",
|
||||||
|
"ForegroundColor",
|
||||||
|
"SecondTick",
|
||||||
|
"Animations"
|
||||||
],
|
],
|
||||||
"resources": {
|
"resources": {
|
||||||
"media": []
|
"media": []
|
||||||
|
|
|
||||||
|
|
@ -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
56
src/pkjs/config.js
Normal 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
3
src/pkjs/index.js
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
var Clay = require('@rebble/clay');
|
||||||
|
var clayConfig = require('./config');
|
||||||
|
var clay = new Clay(clayConfig);
|
||||||
Loading…
Reference in a new issue