Fonts are hinted pretty well at this size, looks sharp.
This commit is contained in:
Neale Pickett 2015-05-14 23:00:14 -06:00
parent c23ba75167
commit ef1bf03f81
5 changed files with 175 additions and 0 deletions

33
appinfo.json Normal file
View File

@ -0,0 +1,33 @@
{
"appKeys": {},
"capabilities": [
""
],
"companyName": "dartcatcher@gmail.com",
"longName": "Helvetica",
"projectType": "native",
"resources": {
"media": [
{
"characterRegex": "[0-9A-Za-z ]",
"file": "fonts/helveticaneue.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
}
}

Binary file not shown.

Binary file not shown.

85
src/main.c Normal file
View File

@ -0,0 +1,85 @@
#include "pebble.h"
static Window *s_main_window;
static TextLayer *s_date_layer, *s_time_layer;
static Layer *s_line_layer;
static void line_layer_update_callback(Layer *layer, GContext* ctx) {
graphics_context_set_fill_color(ctx, GColorWhite);
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
}
static void handle_minute_tick(struct tm *tick_time, TimeUnits units_changed) {
// Need to be static because they're used by the system later.
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 *time_format;
if (clock_is_24h_style()) {
time_format = "%R";
} else {
time_format = "%I:%M";
}
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);
}
text_layer_set_text(s_time_layer, s_time_text);
}
static void main_window_load(Window *window) {
Layer *window_layer = window_get_root_layer(window);
s_date_layer = text_layer_create(GRect(8, 66, 136, 100));
text_layer_set_text_color(s_date_layer, GColorWhite);
text_layer_set_background_color(s_date_layer, GColorClear);
text_layer_set_font(s_date_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_HELVETICA_R_28)));
layer_add_child(window_layer, text_layer_get_layer(s_date_layer));
s_time_layer = text_layer_create(GRect(7, 92, 137, 76));
text_layer_set_text_color(s_time_layer, GColorWhite);
text_layer_set_background_color(s_time_layer, GColorClear);
text_layer_set_font(s_time_layer, fonts_load_custom_font(resource_get_handle(RESOURCE_ID_HELVETICA_B_48)));
layer_add_child(window_layer, text_layer_get_layer(s_time_layer));
}
static void main_window_unload(Window *window) {
text_layer_destroy(s_date_layer);
text_layer_destroy(s_time_layer);
layer_destroy(s_line_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);
tick_timer_service_subscribe(MINUTE_UNIT, handle_minute_tick);
// Prevent starting blank
time_t now = time(NULL);
struct tm *t = localtime(&now);
handle_minute_tick(t, MINUTE_UNIT);
}
static void deinit() {
window_destroy(s_main_window);
tick_timer_service_unsubscribe();
}
int main() {
init();
app_event_loop();
deinit();
}

57
wscript Normal file
View File

@ -0,0 +1,57 @@
#
# 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')
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')
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 [])