Cleanup, only send the ledsPerStrip value to the teensy
parent
b48140d50f
commit
8d371b95df
|
@ -1,5 +1,2 @@
|
||||||
* More cleanup: the only required is the nb of leds/strip, not H/W
|
|
||||||
* Process as fast as possible (no frame sync required)
|
|
||||||
* Get the OctoWS2811 out, try to go upstream
|
* Get the OctoWS2811 out, try to go upstream
|
||||||
* There will be 2 Serial ports used, the startChar will not be used anymore (Serial1 will *only* get LED data)
|
* There will be 2 Serial ports used, the startChar will not be used anymore (Serial1 will *only* get LED data)
|
||||||
* remove commented/debug code
|
|
||||||
|
|
|
@ -60,8 +60,6 @@
|
||||||
|
|
||||||
#include "OctoWS2811.h"
|
#include "OctoWS2811.h"
|
||||||
|
|
||||||
int height = 0;
|
|
||||||
int width = 0;
|
|
||||||
int ledsPerStrip = 0;
|
int ledsPerStrip = 0;
|
||||||
|
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
@ -77,15 +75,10 @@ void setup() {
|
||||||
pinMode(13, OUTPUT);
|
pinMode(13, OUTPUT);
|
||||||
digitalWrite(13, HIGH);
|
digitalWrite(13, HIGH);
|
||||||
Serial.setTimeout(5000);
|
Serial.setTimeout(5000);
|
||||||
//delay(1000);
|
Serial.readBytes((char *)&ledsPerStrip, sizeof(ledsPerStrip));
|
||||||
Serial.readBytes((char *)&height, sizeof(height));
|
Serial.write((char *)&ledsPerStrip, sizeof(ledsPerStrip));
|
||||||
Serial.write((char *)&height, sizeof(height));
|
|
||||||
Serial.readBytes((char *)&width, sizeof(width));
|
|
||||||
Serial.write((char *)&width, sizeof(width));
|
|
||||||
digitalWrite(13, LOW);
|
digitalWrite(13, LOW);
|
||||||
//pinMode(12, INPUT_PULLUP); // Frame Sync
|
|
||||||
Serial.setTimeout(50);
|
Serial.setTimeout(50);
|
||||||
ledsPerStrip = width * height;
|
|
||||||
displayMemory = new int[ledsPerStrip*6];
|
displayMemory = new int[ledsPerStrip*6];
|
||||||
drawingMemory = new int[ledsPerStrip*6];
|
drawingMemory = new int[ledsPerStrip*6];
|
||||||
leds.attach(ledsPerStrip, displayMemory, drawingMemory, config);
|
leds.attach(ledsPerStrip, displayMemory, drawingMemory, config);
|
||||||
|
@ -100,28 +93,12 @@ void loop() {
|
||||||
unsigned int startAt = micros();
|
unsigned int startAt = micros();
|
||||||
unsigned int usecUntilFrameSync = 0;
|
unsigned int usecUntilFrameSync = 0;
|
||||||
count = Serial.readBytes((char *)drawingMemory, sizeof(int) * ledsPerStrip*6);
|
count = Serial.readBytes((char *)drawingMemory, sizeof(int) * ledsPerStrip*6);
|
||||||
//Serial.write((char *)drawingMemory, sizeof(int) * ledsPerStrip*6);
|
|
||||||
if (count >= sizeof(int) * ledsPerStrip*6) {
|
if (count >= sizeof(int) * ledsPerStrip*6) {
|
||||||
unsigned int endAt = micros();
|
|
||||||
unsigned int usToWaitBeforeSyncOutput = 1000;
|
|
||||||
if (endAt - startAt < usecUntilFrameSync) {
|
|
||||||
usToWaitBeforeSyncOutput = usecUntilFrameSync - (endAt - startAt);
|
|
||||||
}
|
|
||||||
//digitalWrite(12, HIGH);
|
|
||||||
//pinMode(12, OUTPUT);
|
|
||||||
delayMicroseconds(usToWaitBeforeSyncOutput);
|
|
||||||
//digitalWrite(12, LOW);
|
|
||||||
// WS2811 update begins immediately after falling edge of frame sync
|
|
||||||
digitalWrite(13, HIGH);
|
digitalWrite(13, HIGH);
|
||||||
leds.show();
|
leds.show();
|
||||||
digitalWrite(13, LOW);
|
digitalWrite(13, LOW);
|
||||||
}
|
}
|
||||||
} else if (startChar >= 0) {
|
} else if (startChar >= 0) {
|
||||||
//Serial.write(startChar);
|
|
||||||
//Serial.flush()
|
|
||||||
//digitalWrite(13, HIGH);
|
|
||||||
//delay(100);
|
|
||||||
//digitalWrite(13, LOW);
|
|
||||||
// discard unknown characters
|
// discard unknown characters
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,6 @@ Forwarder
|
||||||
|
|
||||||
* Control framerate in send function
|
* Control framerate in send function
|
||||||
* Define a max framerate and announce it in the config (redis)
|
* Define a max framerate and announce it in the config (redis)
|
||||||
* Only send the LED/strip value to the adruino code
|
|
||||||
* Remove commented code
|
* Remove commented code
|
||||||
|
|
||||||
Receiver
|
Receiver
|
||||||
|
|
|
@ -38,12 +38,10 @@ def serialConfigure(port_name, baudrate=9600):
|
||||||
sys.stderr.write("Could not open serial port %s: %s\n" % (ser.portstr, e))
|
sys.stderr.write("Could not open serial port %s: %s\n" % (ser.portstr, e))
|
||||||
return
|
return
|
||||||
|
|
||||||
print(height, width)
|
ledsPerStrip = height * width
|
||||||
ser.write(height.to_bytes(4, byteorder='little'))
|
print(ledsPerStrip)
|
||||||
data = ser.read(4)
|
ser.write(ledsPerStrip.to_bytes(4, byteorder='little'))
|
||||||
print(data, int.from_bytes(data, byteorder='little'))
|
|
||||||
|
|
||||||
ser.write(width.to_bytes(4, byteorder='little'))
|
|
||||||
data = ser.read(4)
|
data = ser.read(4)
|
||||||
print(data, int.from_bytes(data, byteorder='little'))
|
print(data, int.from_bytes(data, byteorder='little'))
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue