aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurelien Jarno <aurelien@aurel32.net>2024-02-17 18:29:28 +0100
committerAurelien Jarno <aurelien@aurel32.net>2024-02-17 18:29:28 +0100
commite31fa9a4b981ed900087cb8c5d9c660c1b1a81ce (patch)
tree3b221db0a41fe6c4dc9c87051f3221a6db120685
parent800a81a50b19924f54b3dd901ee095da048e8282 (diff)
downloadtraffic-light-e31fa9a4b981ed900087cb8c5d9c660c1b1a81ce.tar.gz
software: add support for 4 main states, as used in some countries
-rw-r--r--software/main.c32
1 files changed, 31 insertions, 1 deletions
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 = {