Convert to SDK3, start at white BG version

This commit is contained in:
Neale Pickett 2015-07-05 22:26:02 -06:00
parent abb60dd2e5
commit 7224d385cf
3 changed files with 79 additions and 83 deletions

View File

@ -1,33 +1,37 @@
{ {
"appKeys": {}, "appKeys": {},
"capabilities": [ "capabilities": [
"" ""
], ],
"companyName": "dartcatcher@gmail.com", "companyName": "dartcatcher@gmail.com",
"longName": "Helvetica", "longName": "Helvetica",
"projectType": "native", "projectType": "native",
"resources": { "resources": {
"media": [ "media": [
{ {
"characterRegex": "[0-9A-Za-zéô ]", "characterRegex": "[0-9A-Za-z\u00e9\u00f4 ]",
"file": "fonts/HelveticaNeue-Regular.ttf", "file": "fonts/HelveticaNeue-Regular.ttf",
"name": "HELVETICA_R_28", "name": "HELVETICA_R_28",
"type": "font" "type": "font"
}, },
{ {
"characterRegex": "[0-9:]", "characterRegex": "[0-9:]",
"file": "fonts/HelveticaNeue-Bold.ttf", "file": "fonts/HelveticaNeue-Bold.ttf",
"name": "HELVETICA_B_48", "name": "HELVETICA_B_48",
"type": "font" "type": "font"
} }
] ]
}, },
"sdkVersion": "2", "sdkVersion": "3",
"shortName": "Helvetica", "shortName": "Helvetica",
"uuid": "534e5853-7be7-447e-a67d-b236ac9f4f51", "uuid": "534e5853-7be7-447e-a67d-b236ac9f4f51",
"versionCode": 1, "versionCode": 1,
"versionLabel": "1.0", "versionLabel": "1.0",
"watchapp": { "watchapp": {
"watchface": true "watchface": true
} },
"targetPlatforms": [
"aplite",
"basalt"
]
} }

View File

@ -1,13 +1,9 @@
#include "pebble_process_info.h"
#include "pebble.h" #include "pebble.h"
#define WHITE extern const PebbleProcessInfo __pbl_app_info;
#ifdef WHITE
#define BG GColorWhite GColor BG, FG;
#define FG GColorBlack
#else
#define BG GColorBlack
#define FG GColorWhite
#endif
static Window *s_main_window; static Window *s_main_window;
static TextLayer *s_date_layer, *s_time_layer; 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_time_text[] = "00:00";
static char s_date_text[] = "Xxxxxxxxx 00"; static char s_date_text[] = "Xxxxxxxxx 00";
strftime(s_date_text, sizeof(s_date_text), "%e %b", tick_time); char *p;
text_layer_set_text(s_date_layer, s_date_text);
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; char *time_format;
if (clock_is_24h_style()) { 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); strftime(s_time_text, sizeof(s_time_text), time_format, tick_time);
// Handle lack of non-padded hour format string for twelve hour clock. // I always remove leading zero, because I arbitrarily think that looks better.
if (!clock_is_24h_style() && (s_time_text[0] == '0')) { p = s_time_text;
memmove(s_time_text, &s_time_text[1], sizeof(s_time_text) - 1); while (*p == '0') {
} p++;
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);
} }
text_layer_set_text(s_time_layer, p);
} }
static void main_window_load(Window *window) { static void main_window_load(Window *window) {
@ -69,6 +68,15 @@ static void main_window_unload(Window *window) {
} }
static void init() { 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(); s_main_window = window_create();
window_set_background_color(s_main_window, BG); window_set_background_color(s_main_window, BG);
window_set_window_handlers(s_main_window, (WindowHandlers) { window_set_window_handlers(s_main_window, (WindowHandlers) {

52
wscript
View File

@ -6,11 +6,6 @@
# #
import os.path import os.path
try:
from sh import CommandNotFound, jshint, cat, ErrorReturnCode_2
hint = jshint
except (ImportError, CommandNotFound):
hint = None
top = '.' top = '.'
out = 'build' out = 'build'
@ -20,38 +15,27 @@ def options(ctx):
def configure(ctx): def configure(ctx):
ctx.load('pebble_sdk') ctx.load('pebble_sdk')
global hint
if hint is not None:
hint = hint.bake(['--config', 'pebble-jshintrc'])
def build(ctx): 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.load('pebble_sdk')
ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'), build_worker = os.path.exists('worker_src')
target='pebble-app.elf') binaries = []
if os.path.exists('worker_src'): for p in ctx.env.TARGET_PLATFORMS:
ctx.pbl_worker(source=ctx.path.ant_glob('worker_src/**/*.c'), ctx.set_env(ctx.all_envs[p])
target='pebble-worker.elf') ctx.set_group(ctx.env.PLATFORM_NAME)
ctx.pbl_bundle(elf='pebble-app.elf', app_elf='{}/pebble-app.elf'.format(ctx.env.BUILD_DIR)
worker_elf='pebble-worker.elf', ctx.pbl_program(source=ctx.path.ant_glob('src/**/*.c'),
js='pebble-js-app.js' if has_js else []) target=app_elf)
else:
ctx.pbl_bundle(elf='pebble-app.elf',
js='pebble-js-app.js' if has_js else [])
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'))