diff options
author | lonkaars <loek@pipeframe.xyz> | 2021-11-27 12:23:55 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2021-11-27 12:23:55 +0100 |
commit | 9514e58a83f66b57c24bc6a2b4141e9ef475e326 (patch) | |
tree | 7007ed43235bfdffce684df5e49ccd409910400b | |
parent | d4956bc4d9f49936a1aa7a54e976bc86d7062d44 (diff) |
implemented animation 2
-rw-r--r-- | software/animation.h | 3 | ||||
-rw-r--r-- | software/animation.ino | 18 | ||||
-rw-r--r-- | software/effects.ino | 5 |
3 files changed, 26 insertions, 0 deletions
diff --git a/software/animation.h b/software/animation.h index 3e0d3a7..aba955f 100644 --- a/software/animation.h +++ b/software/animation.h @@ -7,3 +7,6 @@ unsigned long clamp_time(unsigned long unclamped_time); /** @brief 'zigzag' value between 0 and `size - 1`, like modulo (`%`) operator */ unsigned int zigzag(unsigned int size, int index); + +/** @brief color leds on plane perpendicular to `direction` with `offset` */ +void fill_plane(unsigned int direction, unsigned int offset); diff --git a/software/animation.ino b/software/animation.ino index 4c4976e..e59bfa1 100644 --- a/software/animation.ino +++ b/software/animation.ino @@ -9,3 +9,21 @@ unsigned int zigzag(unsigned int size, int index) { unsigned int mod = index % zigzag_size; return mod < size - 1 ? mod : zigzag_size - mod; } + +void fill_plane(unsigned int direction, unsigned int offset) { + for(int i = 0; i < 16; i++) { + unsigned char axis1_offset = i / 4; + unsigned char axis2_offset = i % 4; + + unsigned int axis1_weight = pow((direction + 1) % 3, 4); + unsigned int axis2_weight = pow((direction - 1) % 3, 4); + unsigned int axis3_weight = pow((direction ) % 3, 4); + + led_state[ + axis1_offset * axis1_weight + + axis2_offset * axis2_weight + + offset * axis3_weight + ] = 1; + } +} + diff --git a/software/effects.ino b/software/effects.ino index 0768fb8..0fc776a 100644 --- a/software/effects.ino +++ b/software/effects.ino @@ -21,6 +21,11 @@ void fx_roundabout (unsigned long relative_time, bool (*leds)[64]) { #define FX_LEN_WIPEXYZ 6e3 void fx_wipexyz (unsigned long relative_time, bool (*leds)[64]) { + memset(leds, 0, sizeof(leds)); + unsigned long tick = relative_time / 200; + unsigned int direction = (tick / 6) % 3; + + fill_plane(direction, zigzag(4, tick)); return; } |