Cleanup, only send the ledsPerStrip value to the teensy

master
Raphaël Vinot 2015-03-19 00:09:50 +01:00
parent b48140d50f
commit 8d371b95df
4 changed files with 5 additions and 34 deletions

View File

@ -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
* There will be 2 Serial ports used, the startChar will not be used anymore (Serial1 will *only* get LED data)
* remove commented/debug code

View File

@ -60,8 +60,6 @@
#include "OctoWS2811.h"
int height = 0;
int width = 0;
int ledsPerStrip = 0;
int count = 0;
@ -77,15 +75,10 @@ void setup() {
pinMode(13, OUTPUT);
digitalWrite(13, HIGH);
Serial.setTimeout(5000);
//delay(1000);
Serial.readBytes((char *)&height, sizeof(height));
Serial.write((char *)&height, sizeof(height));
Serial.readBytes((char *)&width, sizeof(width));
Serial.write((char *)&width, sizeof(width));
Serial.readBytes((char *)&ledsPerStrip, sizeof(ledsPerStrip));
Serial.write((char *)&ledsPerStrip, sizeof(ledsPerStrip));
digitalWrite(13, LOW);
//pinMode(12, INPUT_PULLUP); // Frame Sync
Serial.setTimeout(50);
ledsPerStrip = width * height;
displayMemory = new int[ledsPerStrip*6];
drawingMemory = new int[ledsPerStrip*6];
leds.attach(ledsPerStrip, displayMemory, drawingMemory, config);
@ -100,28 +93,12 @@ void loop() {
unsigned int startAt = micros();
unsigned int usecUntilFrameSync = 0;
count = Serial.readBytes((char *)drawingMemory, sizeof(int) * ledsPerStrip*6);
//Serial.write((char *)drawingMemory, 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);
leds.show();
digitalWrite(13, LOW);
}
} else if (startChar >= 0) {
//Serial.write(startChar);
//Serial.flush()
//digitalWrite(13, HIGH);
//delay(100);
//digitalWrite(13, LOW);
// discard unknown characters
}
}

View File

@ -3,7 +3,6 @@ Forwarder
* Control framerate in send function
* Define a max framerate and announce it in the config (redis)
* Only send the LED/strip value to the adruino code
* Remove commented code
Receiver

View File

@ -38,12 +38,10 @@ def serialConfigure(port_name, baudrate=9600):
sys.stderr.write("Could not open serial port %s: %s\n" % (ser.portstr, e))
return
print(height, width)
ser.write(height.to_bytes(4, byteorder='little'))
data = ser.read(4)
print(data, int.from_bytes(data, byteorder='little'))
ledsPerStrip = height * width
print(ledsPerStrip)
ser.write(ledsPerStrip.to_bytes(4, byteorder='little'))
ser.write(width.to_bytes(4, byteorder='little'))
data = ser.read(4)
print(data, int.from_bytes(data, byteorder='little'))