mirror of https://github.com/nealey/Twatch
Trying to make configurable
This commit is contained in:
parent
a671bbaa73
commit
9e801e6f1f
17
appinfo.json
17
appinfo.json
|
@ -1,7 +1,18 @@
|
||||||
{
|
{
|
||||||
"appKeys": {},
|
"appKeys": {
|
||||||
|
"bluetooth": 1,
|
||||||
|
"color-bg": 2,
|
||||||
|
"color-day": 4,
|
||||||
|
"color-hr": 9,
|
||||||
|
"color-min": 8,
|
||||||
|
"color-mon": 5,
|
||||||
|
"color-num": 3,
|
||||||
|
"color-sec": 7,
|
||||||
|
"color-tic": 6,
|
||||||
|
"seconds": 0
|
||||||
|
},
|
||||||
"capabilities": [
|
"capabilities": [
|
||||||
""
|
"configurable"
|
||||||
],
|
],
|
||||||
"companyName": "dartcatcher@gmail.com",
|
"companyName": "dartcatcher@gmail.com",
|
||||||
"longName": "Neale's Watch",
|
"longName": "Neale's Watch",
|
||||||
|
@ -29,7 +40,7 @@
|
||||||
"basalt",
|
"basalt",
|
||||||
"chalk"
|
"chalk"
|
||||||
],
|
],
|
||||||
"uuid": "e0b60de0-c43e-4dcd-817b-b60c1be26cb5",
|
"uuid": "8287a53c-1b7e-4f4b-9104-608de13b9f77",
|
||||||
"versionLabel": "1.0",
|
"versionLabel": "1.0",
|
||||||
"watchapp": {
|
"watchapp": {
|
||||||
"watchface": true
|
"watchface": true
|
||||||
|
|
25
src/main.c
25
src/main.c
|
@ -5,8 +5,7 @@ static Window *window;
|
||||||
static Layer *s_simple_bg_layer, *s_date_layer, *s_hands_layer;
|
static Layer *s_simple_bg_layer, *s_date_layer, *s_hands_layer;
|
||||||
static TextLayer *s_bt_label, *s_day_label, *s_mon_label;
|
static TextLayer *s_bt_label, *s_day_label, *s_mon_label;
|
||||||
|
|
||||||
|
static GColor second_color;
|
||||||
|
|
||||||
static GPath *s_tic_path;
|
static GPath *s_tic_path;
|
||||||
static GPath *s_second_arrow, *s_minute_arrow, *s_hour_arrow;
|
static GPath *s_second_arrow, *s_minute_arrow, *s_hour_arrow;
|
||||||
static char s_mon_buffer[4], s_day_buffer[6];
|
static char s_mon_buffer[4], s_day_buffer[6];
|
||||||
|
@ -81,9 +80,7 @@ static void hands_update_proc(Layer *layer, GContext *ctx) {
|
||||||
|
|
||||||
if (seconds) {
|
if (seconds) {
|
||||||
// second hand
|
// second hand
|
||||||
#ifdef PBL_COLOR
|
graphics_context_set_fill_color(ctx, second_color);
|
||||||
graphics_context_set_fill_color(ctx, GColorJaegerGreen);
|
|
||||||
#endif
|
|
||||||
gpath_rotate_to(s_second_arrow, TRIG_MAX_ANGLE * t->tm_sec / 60);
|
gpath_rotate_to(s_second_arrow, TRIG_MAX_ANGLE * t->tm_sec / 60);
|
||||||
gpath_draw_filled(ctx, s_second_arrow);
|
gpath_draw_filled(ctx, s_second_arrow);
|
||||||
//gpath_draw_outline(ctx, s_second_arrow);
|
//gpath_draw_outline(ctx, s_second_arrow);
|
||||||
|
@ -235,9 +232,23 @@ static void bt_handler(bool connected) {
|
||||||
layer_mark_dirty(s_date_layer);
|
layer_mark_dirty(s_date_layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void in_received_handler(DictionaryIterator *rec, void *context) {
|
||||||
|
Tuple *sec_color_tuple = dict_find(rec, CONFIG_KEY_COLOR_SEC);
|
||||||
|
|
||||||
|
if (sec_color_tuple) {
|
||||||
|
second_color = GColorFromHex(sec_color_tuple->value->int32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void in_dropped_handler(AppMessageResult reason, void *context) {
|
||||||
|
// What could we possibly do here?
|
||||||
|
}
|
||||||
|
|
||||||
static void init() {
|
static void init() {
|
||||||
fg = GColorBlack;
|
fg = GColorBlack;
|
||||||
bg = GColorWhite;
|
bg = GColorWhite;
|
||||||
|
second_color = COLOR_FALLBACK(GColorWindsorTan, GColorBlack);
|
||||||
|
|
||||||
window = window_create();
|
window = window_create();
|
||||||
window_set_window_handlers(window, (WindowHandlers) {
|
window_set_window_handlers(window, (WindowHandlers) {
|
||||||
.load = window_load,
|
.load = window_load,
|
||||||
|
@ -270,6 +281,10 @@ static void init() {
|
||||||
} else {
|
} else {
|
||||||
tick_timer_service_subscribe(MINUTE_UNIT, handle_second_tick);
|
tick_timer_service_subscribe(MINUTE_UNIT, handle_second_tick);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app_message_register_inbox_received(in_received_handler);
|
||||||
|
app_message_register_inbox_dropped(in_dropped_handler);
|
||||||
|
app_message_open(256, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void deinit() {
|
static void deinit() {
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
var initialized = false;
|
||||||
|
|
||||||
|
function appMessageAck(e) {
|
||||||
|
console.log("Configuration sent");
|
||||||
|
}
|
||||||
|
|
||||||
|
function appMessageNak(e) {
|
||||||
|
console.log("Configuration not sent: ", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Pebble.addEventListener("ready", function() {
|
||||||
|
console.log("ready called!");
|
||||||
|
initialized = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
Pebble.addEventListener("showConfiguration", function() {
|
||||||
|
console.log("showing configuration");
|
||||||
|
Pebble.openURL('http://woozle.org/t/twatch/');
|
||||||
|
});
|
||||||
|
|
||||||
|
Pebble.addEventListener("webviewclosed", function(e) {
|
||||||
|
console.log("configuration closed");
|
||||||
|
// webview closed
|
||||||
|
var options = JSON.parse(decodeURIComponent(e.response));
|
||||||
|
console.log("Options = " + JSON.stringify(options));
|
||||||
|
Pebble.sendAppMessage(options, appMessageAck, appMessageNak);
|
||||||
|
});
|
|
@ -0,0 +1,62 @@
|
||||||
|
|
||||||
|
#
|
||||||
|
# This file is the default set of rules to compile a Pebble project.
|
||||||
|
#
|
||||||
|
# Feel free to customize this to your needs.
|
||||||
|
#
|
||||||
|
|
||||||
|
import os.path
|
||||||
|
try:
|
||||||
|
from sh import CommandNotFound, jshint, cat, ErrorReturnCode_2
|
||||||
|
hint = jshint
|
||||||
|
except (ImportError, CommandNotFound):
|
||||||
|
hint = None
|
||||||
|
|
||||||
|
top = '.'
|
||||||
|
out = 'build'
|
||||||
|
|
||||||
|
def options(ctx):
|
||||||
|
ctx.load('pebble_sdk')
|
||||||
|
|
||||||
|
def configure(ctx):
|
||||||
|
ctx.load('pebble_sdk')
|
||||||
|
|
||||||
|
def build(ctx):
|
||||||
|
if False and hint is not None:
|
||||||
|
try:
|
||||||
|
hint([node.abspath() for node in ctx.path.ant_glob("src/**/*.js")], _tty_out=False) # no tty because there are none in the cloudpebble sandbox.
|
||||||
|
except ErrorReturnCode_2 as e:
|
||||||
|
ctx.fatal("\nJavaScript linting failed (you can disable this in Project Settings):\n" + e.stdout)
|
||||||
|
|
||||||
|
# Concatenate all our JS files (but not recursively), and only if any JS exists in the first place.
|
||||||
|
ctx.path.make_node('src/js/').mkdir()
|
||||||
|
js_paths = ctx.path.ant_glob(['src/*.js', 'src/**/*.js'])
|
||||||
|
if js_paths:
|
||||||
|
ctx(rule='cat ${SRC} > ${TGT}', source=js_paths, target='pebble-js-app.js')
|
||||||
|
has_js = True
|
||||||
|
else:
|
||||||
|
has_js = False
|
||||||
|
|
||||||
|
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(p)
|
||||||
|
ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'),
|
||||||
|
target=app_elf)
|
||||||
|
|
||||||
|
if build_worker:
|
||||||
|
worker_elf='{}/pebble-worker.elf'.format(p)
|
||||||
|
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='pebble-js-app.js' if has_js else [])
|
||||||
|
|
Loading…
Reference in New Issue