aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--64test/64test.ino32
-rw-r--r--software/consts.h4
-rw-r--r--software/effects.ino10
-rw-r--r--software/scan.ino2
-rw-r--r--software/shift.ino14
5 files changed, 47 insertions, 15 deletions
diff --git a/64test/64test.ino b/64test/64test.ino
new file mode 100644
index 0000000..ed0db9b
--- /dev/null
+++ b/64test/64test.ino
@@ -0,0 +1,32 @@
+#define SERIAL_DELAY 3
+
+#define SERIAL_CLK 4
+#define SERIAL_INP 2
+#define LATCH_CLK 3
+
+void shift(unsigned char gert, unsigned char gert2) {
+ digitalWrite(LATCH_CLK, LOW);
+ shiftOut(SERIAL_INP, SERIAL_CLK, LSBFIRST, gert);
+ shiftOut(SERIAL_INP, SERIAL_CLK, LSBFIRST, gert2);
+ digitalWrite(LATCH_CLK, HIGH);
+}
+
+void setup() {
+ pinMode(SERIAL_CLK, OUTPUT);
+ pinMode(SERIAL_INP, OUTPUT);
+ pinMode(LATCH_CLK, OUTPUT);
+
+ shift(0, 0);
+}
+
+unsigned int i = 0;
+
+void loop() {
+ i = ( i + 1 ) % 64;
+ unsigned char sr1 = 0x00 ^ (1 << (i / 8));
+ unsigned char sr2 = 0xff ^ (1 << (i % 8));
+
+ shift(sr1, sr2);
+
+ delay(10);
+}
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);
}