Teensy 4.0 octo ws2812 sd card glediator/jinx

conteleon

New member
Dear friends i made led matrix project with Teensy 4.0 ,SD card and ws2812 led strips.
Led matrix:
X = 66
Y = 32
Number of leds per strip 66.
Number of leds 2112.
Wiring of strips : ZIK-ZAK (serpentine,snake line).
I am using JINX software for led matrix animation control and everything working perfectly with serial connection.
I am using this code:

Code:
#include <OctoWS2811.h>


//const int ledsPerStrip = 66;
//const int NUM_LEDS = 528;
#define LED_WIDTH    66  // number of LEDs horizontally
#define LED_HEIGHT  32   // number of LEDs vertically (must be multiple of 
#define LED_LAYOUT     0 
const int ledsPerStrip = LED_WIDTH * LED_HEIGHT / 8;
const int NUM_LEDS = 2112; //number of leds in matrix 2112

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);}

Output patch in Jinx is HS_TL (horisontal snake_top left).
This is the video:
https://www.youtube.com/watch?v=xCiRyM-FU_w


When i use SD card and myanim.dat file saved from Jinx glediator file recorder i have problem with patch its always oriented HL_TL (horisontal line_top left).
Problem is in recorded myanim.dat file
This is the code:

Code:
// Glediator example with OctoWS2811, by mortonkopf
//
// [url]https://forum.pjrc.com/threads/33012-Gladiator-with-OctoWS2811-working-example[/url]

#include <OctoWS2811.h>
#include <SPI.h>
#include <SD.h>

#define LED_WIDTH    66  // number of LEDs horizontally 65
#define LED_HEIGHT   32   // number of LEDs vertically (must be multiple of 32
#define LED_LAYOUT     0 //led rows left-right-left
const int ledsPerStrip = LED_WIDTH * LED_HEIGHT / 8;
//const int ledsPerStrip = 11;
const int NUM_LEDS = 2112; //number of leds in matrix 2080


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

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

File myfile;

// Use these for the SD+Wiz820 or other adaptors
#define SDCARD_CS_PIN    10
#define SDCARD_MOSI_PIN  11
#define SDCARD_SCK_PIN   13

// Use these with the Teensy 3.5 & 3.6 SD card
//#define SDCARD_CS_PIN    BUILTIN_SDCARD
//#define SDCARD_MOSI_PIN  11  // not actually used
//#define SDCARD_SCK_PIN   13  // not actually used

// Use these with the Teensy Audio Shield
//#define SDCARD_CS_PIN    10
//#define SDCARD_MOSI_PIN  7
//#define SDCARD_SCK_PIN   14

void setup() {
  leds.begin();
  leds.show();
 
  SPI.setMOSI(SDCARD_MOSI_PIN);
  SPI.setSCK(SDCARD_SCK_PIN);
  if (!(SD.begin(SDCARD_CS_PIN))) {
    // stop here, but print a message repetitively
   Serial.println("Unable to access the SD card");
      return;
    }
     Serial.println("sdcard initialization done.");
// test file open
myfile = SD.open("myanim.dat");  // read only
if (myfile) {
    Serial.println("file open ok");
    myfile.close();
  }
  }


int serialGlediator() {
  while (!Serial.available()) {}
  return Serial.read();
}

int fileGlediator() {
 return myfile.read();
}

 byte r,g,b;
 int i;
  
void loop() {

  
    myfile = SD.open("myanim.dat");
    if (myfile) {
      Serial.println("file open ok");
      
    }else {
      Serial.println("could not open the file!  :(");
      
      //SCB_AIRCR = 0x05FA0004; //command for restar teensy
    }
    
    
  while  (myfile.available()) {

  for (i=0; i < NUM_LEDS; i++) {
    b = fileGlediator();
    r = fileGlediator();
    g = fileGlediator();
    leds.setPixel(i, Color(r,g,b));
  }
  leds.show();
  delay(50);
  }
  myfile.close();
  
}
/* 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 video:
https://www.youtube.com/watch?v=P9BLpaFbk3k


Is there any way to solve this problem with new code exept to rewire my led matrix to HL_TL (horisontal line_top left ) led strips ?
 
Back
Top