]> git.earman.xyz Git - sensor-watch.git/commitdiff
Added LED button combo
authorPrimmR <primmr@icloud.com>
Wed, 24 Jul 2024 10:18:24 +0000 (11:18 +0100)
committerPrimmR <primmr@icloud.com>
Wed, 24 Jul 2024 10:18:24 +0000 (11:18 +0100)
movement/watch_faces/complication/periodic_face.c
movement/watch_faces/complication/periodic_face.h

index cee0033cc99f4bd8a020ec4223231e2ca64bcaf2..162d3e42904ef43b1be60ff95ff48801e01ec648 100644 (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:
-        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;
 }
 
index a459e69dda1e399c60eb5258ec1e90fb6fb77020..c310082452fbea13a1ece6eb4e436132896311dd 100644 (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