These are chat archives for Makuna/NeoPixelBus

17th
Sep 2016
Mehrdad K
@mkeyno
Sep 17 2016 05:40
actually it is related to my POV project which is image with 200 line x 144 LED x 3 size(85KB) store in ESP flash , I set pointer to that memory so it could read one line per time and put in the LED strip
ESP.flashRead(_index,(uint32_t *) LED_BUFFER,NUM_LEDS*3 );
then I should use memcpy(strip.Pixels(),LED_BUFFER,NUM_LEDS*3); ,
do you think is OK?
Michael Miller
@Makuna
Sep 17 2016 06:49
Its ok; but note you have a temporary or intermediate buffer "LED_BUFFER" and you are copying twice, once to it, then again into the pixels. This is fine; but after modifying the data using strip.Pixels(), make sure to call strip.Dirty() so they will get shown.
A better approach is to copy only once, from the flash directly into strip.Pixels(); and this is what the PROGMEM use will do; or use SPIFFS (flash file system) and the bitmap file features of the bitmap to read directly.
There might even be a way to get the address of the Flash from the _index and just use it to copy (can't use memcpy() as flash address are always 4 byte aligned and must always read 4 bytes so you must read a uint32_t at a time or it will crash
Mehrdad K
@mkeyno
Sep 17 2016 07:36
Michael the reason that I go after direct flash reading, was its speed , while the SPIFFS very slow I could get the much faster with direct reading , reading 75KB data with SPIFFS took about 70ms whereas with direct reading get the 2ms . Honestly I don't know how fast can I get with your approach caz I not pro in your lib yet but if you know fast way just let me know
also as it pasted , I could run rainbow effect with SW SPI perfectly but with HW very messy in last part of LED strip , I hope you could help in this way as well
but I must say your SW SPI methods very faster of FastLED, it took about 52 ms for same situation whereas you lib took about 13ms, which is so good , as I said my POV project must show image as least in 30 fps , which is about 40ms per frame , it's mean I should read file and show it in LED stripe less than 40 ms
Michael Miller
@Makuna
Sep 17 2016 17:09

It hit me this morning that you just read directly into the pixels...

ESP.flashRead(_index, (uint32_t*)strip.Pixels(),NUM_LEDS*3 );

But again, I know flash is read by 4 bytes increments; which does beg the question on the call above, is the last argument the number of bytes or the number of uin32_t's?

Mehrdad K
@mkeyno
Sep 17 2016 17:10
I just use the methods ESP folks offer me, and its works , I have no idea whether possible to change or cast any input parameters
as mention , I should deliver RGB data from flash to strip as fast as possible
Michael Miller
@Makuna
Sep 17 2016 17:13
Ok, just checked, the last argument is count of bytes; so the line I gave you above should work; removing one buffer copy that you are doing now, making it even faster.
How are you getting the "data" into flash?
Mehrdad K
@mkeyno
Sep 17 2016 17:16
I made webserver that simply upload my image file in the flash
like FSBrowser
Michael Miller
@Makuna
Sep 17 2016 17:17
On the subject of the hardware SPI problem, Is there anyway you could create a video of the issue and share it? Is it consistent at a specific pixel at the end the messiness starts?
Mehrdad K
@mkeyno
Sep 17 2016 17:18
not exact pixel it seems the closer to end the less stability and nosiy
Michael Miller
@Makuna
Sep 17 2016 17:19
Also, if its easy to try, increase the number of pixels that you pass to NeoPixelBus by 1/4 of the number you have in your strip, I think you said 144, so increase to 180 and see if the problem goes away.
Mehrdad K
@mkeyno
Sep 17 2016 17:20
ok , also I decrease the LED num and get better performance for lesser amount of LEDs
Mehrdad K
@mkeyno
Sep 17 2016 17:25
strange things come up . about 20 last LED has fix color and just about half of first pixel work fine
can you upload my sketch to your hardware , maybe I miss somethings here

#include <NeoPixelBus.h>

#define NUM_LEDS   144
//NeoPixelBus<DotStarBgrFeature, DotStarMethod> strip(NUM_LEDS,14,13);
NeoPixelBus<DotStarBgrFeature, DotStarSpiMethod> strip(NUM_LEDS); 
RgbColor black(0),color;
//RgbColor Red   = {128,   0,   0};
//RgbColor Green = {0  , 128,   0};
//RgbColor Blue  = {0  ,   0, 128};
//RgbColor Black = {0  ,   0,   0};
 //HslColor color(hueValue / 360.0f, 1.0f, 0.5f); 

byte pos;
RgbColor Wheel(uint8_t WheelPos) 
{
  WheelPos = 255 - WheelPos;
       if(WheelPos < 85)                    return RgbColor(255 - WheelPos * 3, 0, WheelPos * 3);
  else if(WheelPos < 170) {WheelPos -= 85;  return RgbColor(0, WheelPos * 3, 255 - WheelPos * 3); } 
  else                    {WheelPos -= 170; return RgbColor(WheelPos * 3, 255 - WheelPos * 3, 0);  }
}


void FillLEDsFromPaletteColors(byte index)
{
  byte hue=index;
  for( int i = 0;i<NUM_LEDS; i++)
    {

      //strip.SetPixelColor(i,  Wheel((hue * 256 / NUM_LEDS) & 255));
       strip.SetPixelColor(i,  Wheel(hue++));
      // strip.SetPixelColor(i,  RgbColor(hue++,0,0));
    }
}

void setup()
{
    Serial.begin(115200);
    while (!Serial); // wait for serial attach

    strip.Begin();

    // just pick some colors
    for( int i = 0;i<NUM_LEDS; i++) strip.SetPixelColor(i, RgbColor((0), (0), (0)));

 strip.Show();
 delay(1000);
    Serial.println();
    Serial.println("Running...");
}
void loop()
{   
    static uint8_t startIndex = 0;
    startIndex = startIndex + 3;  
    FillLEDsFromPaletteColors( startIndex);  
     strip.Show(); 
    delay(50);   

}
Michael Miller
@Makuna
Sep 17 2016 17:36
Try something simpler. Just use strip.ClearTo() to set the color of all of them to Red, Green, Blue with a delay of five seconds between them. I don't see anything wrong with what you have above; but it is always best to start simple to reproduce a problem.
I loaned my DotStars/ADA102 out to a friend so I cant try it today; but I will get them back in a few days.
Mehrdad K
@mkeyno
Sep 17 2016 17:36
ok Micheal
Mehrdad K
@mkeyno
Sep 17 2016 18:04
Michael I did, set the single color and let it value change from 0 to 255 in delay of about 150 ms in loop, it seems , it has no problem in lower number but when it value increased the noisy effect create in end of strip and expand along with value increase
whereas I enable SW SPI , it act perfectly
you know I have same situation with FastLED lib unless disable interrupt during the strip writing . but it was the SW SPI
Michael Miller
@Makuna
Sep 17 2016 18:44
Did you increase the count to 180?
Mehrdad K
@mkeyno
Sep 17 2016 18:45
yes , increase and then decrease , both shows noisy effect at the end
have you check the video
Michael Miller
@Makuna
Sep 17 2016 18:45
"let it value change from 0 to 255 in delay " what do you mean by this? What value?
Mehrdad K
@mkeyno
Sep 17 2016 18:46
strip.SetPixelColor(i, RgbColor(index,0,0));, in loop index change form 0 to 255 with delay about 150ms
Michael Miller
@Makuna
Sep 17 2016 18:49
something seems odd between what you explain and what the video shows. When are you calling Show()? before the delay? Again, please keep test simple. just call ClearTo and then Show, then delay.
Mehrdad K
@mkeyno
Sep 17 2016 18:52
for( int i = 0;i<NUM_LEDS; i++) strip.SetPixelColor(i,  RgbColor(index,0,0));
    strip.Show();
index++;
delay(150);
Michael Miller
@Makuna
Sep 17 2016 18:52
loop() {
  strip.ClearTo( red );
 strip.Show();
delay(3000);
  strip.ClearTo( green);
 strip.Show();
delay(3000);
  strip.ClearTo( blue);
 strip.Show();
delay(3000);
What you have should have a gradiant of the brightness for red, but the video doesn't really show that (maybe you see it, but its not obvious in the video).
Mehrdad K
@mkeyno
Sep 17 2016 18:55
yes , you know it is hard to capture the video from LED by normal camera , but I think it shows sometime the last part of strip get noisy
Michael Miller
@Makuna
Sep 17 2016 18:55
p.s. Its helpful when you video NeoPixels to put a diffuser over the pixels; a sheet of paper works pretty well,
Mehrdad K
@mkeyno
Sep 17 2016 18:55
any way , you code work fine now
strip.ClearTo() work fine
even when I set delay to 10ms
 void ClearTo(typename T_COLOR_FEATURE::ColorObject color)
        uint16_t indexPixel = x + y * _width;
        return T_COLOR_FEATURE::retrievePixelColor_P(_pixels, indexPixel);
    };
Michael Miller
@Makuna
Sep 17 2016 19:01
What code is that?
Mehrdad K
@mkeyno
Sep 17 2016 19:01
what cleaTo() can do whereas strip.SetPixelColor() can't
this is in your lib , trying to figure out how ClearTo work
Michael Miller
@Makuna
Sep 17 2016 19:02
Ehh, no its not.
Do you have an old version of my lib?
Mehrdad K
@mkeyno
Sep 17 2016 19:02
no , you check it it is 2.2.2
Michael Miller
@Makuna
Sep 17 2016 19:03
    void ClearTo(typename T_COLOR_FEATURE::ColorObject color)
    {
        uint8_t temp[T_COLOR_FEATURE::PixelSize]; 
        uint8_t* pixels = _method.getPixels();

        T_COLOR_FEATURE::applyPixelColor(temp, 0, color);

        T_COLOR_FEATURE::replicatePixel(pixels, temp, _countPixels);

        Dirty();
    };
Remember I told you about the warning about you had two NeoPixelLibrarys in your path. Did you clean up your environment like I asked?
Mehrdad K
@mkeyno
Sep 17 2016 19:04
yes , I did buddy , it is compile very good
I'm sure it is not mess with lib or IDE
Michael Miller
@Makuna
Sep 17 2016 19:05
I pasted above the implementation of ClearTo
Mehrdad K
@mkeyno
Sep 17 2016 19:06
same as mine
Michael Miller
@Makuna
Sep 17 2016 19:07
But you pasted a ClearTo above that was not the same? Ahh, you pasted the version on the buffer class NOT the NeoPixelBus class.
That was confusing.
Mehrdad K
@mkeyno
Sep 17 2016 19:09
I've just search this method in your profile and paste part of it to check what if I point to the right direction or not , but in my local install folder it is same as you
Michael Miller
@Makuna
Sep 17 2016 19:10
Please try to be specific as to what you pasting and why. That paste confused me completely and I thought you were pasting the code for ClearTo that you were calling; but it is not.
BUT; back on track, you are saying that by using strip.ClearTo() it works fine with the SPI method?
Mehrdad K
@mkeyno
Sep 17 2016 19:11
please forget what I paste , I just wanted to know whether going to right point or not
yes
must somethings missing between clearTo and SetPixelColor
Michael Miller
@Makuna
Sep 17 2016 19:13
Ok, lets replace the strip.ClearTo() with the following
for (int pixel = 0; pixel < strip.PixelCount(); pixel++)  strip.SetPixelColor(pixel, Red); // replace color with blue, green in the other places
BRB, putting food onto cook. ;-)
Mehrdad K
@mkeyno
Sep 17 2016 19:18
go ahead buddy , sorry for any disturbing , its work fine , also following line is work fine
 strip.ClearTo( Wheel(hue++) );
also I must say I define NUM_LED as #define NUM_LEDS 144
Michael Miller
@Makuna
Sep 17 2016 19:22
foods cooking, back
Mehrdad K
@mkeyno
Sep 17 2016 19:22
oh my Micheal my strip work fine now by replacing NUM_LED to strip.PixelCount()
Michael Miller
@Makuna
Sep 17 2016 19:24
I am still curious as to why it wasn't working. What you had should have been fine, but those last pixels were flaking out.
Mehrdad K
@mkeyno
Sep 17 2016 19:24
no pardon me I set the SW SPI , sorry , the noisy effect come back
Michael Miller
@Makuna
Sep 17 2016 19:25
You were using NUM_LEDS when you defined the strip; so the values should have been the same.
So now, change NUM_LEDS to 180 with what we had; what do you see?
Mehrdad K
@mkeyno
Sep 17 2016 19:29
no good , set num LED to 180 and use following code , just about 70% of strip work fine
// for (int pixel = 0; pixel < strip.PixelCount(); pixel++)  strip.SetPixelColor(pixel, Red); // replace color with blue, green in the other places   
     strip.ClearTo( Red );
 strip.Show();
delay(1000);
//for (int pixel = 0; pixel < strip.PixelCount(); pixel++)  strip.SetPixelColor(pixel, Green); // replace color with blue, green in the other places   
  strip.ClearTo( Green);
 strip.Show();
delay(1000);
//for (int pixel = 0; pixel < strip.PixelCount(); pixel++)  strip.SetPixelColor(pixel, Blue); // replace color with blue, green in the other places   
   strip.ClearTo( Blue);
 strip.Show();
delay(1000);
Michael Miller
@Makuna
Sep 17 2016 19:32
In the library file "DotStarSpiMethod.h", find these lines
#if defined(ARDUINO_ARCH_ESP8266)
        SPI.setFrequency(20000000L);
Change the frequency from 20000000L to 10000000L
Mehrdad K
@mkeyno
Sep 17 2016 19:33
I did before , not very success but less noisy effect
Michael Miller
@Makuna
Sep 17 2016 19:34
Try 8000000L then. That's 8Mhz
Mehrdad K
@mkeyno
Sep 17 2016 19:37
the 8Mhz work fine Michael
as well as my rainbow effect
with this speed the whole LED writing took place about 2640 us
Michael Miller
@Makuna
Sep 17 2016 19:39
And you stated you have which board? Amica NodeMcu v1.0 board?
Mehrdad K
@mkeyno
Sep 17 2016 19:40
yes
but I also check it with 12F
Michael Miller
@Makuna
Sep 17 2016 19:40
Lets try one more thing, change the value to 16000000L16Mhz
Mehrdad K
@mkeyno
Sep 17 2016 19:42
also it is work fine and writing took about 1742us
Michael Miller
@Makuna
Sep 17 2016 19:42
But you stated that 10000000 didn't work (which is between the two that did work).
Try 10mhz again?
Mehrdad K
@mkeyno
Sep 17 2016 19:45
yes maybe it must be factor of 8
Michael Miller
@Makuna
Sep 17 2016 19:46
(or a factor of being binary), 8, 16, 32. If 10mhz fails, I was going to ask you do 32Mhz.
Mehrdad K
@mkeyno
Sep 17 2016 19:49
I set it to 32Mhz and strange things the noisy position is now located in beginning of strip
Michael Miller
@Makuna
Sep 17 2016 19:49
32 maybe a little too fast; but I was curious. Lets try one more, try 24mhz.
Mehrdad K
@mkeyno
Sep 17 2016 19:52
no success , the noisy part extended more , in 24MHz
it is very good with 16MHz, 2ms is so good for me , I can do lot work with it
Michael Miller
@Makuna
Sep 17 2016 19:54
Ok, for now leave it the 16mhz and I am opening an issue to track this.
Mehrdad K
@mkeyno
Sep 17 2016 19:55
also I thinking may I have enough time to get the image by UDP and show it in strip
what do you think dear Michael ?
Michael Miller
@Makuna
Sep 17 2016 19:56
Makuna/NeoPixelBus#131 is tracking this issue we have been working on.
You do know that UDP is not guaenteed, you may loose packets. Further, the UDP packet does have a max size, 144 * 3 (bytes per strip) might fit if that is all that is sent.
Mehrdad K
@mkeyno
Sep 17 2016 19:59
do you think do I have enough to send the whole frame (85KB) and then show it in the strip
Michael Miller
@Makuna
Sep 17 2016 20:00
UDP is weird, some routers limit its data size to I believe it was 384 bytes (header takes up more), good comercial routers I think its total of 1024 per packet.
85K? How many pixels are you driving? 144 x 3 = 432.
Mehrdad K
@mkeyno
Sep 17 2016 20:02
do you know Markus (Links2004) , another cool German guy say it is possible #define WIFICLIENT_MAX_PACKET_SIZE 1460
every image consist 200 line
200x144x3 =85KB
he made excellent lib to show even movie by ESP
https://github.com/Links2004/arduinoVNC
Michael Miller
@Makuna
Sep 17 2016 20:05
Yeah, in reality UDP packets get limited by the routers you send through. So you have check if your WiFi router can handle it. I had one that was limited to 512. The Standards say you can only ever realistically rely on 384 bytes of data in a packet due to routers. BUT if you control the routers (local network) and it works at larger numbers, then you are set.
Mehrdad K
@mkeyno
Sep 17 2016 20:06
thanks Michael
Michael Miller
@Makuna
Sep 17 2016 20:07
And UDP packet versus a Socket Packet or even a TCPIP packet are all different. Sockets and TCPIP are guaranteed and sequential. UDP is neither guarentted to arrive nor even arrive in sequence so they can come out of order.
Mehrdad K
@mkeyno
Sep 17 2016 20:10
actually it is good for dedicated router , I set up screen with UDP
Michael Miller
@Makuna
Sep 17 2016 20:11
(it can fail if the router gets overloaded with traffic, use the same router to watch YouTube while you use it and see what happens ;-) )
It may take more than one stream of YouTube, but when its starts to get overloaded is when UDP will start to fail.
But, that maybe ok, just know that it can fail.
Mehrdad K
@mkeyno
Sep 17 2016 20:12
11052016084 - Copy.jpg
Michael Miller
@Makuna
Sep 17 2016 20:13
Where are you from (located?). Are those all 144 strips?
Mehrdad K
@mkeyno
Sep 17 2016 20:14
Picture1.jpg
no those 60*60 LED
1 meter for each strip
I use processing to pixelize my video then send it to router then every board take its part
Michael Miller
@Makuna
Sep 17 2016 20:16
if you have a project page and if you want me to link to it, you can either edit the Wiki or I can to point to your project in the wiki. https://github.com/Makuna/NeoPixelBus/wiki/Project-References
Mehrdad K
@mkeyno
Sep 17 2016 20:16
I might add this made by arduino connected to LAN shield and each board control 8 strip
but I'm going to replace it with ESP
sure , I like to collaborate with you guys
Michael Miller
@Makuna
Sep 17 2016 20:17
Was there a reason you used ADA102 over using NeoPixels?
Mehrdad K
@mkeyno
Sep 17 2016 20:17
my POV
also I made POV with teensy 3.2
Michael Miller
@Makuna
Sep 17 2016 20:17
Oh, POV you have to really use ADA102s
Mehrdad K
@mkeyno
Sep 17 2016 20:18
photo_2016-04-12_19-21-51.jpg
but I have to work with SD and so one , you know I'm not fan of Arduino or teensy anymore
I just like work with ESP and many cool feature that it has
Michael Miller
@Makuna
Sep 17 2016 20:19
Yeah, can't wait for the Esp32 coming out in a few weeks. I hope I don't have to change too much in my library to support it ;-)
Mehrdad K
@mkeyno
Sep 17 2016 20:19
right now I made webserve can upload the image and made scenario of show , but the FastLED was not fast enough for this
thanks to you Michael , I can now back to my project
Michael Miller
@Makuna
Sep 17 2016 20:20
So he could not update as fast as my library?
Mehrdad K
@mkeyno
Sep 17 2016 20:20
it is really fast
Michael Miller
@Makuna
Sep 17 2016 20:21
I know he had support for more than one channel at one point but I think it only worked on Arm chips.
Mehrdad K
@mkeyno
Sep 17 2016 20:21
Danial told me he is so busy and lot of work to do and he may no implemented HW SPI soon
Michael Miller
@Makuna
Sep 17 2016 20:22
So he could update 8 "buses" in the same time; but it can't be done on a Esp8266 (I tried it also, but it can't be reliable).
Mehrdad K
@mkeyno
Sep 17 2016 20:22
also he mentioned his lib very messy now and need to to clean it up
yes , also tried same things with no success
Michael Miller
@Makuna
Sep 17 2016 20:23
Yeah, mine was that way in January, I completely refactored in February to clean it up.
(I had different branches for Esp versus AVR, now only one code base that builds smaller and tighter).
The Esp32 might allow me to look into the multi-channel again; but that's a far future play item.
Mehrdad K
@mkeyno
Sep 17 2016 20:26
I think you implemented pixel concept like processing and can do lot work with it but I think you lib is not so easy for every one specially for ordinary work
Michael Miller
@Makuna
Sep 17 2016 20:26
Ok, glad I unblocked you; when I get my Ada102s back I will try my Amica (normally I use a WeMos) and see why its finiky with 20mhz.
Mehrdad K
@mkeyno
Sep 17 2016 20:27
thanks Michael
but also I suggest change your opinion about palette feature , or at least look at it
Michael Miller
@Makuna
Sep 17 2016 20:33
First describe to me by what you mean by Palette Feature ;-) FastLed overloads it beyond the standard meaning of a palette which is what I disagreed with. Further, using a palette may save some memory but it has a high cost when trying to render them as they are not natively supported and thus require every pixel to be translated; while using my buffers the render is really just a memory copy and thus VERY FAST.
Mehrdad K
@mkeyno
Sep 17 2016 20:36
maybe I not say it in correct technical way , however there is feature in FastLED lib so I could easily choose up to 16 different color and ,made my effect
but also suggest take to his wiki or code, you do understand so fast and better than I describe you here with my lasy English
also if you check its community they much talk about your approach and you