aboutsummaryrefslogtreecommitdiffstats
path: root/src/neopixel.c
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2025-04-17 13:06:22 -0400
committerKevin O'Connor <kevin@koconnor.net>2025-04-17 13:06:22 -0400
commit413ff19ea8e0e5e09c0233225ffa8ad07b1233d6 (patch)
treee18ca12eaf68e21d4e332484a85332dd993e76ae /src/neopixel.c
parent4e7fcc27040da2ae72bf44b445a97bf9a981dd98 (diff)
downloadkutter-413ff19ea8e0e5e09c0233225ffa8ad07b1233d6.tar.gz
kutter-413ff19ea8e0e5e09c0233225ffa8ad07b1233d6.tar.xz
kutter-413ff19ea8e0e5e09c0233225ffa8ad07b1233d6.zip
neopixel: Add comments on timing
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/neopixel.c')
-rw-r--r--src/neopixel.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/neopixel.c b/src/neopixel.c
index e7890a06..4e171658 100644
--- a/src/neopixel.c
+++ b/src/neopixel.c
@@ -1,6 +1,6 @@
// Support for bit-banging commands to WS2812 type "neopixel" LEDs
//
-// Copyright (C) 2019 Kevin O'Connor <kevin@koconnor.net>
+// Copyright (C) 2019-2025 Kevin O'Connor <kevin@koconnor.net>
//
// This file may be distributed under the terms of the GNU GPLv3 license.
@@ -74,8 +74,11 @@ neopixel_delay(neopixel_time_t start, neopixel_time_t ticks)
#endif
+// Minimum amount of time for a '1 bit' to be reliably detected
#define PULSE_LONG_TICKS nsecs_to_ticks(650)
-#define PULSE_SHORT_TICKS nsecs_to_ticks(200)
+// Minimum amount of time for any level change to be reliably detected
+#define EDGE_MIN_TICKS nsecs_to_ticks(200)
+// Minimum average time needed to transmit each bit (two level changes)
#define BIT_MIN_TICKS nsecs_to_ticks(1250)
@@ -147,14 +150,14 @@ send_data(struct neopixel_s *n)
gpio_out_toggle_noirq(pin);
irq_enable();
- neopixel_delay(neopixel_get_time(), PULSE_SHORT_TICKS);
+ neopixel_delay(neopixel_get_time(), EDGE_MIN_TICKS);
} else {
// Short pulse
neopixel_delay(last_start, BIT_MIN_TICKS);
irq_disable();
neopixel_time_t start = neopixel_get_time();
gpio_out_toggle_noirq(pin);
- neopixel_delay(start, PULSE_SHORT_TICKS);
+ neopixel_delay(start, EDGE_MIN_TICKS);
gpio_out_toggle_noirq(pin);
irq_enable();