Gladiator with OctoWS2811 - working example

Status
Not open for further replies.

mortonkopf

Well-known member
@Paul, as discussed, here is a working example sketch for using Glediator with OctoWS2811 library, and some guidance on setting up.


To get Glediator running, you need to install two files that allow java applications to communicate via the computers ports. The two files you need are:
librxtxSerial.jnilib and RXTXcomm.jar

you can download these files from the RXTX site, and also find further help on installing, although I did not find the help so helpful.
http://rxtx.qbang.org/wiki/index.php/Main_Page

The download page is here: http://rxtx.qbang.org/wiki/index.php/Download

The two files need to go into a folder called Library. For some reason, i did not have a folder, so had to create one.
If you don’t have it already, create folders in the library folder and call it /Java/Extensions.
in my mac file structure this is put under /Users/Home/Library

Library_grab.jpg

Into this folder put the two files
librxtxSerial.jnilib
and
RXTXcomm.jar

for linux there is info on this link http://rxtx.qbang.org/wiki/index.php/Installation_on_Linux
but unfortunately I don’t use it, so I have this example running on MacBook Pro.

Upload the sketch below to your Teensy.

Code:
#include <OctoWS2811.h>

const int ledsPerStrip = 34;
const int NUM_LEDS =272;

DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];

const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

void setup() {
  leds.begin();
  leds.show();
}
int serialGlediator() {
  while (!Serial.available()) {}
  return Serial.read();
}
   byte r,g,b;
   int i;
   
void loop()
{                                       
   while (serialGlediator() != 1) {} 

   for (i=0; i < NUM_LEDS; i++) {
   b = serialGlediator();
   r = serialGlediator();
   g = serialGlediator();
   
        leds.setPixel(i, Color(r,g,b));             
   }                                   
    leds.show();                                                       
  }                                         
                                        

/* Helper functions */
// Create a 24 bit color value from R,G,B 
unsigned int Color(byte r, byte g, byte b)
{
  //Take the lowest 8 bits of each value and append them end to end
return( ((unsigned int)b & 0xFF )<<16 | ((unsigned int)r & 0xFF)<<8 | (unsigned int)g & 0xFF);}

Gladiator is a pain, in that it seems to hang and crash on my Mac if you do things in the wrong order. First you need to set the matrix size, and then set the output parameters. Also, when setting the output parameters, you can’t go back and change settings after opening the serial port, so do this last.

gled1.jpg

when restarting Glediator, in the setup menu, you should now see the list of ports. Select the tty port usbmodemxxxx or some such. and then click apply.

gled2.jpg

Ensure that you have selected the output type as Glediator protocol.
 
Last edited:
Do you add librxtxSerial.jnilib and RXTXcomm.jar to just Mac computer or both Mac and Windows as well. It says that the librxtxSerial.jnilib is a Mac file or it does not matter.
 
I have not installed this on windows, but the installation instructions suggest that you do need those two files.
Screenshot_2016-02-13-09-06-53.jpg
 
You need the RXTX files for your type of computer. You can't use the RXTX files made for a Mac on your Windows computer.

You need to get copies the RXTX files that are built for Windows.
 
sorry Paul, yes, my response was ambiguous this morning. the screen shot explicitly mentions windows and the need for system specific rxtx files.
 
This link that was posted earlier solved all of my problems. If you are using snakeline leds meaning they all connect to one line forming several lines like a snake. This is the script to use for WS2812b using all of the same information above for Java Files.
 
Yes, you can have the onboard led flicker whilst receiving data from Glediator by using pinMode() and digitalWrite(). You can set pin 13 to HIGH at the start of each data update cycle, and set it to LOW at the end after writing to the leds. You need to set the pin to OUTPUT in setup. After setting the pin to OUTPUT, set it low by using digitalWrite, then in the loop toggle between high and low states. Here is an example of what it might look like:

HOWEVER, I have not tested this on an led array, it might cause issues with led update, it might not.

Code:
void setup() {
        Serial.begin(115200); 
     LEDS.addLeds<WS2812B, dataline>(leds, NUM_LEDS);
     pinMode(13, OUTPUT); 
     digitalWrite(13, LOW); 
}

Code:
void loop() {
   while (serialGlediator() != 1) {} 
     digitalWrite(13, HIGH);
   for (int i=0; i < NUM_LEDS; i++) {
     leds[i].r = serialGlediator();
     leds[i].g = serialGlediator();
     leds[i].b = serialGlediator();
   }
     FastLED.show();
     digitalWrite(13, LOW); 
}
 
Any idea of a maximum limit for number of pixels with this code?
I'm wondering if it's realistic to attempt drive 3000 pixels from Jinx using the Glediator protocol?
 
Teensy certainly can handle 3000 LEDs.

We built this project a couple years ago with 4320 LEDs. While it's controlled by a SD card without an PC, I can tell you I did run it with the VideoDisplay code and movie2serial on my PC. It ran fine with 30 Hz video.

https://community.arm.com/groups/embedded/blog/2014/05/23/led-video-panel-at-maker-faire-2014

This Glediator example code is running a 1-byte-at-a-time read, which isn't the fastest way to receive incoming data. I believe it should still be fine for 3000 LEDs. But if this does turn out to be a limitation, please speak up. It's not terribly difficult to change this to use a buffer, like VideoDisplay does.

I've never used Jinx. I have no idea whether it can handle 3000 LEDs. I can really only help you with the Teensy side, and I can tell you Robin, Erin and I personally built that 4320 LED project in 2014 which was controlled by a single Teensy 3.1, so I'm confident Teensy will be up to the task.
 
Thanks - yeah I know Teensy can do 4000 Leds easy - just wasn't sure whether the serial stuff would work that quickly.

I'll give it a try Monday - annoyingly I stepped on my OctoWs2811 adaptor and snapped the usb port off the teensy I'd soldered to it! Doh! New one not here till Monday. I don't think I can unsolder it. Maybe I'll connect another Teensy with some jumpers.
 
How do you add the onboard led flicker code to this code.
Back]

#include "FastLED.h"
#define NUM_LEDS 400
const int dataline = 6;

CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(115200);
LEDS.addLeds<WS2812B, dataline>(leds, NUM_LEDS);
}
int serialGlediator() {
while (!Serial.available()) {}
return Serial.read();
}
void loop() {
while (serialGlediator() != 1) {}

for (int i=0; i < NUM_LEDS; i++) {
leds.r = serialGlediator();
leds.g = serialGlediator();
leds.b = serialGlediator();
}
FastSPI_LED.show();
}
 
@deeveejay, to get the onboard led to flicker, first set pin 13 to output, by adding the line "pinMode(13, OUTPUT); " into the setup() area of code, try just below the "LEDS.addLeds....." line. Then, in the loop you need to toggle the pin between HIGH and LOW states. You do this by adding in two lines as in post #11, that use digitalWrite() to set the pin. These lines are digitalWrite(13, HIGH); and digitalWrite(13, LOW);
Have a look at post #11 to see where I put them in as an example, and paste the two new lines in in those places. It should work.
 
I'll check this tonight Morton. No reason it shouldn't do what @deeveejay hopes for. I do currently I have it running Jinx! through the gladiator protocol on a 16 x 70 (1120) matrix. Working great. Thanks!
 
Thanks - yeah I know Teensy can do 4000 Leds easy - just wasn't sure whether the serial stuff would work that quickly.

I'll give it a try Monday - annoyingly I stepped on my OctoWs2811 adaptor and snapped the usb port off the teensy I'd soldered to it! Doh! New one not here till Monday. I don't think I can unsolder it. Maybe I'll connect another Teensy with some jumpers.

Ok I've tried it and I'm having a few issues. I've got it a 192 x 22 matrix set up and I'm sending data from Jinx to Teensy.
Its working great except for the last chunk of data which is a bit scrambled.
I'm wondering if this could be because the serial data isn't being sent/read fast enough?
I've ruled out the matrix itself - the panel works if I swap the cat 6 cables around or run the octows2811 demo.

I've hacked the sketch a bit to try to minimise the amount of data I was sending. I can't remember if it made any difference but its still acting up.
I have 552 pixels on output 0,2 and 4, 460 on 1,3 and 5 ,550 on 6 and zero on the last one (if that makes any sense)

Code:
#include <OctoWS2811.h>

const int ledsPerStrip = 600;
const int NUM_LEDS =4800;

DMAMEM int displayMemory[ledsPerStrip*6];
int drawingMemory[ledsPerStrip*6];

const int config = WS2811_GRB | WS2811_800kHz;
OctoWS2811 leds(ledsPerStrip, displayMemory, drawingMemory, config);

void setup() {
  leds.begin();
  leds.show();
}
int serialGlediator() {
  while (!Serial.available()) {}
  return Serial.read();
}
   byte r,g,b;
   int i,j,limit;
   
void loop()
{                                       
   while (serialGlediator() != 1) {} 

   for (j=0; j<4;j++) {
    limit=(j*2)*600;
    for (i=limit; i < limit+552; i++) {
   
   b = serialGlediator();
   r = serialGlediator();
   g = serialGlediator();
   
        leds.setPixel(i, Color(r/2,g/2,b/2)); 
    }            
     
   limit=((j*2)+1)*600;
   for (i=limit; i < limit+460; i++) {
   b = serialGlediator();
   r = serialGlediator();
   g = serialGlediator();
   
        leds.setPixel(i, Color(r/2,g/2,b/2));             
   }
}
  
   for (i=3600; i < 4150; i++) {
   b = serialGlediator();
   r = serialGlediator();
   g = serialGlediator();
   
        leds.setPixel(i, Color(g/2,b/2,r/2));             
   }  
    leds.show();                                                       
  }                                         
                                        

/* Helper functions */
// Create a 24 bit color value from R,G,B 
unsigned int Color(byte r, byte g, byte b)
{
  //Take the lowest 8 bits of each value and append them end to end
return( ((unsigned int)b & 0xFF )<<16 | ((unsigned int)r & 0xFF)<<8 | (unsigned int)g & 0xFF);}
 
This is the code I compiled from your advice for the onboard led flicker. I actually worked. Thanks a million.


Code:
#include "FastLED.h"
#define NUM_LEDS 1540
const int dataline = 5;

CRGB leds[NUM_LEDS];
void setup() {
Serial.begin(115200); 
LEDS.addLeds<WS2812B, dataline>(leds, NUM_LEDS);
  pinMode(13, OUTPUT); 
  digitalWrite(13, LOW);
}
int serialGlediator() {
while (!Serial.available()) {}
return Serial.read();
}
void loop() {
   while (serialGlediator() != 1) {} 
     digitalWrite(13, HIGH);
   for (int i=0; i < NUM_LEDS; i++) {
     leds[i].r = serialGlediator();
     leds[i].g = serialGlediator();
     leds[i].b = serialGlediator();
   }
     FastLED.show();
     digitalWrite(13, LOW); 
}
 
Last edited:
@gavspav, do you think it might be scrambled because the order of colour you use for the last led group: leds.setPixel(i, Color(g/2,b/2,r/2)); instead of RGB as you have for the other led groups?
 
Last edited:
No I changed that myself to try and sort the scramble out!
I haven't run out of memory have I?
If I reduce the leds per strip to 500 the problems seem to go away - a bit hard to tell but the colours definintely right themselves.

On testing the last panel is not displaying the correct data. It is showing a scrambled version of the second panel.
If there is nothing on the second, the seventh is blank - it is like a scrambled mirror of the second.
I've tried swapping the data (and code) for the unused 8th output - same behaviour.

Works fine with OctoWs2811 sketches.

Any ideas?
 
Last edited:
Ok I've got to the bottom of this one and surprise suprise, wait for it.......
It was a basic programming mistake!
My loop reading the serial data was from i=0 to 4 when it should have been 0 to 3 meaning it was reading more data than there actually was.,
And confusing the hell out of me.

So I can confirm that Jinx with a 4800 pixel matrix and OctoWs2811 library/adaptor via Glediator output is working.
Thanks for your help.
 
@gavspav a video of Glediator - Jinx - OctoWS2811 lib with 4800 pixels would be very nice to see if you get the time. It will support interest in further dev around using this type of software to output to teensy 'nodes'.
 
@gavspav a video of Glediator - Jinx - OctoWS2811 lib with 4800 pixels would be very nice to see if you get the time. It will support interest in further dev around using this type of software to output to teensy 'nodes'.
Will do at the weekend. My workshop is too small to get any decent video. In fact I can't really tell what it looks like!
I say 4800 pixels cos that's how many the teensy thinks there is. In reality it's about 3500.
 
Will do at the weekend. My workshop is too small to get any decent video. In fact I can't really tell what it looks like!
I say 4800 pixels cos that's how many the teensy thinks there is. In reality it's about 3500.

Ok here's a link to a video clip of the matrix.
It is an interactive sign which lights up when a chain of people bridge two pedestrian barriers mounted on a platform.
It was installed at Cheriton, UK at a small lighting festival. It went down pretty well!
Thanks for your help.

EDIT I probably should've started a new thread for this but just realised I've made another Teensy based lighting piece which you can see in this music video
 
Last edited:
Status
Not open for further replies.
Back
Top