lcd autodetect: use buttons as a backup option

This commit is contained in:
Joey Castillo
2025-03-15 09:48:53 -04:00
parent e9ede6f060
commit c1efea4db7
2 changed files with 21 additions and 1 deletions

View File

@@ -73,6 +73,13 @@ void watch_discover_lcd_type(void) {
HAL_GPIO_SLCD3_pmuxen(HAL_GPIO_PMUX_ADC);
HAL_GPIO_SLCD4_pmuxen(HAL_GPIO_PMUX_ADC);
// as a failsafe, we have button inputs: MODE for classic, ALARM for new.
// (think: left button, backwards in time: classic; right button, forward, new: custom)
HAL_GPIO_BTN_MODE_in();
HAL_GPIO_BTN_MODE_pulldown();
HAL_GPIO_BTN_ALARM_in();
HAL_GPIO_BTN_ALARM_pulldown();
/// TODO: Remove this and the watch_set_led_off below; it's here for testing (people will see red if their LCD was undetectable)
watch_set_led_red();
@@ -103,6 +110,17 @@ void watch_discover_lcd_type(void) {
if (valid_frames_classic > 16 || valid_frames_custom > 16) {
break;
}
// The failsafe: if our detection isn't working, the user can tell us which display is installed.
if (HAL_GPIO_BTN_MODE_read()) {
_installed_display = WATCH_LCD_TYPE_CLASSIC;
goto valid_display_detected;
}
if (HAL_GPIO_BTN_ALARM_read()) {
_installed_display = WATCH_LCD_TYPE_CUSTOM;
goto valid_display_detected;
}
delay_ms(4);
}