diff --git a/appinfo.json b/appinfo.json index 21a2a58..cc9138e 100644 --- a/appinfo.json +++ b/appinfo.json @@ -1,33 +1,37 @@ { - "appKeys": {}, - "capabilities": [ - "" - ], - "companyName": "dartcatcher@gmail.com", - "longName": "Helvetica", - "projectType": "native", - "resources": { - "media": [ - { - "characterRegex": "[0-9A-Za-zéô ]", - "file": "fonts/HelveticaNeue-Regular.ttf", - "name": "HELVETICA_R_28", - "type": "font" - }, - { - "characterRegex": "[0-9:]", - "file": "fonts/HelveticaNeue-Bold.ttf", - "name": "HELVETICA_B_48", - "type": "font" - } - ] - }, - "sdkVersion": "2", - "shortName": "Helvetica", - "uuid": "534e5853-7be7-447e-a67d-b236ac9f4f51", - "versionCode": 1, - "versionLabel": "1.0", - "watchapp": { - "watchface": true - } + "appKeys": {}, + "capabilities": [ + "" + ], + "companyName": "dartcatcher@gmail.com", + "longName": "Helvetica", + "projectType": "native", + "resources": { + "media": [ + { + "characterRegex": "[0-9A-Za-z\u00e9\u00f4 ]", + "file": "fonts/HelveticaNeue-Regular.ttf", + "name": "HELVETICA_R_28", + "type": "font" + }, + { + "characterRegex": "[0-9:]", + "file": "fonts/HelveticaNeue-Bold.ttf", + "name": "HELVETICA_B_48", + "type": "font" + } + ] + }, + "sdkVersion": "3", + "shortName": "Helvetica", + "uuid": "534e5853-7be7-447e-a67d-b236ac9f4f51", + "versionCode": 1, + "versionLabel": "1.0", + "watchapp": { + "watchface": true + }, + "targetPlatforms": [ + "aplite", + "basalt" + ] } diff --git a/src/main.c b/src/main.c index cfe9cf8..34c23eb 100644 --- a/src/main.c +++ b/src/main.c @@ -1,13 +1,9 @@ +#include "pebble_process_info.h" #include "pebble.h" -#define WHITE -#ifdef WHITE -#define BG GColorWhite -#define FG GColorBlack -#else -#define BG GColorBlack -#define FG GColorWhite -#endif +extern const PebbleProcessInfo __pbl_app_info; + +GColor BG, FG; static Window *s_main_window; static TextLayer *s_date_layer, *s_time_layer; @@ -23,8 +19,14 @@ static void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) { static char s_time_text[] = "00:00"; static char s_date_text[] = "Xxxxxxxxx 00"; - strftime(s_date_text, sizeof(s_date_text), "%e %b", tick_time); - text_layer_set_text(s_date_layer, s_date_text); + char *p; + + strftime(s_date_text, sizeof(s_date_text), "%d %b", tick_time); + p = s_date_text; + while (*p == '0') { + p++; + } + text_layer_set_text(s_date_layer, p); char *time_format; if (clock_is_24h_style()) { @@ -34,15 +36,12 @@ static void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) { } strftime(s_time_text, sizeof(s_time_text), time_format, tick_time); - // Handle lack of non-padded hour format string for twelve hour clock. - if (!clock_is_24h_style() && (s_time_text[0] == '0')) { - memmove(s_time_text, &s_time_text[1], sizeof(s_time_text) - 1); - } - if (s_time_text[0] == '0') { - text_layer_set_text(s_time_layer, s_time_text + 1); - } else { - text_layer_set_text(s_time_layer, s_time_text); + // I always remove leading zero, because I arbitrarily think that looks better. + p = s_time_text; + while (*p == '0') { + p++; } + text_layer_set_text(s_time_layer, p); } static void main_window_load(Window *window) { @@ -69,6 +68,15 @@ static void main_window_unload(Window *window) { } static void init() { + // First things first: are we black or white? + if (__pbl_app_info.uuid.byte15 % 2) { + BG = GColorBlack; + FG = GColorWhite; + } else { + BG = GColorWhite; + FG = GColorBlack; + } + s_main_window = window_create(); window_set_background_color(s_main_window, BG); window_set_window_handlers(s_main_window, (WindowHandlers) { diff --git a/wscript b/wscript index fbc4753..040ab7c 100644 --- a/wscript +++ b/wscript @@ -6,11 +6,6 @@ # import os.path -try: - from sh import CommandNotFound, jshint, cat, ErrorReturnCode_2 - hint = jshint -except (ImportError, CommandNotFound): - hint = None top = '.' out = 'build' @@ -20,38 +15,27 @@ def options(ctx): def configure(ctx): ctx.load('pebble_sdk') - global hint - if hint is not None: - hint = hint.bake(['--config', 'pebble-jshintrc']) 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') - ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'), - target='pebble-app.elf') + build_worker = os.path.exists('worker_src') + binaries = [] - if os.path.exists('worker_src'): - ctx.pbl_worker(source=ctx.path.ant_glob('worker_src/**/*.c'), - target='pebble-worker.elf') - ctx.pbl_bundle(elf='pebble-app.elf', - worker_elf='pebble-worker.elf', - js='pebble-js-app.js' if has_js else []) - else: - ctx.pbl_bundle(elf='pebble-app.elf', - js='pebble-js-app.js' if has_js else []) + 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'))