Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 18 of 18

Thread: I need a sketch that will read and display Jinx! .dat files from a Teensy 3.6 SDcard

  1. #1

    I need a sketch that will read and display Jinx! .dat files from a Teensy 3.6 SDcard

    I have an array of 5ea. 32X8 NeoPixel Panels connected to a teensy 3.6 with a OctoWS2811 card.
    I can display Jinx generated animations, including scrolling text on the array with Glediator.ino.

    I saved a "myanim.dat" file to an SD card but I can not properly read, then display the contents on the array.

    With the sketch in https://hackaday.io/project/5714-gle...rduino/details (modified for NUM_LEDS and SD pin) I get an indication of a good read/display but it was only on a portion of the 1st panel. The sketch does not include OctoWS2811.

    Any help will be much appreciated.

    Thank you.

  2. #2
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    15,711
    We can probably help you get this running, but you have to do more. At the very least, you must post the full code you tried (even if only a slight change) and details of how your LEDs are wired. Photos are best.

  3. #3
    Paul,

    I can not find instructions about formatting code or inserting pictures for this Forum.

  4. #4
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    15,711
    Use these buttons...

    Name:  sc.png
Views: 222
Size:  8.6 KB

    To check, click "Go Advanced" or "Preview Post" to see how your message will appear.

  5. #5
    On my iMac the pjrc forum formatting menu doesn't show. I'm now on my PC.

    I was using this code to read and display a Jinx! generated 'myanim.dat' file on my 5 panel 32X8 neopixel array.

    Code:
    // Glediator Arduino UNO sketch by Jens Andrée
    // 500k bauds with 80 pixels no problem
    // sdcard stream for stand-alone operation.
    
    #include <FastLED.h>
    #include <SPI.h>
    #include <SD.h>
    
    #define NUM_LEDS 1280
    #define DATA_PIN 2
    #define CLOCK_PIN 3
    #define CMD_NEW_DATA 1
    #define BAUD_RATE 100000  //if using Glediator via serial
    
    File fxdata;
    CRGB leds[NUM_LEDS];
    
    void setup()
    {
      FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS); //se doc for different LED strips
    //  Serial.begin(BAUD_RATE); // when using Glediator via usb
      Serial.begin(115200);
      
      for(int y = 0 ; y < NUM_LEDS ; y++) 
      {
        leds[y] = CRGB::Black; // set all leds to black during setup
      }
      FastLED.show();
    
      pinMode(10, OUTPUT); // CS/SS pin as output for SD library to work.
      digitalWrite(10, HIGH); // workaround for sdcard failed error...
    
      if (!SD.begin(BUILTIN_SDCARD))
      {
        Serial.println("sdcard initialization failed!");
        return;
      }
      Serial.println("sdcard initialization done.");
      
      // test file open
      fxdata = SD.open("myanim.dat");  // read only
      if (fxdata)
      {
        Serial.println("file open ok");      
        fxdata.close();
      }
    }
    
    int serialGlediator ()
    {
      while (!Serial.available()) {}
      return Serial.read();
    }
    
    void loop()
    {
    
    // uncomment for Glediator  
    //  while (fileGlediator () != CMD_NEW_DATA) {}
    //  Serial.readBytes((char*)leds, NUM_LEDS*3);
    
      fxdata = SD.open("myanim.dat");  // read only
      if (fxdata)
        {
          Serial.println("file open ok");      
        }
    
      while (fxdata.available()) 
      {
        fxdata.readBytes((char*)leds, NUM_LEDS*3);
        FastLED.show();
        delay(20); // set the speed of the animation. 20 is appx ~ 500k bauds
      }
      
      // close the file in order to prevent hanging IO or similar throughout time
      fxdata.close();
    }
    I tried to 'Insert Image' of the display showing proper scrolling of "Jinx!" with Glediator.ino and the display I get with the above code - but - I got this with both pictures:
    Click image for larger version. 

Name:	Capture.PNG 
Views:	14 
Size:	3.2 KB 
ID:	11496
    I'll try again later with the Insert Image of my array.

  6. #6
    This video shows the proper operation of the 5 32X8 neopixel panel array..



    This is how the code in post #5 displayed the Jinx! generated myanim.dat file from the SD Card.



    Thanks for your attention.

  7. #7
    Is there any additional information I need to supply to get help with the sketch?
    I think the first video shows that the 8X32 panels were wired properly.

  8. #8
    Should be OK now.

  9. #9
    Does anyone have any ideas how to write the sketch that I need?

  10. #10
    Quote Originally Posted by OldBotBuilder View Post
    Does anyone have any ideas how to write the sketch that I need?
    I need this script for another project too. It will be a 24X90 sign display. We want to run the teensy headless because the sign will be remotely located and battery powered.

  11. #11
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    15,711
    Are there any tutorials or step-by-step instructions for using Jinx, and specifically how to get it to export these .DAT files?

    Is there any documentation about the .DAT file data format?

    I have personally never used Jinx, and honestly I just don't have time to get into it, if I were to look at this application. I would like to create an example for the OctoWS2811 library, if I could do this pretty quickly. But such an example would not be very useful (and perhaps create more questions than it helps anyone) if there isn't good info for others about how to get the .DAT file created.

  12. #12
    Paul,

    For the Jinx! User Manual (Version 2.4) go to http://www.live-leds.de/downloads/
    Should I send you the .dat file that I used for the 2nd video? It is about 4KB.

    For customers using Teensy 3.6 and OctoWS2811 to make signage from LED strips, Jinx is a very powerful 'animation/effects' generator.

  13. #13
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    15,711
    Quote Originally Posted by OldBotBuilder View Post
    For the Jinx! User Manual (Version 2.4) go to http://www.live-leds.de/downloads/
    This user manual is not enough. You didn't even manage to say which page number to read!

    I will *not* invest engineering time into writing a .DAT file player if this manual (and it's info on page 24) is all that is available to new users. There must be a step-by-step tutorial of some sort (screenshots or video). There must also be clear documentation. The manual says "Glediator2 / Solderlab UIB compatible recording files", but there is no link to documentation about this format.

  14. #14
    Paul,

    The info needed to create the .dat file is on page 22 Add and Edit Output Devices.

    "The Data section will give you control over protocol specific options and
    includes the number of channels as well as the block size for some protocols.
    The next section will configure the serial port and the baud rate if it is a serial
    or usb (e.g. FTDI) based device and the last section will let you redirect the
    protocol output into a file. This would be useful to create animation files,
    which you can play on a standalone controller. After selecting the Redirect
    Output to File option you have to choose the file to record into with the select
    button. Recording starts on activating output and stops on closing output. "

    Here is a myanim.dat file:
    Attached Files Attached Files

  15. #15
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    15,711
    Well if you have a big file filled with normal glediator data, just edit the example to read the file instead of getting it from the serial port. Same code, but instead of Serial.read() use myfile.read().

  16. #16
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Posts
    15,711
    I'm going to try to help you with some code to get you started. But in doing so, I want to be clear that I do not intend to do your project for you. If this doesn't work, you will need to figure out how to adapt it. This is meant to help you, but I'm not going to do more than this. Ok?

    Here goes...

    Code:
    // Glediator example with OctoWS2811, by mortonkopf
    //
    // https://forum.pjrc.com/threads/33012-Gladiator-with-OctoWS2811-working-example
    
    #include <OctoWS2811.h>
    #include <SPI.h>
    #include <SD.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);
    
    File myfile;
    
    // Use these for the SD+Wiz820 or other adaptors
    //#define SDCARD_CS_PIN    4
    //#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
        while (1) {
          Serial.println("Unable to access the SD card");
          delay(500);
        }
      }
    }
    
    int serialGlediator() {
      while (!Serial.available()) {}
      return Serial.read();
    }
    
    int fileGlediator() {
      return myfile.read();
    }
    
    void loop() {
      byte r,g,b;
      int i;
    
      if (!myfile) {
        // need to open the file
        myfile = SD.open("myanim.dat");
        if (!myfile) {
          Serial.println("could not open the file!  :(");
          delay(500);
          return;
        }
      }
      while (fileGlediator() != 1) {}
    
      for (i=0; i < NUM_LEDS; i++) {
        b = fileGlediator();
        r = fileGlediator();
        g = fileGlediator();
    
        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)
    {
      return (((unsigned int)b << 16) | ((unsigned int)r << 8) | (unsigned int)g);
    }

  17. #17
    Paul,

    Thank you very much for your help.

  18. #18
    Paul,

    The code works great! I changed ledsPerStrip = 256; and NUM_LEDS = 1280; (for my panels).
    To manage the display speed I added delay(20); after leds.show();

    Again, thanks very much.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •