These are chat archives for Makuna/NeoPixelBus

15th
Sep 2016
Mehrdad K
@mkeyno
Sep 15 2016 11:06
Thanks Michael for explanation , but still dark to animation features , if it OK by you lets put it in actually normal example , for instance consider there is strip of LED and I want to define couple of effects such as rainbow, single color , blended or not blended multi color and some special effect function for LED strip, also I want to define brightness , duration,speed and direction for each effect , if I want to use animation object , should define one object for whole effects and change parameters or must define multi object for each effect
Michael have you check the Cyclon example of other library such as FastLED
can you guide to how to have such example with your lib
Mehrdad K
@mkeyno
Sep 15 2016 11:47
following is my code to create the single strip on moving rainbow
#include <NeoPixelBus.h>

#define NUM_LEDS   144
NeoPixelBus<DotStarBgrFeature, DotStarSpiMethod> strip(NUM_LEDS);

RgbColor black(0);

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 setup()
{
    Serial.begin(115200);
    while (!Serial); // wait for serial attach

    Serial.println();
    Serial.println("Initializing...");
    Serial.flush();

    // this resets all the neopixels to an off state
    strip.Begin();
    strip.ClearTo(black);
    strip.Show();
//    strip.setBrightness(50);
    Serial.println();
    Serial.println("Running...");
}

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

      strip.SetPixelColor(i, Wheel(hue++));
    }
}
void loop()
{
    static uint8_t startIndex = 0;
    startIndex = startIndex + 1; /* motion speed */    
    FillLEDsFromPaletteColors( startIndex);     
    strip.Show();
    delay(50);   
}
Michael Miller
@Makuna
Sep 15 2016 17:42
@mkeyno Sorry, I don't have time to play or worry about FastLed. I did take a quick glance and was totally confused about so much as he created his own language for features (I am from a computer animation background). I don't plan to write anything on how to switch from FastLed to NeoPixelBus.
You continue to use the phrase effect "rainbow", single color, blended like they are animations. Rainbow is a static color swath; not an animation. Maybe this is again something from FastLed; but you are going to have to describe it if you want to me to understand what you are trying to do. Take one example at a time; don't make the conversation to complex.
Mehrdad K
@mkeyno
Sep 15 2016 17:44
Michael I just want to know how could I rewrite combination of couple of normal effect with animation object
Michael Miller
@Makuna
Sep 15 2016 17:45
Are you looking at the Wiki? There is a specific FAQ on the wheel function. https://github.com/Makuna/NeoPixelBus/wiki/FAQ-%236
Mehrdad K
@mkeyno
Sep 15 2016 17:45
as it described I want to manage couple of pre effects with animation parameter like time, direction , speed
I read that couple of times but unfortunately I'm not wise yet to fully understand that
Michael Miller
@Makuna
Sep 15 2016 17:46
First: Describe what you want you effect to do; not how you want to do it.
Mehrdad K
@mkeyno
Sep 15 2016 17:47
I want to mange couple of effects with time, speed , direction and duration
this is what I already do with other library and I'm so sad I cant use your animation object to manage that
Michael Miller
@Makuna
Sep 15 2016 17:48
like, cyclon: I want a red pixel that moves back and forth across all the pixels; with a natural slow and stop at the ends, leaving a persistence of vision trail as it moves. It should take 3 seconds to cross from ones side to the other.
Again, you are not describing the effect, you are describing how you want to do it.
Mehrdad K
@mkeyno
Sep 15 2016 17:49
you are right , but let have your example explanation for what you just describe now and let the other topic aside for now
1- red pixel that moves back and forth across all the pixels
2-natural slow and stop at the ends
3-leaving a persistence of vision trail
4-take 3 seconds to cross from ones side to the other
Michael Miller
@Makuna
Sep 15 2016 17:51
There are two ways to do this.
1) use a bitmap that contains the sprite cells for every state of the animation. This is the example I pointed at above; which is often the easiest way artist find to do this sort of work. https://github.com/Makuna/NeoPixelBus/blob/master/examples/NeoPixelBufferCylon/NeoPixelBufferCylon.ino
2) use multiple animations to move a pixel and fade. This is covered in the example https://github.com/Makuna/NeoPixelBus/blob/master/examples/NeoPixelCylon/NeoPixelCylon.ino
It uses two seconds to move across them.
Mehrdad K
@mkeyno
Sep 15 2016 17:58
Michael forgive my manner but may I ask simply write the codes here for each of the those 4 aspect that you described , for example I don't know how to use a bitmap that contains the sprite cells for every state of the animation
Michael Miller
@Makuna
Sep 15 2016 17:59
You don't write code to create the bitmap image. You use a paint program.
Mehrdad K
@mkeyno
Sep 15 2016 18:02
sorry buddy , I'm confuse , why do I need paint program , for creating an effect for trailing red pixel
Michael Miller
@Makuna
Sep 15 2016 18:02
If you look at the files in the sample, you will find a *.pdn file. this is Paint Dot Net file (free paint program with some great features). I wrote a plugin that exports the bits into a PROGMEM structure (the other files).
// To recreate the data below, use the Paint.Net plugin "Arduino Progmem NeoPixel FileType"
// to save as/export the included Cylon.pdn
// Paint.Net - http://www.getpaint.net/download.html#download
// Plugin - http://forums.getpaint.net/index.php?/topic/107921-arduino-neopixel-sketch-exporter/
// This uses Flatten, GRB, Hexadecimal
Ok, you need to go read on how to do sprite animations first. They are based on images not code/physics/math. This is why I stated this what artists generally use.
Mehrdad K
@mkeyno
Sep 15 2016 18:05
yes , most of amateur like me tend to make scenario from different pre define effects
Michael Miller
@Makuna
Sep 15 2016 18:06
I don't provide those; I provide the building blocks for you to create your own. The samples are just to show you how to do a few.
Mehrdad K
@mkeyno
Sep 15 2016 18:06
I really appreciated if you could guide me to how to write the code for those 4 line of feature
Michael Miller
@Makuna
Sep 15 2016 18:10
I am not here to write your code, I am here to support my library. I have pointed you at code that demonstrates uses multiple animations. There are other samples you can "study". If you have specific questions on how something is not working I can answer that.
Mehrdad K
@mkeyno
Sep 15 2016 18:14
sorry for any rude Michael , ok , let's put this away now and kindly look and my code that I paste here , I've tried to make simple rainbow effect but when I uploaded to my NodeMCU which is connected to 144 APA102 LED strip , it is just work for about 60% of strip and the rest of strip like noisy and flicky
I use the same hardware with same effect and other library and it is work fine
I've tried other samples in github and face same effect
do you have any Idea why the last part of strip shows noisy effect
Michael Miller
@Makuna
Sep 15 2016 18:18
Is your strip set to 144 pixels?
Mehrdad K
@mkeyno
Sep 15 2016 18:18
yes
Michael Miller
@Makuna
Sep 15 2016 18:19
You stated you used FastLed, same hardware, just a different sketch?
Mehrdad K
@mkeyno
Sep 15 2016 18:20
yes , but the sketch so similar for what I use for NeopixelBus
Michael Miller
@Makuna
Sep 15 2016 18:21
Copy the line here that defines your strip
Mehrdad K
@mkeyno
Sep 15 2016 18:21
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++));
    }
}
void loop()
{

    static uint8_t startIndex = 0;
    startIndex = startIndex + 3;  
    FillLEDsFromPaletteColors( startIndex);  
     strip.Show();
    delay(50); 
}
Michael Miller
@Makuna
Sep 15 2016 18:22
I said DEFINES, not implements it. The code above does not include the line that the strip is defined at.
Mehrdad K
@mkeyno
Sep 15 2016 18:23
#include <NeoPixelBus.h>

#define NUM_LEDS   144
NeoPixelBus<DotStarBgrFeature, DotStarSpiMethod> strip(NUM_LEDS);

RgbColor black(0),color;

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

    Serial.println();
    Serial.println("Initializing...");
    Serial.flush();

    // this resets all the neopixels to an off state
    strip.Begin();
   // strip.ClearTo(black);
   for(uint16_t i=0; i<144; i++) strip.SetPixelColor(i, black);    strip.Show();
//    strip.setBrightness(50);
    Serial.println();
    Serial.println("Running...");
}
Michael Miller
@Makuna
Sep 15 2016 18:24
'NeoPixelBus<DotStarBgrFeature, DotStarSpiMethod> strip(NUM_LEDS);' would have sufficed.
try using DotStarMethod instead of DotStarSpiMethod and see if there is a difference.
Mehrdad K
@mkeyno
Sep 15 2016 18:25
let me
change line to this NeoPixelBus<DotStarBgrFeature, DotStarMethod> strip(NUM_LEDS);
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
Michael Miller
@Makuna
Sep 15 2016 18:27
What Arduino IDE version are you using? What Esp Board version are you using?
Mehrdad K
@mkeyno
Sep 15 2016 18:28
libraries\NeoPixelBus\src/NeoPixelBus.h: In instantiation of 'NeoPixelBus<T_COLOR_FEATURE, T_METHOD>::NeoPixelBus(uint16_t) [with T_COLOR_FEATURE = DotStarBgrFeature; T_METHOD = DotStarGenericMethod; uint16_t = short unsigned int]':

Multiple libraries were found for "NeoPixelBus.h"
 Used: D:\arduino-1.6.9\libraries\NeoPixelBus
 Not used:  libraries\NeoPixelBus_by_Makuna
\rainbow_neo_pixel_bus.ino:4:61:   required from here

\NeoPixelBus\src/NeoPixelBus.h:103:56: error: no matching function for call to 'DotStarGenericMethod::DotStarGenericMethod(uint16_t&, const size_t&)'

         _method(countPixels, T_COLOR_FEATURE::PixelSize)
1.6.9 and nodeMCU ver 1
if you kindly remember I've tried to use HW SPI for my strip
Michael Miller
@Makuna
Sep 15 2016 18:30
Sorry, what Esp8266Arduino "board" version; not hardware, but the "board" support library for Arduino.
Mehrdad K
@mkeyno
Sep 15 2016 18:30
12E
all my hardware ,lib and IDE is up to date
Michael Miller
@Makuna
Sep 15 2016 18:31
Goto the Arduino IDE Board Manager, look for espboard support and what version does it show
Well, your IDE is out of date, 1.6.11 is the newest.
Mehrdad K
@mkeyno
Sep 15 2016 18:32
you mean the IDE cause the problem and it can affect you lib core ?
Michael Miller
@Makuna
Sep 15 2016 18:33
I don't know, but it compiles on my machine targeting your board and it doesn't compile on yorus, so there is an issue somewhere.
This is why I am asking about versions.
Mehrdad K
@mkeyno
Sep 15 2016 18:34
I might add the current version of FastLED use soft SPI
Michael Miller
@Makuna
Sep 15 2016 18:34
What is your "Board Manager" esp8266 version?
(the change I asked you to make switched from hardware to software SPI as a test).
But it didn't compile which points to a environment setup issue; usually old versions.
Did you find the "board manager" esp8266 version for me?
Mehrdad K
@mkeyno
Sep 15 2016 18:37
1.JPG
Michael Miller
@Makuna
Sep 15 2016 18:38
Under the board menu, the top item in the secondary menu is Board Manager, click it
The menu item starting with "Board: ...", when you hover over it, another opens, the top item is board manager.
In the board manager, just type esp8266 to filter it to just show the one we are looking for
Mehrdad K
@mkeyno
Sep 15 2016 18:40
1.6.13
1.JPG
Michael Miller
@Makuna
Sep 15 2016 18:41
GEEZE! That's unsupported! 2.3.0 is the latest.
Mehrdad K
@mkeyno
Sep 15 2016 18:41
you mean my ESP lib version
Michael Miller
@Makuna
Sep 15 2016 18:41
Wait, that image doesn't show the esp8266, type esp8266 in the filter list
Mehrdad K
@mkeyno
Sep 15 2016 18:42
I use git to update my ESP lib not board manager
Michael Miller
@Makuna
Sep 15 2016 18:42
Its not really a Arduino Lib (like NeoPixelBus); its a board support environment.
It still should show here, is it not?
Mehrdad K
@mkeyno
Sep 15 2016 18:43
it is not , accuse I don't use board manager to get last version of Arduino ESP
Michael Miller
@Makuna
Sep 15 2016 18:44
Why do you use GIT? If you are not an expert or contributing to it, you really should avoid that.
There is something wrong with your environment at the moment. It could be this board support; it could be the slightly older Arduino IDE. What version does the library manager show for NeoPixelBus?
Mehrdad K
@mkeyno
Sep 15 2016 18:45
but some folk like Ivan and Me-no-dev suggest me to use git
2.2.2
Michael Miller
@Makuna
Sep 15 2016 18:47
Maybe there was a feature broken in GIT? Think of the Board manager versions are being stable versions, the GIT version isn't tested as well as they make minor changes; so maybe they thought you needed some latest something? I don't even use GIT version as most consumers of my library won't.
Mehrdad K
@mkeyno
Sep 15 2016 18:48
do you have any APA102 strip
Michael Miller
@Makuna
Sep 15 2016 18:48
yes. Mine are working fine with both hardware and software.
Its even a 144 strip like you have.
Mehrdad K
@mkeyno
Sep 15 2016 18:49
can you upload my sketch to your hardware
even set my LED num to half the rest of strip still noisy
I change the SPI.setFrequency(20000000L); to 12MHz and it shows better performance
is it possible the SPI.setFrequency not set correctly
Michael Miller
@Makuna
Sep 15 2016 18:54
Would you be willing to remove the github version of esp8166 board support and pick up the official release? Maybe there is something there causing it.
Mehrdad K
@mkeyno
Sep 15 2016 18:55
I might add all the lib example work fine with this hardware
Michael Miller
@Makuna
Sep 15 2016 18:55
this is why I asked about swithing the method; we need to understand if its hardware SPI or software; but your environment won't build it correctly for some reason.
Mehrdad K
@mkeyno
Sep 15 2016 18:56
ok Michael , I'll do that and let you know
sorry for any inconvenience and take your time
Michael Miller
@Makuna
Sep 15 2016 18:57
BTW, do you also use the GITHUB version of my library?
Mehrdad K
@mkeyno
Sep 15 2016 18:57
yes
update by lib manager
Michael Miller
@Makuna
Sep 15 2016 18:57
The error above when you switched is showing TWO versions are present in two different locations!
I know this sounds draconian; but you might want to uninstall the Arduino IDE, remove the NeoPixelBus "github" enlistment (maybe also the esp8266); then install the newest Arduino IDE, and use the library manager to get NeoPixelBus and the Board Manager to get Esp8266.
Mehrdad K
@mkeyno
Sep 15 2016 19:00
where? the error location show only one location
Michael Miller
@Makuna
Sep 15 2016 19:01
Multiple libraries were found for "NeoPixelBus.h"
 Used: D:\arduino-1.6.9\libraries\NeoPixelBus
 Not used:  libraries\NeoPixelBus_by_Makuna
The environment is using the wrong versions (the above is from your error) so its getting confused
The location of libraries is not within the Arduino-1.6.9 folder; its in your user documents folder.
Mehrdad K
@mkeyno
Sep 15 2016 19:03
I remove it
In file included from C:\Users\Private\Documents\Arduino\My ESP8266\ESP Lighting Project\rainbow_neo_pixel_bus\rainbow_neo_pixel_bus.ino:1:0:

D:\arduino-1.6.9\libraries\NeoPixelBus\src/NeoPixelBus.h: In instantiation of 'NeoPixelBus<T_COLOR_FEATURE, T_METHOD>::NeoPixelBus(uint16_t) [with T_COLOR_FEATURE = DotStarBgrFeature; T_METHOD = DotStarGenericMethod; uint16_t = short unsigned int]':

C:\Users\Private\Documents\Arduino\My ESP8266\ESP Lighting Project\rainbow_neo_pixel_bus\rainbow_neo_pixel_bus.ino:4:61:   required from here

D:\arduino-1.6.9\libraries\NeoPixelBus\src/NeoPixelBus.h:103:56: error: no matching function for call to 'DotStarGenericMethod::DotStarGenericMethod(uint16_t&, const size_t&)'

         _method(countPixels, T_COLOR_FEATURE::PixelSize)

                                                        ^

D:\arduino-1.6.9\libraries\NeoPixelBus\src/NeoPixelBus.h:103:56: note: candidates are:

In file included from D:\arduino-1.6.9\libraries\NeoPixelBus\src/NeoPixelBus.h:60:0,

                 from C:\Users\Private\Documents\Arduino\My ESP8266\ESP Lighting Project\rainbow_neo_pixel_bus\rainbow_neo_pixel_bus.ino:1:

D:\arduino-1.6.9\libraries\NeoPixelBus\src/internal/DotStarGenericMethod.h:32:5: note: DotStarGenericMethod::DotStarGenericMethod(uint8_t, uint8_t, uint16_t, size_t)

     DotStarGenericMethod(uint8_t pinClock, uint8_t pinData, uint16_t pixelCount, size_t elementSize) :

     ^

D:\arduino-1.6.9\libraries\NeoPixelBus\src/internal/DotStarGenericMethod.h:32:5: note:   candidate expects 4 arguments, 2 provided

D:\arduino-1.6.9\libraries\NeoPixelBus\src/internal/DotStarGenericMethod.h:29:7: note: constexpr DotStarGenericMethod::DotStarGenericMethod(const DotStarGenericMethod&)

 class DotStarGenericMethod

       ^

D:\arduino-1.6.9\libraries\NeoPixelBus\src/internal/DotStarGenericMethod.h:29:7: note:   candidate expects 1 argument, 2 provided

Using library NeoPixelBus at version 2.2.2 in folder: D:\arduino-1.6.9\libraries\NeoPixelBus 
Using library SPI at version 1.0 in folder: D:\arduino-1.6.9\hardware\esp8266com\esp8266\libraries\SPI 
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
maybe when I choose DotStarMethod , I also should pins for that
Michael Miller
@Makuna
Sep 15 2016 19:06
yes, that must be it...
NeoPixelBus<DotStarBgrFeature, DotStarMethod> strip(PixelCount, DotClockPin, DotDataPin);
Mehrdad K
@mkeyno
Sep 15 2016 19:08
change it to NeoPixelBus<DotStarBgrFeature, DotStarMethod> strip(NUM_LEDS,14,13);
C:\Users\Private\AppData\Local\Temp\builda9dbf57e0a9768bba61a06552580c59d.tmp/arduino.ar(core_esp8266_main.cpp.o):(.text._ZL12loop_wrapperv+0x4): undefined reference to `setup'

C:\Users\Private\AppData\Local\Temp\builda9dbf57e0a9768bba61a06552580c59d.tmp/arduino.ar(core_esp8266_main.cpp.o): In function `loop_wrapper':

D:\arduino-1.6.9\hardware\esp8266com\esp8266\cores\esp8266/core_esp8266_main.cpp:56: undefined reference to `setup'

collect2.exe: error: ld returned 1 exit status

Using library NeoPixelBus at version 2.2.2 in folder: D:\arduino-1.6.9\libraries\NeoPixelBus 
Using library SPI at version 1.0 in folder: D:\arduino-1.6.9\hardware\esp8266com\esp8266\libraries\SPI 
exit status 1
Error compiling for board NodeMCU 1.0 (ESP-12E Module).
Michael Miller
@Makuna
Sep 15 2016 19:13
there is something wrong with your environment. Again I think its a bad idea for a novice to be using the GitHub version of any board or library; use the board manager and library manager.
Mehrdad K
@mkeyno
Sep 15 2016 19:14
ok Michael , I'll do that
any way , do you have time to discuss about palette? may I ask you to see this sample https://github.com/FastLED/FastLED/blob/master/examples/ColorPalette/ColorPalette.ino
that example use user define palette for its effect
can define 16 different color for each palette and then fed it in the strip and manage its animation effect
there pre define pallet like rainbow so can easily be chosen and fill the strip with that
Michael Miller
@Makuna
Sep 15 2016 19:19
If you understand what it does, then you can implement it; if you don't understand what it is doing why are you expecting me to do the work?
Mehrdad K
@mkeyno
Sep 15 2016 19:19
actually I've tried to convert that example by you lib
Michael Miller
@Makuna
Sep 15 2016 19:20
AND again, a predefined pallete sounds like a bitmap; did you look at the Wiki and samples that use them?
https://github.com/Makuna/NeoPixelBus/wiki/Raster-Image-Support
Mehrdad K
@mkeyno
Sep 15 2016 19:23
but as you said and also in your example , first must use SD object to read a bitmap file, it was confusing for how to define bitmap with out external file but I'll read NeoVerticalSpriteSheet again
Michael Miller
@Makuna
Sep 15 2016 20:02
I am so confused; I never pointed you at the examples that use a SD object. I pointed you at one that used PROGMEM (const data rather than RAM). You could just modify the const values. Further, if you read, you will see you can define one to use RAM, and then just call SetPixelColor() into it if that is what you really want to do (which if the data is static is not the best plan).