From e31fa9a4b981ed900087cb8c5d9c660c1b1a81ce Mon Sep 17 00:00:00 2001
From: Aurelien Jarno <aurelien@aurel32.net>
Date: Sat, 17 Feb 2024 18:29:28 +0100
Subject: software: add support for 4 main states, as used in some countries

---
 software/main.c | 32 +++++++++++++++++++++++++++++++-
 1 file changed, 31 insertions(+), 1 deletion(-)

diff --git a/software/main.c b/software/main.c
index 5261d34..14dedc6 100644
--- a/software/main.c
+++ b/software/main.c
@@ -1,7 +1,7 @@
 /*
  * Traffic light
  *
- * Copyright (C) 2019-2022 Aurelien Jarno
+ * Copyright (C) 2019-2024 Aurelien Jarno
  *
  * Authors:
  *  Aurelien Jarno <aurelien@aurel32.net>
@@ -42,6 +42,7 @@ enum state {
     state_off,
     state_red,
     state_orange,
+    state_orange_red,
     state_green,
     state_blinking_on,
     state_blinking_off,
@@ -98,6 +99,34 @@ const struct state_desc states_desc[] = {
         .next_button_medium = state_blinking_on,
         .next_button_long = state_off,
     },
+/* Define to 1 for a four main states traffic light, as used in some countries,
+ * i.e. going to orange + red in between red and green. */
+#if 0
+    [state_red] = {
+        .leds = {
+            { .r = 0x7f, .g = 0x00, .b = 0x00, },
+            { .r = 0x00, .g = 0x00, .b = 0x00, },
+            { .r = 0x00, .g = 0x00, .b = 0x00, },
+        },
+        .duration = 13500,
+        .next = state_orange_red,
+        .next_button_short = state_orange_red,
+        .next_button_medium = state_blinking_on,
+        .next_button_long = state_off,
+    },
+    [state_orange_red] = {
+        .leds = {
+            { .r = 0x7f, .g = 0x00, .b = 0x00, },
+            { .r = 0x7f, .g = 0x2f, .b = 0x00, },
+            { .r = 0x00, .g = 0x00, .b = 0x00, },
+        },
+        .duration = 1500,
+        .next = state_green,
+        .next_button_short = state_green,
+        .next_button_medium = state_blinking_on,
+        .next_button_long = state_off,
+    },
+#else
     [state_red] = {
         .leds = {
             { .r = 0x7f, .g = 0x00, .b = 0x00, },
@@ -110,6 +139,7 @@ const struct state_desc states_desc[] = {
         .next_button_medium = state_blinking_on,
         .next_button_long = state_off,
     },
+#endif
 
     [state_blinking_on] = {
         .leds = {
-- 
cgit v1.2.3