These are chat archives for Makuna/NeoPixelBus

29th
Mar 2016
marksev1
@marksev1
Mar 29 2016 08:30 UTC
@Makuna in that sketch you reworked for me there are some compile errors can we go through some of them which i don't quite get
marksev1
@marksev1
Mar 29 2016 09:18 UTC

C:\Users\PC\AppData\Local\Temp\arduino_modified_sketch_844583\sketch_mar29a.ino: In function 'void AnimBlendUpdate(const AnimationParam&)':

sketch_mar29a:52: error: 'progress' was not declared in this scope

     progress);

     ^

sketch_mar29a:54: error: 'i' was not declared in this scope

 for(i=0; i<strip.PixelCount(); i++) {

     ^

C:\Users\PC\AppData\Local\Temp\arduino_modified_sketch_844583\sketch_mar29a.ino: In function 'void callback(const MQTT::Publish&)':

sketch_mar29a:204: error: a function-definition is not allowed here before '{' token

void setup() {

          ^

sketch_mar29a:276: error: expected '}' at end of input

}

^

exit status 1
'progress' was not declared in this scope

errors
Aditya Tannu
@AdySan
Mar 29 2016 09:32 UTC
Line 58, that & looks like a syntax error?
marksev1
@marksev1
Mar 29 2016 09:34 UTC
cool
gonna try to see what i get without it

C:\Users\PC\AppData\Local\Temp\arduino_modified_sketch_852479\sketch_mar29a.ino: In function 'void callback(MQTT::Publish)':

sketch_mar29a:203: error: a function-definition is not allowed here before '{' token

void setup() {

          ^

sketch_mar29a:275: error: expected '}' at end of input

i kinda still get the same errors
Aditya Tannu
@AdySan
Mar 29 2016 09:37 UTC
You're call back fn has a missing or extra }
marksev1
@marksev1
Mar 29 2016 09:40 UTC
ok
yep
that was it
now just 2 more errors

WARNING: Category '' in library souliss is not valid. Setting to 'Uncategorized'
C:\Users\PC\AppData\Local\Temp\arduino_modified_sketch_545775\sketch_mar29a.ino: In function 'void AnimBlendUpdate(const AnimationParam&)':

sketch_mar29a:51: error: 'progress' was not declared in this scope

     progress);

     ^

sketch_mar29a:53: error: 'i' was not declared in this scope

 for(i=0; i<strip.PixelCount(); i++) {

     ^

exit status 1
'progress' was not declared in this scope

marksev1
@marksev1
Mar 29 2016 10:02 UTC
AdySan how shoud i declare i?
marksev1
@marksev1
Mar 29 2016 10:13 UTC
should i just do for(int i=0;
is this correct?
then i just have progress
Aditya Tannu
@AdySan
Mar 29 2016 16:16 UTC
Where did you copy this from?
void AnimBlendUpdate(const AnimationParam& param)
{
    // this gets called for each animation on every time step
    // progress will start at 0.0 and end at 1.0
    // we use the blend function on the HsbColor to mix
    // color based on the progress given to us in the animation
    HsbColor updatedColor = HsbColor::LinearBlend(
        AnimStartingColor,
        AnimEndingColor,
        progress);
    // apply the color to the strip
    for(i=0; i<strip.PixelCount(); i++) {
      strip.SetPixelColor(i, updatedColor);
    }
}
marksev1
@marksev1
Mar 29 2016 16:19 UTC
ammm
lemme see
then i changed it from Rgb to Hsb, but its wrong i know :/
should i just leave as is
in the original?
i'm confused now
or maybe I didn't even copy that from somewhere, don't know...I'm totally confused
don't know if maybe makuna wrote that not sure when he rewrote the sketch...I'm totally confused
marksev1
@marksev1
Mar 29 2016 16:24 UTC
can you please translate this object to me
I already looked at that line
but I don't know how to write it
Aditya Tannu
@AdySan
Mar 29 2016 16:25 UTC
its actuallly the same, hang on
you probably need param.progress like this
marksev1
@marksev1
Mar 29 2016 16:26 UTC

C:\Users\PC\Documents\Arduino\libraries\NeoPixelBus_by_Makuna\src/internal/HsbColor.h:66:55: note: template argument deduction/substitution failed:

C:\Users\PC\AppData\Local\Temp\arduino_modified_sketch_303013\sketch_mar29a.ino:52:23: note: couldn't deduce template parameter 'T_NEOHUEBLEND'

     param.progress);

                   ^

exit status 1
no matching function for call to 'HsbColor::LinearBlend(HsbColor&, HsbColor&, const float&)'

Aditya Tannu
@AdySan
Mar 29 2016 16:27 UTC
yeah so go bakc to rgb
see if that builds first
marksev1
@marksev1
Mar 29 2016 16:28 UTC
but its actually not the same
like the funloop example
Aditya Tannu
@AdySan
Mar 29 2016 16:28 UTC
i'm just guessing based on syntax errors, not sure what you're trying to do
u havent used this library recently
i'd suggest first get rid of all compile errors
then try changing to hsb
marksev1
@marksev1
Mar 29 2016 16:29 UTC
cool it compiled now
sketch looks now like this http://pastebin.com/3WtkUmdi
that thing like blends colors
that function
is this a bug that it works for Rgb but not for Hsb?
and can i input colors like hsb and then blend them like rgb without doing the conversion in the code?
marksev1
@marksev1
Mar 29 2016 16:39 UTC
this is gonna complicate the whole thing again :(
Michael Miller
@Makuna
Mar 29 2016 16:39 UTC
Line 58, that & is not a syntax error, its a call a reference symbol (in the case of arguments). It means to pass the object as a reference. For large objects like struct and class, if you don't do this, then it will copy the complete object when it gets passed, the reference will just reference the original parameter. But without that const, it also means you can modify the class being passed in, so in general, & and const go hand in hand.
marksev1
@marksev1
Mar 29 2016 16:40 UTC
Makuna
void AnimBlendUpdate(const AnimationParam& param)
{
// this gets called for each animation on every time step
// progress will start at 0.0 and end at 1.0
// we use the blend function on the HsbColor to mix
// color based on the progress given to us in the animation
HsbColor updatedColor = HsbColor::LinearBlend(
AnimStartingColor,
AnimEndingColor,
progress);
// apply the color to the strip
for(i=0; i<strip.PixelCount(); i++) {
strip.SetPixelColor(i, updatedColor);
}
}
like this it didnt compile
Michael Miller
@Makuna
Mar 29 2016 16:40 UTC
Lin 53, just add int in front of I in the for, so ...
for (int i = 0; ....
marksev1
@marksev1
Mar 29 2016 16:41 UTC
yes for that one i did
Michael Miller
@Makuna
Mar 29 2016 16:41 UTC
For linear blend method, go look at the Wiki, for HslColor and HsbColor the function changed as of yesterday, so this is why you are seeing this now.
marksev1
@marksev1
Mar 29 2016 16:43 UTC
HsbColor results = HsbColor::LinearBlend<NeoHueBlendShortestDistance>(HsbColor(0.88f,1.0f,1.0f), HsbColor(0.12f,1.0f,1.0f), 0.33f);
Michael Miller
@Makuna
Mar 29 2016 16:44 UTC
the <NeoHueBlendShortestDistance> being the key change
marksev1
@marksev1
Mar 29 2016 16:45 UTC
HsbColor updatedColor = HsbColor::LinearBlend<NeoHueBlendLongestDistance>(
    AnimStartingColor,
    AnimEndingColor,
    param.progress);
then like this?
Michael Miller
@Makuna
Mar 29 2016 16:45 UTC
yes
marksev1
@marksev1
Mar 29 2016 16:46 UTC
it compiled
:D thanks
lots of space left on the esp for animations :D
that one...where i tried to put fun loop inside this sketch has way more compile errors :/
I suck
Michael Miller
@Makuna
Mar 29 2016 16:47 UTC
Take some time and figure them out. Copy the keywords of the error message into your favorite Search tool and and Arduino and C++ and often you will see that others have hit similar problems and it may lead to the solution. You will learn also by doing.
Some of the strangest errors can often be solved by a missing semicolon, comma, or colon.
marksev1
@marksev1
Mar 29 2016 16:49 UTC
at least I have the basic sketch now compiled :D that is a good start
NeoPixelAnimator animations(10); and this NeoPixelAnimator animations(AnimCount); is the same right?
Michael Miller
@Makuna
Mar 29 2016 16:56 UTC
Is AnimCount defined anywhere? That was the first thing I noticed yesterday.
marksev1
@marksev1
Mar 29 2016 16:57 UTC
now i'm reducing the number of errors and I think i'm gonna narrow it down
yes i defined it now int AnimCount = 10;
now i have problems regarding 'animationState

only this remains: sketch_mar29a:52: error: array bound is not an integer constant before ']' token

MyAnimationState animationState[AnimCount];

                                      ^

C:\Users\PC\AppData\Local\Temp\arduino_modified_sketch_128723\sketch_mar29a.ino: In function 'void FadeOutAnimUpdate(const AnimationParam&)':

sketch_mar29a:82: error: 'animationState' was not declared in this scope

     animationState[param.index].AnimStartingColor,

     ^

C:\Users\PC\AppData\Local\Temp\arduino_modified_sketch_128723\sketch_mar29a.ino: In function 'void LoopAnimUpdate(const AnimationParam&)':

sketch_mar29a:113: error: 'animationState' was not declared in this scope

         animationState[indexAnim].AnimStartingColor = frontColor;

         ^

exit status 1
array bound is not an integer constant before ']' token

marksev1
@marksev1
Mar 29 2016 17:06 UTC
hmmm lemme see maybe i fixed it
yeeeeeeeeessssssssss
it compiled
i changed int AnimCount = 10 to "const int AnimCount = 10"
@Makuna now that the sketch compiled may I show it to you for review :D
if logic is good
Michael Miller
@Makuna
Mar 29 2016 17:12 UTC
Did you run it?
marksev1
@marksev1
Mar 29 2016 17:13 UTC
no
don't have neopixels yet (are on the slow boat from china)
I have esp tho+
tho', so I give with for review only if it doesn't run properly? :D
Makuna I'd like to ask you something
SetupAnimations() where can i read about that
nevermind its inside the cyclon
so its not systemwide right
now I'm gonna try to port cyclon in and make it compile
:D
Michael Miller
@Makuna
Mar 29 2016 17:18 UTC
@3DSasha Your stated you wrote a routine to load from BMP, do you translate at load time to native pixel format or just to RgbColor object? Or do you don't translate at all at load time?
marksev1
@marksev1
Mar 29 2016 17:20 UTC
cool cyclone compiled too, now i have funloop and cyclone animation inside
hope it works also not just compiles
@Makuna for cyclone animation https://github.com/Makuna/NeoPixelBus/blob/2c078353407b4479b6352d91b513b284a581faaf/examples/NeoPixelCylon/NeoPixelCylon.ino I need to call SetupAnimations(); to fire it up right?
Michael Miller
@Makuna
Mar 29 2016 17:25 UTC
if you look at the method, all it does is start two animations, you just as well just start the two animations.
marksev1
@marksev1
Mar 29 2016 17:26 UTC
yeah but if I have already inside the code SetupAnimations() i can call that right? to start it up
right?
or maybe if i remove that and just call the animations which are inside, will be less text in the code
cool that compiles too
ok gonna do it like that
Can mosaic be also just in a strip?
Michael Miller
@Makuna
Mar 29 2016 17:43 UTC
mosaic is about organizing/collecting already existing 2D matrix of pixels into a larger collection that are all on the same bus. All it does is translate the 2D coordinates of the complex arrangement into a single index value for the strip.
3DSasha
@3DSasha
Mar 29 2016 17:46 UTC
How to insert that black window for code here?
3DSasha
@3DSasha
Mar 29 2016 17:47 UTC
oh, i saw how
@Makuna Here my current procedure to read raster data with ESP.
boolean Get_Current_BMP_line(File bmpFile) {

  long      bmpWidth, bmpHeight, pos;  // W+H in pixels
  uint32_t bmpImageoffset;        // Start of image data in file
  //  uint32_t rowSize;               // Not always = bmpWidth; may have padding
  uint8_t  *ledbuffer; // pixel buffer (R+G+B per pixel)
  RgbColor pix;
  //  boolean  flip;        // BMP is stored bottom-to-top
  int      i, j;
  uint8_t rr, gg, bb;
  //  uint32_t pos = 0;
  bmpWidth = SD_Effects_List.GetWidth();
  bmpHeight = SD_Effects_List.GetFrames();
  bmpImageoffset = 54;
  //  flip = SD_Effects_List.is_flip;

  // BMP rows are padded (if needed) to 4-byte boundary
  //  rowSize = (bmpWidth * 3 + 3) & ~3;

  // Seek to start of scan line
  //  row = (bmpFile.position() - bmpImageoffset) / (PixelCount * 3);
  //  if (flip) // Bitmap is stored bottom-to-top order (normal BMP)
  //    pos = bmpImageoffset + (bmpHeight - 1 - row) * rowSize;
  //  else     // Bitmap is stored top-to-bottom
  //    pos = bmpImageoffset + row * rowSize;
  //  if (bmpFile.position() != pos) { // Need seek?
  //    bmpFile.seek(pos);
  //  }
  //ledbuffer = strip.Pixels();
  if (PixelCount == bmpWidth) {
    for (int p = 0; p < bmpWidth; p++) {
      bb = bmpFile.read();
      gg = bmpFile.read();
      rr = bmpFile.read();

      strip.SetPixelColor(p, RgbColor(rr, gg, bb));
      //Serial.print(rr); Serial.print(" "); Serial.print(gg); Serial.print(" "); Serial.print(bb); Serial.println(" ");
    }
    i = bmpFile.read(); i = bmpFile.read(); // fucking photoshop leaves 2 bytes of zero at end of every raw??????
  }

  else {
    if (PixelCount > bmpWidth) {
      pos = bmpFile.position();
      i = 0;
      do {
        j = 0;
        do {
          bb = bmpFile.read();
          gg = bmpFile.read();
          rr = bmpFile.read();
          //Serial.print(strip.PixelsSize()); Serial.print(" ");
          strip.SetPixelColor(i, RgbColor(rr, gg, bb));
          i++;
          j++;
        } while (j < bmpWidth);
        bmpFile.seek(pos);
      } while (i < PixelCount);
      bmpFile.seek(pos + bmpWidth * 3 + 2);
    }
  }
  //ledbuffer = strip.Pixels();
  //  bmpFile.read(&ledbuffer, PixelCount * 3);

  return (!bmpFile.available());
}
3DSasha
@3DSasha
Mar 29 2016 17:52 UTC
It is no clean yet :-)
marksev1
@marksev1
Mar 29 2016 17:52 UTC
https://learn.adafruit.com/led-ampli-tie/the-code here is some code for music reactivity
3DSasha
@3DSasha
Mar 29 2016 18:02 UTC
On arduino with FastLed was one line with direct stream copy from open bmp file to led bufer like this pf_read((char*)leds, NUM_LEDS * 3, &nr)
marksev1
@marksev1
Mar 29 2016 18:11 UTC
Makuna is that ampli-tie code portable to this sketch of mine :), can you glance it quickly
Michael Miller
@Makuna
Mar 29 2016 21:02 UTC
@marksev1 Define Portable? That code doesn't use any animations and assumes its the only thing running. But the calls it make are all common methods exposed by my library with similar names. Look at my Wiki FAQ on Wheel method for a replacement. Maybe you should consider having separate sketches until you are confortable enough to merge concepts?
Michael Miller
@Makuna
Mar 29 2016 21:08 UTC
@3DSasha One of the open questions I am trying to answer, Is it better to have the file format common like BMP, or custom that better fits the NeoPixelBus so you can just stream bits. Some of the issues are that BMPs have 32 bits per pixel, while NeoPixel is 24 bits, and the order can be different for RGB. You can make it MUCH faster if you can save the file in a custom format.
The other question is instead of streaming into strip's buffer, stream the file once into a custom buffer, that you then copy parts you want. The last I suspect would be good for you. Reading from a file can be slow, so it can effect the speed of your animation as you were wanting to use the rows as different "frames" in the animations (very common technique).
3DSasha
@3DSasha
Mar 29 2016 21:36 UTC
@Makuna Benefits of BMP format: it can be created and edited with huge number of graphic tools as universal way to save effects. And we'll use BMP only with 24 bit flipped order BMP due to straight RGB data in it without any compression and linear data flow in file. But if pixelcount rises - more file reading speed is needed. I dont know what max number of pixels can be readed from SD to provide lightshow with 25 FPS but on arduino with my 100 pixels speed was enough. May be custom format is better to use, maybe that could be some kind of GIF engine to compress trafic. My ideas started from tool I planning to create FX - Adobe AfterEffects. There are easy ways for motion designer (me) to organize layouts and visualize 2D 3D structure of real position leds and build some fun with WYSIWYG and convert it to 1-line of RGB flow for 1 ledstrip
Buffer is good idea for not big files. What size of buffer is available to use?
Michael Miller
@Makuna
Mar 29 2016 21:47 UTC
@3DSasha The size of the buffer really depends on the memory you have available. Let us use your comments so far as an example.
Assuming a standard GRB NeoPixel, 100 pixels x 1 pixel (the size of a cell, like animation cell), with 15 frames (cells), is 100 x 15 x 3 =4500 bytes.
That's not a big dent in the RAM on a Esp8266, its about half the RAM on a Avr Mega 2560 Arduino.
But a cell update would now be VERY fast, 30us at most.
3DSasha
@3DSasha
Mar 29 2016 21:51 UTC
And what memory size i have? My esp is 4M
Michael Miller
@Makuna
Mar 29 2016 21:51 UTC
80K
3DSasha
@3DSasha
Mar 29 2016 21:52 UTC
That is size what written as dynamic variables? And if we use for buffer SPIFFs 3M?
Michael Miller
@Makuna
Mar 29 2016 21:52 UTC
When you compile a sketch, at the bottom, it will list how much is expected to be consumed like ...
Sketch uses 231,847 bytes (22%) of program storage space. Maximum is 1,044,464 bytes.
Global variables use 32,100 bytes (39%) of dynamic memory, leaving 49,820 bytes for local variables. Maximum is 81,920 bytes.
marksev1
@marksev1
Mar 29 2016 21:53 UTC
Makuna je probably best that i first work in it separately
Yes*
Michael Miller
@Makuna
Mar 29 2016 21:54 UTC
Since this buffer really is const if you weren't reading from a SD card, then the data could be placed into flash space, it would take 4 bytes of ram (tracking data) and then directly copy from flash (slightly slower but still under 80us).
The problem is getting it into flash space. You have to build it in converted as const uint8_t PROGMEM buffer[] or use SPIFFs which I would have to investigate; but that again would only be slightly different than what you are doing now; incurring a convert cost on every pixel. If there was a conversion into a custom raw file of bytes, then the covert cost goes away and theoritcally with SPIFFs at least, I can just point at it as Flash Memory is just a memory pointer.
Michael Miller
@Makuna
Mar 29 2016 22:00 UTC
I will build a buffer version for memory, I can extend it as we learn more.
marksev1
@marksev1
Mar 29 2016 22:04 UTC
How can i search the wiki?
3DSasha
@3DSasha
Mar 29 2016 22:06 UTC
@Makuna there is another aspect of use SD card - easy add or upgrade or convert effects without updating ESP firmware for me or other user
Michael Miller
@Makuna
Mar 29 2016 22:09 UTC
@marksev1 I don't see a way to search the Wiki from the UI, but you could use google and scope it to the project.
@3DSasha I agree. I looked at SPIFFS, you can treat it like a SD card, you have to install a tool, but it then exposes in the IDE the ability to upload; but just as you were saying, it not the same as pulling out a SD card, update the files, and then inserting the SD card (which you can expect a customer to do).
@3DSasha But it also looks like SPIFFS exposes the ability of the program to write to files in it. SO, if the SD card had BMPs, there could be a small function that reads them and converts to a more native NeoPixel format and writes that to SPIFFs for direct use; treating SPIFFs as a temporary.
Michael Miller
@Makuna
Mar 29 2016 22:15 UTC
@3DSasha something just hit me, you have an external SD card, that uses SPI, what pins do you use for that? If you are using hardware SPI, then this is why the DMA mode may not work as I am using it also. Mmmm.
3DSasha
@3DSasha
Mar 29 2016 22:16 UTC
@Makuna Thats good idea. Another idea is to use internet cloud to read or upgrade local effects by Wi-Fi with smartphone control like MQTT or Blynk
Michael Miller
@Makuna
Mar 29 2016 22:16 UTC
Is the NeoPixelBus::begin() below the SD card begin?
Ok, first version will be pure memory (compatible with all Arduino Platforms), second version will be a SPIFFs caching.
@3DSasha Do you have a feal for how many frames you have in your animations?
3DSasha
@3DSasha
Mar 29 2016 22:21 UTC
@Makuna NeoPixelBus::begin() Where is that? Do you mean order in setup (){}?
Michael Miller
@Makuna
Mar 29 2016 22:21 UTC
yes the order within setup.
3DSasha
@3DSasha
Mar 29 2016 22:23 UTC
@Makuna strip.Begin(); strip.Show(); are last in setup. Sd card opens before
Michael Miller
@Makuna
Mar 29 2016 22:24 UTC
When you tried the samples, did you have the SD module connected?
3DSasha
@3DSasha
Mar 29 2016 22:27 UTC
@Makuna I thought about that and when i got problems with dma i disconnect SD modele physically - without results. And with my sketch and with your examples too.. :-(
3DSasha
@3DSasha
Mar 29 2016 22:32 UTC
About FX length. For some simple FX loops it will be short. But what if i have idea (i have huge number of ideas :-)) is play defined FX compostion sync to defined music playing on other device like PC or Android ? BMP file will be big size