static void draw_ticks(Layer *layer, GContext *ctx) { graphics_context_set_antialiased(ctx, true); graphics_context_set_fill_color(ctx, GColorWhite); graphics_context_set_stroke_color(ctx, GColorBlack); graphics_context_set_stroke_width(ctx, 5); gpath_draw_outline(ctx, tick_path_1); gpath_draw_filled(ctx, tick_path_1); gpath_draw_outline(ctx, tick_path_3); gpath_draw_filled(ctx, tick_path_3); gpath_draw_outline(ctx, tick_path_5); gpath_draw_filled(ctx, tick_path_5); gpath_draw_outline(ctx, tick_path_7); gpath_draw_filled(ctx, tick_path_7); gpath_draw_outline(ctx, tick_path_9); gpath_draw_filled(ctx, tick_path_9); gpath_draw_outline(ctx, tick_path_11); gpath_draw_filled(ctx, tick_path_11); draw_hour(2); draw_hour(4); draw_hour(6); draw_hour(8); draw_hour(10); draw_hour(12); }
static void canvas_update_proc(Layer *this_layer, GContext *ctx) { GRect bounds = layer_get_bounds(this_layer); uint16_t ms_start = time_ms(NULL, NULL); graphics_context_set_antialiased(ctx, true); if (!isBtConnected) { graphics_context_set_fill_color(ctx, GColorDukeBlue); graphics_fill_rect(ctx, bounds, 0, GCornerNone); } else { graphics_context_set_fill_color(ctx, GColorBlack); graphics_fill_rect(ctx, bounds, 0, GCornerNone); } graphics_context_set_fill_color(ctx, GColorBlack); uint16_t ms_fill = time_ms(NULL, NULL); graphics_context_set_stroke_color(ctx, COLOR_FALLBACK(GColorRed, GColorWhite)); #if defined(PBL_PLATFORM_APLITE) || defined(PBL_PLATFORM_DIORITE) graphics_context_set_stroke_width(ctx, 1); #else graphics_context_set_stroke_width(ctx, 3); #endif graphics_draw_line(ctx, GPoint(bounds.size.w/2, 0), GPoint(bounds.size.w/2, bounds.size.h)); graphics_context_set_stroke_color(ctx, GColorWhite); int hour_loc = bounds.size.h/2; if(ctick_time->tm_min < 20) draw_hour(this_layer, ctx, -1, tz2, hour_loc, FONT_KEY_ROBOTO_BOLD_SUBSET_49, 49); draw_hour(this_layer, ctx, 0, tz2, hour_loc, FONT_KEY_ROBOTO_BOLD_SUBSET_49, 49); draw_hour(this_layer, ctx, 1, tz2, hour_loc, FONT_KEY_ROBOTO_BOLD_SUBSET_49, 49); if(ctick_time->tm_min > 50) draw_hour(this_layer, ctx, 2, tz2, hour_loc, FONT_KEY_ROBOTO_BOLD_SUBSET_49, 49); graphics_context_set_stroke_width(ctx, 1); uint16_t ms_hour = time_ms(NULL, NULL); draw_minutes(this_layer, ctx, bounds.size.h/2+49/2+5); uint16_t ms_day = time_ms(NULL, NULL); int day_loc = bounds.size.h/2-49/2-12; draw_day(this_layer, ctx, -1, day_loc); draw_day(this_layer, ctx, 0, day_loc); draw_day(this_layer, ctx, 1, day_loc); draw_day(this_layer, ctx, 2, day_loc); draw_day_ticks(this_layer, ctx, bounds.size.h/2-49/2-12); if (temp != INVALID_TEMP) { draw_temp(this_layer, ctx, bounds.size.h/2+75); } getWeather(); getForecast(); uint16_t ms_end = time_ms(NULL, NULL); draw_bat(this_layer, ctx, 0); #if defined(PBL_HEALTH) // Check step data is available HealthServiceAccessibilityMask mask = health_service_metric_accessible(HealthMetricStepCount, time_start_of_today(), cur_time); if(mask & HealthServiceAccessibilityMaskAvailable) { // Data is available! int total_steps = (int)health_service_sum_today(HealthMetricStepCount); draw_step(this_layer, ctx, 22, total_steps); } time_t end_time = time(NULL); time_t start_time = end_time - 600; HealthServiceAccessibilityMask hr = health_service_metric_accessible(HealthMetricHeartRateBPM, start_time, end_time); if (hr & HealthServiceAccessibilityMaskAvailable) { uint32_t bpm = health_service_peek_current_value(HealthMetricHeartRateBPM); APP_LOG(APP_LOG_LEVEL_INFO, "HR: %d", (int)bpm); draw_bpm(this_layer, ctx, 9, bpm); } #endif static int repaints = 0; ++repaints; ms_fill = ms_fill < ms_start ? ms_fill + 1000 : ms_fill; ms_hour = ms_hour < ms_start ? ms_hour + 1000 : ms_hour; ms_day = ms_day < ms_start ? ms_day + 1000 : ms_day; ms_end = ms_end < ms_start ? ms_end + 1000 : ms_end; static uint16_t tt_max = 0; if ((ms_end-ms_start) > tt_max) tt_max = ms_end-ms_start; }