Toggle switches work

This commit is contained in:
Dylan Smith
2026-01-16 15:45:32 -05:00
parent ed31755a3a
commit fd46ea65ca
3 changed files with 38 additions and 14 deletions

View File

@@ -78,22 +78,26 @@ static graphical_menu_t *current_menu = &main_menu;
void ui_toggle_led1(void *const args)
{
LED1_TOGGLE();
ui_request_redraw();
}
void ui_toggle_led2(void *const args)
{
LED2_TOGGLE();
ui_request_redraw();
}
void ui_toggle_led1_switch(const menu_entry_size_t *const menu_entry_size, void *const args)
{
const uint16_t width_padding = 10;
const uint16_t height_padding = 10;
const uint16_t x = menu_entry_size->x + (menu_entry_size->width + width_padding);
const uint16_t x = menu_entry_size->x + ( (menu_entry_size->width / 2) + width_padding);
const uint16_t y = menu_entry_size->y + height_padding;
const toggle_switch_t toggle_switch = {
.x = x,
.y = y,
.inner_padding_pixels = 3,
.value = HAL_GPIO_ReadPin(LD3_GPIO_Port, LD3_Pin) == GPIO_PIN_SET,
};
@@ -104,11 +108,13 @@ void ui_toggle_led2_switch(const menu_entry_size_t *const menu_entry_size, void
{
const uint16_t width_padding = 10;
const uint16_t height_padding = 10;
const uint16_t x = menu_entry_size->x + (menu_entry_size->width + width_padding);
const uint16_t x = menu_entry_size->x + ( (menu_entry_size->width / 2) + width_padding);
const uint16_t y = menu_entry_size->y + height_padding;
const toggle_switch_t toggle_switch = {
.x = x,
.y = y,
.inner_padding_pixels = 3,
.value = HAL_GPIO_ReadPin(LD4_GPIO_Port, LD4_Pin) == GPIO_PIN_SET,
};