diff options
author | lonkaars <loek@pipeframe.xyz> | 2021-11-26 15:30:34 +0100 |
---|---|---|
committer | lonkaars <loek@pipeframe.xyz> | 2021-11-26 15:30:34 +0100 |
commit | 0169625b253301ed24267ebfd19afb55e5121bca (patch) | |
tree | 6d27e9b12823c5086dc6ab25bbd31978df746e0d /software | |
parent | b2a27b3f0dc4b9db227184595062ffded0f5decb (diff) |
working software
Diffstat (limited to 'software')
-rw-r--r-- | software/consts.h | 4 | ||||
-rw-r--r-- | software/effects.ino | 10 | ||||
-rw-r--r-- | software/scan.ino | 2 | ||||
-rw-r--r-- | software/shift.ino | 14 |
4 files changed, 15 insertions, 15 deletions
diff --git a/software/consts.h b/software/consts.h index 4c577e1..2598d29 100644 --- a/software/consts.h +++ b/software/consts.h @@ -6,8 +6,6 @@ #define CONFIG_FRAMERATE 60 #define CONFIG_PWM_FREQ 1000 -// shift register serial delay (rekening houden met propagation delay) (in nanoseconden) -#define CONFIG_SRSER_DELAY 20 #define CONFIG_SERIAL_BAUD 115200 -// #define DEBUG +#define DEBUG diff --git a/software/effects.ino b/software/effects.ino index 02a56e9..c27179f 100644 --- a/software/effects.ino +++ b/software/effects.ino @@ -3,8 +3,14 @@ void fx_roundabout (unsigned long relative_time, bool (*leds)[64]) { unsigned long segment_time = SLIDESHOW_DURATION / 64; - memset(led_state, 0, sizeof(led_state)); - led_state[(relative_time / segment_time) % 64] = 1; + #ifdef DEBUG + Serial.print(segment_time, DEC); + Serial.print(" "); + Serial.print((relative_time / segment_time) % 64, DEC); + Serial.print("\n\r"); + #endif + memset(led_state, 1, sizeof(led_state)); + led_state[(relative_time / segment_time) % 64] = 0; return; } diff --git a/software/scan.ino b/software/scan.ino index 8711502..9feba79 100644 --- a/software/scan.ino +++ b/software/scan.ino @@ -18,7 +18,7 @@ unsigned char get_state_row(unsigned char row, unsigned char direction) { } void scan() { - shift_state[0] = 0xff ^ (1 << scan_index); + shift_state[0] = (1 << scan_index); shift_state[1] = get_state_row(scan_index, scan_direction); update_shift_state(); diff --git a/software/shift.ino b/software/shift.ino index 20c1123..d8062af 100644 --- a/software/shift.ino +++ b/software/shift.ino @@ -9,22 +9,18 @@ unsigned char shift_state[2]; void update_shift_state() { for(int i = 0; i < 2; i++) shift(shift_state[i]); -} -void shift(unsigned char data) { - // pull down latch + digitalWrite(PINOUT_LCK, HIGH); digitalWrite(PINOUT_LCK, LOW); +} +void shift(unsigned char data) { for(int i = 0; i < 8; i++) { - bool bit = (data & 1 << i) > 0; + bool bit = (data & 1 << (7 - i)) > 0; - // write bit and pulse serial clock digitalWrite(PINOUT_SER, bit); + digitalWrite(PINOUT_SCK, HIGH); - delayMicroseconds(CONFIG_SRSER_DELAY); digitalWrite(PINOUT_SCK, LOW); } - - // pull up latch - digitalWrite(PINOUT_LCK, HIGH); } |