dashboard: force relay strip layout
This commit is contained in:
@@ -257,19 +257,17 @@ static void layout_relay_buttons()
|
||||
visible_count = 6;
|
||||
}
|
||||
|
||||
int available_width = RELAY_STRIP_W - 28;
|
||||
int button_width = (available_width - ((visible_count - 1) * RELAY_BUTTON_GAP)) / visible_count;
|
||||
const int card_width = 960;
|
||||
const int horizontal_pad = 18;
|
||||
const int button_gap = 12;
|
||||
const int button_y = 10;
|
||||
const int button_height = 178;
|
||||
|
||||
if (button_width < 110) {
|
||||
button_width = 110;
|
||||
}
|
||||
int available_width = card_width - (horizontal_pad * 2);
|
||||
int button_width = (available_width - ((visible_count - 1) * button_gap)) / visible_count;
|
||||
|
||||
if (button_width > 210) {
|
||||
button_width = 210;
|
||||
}
|
||||
|
||||
int total_width = (button_width * visible_count) + (RELAY_BUTTON_GAP * (visible_count - 1));
|
||||
int start_x = (available_width - total_width) / 2;
|
||||
int total_width = (button_width * visible_count) + (button_gap * (visible_count - 1));
|
||||
int start_x = (card_width - total_width) / 2;
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if (relay_buttons[i] == nullptr) {
|
||||
@@ -277,12 +275,19 @@ static void layout_relay_buttons()
|
||||
}
|
||||
|
||||
if (i < relay_count) {
|
||||
lv_obj_set_size(relay_buttons[i], button_width, 150);
|
||||
lv_obj_align(relay_buttons[i], LV_ALIGN_TOP_LEFT, start_x + (i * (button_width + RELAY_BUTTON_GAP)), 18);
|
||||
lv_obj_set_size(relay_buttons[i], button_width, button_height);
|
||||
lv_obj_align(
|
||||
relay_buttons[i],
|
||||
LV_ALIGN_TOP_LEFT,
|
||||
start_x + (i * (button_width + button_gap)),
|
||||
button_y
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static void update_relay_buttons()
|
||||
{
|
||||
lvgl_port_lock(-1);
|
||||
@@ -724,7 +729,7 @@ static void create_overland_overview_screen()
|
||||
lv_obj_t *battery_card = create_card(screen, "", 380, 310, LV_ALIGN_TOP_LEFT, 32, 76);
|
||||
lv_obj_t *temp_card = create_card(screen, "", 260, 310, LV_ALIGN_TOP_LEFT, 426, 76);
|
||||
lv_obj_t *vehicle_card = create_card(screen, "", 274, 310, LV_ALIGN_TOP_RIGHT, -32, 76);
|
||||
lv_obj_t *relay_card = create_card(screen, "", RELAY_STRIP_W, 126, LV_ALIGN_TOP_LEFT, RELAY_STRIP_X, 408);
|
||||
lv_obj_t *relay_card = create_card(screen, "", 960, 205, LV_ALIGN_BOTTOM_MID, 0, -8);
|
||||
|
||||
battery_charge_pulse_arc = lv_arc_create(battery_card);
|
||||
lv_obj_set_size(battery_charge_pulse_arc, 286, 286);
|
||||
@@ -820,8 +825,8 @@ static void create_overland_overview_screen()
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
relay_buttons[i] = lv_btn_create(relay_card);
|
||||
lv_obj_set_size(relay_buttons[i], 140, 150);
|
||||
lv_obj_align(relay_buttons[i], LV_ALIGN_TOP_LEFT, 14 + (i * 150), 18);
|
||||
lv_obj_set_size(relay_buttons[i], 200, 178);
|
||||
lv_obj_align(relay_buttons[i], LV_ALIGN_TOP_LEFT, 18 + (i * 212), 10);
|
||||
lv_obj_add_event_cb(
|
||||
relay_buttons[i],
|
||||
relay_button_event_cb,
|
||||
|
||||
Reference in New Issue
Block a user