aboutsummaryrefslogtreecommitdiff
path: root/software/animation.ino
diff options
context:
space:
mode:
Diffstat (limited to 'software/animation.ino')
-rw-r--r--software/animation.ino6
1 files changed, 6 insertions, 0 deletions
diff --git a/software/animation.ino b/software/animation.ino
index 547caaa..4c4976e 100644
--- a/software/animation.ino
+++ b/software/animation.ino
@@ -3,3 +3,9 @@
unsigned long clamp_time(unsigned long unclamped_time) {
return unclamped_time / frame_time_millis * frame_time_millis;
}
+
+unsigned int zigzag(unsigned int size, int index) {
+ unsigned int zigzag_size = 2 * size - 2;
+ unsigned int mod = index % zigzag_size;
+ return mod < size - 1 ? mod : zigzag_size - mod;
+}