watch_rtc_register_alarm_callback(cb_alarm_fired, alarm_time, ALARM_MATCH_SS);
}
+ // LCD autodetect uses the buttons as a a failsafe, so we should run it before we enable the button interrupts
+ watch_enable_display();
+
if (movement_state.le_mode_ticks != -1) {
watch_disable_extwake_interrupt(HAL_GPIO_BTN_ALARM_pin());
watch_enable_buzzer();
watch_enable_leds();
- watch_enable_display();
movement_request_tick_frequency(1);
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();
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);
}