static void draw_bpm_field(SDL_Surface *surface, const struct rect *rect, double bpm, SDL_Color bg_col) { if (show_bpm(bpm)) draw_bpm(surface, rect, bpm, bg_col); else draw_rect(surface, rect, bg_col); }
static void draw_record(SDL_Surface *surface, const struct rect *rect, const struct record *record) { struct rect artist, title, left, right; split(*rect, from_top(BIG_FONT_SPACE, 0), &artist, &title); draw_text(surface, &artist, record->artist, big_font, text_col, background_col); /* Layout changes slightly if BPM is known */ if (show_bpm(record->bpm)) { split(title, from_left(BPM_WIDTH, 0), &left, &right); draw_bpm(surface, &left, record->bpm, background_col); split(right, from_left(HALF_SPACER, 0), &left, &title); draw_rect(surface, &left, background_col); } draw_text(surface, &title, record->title, font, text_col, background_col); }
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; }