Added LED button combo

This commit is contained in:
PrimmR 2024-07-24 11:18:24 +01:00
parent c8702d346e
commit cb90a1980f
2 changed files with 34 additions and 8 deletions

View file

@ -2,6 +2,7 @@
* MIT License
*
* Copyright (c) 2023 PrimmR
* Copyright (c) 2024 David Volovskiy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -34,6 +35,7 @@ static uint8_t _ts_ticks = 0;
static int16_t _text_pos;
static const char* _text_looping;
static const char title_text[] = "Periodic Table";
static bool _led_on = false;
void periodic_face_setup(movement_settings_t *settings, uint8_t watch_face_index, void **context_ptr)
{
@ -410,20 +412,38 @@ bool periodic_face_loop(movement_event_t event, movement_settings_t *settings, v
_handle_mode_still_pressed(state, settings->bit.button_should_sound);
break;
case EVENT_LIGHT_BUTTON_UP:
_handle_backward(state, settings->bit.button_should_sound);
break;
case EVENT_LIGHT_BUTTON_DOWN:
if (!_led_on) _handle_backward(state, settings->bit.button_should_sound);
if (!watch_get_pin_level(BTN_ALARM)) _led_on = false;
break;
case EVENT_ALARM_BUTTON_UP:
_handle_forward(state, settings->bit.button_should_sound);
if (!_led_on) _handle_forward(state, settings->bit.button_should_sound);
if (!watch_get_pin_level(BTN_LIGHT)) _led_on = false;
break;
case EVENT_ALARM_LONG_PRESS:
if (!_led_on) {
start_quick_cyc();
_handle_forward(state, settings->bit.button_should_sound);
}
break;
case EVENT_LIGHT_LONG_PRESS:
if (!_led_on) {
start_quick_cyc();
_handle_backward(state, settings->bit.button_should_sound);
}
break;
case EVENT_LIGHT_BUTTON_DOWN:
if (watch_get_pin_level(BTN_ALARM)) _led_on = true;
stop_quick_cyc();
break;
case EVENT_ALARM_BUTTON_DOWN:
if (watch_get_pin_level(BTN_LIGHT)) _led_on = true;
stop_quick_cyc();
break;
case EVENT_LIGHT_LONG_UP:
_led_on = false;
break;
case EVENT_ALARM_LONG_UP:
_led_on = false;
break;
case EVENT_MODE_BUTTON_UP:
if (state->mode == SCREEN_TITLE) movement_move_to_next_face();
@ -468,6 +488,8 @@ bool periodic_face_loop(movement_event_t event, movement_settings_t *settings, v
return movement_default_loop_handler(event, settings);
}
if (_led_on) movement_illuminate_led();
return true;
}

View file

@ -2,6 +2,7 @@
* MIT License
*
* Copyright (c) 2023 PrimmR
* Copyright (c) 2024 David Volovskiy
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@ -58,6 +59,9 @@
* Alarm Hold
* Fast Cycle through Next Elements
*
* Light & Alarm Hold
* Activate LED backlight
*
*/
#define MODE_VIEW 0