* 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
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)
{
_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:
- start_quick_cyc();
- _handle_forward(state, settings->bit.button_should_sound);
+ if (!_led_on) {
+ start_quick_cyc();
+ _handle_forward(state, settings->bit.button_should_sound);
+ }
break;
case EVENT_LIGHT_LONG_PRESS:
- start_quick_cyc();
- _handle_backward(state, settings->bit.button_should_sound);
+ 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();
return movement_default_loop_handler(event, settings);
}
+ if (_led_on) movement_illuminate_led();
+
return true;
}