Skip to content

Commit

Permalink
v1
Browse files Browse the repository at this point in the history
  • Loading branch information
james-woo committed Dec 17, 2017
1 parent 6248170 commit cb5a9b6
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 56 deletions.
50 changes: 22 additions & 28 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,98 +20,92 @@
"resources": {
"media": [
{
"file": "images/footstep.png",
"name": "IMAGE_FOOTSTEP",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/wi-na.png",
"file": "images/na.png",
"name": "IMAGE_WEATHER_NA",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/09n.png",
"file": "images/rainynight.png",
"name": "IMAGE_WEATHER_RAIN_NIGHT",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/09d.png",
"name": "IMAGE_WEATHER_RAIN_DAY",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/90.png",
"file": "images/extreme.png",
"name": "IMAGE_WEATHER_EXTREME",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/50.png",
"file": "images/mist.png",
"name": "IMAGE_WEATHER_MIST",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/13.png",
"file": "images/snow.png",
"name": "IMAGE_WEATHER_SNOW",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/11.png",
"file": "images/thunder.png",
"name": "IMAGE_WEATHER_THUNDER",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/03.png",
"file": "images/rainyday.png",
"name": "IMAGE_WEATHER_RAIN_DAY",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/cloudy.png",
"name": "IMAGE_WEATHER_CLOUDY",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/02n.png",
"file": "images/cloudynight.png",
"name": "IMAGE_WEATHER_PARTLY_CLOUDY_NIGHT",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/02d.png",
"file": "images/cloudyday.png",
"name": "IMAGE_WEATHER_PARTLY_CLOUDY_DAY",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/01n.png",
"file": "images/clearnight.png",
"name": "IMAGE_WEATHER_CLEAR_NIGHT",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "images/01d.png",
"file": "images/clearday.png",
"name": "IMAGE_WEATHER_CLEAR_DAY",
"targetPlatforms": null,
"type": "bitmap"
},
{
"file": "fonts/Roboto",
"name": "FONT_ROBOTO_12",
"file": "images/footstep.png",
"name": "IMAGE_FOOTSTEP",
"targetPlatforms": null,
"type": "font"
"type": "bitmap"
},
{
"file": "fonts/Roboto",
"name": "FONT_ROBOTO_24",
"name": "FONT_ROBOTO_48",
"targetPlatforms": null,
"type": "font"
},
{
"file": "fonts/Roboto",
"name": "FONT_ROBOTO_48",
"name": "FONT_ROBOTO_12",
"targetPlatforms": null,
"type": "font"
}
Expand Down
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
46 changes: 18 additions & 28 deletions src/c/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ static Layer *s_battery_layer, *s_battery_icon_layer;
static TextLayer *s_battery_text_layer;

// Fonts
static GFont s_font_48, s_font_24, s_font_12;
static GFont s_font_48, s_font_12;

static void update_time() {
// Get a tm structure
Expand Down Expand Up @@ -92,13 +92,6 @@ static void tick_handler(struct tm *tick_time, TimeUnits units_changed) {
}
}

static void status_bar_update_proc(Layer *layer, GContext *ctx) {
graphics_context_set_stroke_color(ctx, GColorWhite);
graphics_context_set_fill_color(ctx, GColorBlack);
graphics_draw_rect(ctx, layer_get_bounds(layer));
graphics_fill_rect(ctx, layer_get_bounds(layer), 0, GCornerNone);
}

static GBitmap* lookup_weather_icon(int code, int night) {
if (code <= 800 && night) {
return gbitmap_create_with_resource(night_weather_icon_table[code/100]);
Expand Down Expand Up @@ -169,7 +162,7 @@ static void get_steps_average() {
s_steps_average = (int)health_service_sum_averaged(HealthMetricStepCount, start, end, HealthServiceTimeScopeDaily);
}

static void display_steps_count() {
static void display_steps_count() {
if (s_steps_count >= s_steps_average) {
text_layer_set_text_color(s_steps_text_layer, s_steps_color_winner);
snprintf(s_steps_emoji, sizeof(s_steps_emoji), "\U0001F60C");
Expand Down Expand Up @@ -253,7 +246,6 @@ static void battery_update_icon_proc(Layer *layer, GContext *ctx) {

static void load_fonts() {
s_font_12 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_12));
s_font_24 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_24));
s_font_48 = fonts_load_custom_font(resource_get_handle(RESOURCE_ID_FONT_ROBOTO_48));
}

Expand Down Expand Up @@ -297,12 +289,11 @@ static void load_time(GRect bounds, Layer *layer) {
}

static void load_status_bar(GRect bounds, Layer *layer) {
s_status_bar_layer = layer_create(GRect(PBL_IF_ROUND_ELSE(24, 0), 3*bounds.size.h/4 - 16, bounds.size.w, 16));
layer_set_update_proc(s_status_bar_layer, status_bar_update_proc);
s_status_bar_layer = layer_create(GRect(PBL_IF_ROUND_ELSE(24, 0), 3*bounds.size.h/4 - 18, bounds.size.w, 32));
GRect status_bar_bounds = layer_get_bounds(s_status_bar_layer);

// Weather
s_weather_layer = layer_create(GRect(8, 0, status_bar_bounds.size.w, status_bar_bounds.size.h));
s_weather_layer = layer_create(GRect(28, 0, status_bar_bounds.size.w, status_bar_bounds.size.h/2));
GRect weather_bounds = layer_get_bounds(s_weather_layer);
s_weather_bitmap = gbitmap_create_with_resource(RESOURCE_ID_IMAGE_WEATHER_NA);
s_weather_bitmap_layer = bitmap_layer_create(GRect(0, 0, 24, weather_bounds.size.h));
Expand All @@ -317,21 +308,9 @@ static void load_status_bar(GRect bounds, Layer *layer) {
text_layer_set_text(s_weather_text_layer, "");
layer_add_child(s_weather_layer, text_layer_get_layer(s_weather_text_layer));
layer_add_child(s_status_bar_layer, s_weather_layer);

// Steps
s_steps_layer = layer_create(GRect(status_bar_bounds.size.w/4, 0, status_bar_bounds.size.w/2, status_bar_bounds.size.h));
GRect steps_bounds = layer_get_bounds(s_steps_layer);
s_steps_text_layer = text_layer_create(GRect(0, 0, steps_bounds.size.w, steps_bounds.size.h));
text_layer_set_background_color(s_steps_text_layer, GColorClear);
text_layer_set_text_color(s_steps_text_layer, GColorWhite);
text_layer_set_font(s_steps_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
text_layer_set_text_alignment(s_steps_text_layer, GTextAlignmentCenter);
text_layer_set_text(s_steps_text_layer, "A10000");
layer_add_child(s_steps_layer, text_layer_get_layer(s_steps_text_layer));
layer_add_child(s_status_bar_layer, s_steps_layer);


// Battery
s_battery_layer = layer_create(GRect(2*status_bar_bounds.size.w/3 + 2, 0, status_bar_bounds.size.w/3, status_bar_bounds.size.h));
s_battery_layer = layer_create(GRect(status_bar_bounds.size.w/2 + 8, 0, status_bar_bounds.size.w/3, status_bar_bounds.size.h/2));
GRect battery_bounds = layer_get_bounds(s_battery_layer);
s_battery_icon_layer = layer_create(GRect(0, 2, 6, 12));
layer_set_update_proc(s_battery_icon_layer, battery_update_icon_proc);
Expand All @@ -346,6 +325,18 @@ static void load_status_bar(GRect bounds, Layer *layer) {
layer_add_child(s_battery_layer, text_layer_get_layer(s_battery_text_layer));
layer_add_child(s_status_bar_layer, s_battery_layer);

// Steps
s_steps_layer = layer_create(GRect(status_bar_bounds.size.w/4, 16, status_bar_bounds.size.w/2, status_bar_bounds.size.h/2));
GRect steps_bounds = layer_get_bounds(s_steps_layer);
s_steps_text_layer = text_layer_create(GRect(0, 0, steps_bounds.size.w, steps_bounds.size.h));
text_layer_set_background_color(s_steps_text_layer, GColorClear);
text_layer_set_text_color(s_steps_text_layer, GColorWhite);
text_layer_set_font(s_steps_text_layer, fonts_get_system_font(FONT_KEY_GOTHIC_14));
text_layer_set_text_alignment(s_steps_text_layer, GTextAlignmentCenter);
text_layer_set_text(s_steps_text_layer, "A10000");
layer_add_child(s_steps_layer, text_layer_get_layer(s_steps_text_layer));
layer_add_child(s_status_bar_layer, s_steps_layer);

layer_add_child(layer, s_status_bar_layer);
}

Expand Down Expand Up @@ -375,7 +366,6 @@ static void main_window_unload(Window *window) {

// Unload GFont
fonts_unload_custom_font(s_font_12);
fonts_unload_custom_font(s_font_24);
fonts_unload_custom_font(s_font_48);

// Destroy layers
Expand Down

0 comments on commit cb5a9b6

Please sign in to comment.