From cb90a1980f98d1f5353721382f59a04337dc096b Mon Sep 17 00:00:00 2001 From: PrimmR Date: Wed, 24 Jul 2024 11:18:24 +0100 Subject: [PATCH] Added LED button combo --- .../watch_faces/complication/periodic_face.c | 38 +++++++++++++++---- .../watch_faces/complication/periodic_face.h | 4 ++ 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/movement/watch_faces/complication/periodic_face.c b/movement/watch_faces/complication/periodic_face.c index cee0033..162d3e4 100644 --- a/movement/watch_faces/complication/periodic_face.c +++ b/movement/watch_faces/complication/periodic_face.c @@ -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: - 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(); @@ -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; } diff --git a/movement/watch_faces/complication/periodic_face.h b/movement/watch_faces/complication/periodic_face.h index a459e69..c310082 100644 --- a/movement/watch_faces/complication/periodic_face.h +++ b/movement/watch_faces/complication/periodic_face.h @@ -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