mirror of
https://git.wetfence.xyz/RandyTheSilly/Civic-Segments.git
synced 2026-09-05 10:07:14 -04:00
Initial radial bar rendering for Gabbro
This commit is contained in:
+56
-7
@@ -58,8 +58,18 @@ static bool s_temp_is_warning = false;
|
||||
static int8_t s_temp_level;
|
||||
|
||||
// bar statics
|
||||
static const uint8_t s_bar_height = 8;
|
||||
#if PBL_RECT
|
||||
static const uint8_t s_bar_width = 17;
|
||||
static const uint8_t s_bar_height = 8; // pixels
|
||||
#else
|
||||
static const uint8_t s_bar_width = 24;
|
||||
static const uint8_t s_bar_height = 3; // degrees
|
||||
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
|
||||
@@ -128,26 +138,53 @@ static void batt_callback(BatteryChargeState state) {
|
||||
toggle_fuel_warning_state(state.charge_percent <= settings.LowFuelPercent, false);
|
||||
}
|
||||
|
||||
#if PBL_RECT
|
||||
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_pos = 195;
|
||||
|
||||
for (uint8_t i = 0; i < bar_count; ++i) {
|
||||
graphics_fill_rect(ctx, GRect(0, bar_bottom_pos, s_bar_width, s_bar_height), 0, GCornerNone);
|
||||
bar_bottom_pos -= s_bar_spacing;
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void temp_update_proc(Layer *layer, GContext *ctx) {
|
||||
GRect bounds = layer_get_bounds(layer);
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PBL_RECT
|
||||
static void fuel_update_proc(Layer *layer, GContext *ctx) {
|
||||
graphics_context_set_fill_color(ctx, settings.ColorBarsFill);
|
||||
uint16_t bar_bottom_pos = 195;
|
||||
|
||||
uint16_t bar_bottom_pos = 195;
|
||||
for (uint8_t i = 0; i < s_batt_level; ++i) {
|
||||
graphics_fill_rect(ctx, GRect(0, bar_bottom_pos, s_bar_width, s_bar_height), 0, GCornerNone);
|
||||
bar_bottom_pos -= s_bar_spacing;
|
||||
}
|
||||
}
|
||||
#else
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#if PBL_RECT
|
||||
static void temp_fuel_mg_update_proc_helper(Layer *layer, GContext *ctx, bool isFuel) {
|
||||
@@ -172,13 +209,20 @@ static void temp_fuel_mg_update_proc_helper(Layer *layer, GContext *ctx, bool is
|
||||
#else
|
||||
static void temp_fuel_mg_update_proc_helper(Layer *layer, GContext *ctx, bool isFuel) {
|
||||
GRect bounds = layer_get_bounds(layer);
|
||||
APP_LOG(APP_LOG_LEVEL_DEBUG, "%d,%d,%d,%d", bounds.origin.x, bounds.origin.y, bounds.size.w, bounds.size.h);
|
||||
graphics_context_set_fill_color(ctx, settings.ColorBarsMG);
|
||||
graphics_context_set_antialiased(ctx, false);
|
||||
if (isFuel) {
|
||||
graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(5)), GOvalScaleModeFitCircle, s_bar_width + 2, DEG_TO_TRIGANGLE(230), DEG_TO_TRIGANGLE(310));
|
||||
graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(5)), GOvalScaleModeFitCircle, s_bar_width + 2, DEG_TO_TRIGANGLE(s_bar_fuel_deg_top), DEG_TO_TRIGANGLE(s_bar_fuel_deg_bottom));
|
||||
// graphics_context_set_fill_color(ctx, settings.ColorBarsCool);
|
||||
// graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, DEG_TO_TRIGANGLE(s_bar_fuel_deg_top + 1), DEG_TO_TRIGANGLE(s_bar_fuel_deg_top + 2));
|
||||
// graphics_context_set_fill_color(ctx, settings.ColorBarsHot);
|
||||
// graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, DEG_TO_TRIGANGLE(s_bar_fuel_deg_bottom - 2), DEG_TO_TRIGANGLE(s_bar_fuel_deg_bottom - 1));
|
||||
} else {
|
||||
graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(5)), GOvalScaleModeFitCircle, s_bar_width + 2, DEG_TO_TRIGANGLE(50), DEG_TO_TRIGANGLE(130));
|
||||
graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(5)), GOvalScaleModeFitCircle, s_bar_width + 2, DEG_TO_TRIGANGLE(s_bar_temp_deg_bottom), DEG_TO_TRIGANGLE(s_bar_temp_deg_top));
|
||||
// graphics_context_set_fill_color(ctx, settings.ColorBarsCool);
|
||||
// graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, DEG_TO_TRIGANGLE(s_bar_temp_deg_bottom + 1), DEG_TO_TRIGANGLE(s_bar_temp_deg_bottom + 2));
|
||||
// graphics_context_set_fill_color(ctx, settings.ColorBarsHot);
|
||||
// graphics_fill_radial(ctx, grect_inset(bounds, GEdgeInsets(7)), GOvalScaleModeFitCircle, s_bar_width - 2, DEG_TO_TRIGANGLE(s_bar_temp_deg_top - 2), DEG_TO_TRIGANGLE(s_bar_temp_deg_top - 1));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -684,9 +728,14 @@ static void init() {
|
||||
s_digit_fg_layers[i] = bitmap_layer_create(s_digit_grects[i]);
|
||||
bitmap_layer_set_compositing_mode(s_digit_fg_layers[i], GCompOpSet);
|
||||
}
|
||||
#if PBL_RECT
|
||||
s_temp_layer = layer_create(GRect(s_temp_guage_x_pos, 0, s_bar_width, PBL_DISPLAY_HEIGHT));
|
||||
layer_set_update_proc(s_temp_layer, temp_update_proc);
|
||||
s_fuel_layer = layer_create(GRect(s_fuel_guage_x_pos, 0, s_bar_width, PBL_DISPLAY_HEIGHT));
|
||||
#else
|
||||
s_temp_layer = layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
|
||||
s_fuel_layer = layer_create(GRect(0, 0, PBL_DISPLAY_WIDTH, PBL_DISPLAY_HEIGHT));
|
||||
#endif
|
||||
layer_set_update_proc(s_temp_layer, temp_update_proc);
|
||||
layer_set_update_proc(s_fuel_layer, fuel_update_proc);
|
||||
|
||||
update_minute_1();
|
||||
|
||||
Reference in New Issue
Block a user