Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playback issue with flickering #11

Open
wizzgit opened this issue Jun 2, 2023 · 1 comment
Open

Playback issue with flickering #11

wizzgit opened this issue Jun 2, 2023 · 1 comment

Comments

@wizzgit
Copy link

wizzgit commented Jun 2, 2023

Hello i play with 256 led matrix.
When i record i lost 30%
and when i playback there is some flickering.
How can i have better results ?
Is there i possibility to sd playback without wifi ?
The biggest problem is the flickering when i playback from SD (is it because i have 30% lost frame ?).

PS : I uncomment line 144 (if i dont do that my esp32 reboot alltimes)

//create the task for the display
    xTaskCreatePinnedToCore(ArtnetESP32::afterFrameTask, "afterFrameTask", 3000, this, 1, &artnetAfterFrameHandle, 0);
    xTaskCreatePinnedToCore(ArtnetESP32::readFromSDTask, "readFromSDTask", 3000, this,1, &readFromSDHandle, 0);

thanks for your help

first sketch SD-artnet:

#include "SD.h"
#include "SPI.h"
#include <ArtnetESP32.h>
#include "FastLED.h"
FASTLED_USING_NAMESPACE

//The following has to be adapted to your specifications

#define LED_PIN 2
#define LED_WIDTH 8
#define LED_HEIGHT 32
#define NUM_LEDS LED_WIDTH*LED_HEIGHT
#define UNIVERSE_SIZE 170 //my setup is 170 leds per universe no matter if the last universe is not full.
CRGB leds[NUM_LEDS];
File myFile;

ArtnetESP32 artnet;

bool record_status=false;
bool has_recorded=false;
bool sd_card_present=false;
#define PIN_RECORD     22
#define PIN_SD_CS      17 


void recordfunction()
{
  if (artnet.frameslues%100==0)
   Serial.printf("nb frames read: %d  nb of incomplete frames:%d lost:%.2f %%\n",artnet.frameslues,artnet.lostframes,(float)(artnet.lostframes*100)/artnet.frameslues);
   //here the buffer is the led array hence a simple FastLED.show() is enough to display the array
   FastLED.show(); //if the array is really big I would not put any FastLED.show() because it takes time
}


void setup() {
  Serial.begin(115200);


   WiFi.mode(WIFI_STA);

        WiFi.begin("Jaupi Wifi", "manonjaupitre");

    while (WiFi.status() != WL_CONNECTED) {
      Serial.println(WiFi.status());

        delay(500);
        Serial.print("Wifi connecting.");
    }

    Serial.println("");
    Serial.println("WiFi connected.");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());


//set up your FastLED to your configuration ps: the more pins the better
    FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);

    pinMode(PIN_RECORD,INPUT);
   

      if(!SD.begin(PIN_SD_CS)){
          Serial.println("Card Mount Failed");
          sd_card_present=false;
      }
      else
      {
          uint8_t cardType = SD.cardType();
          if(cardType == CARD_NONE){
              Serial.println("No SD card attached");
              sd_card_present=false;
          }
          else
          {
              sd_card_present=true;
              Serial.println("SD Card ready");
          }
      }
    myFile=SD.open("/filename",FILE_WRITE);
    artnet.setLedsBuffer((uint8_t*)leds); //set the buffer to put the frame once a frame has been received this is mandatory
    artnet.setframeRecordCallback(&recordfunction); //this is not mandatory
    if(sd_card_present)
        artnet.startArtnetrecord(myFile);
    artnet.begin(NUM_LEDS,UNIVERSE_SIZE); //configure artnet

}

void loop() {
    

// put pin PIN_RECORD  to HIGH to start the  record
// put it back to LOW to stop it

  while(record_status && sd_card_present){

              has_recorded=true; 
              artnet.readFrameRecord();
              record_status=digitalRead(PIN_RECORD);
                          
          }

  if(has_recorded && sd_card_present)
  {
    artnet.stopArtnetRecord();
  }
  record_status=digitalRead(PIN_RECORD);
}

Second sketch read-SD

#include "SD.h"
#include "SPI.h"
#include <ArtnetESP32.h>

#include "FastLED.h"
FASTLED_USING_NAMESPACE

// ATTENTION J'AI UNCOMMENT LA LINE 144 de ArtnetESP32.cpp

//The following has to be adapted to your specifications
#define LED_PIN 2
#define LED_WIDTH 8
#define LED_HEIGHT 32
#define NUM_LEDS LED_WIDTH*LED_HEIGHT
#define UNIVERSE_SIZE 170 //my setup is 170 leds per universe no matter if the last universe is not full.
CRGB leds[NUM_LEDS];
File myFile;

ArtnetESP32 artnet;

uint32_t record_duration2=0;
bool sd_card_present=false;

void afterSDread()
{
  FastLED.show();
}

void setup() {
  Serial.begin(115200);


   WiFi.mode(WIFI_STA);

    Serial.printf("Connecting ");
    WiFi.begin("Jaupi Wifi", "manonjaupitre");

    while (WiFi.status() != WL_CONNECTED) {
      Serial.println(WiFi.status());

        delay(500);
        Serial.print(".");
    }

    Serial.println("");
    Serial.println("WiFi connected.");
    Serial.println("IP address: ");
    Serial.println(WiFi.localIP());


//set up your FastLED to your configuration ps: the more pins the better
    // FastLED.addLeds<WS2812, 12>(leds, NUM_LEDS);

    FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);



      if(!SD.begin()){
          Serial.println("Card Mount Failed");
          sd_card_present=false;
      }
      else
      {
          uint8_t cardType = SD.cardType();
          if(cardType == CARD_NONE){
              Serial.println("No SD card attached");
              sd_card_present=false;
          }
          else
          {
              sd_card_present=true;
          }
      }
    myFile=SD.open("/filename");
    artnet.setLedsBuffer((uint8_t*)leds); //set the buffer to put the frame once a frame has been received this is mandatory
    artnet.setreadFromSDCallback(&afterSDread);
    artnet.begin(NUM_LEDS,UNIVERSE_SIZE); //configure artnet

}

void loop() {
    if(sd_card_present)
    {
      if (!artnet.readNextFrameAndWait(myFile))

              {
                record_duration2=millis()-record_duration2;
                  myFile.seek(0);

                  Serial.printf("duration %ld \n",record_duration2);

                  record_duration2=millis();

              }
    }
}

Thanks for your help

@wizzgit
Copy link
Author

wizzgit commented Jul 18, 2023

Excuse me, can i have some help please ???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant