#define WIDTH 64
#define HEIGHT 16
-// LEDMatrix(a, b, c, d, oe, r1, stb, clk);
-LEDMatrix matrix(4, 5, 6, 7, 8, 9, 10, 11);
+// LEDMatrix(a, b, c, d, oe, r1, stb, clk);
+LEDMatrix matrix(4, 5, 6, 7, 9, 11, 10, 13);
// Display Buffer 128 = 64 * 16 / 8
uint8_t displaybuf[WIDTH * HEIGHT / 8] = {
#include "LEDMatrix.h"
#include "Arduino.h"
+#define USE_SPI 1
+
+#if USE_SPI
+#include <SPI.h>
+#endif
+
#if 0
#define ASSERT(e) if (!(e)) { Serial.println(#e); while (1); }
#else
mask = 0xff;
state = 0;
+#if USE_SPI
+ SPI.begin();
+#endif
}
void LEDMatrix::begin(uint8_t *displaybuf, uint16_t width, uint16_t height)
uint8_t pixels = *ptr;
ptr++;
pixels = pixels ^ mask; // reverse: mask = 0xff, normal: mask =0x00
+#if USE_SPI
+ SPI.transfer(pixels);
+#else
for (uint8_t bit = 0; bit < 8; bit++) {
digitalWrite(clk, LOW);
digitalWrite(r1, pixels & (0x80 >> bit));
digitalWrite(clk, HIGH);
}
+#endif
}
}