mirror of https://github.com/radex/radmatrix.git
firmware: faster
parent
69c6ab51aa
commit
b8aa12aac5
|
@ -2,6 +2,7 @@
|
||||||
#include "gfx_png.h"
|
#include "gfx_png.h"
|
||||||
#include "lodepng.h"
|
#include "lodepng.h"
|
||||||
#include "pico/multicore.h"
|
#include "pico/multicore.h"
|
||||||
|
#include "hardware/gpio.h"
|
||||||
#include "mbed_wait_api.h"
|
#include "mbed_wait_api.h"
|
||||||
|
|
||||||
#define Serial Serial1
|
#define Serial Serial1
|
||||||
|
@ -19,18 +20,18 @@
|
||||||
#define ROW_SRCLR 10
|
#define ROW_SRCLR 10
|
||||||
|
|
||||||
inline void pulsePin(uint8_t pin) {
|
inline void pulsePin(uint8_t pin) {
|
||||||
digitalWrite(pin, HIGH);
|
gpio_put(pin, HIGH);
|
||||||
digitalWrite(pin, LOW);
|
gpio_put(pin, LOW);
|
||||||
}
|
}
|
||||||
|
|
||||||
void clearShiftReg(uint8_t srclk, uint8_t srclr) {
|
void clearShiftReg(uint8_t srclk, uint8_t srclr) {
|
||||||
digitalWrite(srclr, LOW);
|
gpio_put(srclr, LOW);
|
||||||
pulsePin(srclk);
|
pulsePin(srclk);
|
||||||
digitalWrite(srclr, HIGH);
|
gpio_put(srclr, HIGH);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void outputEnable(uint8_t pin, bool enable) {
|
inline void outputEnable(uint8_t pin, bool enable) {
|
||||||
digitalWrite(pin, !enable);
|
gpio_put(pin, !enable);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ROW_COUNT 40
|
#define ROW_COUNT 40
|
||||||
|
@ -57,6 +58,10 @@ void setup() {
|
||||||
|
|
||||||
memset(framebuffer, 0, sizeof(framebuffer));
|
memset(framebuffer, 0, sizeof(framebuffer));
|
||||||
|
|
||||||
|
// disable output
|
||||||
|
outputEnable(COL_OE, false);
|
||||||
|
outputEnable(ROW_OE, false);
|
||||||
|
|
||||||
// set up col pins
|
// set up col pins
|
||||||
pinMode(COL_SER, OUTPUT);
|
pinMode(COL_SER, OUTPUT);
|
||||||
pinMode(COL_OE, OUTPUT);
|
pinMode(COL_OE, OUTPUT);
|
||||||
|
@ -71,20 +76,14 @@ void setup() {
|
||||||
pinMode(ROW_SRCLK, OUTPUT);
|
pinMode(ROW_SRCLK, OUTPUT);
|
||||||
pinMode(ROW_SRCLR, OUTPUT);
|
pinMode(ROW_SRCLR, OUTPUT);
|
||||||
|
|
||||||
// disable output
|
|
||||||
outputEnable(COL_OE, false);
|
|
||||||
outputEnable(ROW_OE, false);
|
|
||||||
|
|
||||||
// clear output - cols
|
// clear output - cols
|
||||||
digitalWrite(COL_SER, LOW);
|
|
||||||
clearShiftReg(COL_SRCLK, COL_SRCLR);
|
clearShiftReg(COL_SRCLK, COL_SRCLR);
|
||||||
|
pulsePin(COL_RCLK);
|
||||||
outputEnable(COL_OE, true);
|
outputEnable(COL_OE, true);
|
||||||
|
|
||||||
// clear output - rows
|
// clear output - rows
|
||||||
digitalWrite(ROW_SRCLR, HIGH);
|
|
||||||
digitalWrite(ROW_SER, HIGH);
|
|
||||||
clearShiftReg(ROW_SRCLK, ROW_SRCLR);
|
clearShiftReg(ROW_SRCLK, ROW_SRCLR);
|
||||||
outputEnable(ROW_OE, true);
|
pulsePin(ROW_RCLK);
|
||||||
|
|
||||||
// clear frames
|
// clear frames
|
||||||
frameIndex = 0;
|
frameIndex = 0;
|
||||||
|
@ -181,7 +180,7 @@ void loop() {
|
||||||
// apply brightness
|
// apply brightness
|
||||||
bool gotLight = (pxValue >> (4 + brightnessPhase)) & 1;
|
bool gotLight = (pxValue >> (4 + brightnessPhase)) & 1;
|
||||||
// set value (note: inverted logic)
|
// set value (note: inverted logic)
|
||||||
digitalWrite(COL_SER, !gotLight);
|
gpio_put(COL_SER, !gotLight);
|
||||||
// push value
|
// push value
|
||||||
pulsePin(COL_SRCLK);
|
pulsePin(COL_SRCLK);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue