Was this ever tested? I'm having trouble with this at the moment. Slightly different based on this:
http://www.epyon.be/2013/07/06/using-the-teensy-3-0-with-the-arduino-ethernet-shield/
I'm just trying to adapt the Video Display example to work with UDP input instead.
I switched out serial inputs for the recommended read(buffer, length).
int packetSize = Udp.parsePacket();
if(packetSize)
{
Udp.read(packetBuffer,UDP_TX_PACKET_MAX_SIZE);
if(packetBuffer[0] == '*'){
// receive a "master" frame - we send the frame sync to other boards
// the sender is controlling the video pace. The 16 bit number is
// how far into this frame to send the sync to other boards.
unsigned int startAt = micros();
unsigned int usecUntilFrameSync = 0;
int count = Udp.read((char *)&usecUntilFrameSync, 2); //Serial.readBytes((char *)&usecUntilFrameSync, 2);
if (count != 2) return;
count = Udp.read((char *)drawingMemory, sizeof(drawingMemory)); //Serial.readBytes((char *)drawingMemory, sizeof(drawingMemory));
if (count == sizeof(drawingMemory)) {
unsigned int endAt = micros();
unsigned int usToWaitBeforeSyncOutput = 100;
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);
}
}
Does this look proper?