diff --git a/src/c/main.c b/src/c/main.c index 2d100c4..94fe7e6 100644 --- a/src/c/main.c +++ b/src/c/main.c @@ -60,17 +60,18 @@ static int8_t s_temp_level; // bar statics #if PBL_RECT static const uint8_t s_bar_width = 17; -static const uint8_t s_bar_height = 8; // pixels +static const uint8_t s_bar_height = 8; +static const uint8_t s_bar_spacing = s_bar_height + 1; #else static const uint8_t s_bar_width = 24; -static const uint8_t s_bar_height = 3; // degrees +static const uint16_t s_bar_height = DEG_TO_TRIGANGLE(3); +static const uint16_t s_bar_spacing = DEG_TO_TRIGANGLE(4); // height (3) + 1 static const uint8_t s_bar_deg_range = 40; static const uint16_t s_bar_fuel_deg_top = 90 - s_bar_deg_range; static const uint16_t s_bar_fuel_deg_bottom = 90 + s_bar_deg_range; static const uint16_t s_bar_temp_deg_top = 270 + s_bar_deg_range; static const uint16_t s_bar_temp_deg_bottom = 270 - s_bar_deg_range; #endif -static const uint8_t s_bar_spacing = s_bar_height + 1; // resource ID arrays for digit bitmaps static const uint32_t s_digit_resource_ids[10] = {RESOURCE_ID_0, RESOURCE_ID_1, RESOURCE_ID_2, RESOURCE_ID_3, RESOURCE_ID_4, @@ -155,10 +156,11 @@ static void temp_update_proc(Layer *layer, GContext *ctx) { graphics_context_set_fill_color(ctx, settings.ColorBarsFill); const uint8_t bar_count = s_temp_level; - uint16_t bar_bottom_deg = s_bar_temp_deg_bottom; + static const uint8_t half_gap = (s_bar_spacing - s_bar_height) / 2; + int32_t bar_bottom = DEG_TO_TRIGANGLE(s_bar_temp_deg_bottom) + half_gap; for (uint8_t i = 0; i < bar_count; ++i) { - graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, DEG_TO_TRIGANGLE(bar_bottom_deg), DEG_TO_TRIGANGLE(bar_bottom_deg + s_bar_height)); - bar_bottom_deg += s_bar_spacing; + graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, bar_bottom, bar_bottom + s_bar_height); + bar_bottom += s_bar_spacing; } } #endif @@ -178,10 +180,11 @@ static void fuel_update_proc(Layer *layer, GContext *ctx) { GRect bounds = layer_get_bounds(layer); graphics_context_set_fill_color(ctx, settings.ColorBarsFill); - uint16_t bar_bottom_deg = s_bar_fuel_deg_bottom; + static const uint8_t half_gap = (s_bar_spacing - s_bar_height) / 2; + int32_t bar_bottom = DEG_TO_TRIGANGLE(s_bar_fuel_deg_bottom) - half_gap; for (uint8_t i = 0; i < s_batt_level; ++i) { - graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, DEG_TO_TRIGANGLE(bar_bottom_deg - s_bar_height), DEG_TO_TRIGANGLE(bar_bottom_deg)); - bar_bottom_deg -= s_bar_spacing; + graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, bar_bottom - s_bar_height, bar_bottom); + bar_bottom -= s_bar_spacing; } } #endif