Merge PR #293 - add instant LED duration
Adds an instant LED duration preference that only keeps the LED lit while the LIGHT button remains held down. Matches the behavior of the original watch. Reviewed-by: Matheus Afonso Martins Moreira <matheus@matheusmoreira.com> Tested-on-hardware-by: Wesley Aptekar-Cassels <me@wesleyac.com> Tested-on-hardware-by: 814d3 (GitHub) GitHub-Pull-Request: https://github.com/joeycastillo/Sensor-Watch/pull/293
This commit is contained in:
@@ -278,14 +278,24 @@ void movement_request_tick_frequency(uint8_t freq) {
|
||||
}
|
||||
|
||||
void movement_illuminate_led(void) {
|
||||
if (movement_state.settings.bit.led_duration) {
|
||||
if (movement_state.settings.bit.led_duration != 0b111) {
|
||||
watch_set_led_color(movement_state.settings.bit.led_red_color ? (0xF | movement_state.settings.bit.led_red_color << 4) : 0,
|
||||
movement_state.settings.bit.led_green_color ? (0xF | movement_state.settings.bit.led_green_color << 4) : 0);
|
||||
movement_state.light_ticks = (movement_state.settings.bit.led_duration * 2 - 1) * 128;
|
||||
if (movement_state.settings.bit.led_duration == 0) {
|
||||
movement_state.light_ticks = 1;
|
||||
} else {
|
||||
movement_state.light_ticks = (movement_state.settings.bit.led_duration * 2 - 1) * 128;
|
||||
}
|
||||
_movement_enable_fast_tick_if_needed();
|
||||
}
|
||||
}
|
||||
|
||||
static void _movement_led_off(void) {
|
||||
watch_set_led_off();
|
||||
movement_state.light_ticks = -1;
|
||||
_movement_disable_fast_tick_if_possible();
|
||||
}
|
||||
|
||||
bool movement_default_loop_handler(movement_event_t event, movement_settings_t *settings) {
|
||||
(void)settings;
|
||||
|
||||
@@ -296,6 +306,11 @@ bool movement_default_loop_handler(movement_event_t event, movement_settings_t *
|
||||
case EVENT_LIGHT_BUTTON_DOWN:
|
||||
movement_illuminate_led();
|
||||
break;
|
||||
case EVENT_LIGHT_BUTTON_UP:
|
||||
if (movement_state.settings.bit.led_duration == 0) {
|
||||
_movement_led_off();
|
||||
}
|
||||
break;
|
||||
case EVENT_MODE_LONG_PRESS:
|
||||
if (MOVEMENT_SECONDARY_FACE_INDEX && movement_state.current_face_idx == 0) {
|
||||
movement_move_to_face(MOVEMENT_SECONDARY_FACE_INDEX);
|
||||
@@ -559,9 +574,7 @@ bool app_loop(void) {
|
||||
if (watch_get_pin_level(BTN_LIGHT)) {
|
||||
movement_state.light_ticks = 1;
|
||||
} else {
|
||||
watch_set_led_off();
|
||||
movement_state.light_ticks = -1;
|
||||
_movement_disable_fast_tick_if_possible();
|
||||
_movement_led_off();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -690,7 +703,7 @@ static movement_event_type_t _figure_out_button_event(bool pin_level, movement_e
|
||||
}
|
||||
|
||||
static movement_event_type_t btn_action(bool pin_level, int code, uint16_t *timestamp) {
|
||||
_movement_reset_inactivity_countdown();
|
||||
_movement_reset_inactivity_countdown();
|
||||
return _figure_out_button_event(pin_level, code, timestamp);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user