These are chat archives for Makuna/NeoPixelBus

22nd
Apr 2016
marksev1
@marksev1
Apr 22 2016 09:02
@Makuna how to make a Vu-meter animation, so I could tie the value from the msgeq7 to that animation?
can you show me a code snippet
plz
an example for such an animation with definable amplitude in sketch would be awesome
in the examples repository of this library :)
marksev1
@marksev1
Apr 22 2016 09:08
besides the ampli-tee with that wheel method which is probably to hard for me to rewrite without significant help. I found this: https://dl.dropboxusercontent.com/u/25122896/VU_Meter.ino
marksev1
@marksev1
Apr 22 2016 10:17
This message was deleted
This message was deleted
This message was deleted
dang dunno how to paste code here :)
#include <NeoPixelBus.h>
#include <NeoPixelAnimator.h>

const uint16_t PixelCount = 4; // this example assumes 4 pixels, making it smaller will cause a failure
const uint8_t PixelPin = 2;  // make sure to set this to the correct pin, ignored for Esp8266


// MSGEQ7
#include "MSGEQ7.h"
#define pinAnalog A0
#define pinReset 6
#define pinStrobe 4
#define MSGEQ7_INTERVAL ReadsPerSecond(50)
#define MSGEQ7_SMOOTH true

CMSGEQ7<MSGEQ7_SMOOTH, pinReset, pinStrobe, pinAnalog> MSGEQ7;

void setup() {
  strip.Begin();
  strip.Show();

  // This will set the IC ready for reading
  MSGEQ7.begin();
}

void loop() {
  // Analyze without delay
  bool newReading = MSGEQ7.read(MSGEQ7_INTERVAL);

  // Led strip output
  if (newReading) {
    // visualize the average bass
    uint8_t val = MSGEQ7.get(MSGEQ7_BASS);

    // Reduce noise
    val = mapNoise(val);

    // Visualize leds to the beat


    // Update Leds
    strip.Show();
  }
}
this i have so far
like fromt the examples :D
marksev1
@marksev1
Apr 22 2016 14:59
 for(int i = 0; i < map(val, 0, 1023, 0, 60); i++){
 strip.SetPixelColor(i, strip.Color(i*4, 60 - i, 0)); //Without blue flash
}
I would need this rewritten this snippet
marksev1
@marksev1
Apr 22 2016 15:42
The most crucial piece of the puzzle :smile:
This is from that VU-meter ino
I dont know why but its so hard for me to understand this neopixelbus
marksev1
@marksev1
Apr 22 2016 15:52
I would need it with that HsbColor object i think which i have in that sketch of mine
TheAustrian
@TheAustrian
Apr 22 2016 16:33
Hi! Coming from FastLed (because it crashes after 10-20 hours when I use Wifi on my ESP) I would like to know if there is some tutorial or reference? I read the Wiki and looked through the examples but I'd like to avoid a trial and error approach but rather understand the basics better. And is there some method I haven't found yet of changing the color of the whole strip other than looping through each led? Thanks, Alex
Michael Miller
@Makuna
Apr 22 2016 17:41
@TheAustrian the ClearTo() method on the NeoPixelBus. See Wiki ClearTo
Michael Miller
@Makuna
Apr 22 2016 17:48
@marksev1 I have mentioned this before, specific animations are not something I plan to show examples for. If I happen to need one and build it I would share it; please be considerate.
Further, I also have mentioned about wheel method everyone seems to use here.
marksev1
@marksev1
Apr 22 2016 17:50
but here is not wheel method
can you help me in this specific case please
Michael Miller
@Makuna
Apr 22 2016 17:50
@TheAustrian The Wiki contains API references from specific areas inside, I will look at all building a "Reference" section to bring them all together in one place for discoverability. Each section usually starts with a mini tutorial on how to use them; but its more a introduction to the concepts.
Makuna vu-meters are very popular on youtube :D
Look at me this way, if you help me achieve this I'll be really happy and tell lot of people about your library :D
I wish that just the examples from neopixel adafruit library would be able to work with yours, that it would have some translation layer
marksev1
@marksev1
Apr 22 2016 17:56
Can you explain to me this wheel method
is this wheel method the rainbow
like seen in this vu-meter
so that lots of colors are visible on one strip?
how do i control how much pixels are lit up
Michael Miller
@Makuna
Apr 22 2016 17:57
Did you read the link I gave you? "The color wheel routines you may have seen in other code is really a hack of the core feature of HSL or HSB(HSV) color space. The number often represented in degrees of 0 to 360 is actually the Hue value for these alternate color spaces"
marksev1
@marksev1
Apr 22 2016 17:58
i did read but i don't understand it
now I googled hue and i get it
Michael Miller
@Makuna
Apr 22 2016 17:58
The number you give is JUST HUE! Period. If you don't understand what hue is, then you need to go research and study on colors.
marksev1
@marksev1
Apr 22 2016 17:59
so this is the "rainbow"
so I modify just hue
this is simple then
I think
Michael Miller
@Makuna
Apr 22 2016 18:00
They may have in a range of 0-255, or 0.0 - 360.0; while my color objects expect 0.0-1.0; you will either need to modifiy the code to think in floats using 0.0 to 1.0 or just convert before calling.
marksev1
@marksev1
Apr 22 2016 18:01
ok so this wheel is the solution for the colors, what about regarding number of pixels lit
I think I'm gonna need to do PixelCount - that value val scaled from max to min with number of pixels
does it sound correct
Michael Miller
@Makuna
Apr 22 2016 18:03
did you research to understand what the map() function does? Its a standard Arduino function.
And yes, the key is that hardcoded number 60, its the count of pixels on the strip. Better code would have use a constant or the "count" off the object they used; but oh well.
marksev1
@marksev1
Apr 22 2016 18:08
yes i knew that
that 60 is the number of pixels
but now in case of neopixelbus library i'm not sure how much arguments would map have
nevermind
I'm sorry Makuna that i'm bothering you...
marksev1
@marksev1
Apr 22 2016 18:22
Makuna now I get the map part he maps from some value with an upper limit of 1023 to some value with and upper limit of 60.....So for neopixelbus wheel method hue value what would be the upper limit?
would it be float 1.0
marksev1
@marksev1
Apr 22 2016 18:28
this part for(int i = 0; i < map(val, 0, 1023, 0, 60); i++){} I now understand :D
marksev1
@marksev1
Apr 22 2016 18:46
and also that 60 is the PixelCount
TheAustrian
@TheAustrian
Apr 22 2016 18:46
@Makuna Thanks a lot - I must have missed that - have now found it and will use the weekend to change my code & hardware to your library. Great job, btw. ;)
marksev1
@marksev1
Apr 22 2016 19:17
@Makuna so would I need to divide wheelValue with number of "turned" on pixels to get the "rainbow" or where in the logic this rainbow is generated
so far i have like this for(int i = 0; i < map(val, 0, 1023, 0, PixelCount); i++){ strip.SetPixelColor(PixelCount-i, Wheelcolor???); // }
in Faq 6
marksev1
@marksev1
Apr 22 2016 19:22
this setting the rainbow is stretching my brain :D
TheAustrian
@TheAustrian
Apr 22 2016 19:59

@marksev1

no expert, but try this:

byte whatevercolor = 0; // set once in setup or before, not in loop()


//in the loop() function:
strip.ClearTo(HsbColor(0.0f,0.0f,0.0f );  // make all pixels black
for(int i = 0; i < map(val, 0, 1023, 0, PixelCount); i++){ 
strip.SetPixelColor(i, HsbColor(whatevercolor/255.0f, 1, 1)); //
strip.Show;
whatevercolor++; 
 }
marksev1
@marksev1
Apr 22 2016 20:00
Thank you very much
TheAustrian
@TheAustrian
Apr 22 2016 20:01
strip.Show; after the for-loop, sorry
marksev1
@marksev1
Apr 22 2016 20:03
So this is for the rainbow? Like pixels on the bottom one color and going to the top changing colors
TheAustrian
@TheAustrian
Apr 22 2016 20:08
Oh, only just now saw the video, u want:
strip.ClearTo(HsbColor(0.0f,0.0f,0.0f ));  // make all pixels black
for(int i = 0; i < map(val, 0, 1023, 0, PixelCount); i++){ 
strip.SetPixelColor(i, HsbColor(i/60.0f, 1, 1)); // change 60 to whatever - this will make a full color wheel when all pixels are lit, 120.0 would only use half the circle etc.
 }
strip.Show;
marksev1
@marksev1
Apr 22 2016 20:12
Thanks thanks, you are very smart :)..i couldnt wrap my head around it.
TheAustrian
@TheAustrian
Apr 22 2016 20:13
I don't know if it will work or throw an error, though - in theory it should, but I only found this library yesterday, lol
marksev1
@marksev1
Apr 22 2016 20:15
Thats good enough for me :)
marksev1
@marksev1
Apr 22 2016 20:24
Do those 1's in the last HsbColoe have 1.0f
TheAustrian
@TheAustrian
Apr 22 2016 20:25
Would be good practice, yes
The first 1 is saturation (the lower you go, the more washed out the color becomes), the second is how bright the leds are
marksev1
@marksev1
Apr 22 2016 20:44
Thanks :)
What about that 60, why is that number there?
In the hue part, the division by 60
TheAustrian
@TheAustrian
Apr 22 2016 20:50
60 is the number of pixels in your strip if I understood. So if you use that, if each pixel in your strip is lit, it will display a full color wheel (from red to red via all other colors). If you make it bigger it will only display a part of the colors (starting from red). You could also map() your variable i to different values and then divide the result (remember the max value you can have in hsbcolor() is 1). This was just a simple example...
marksev1
@marksev1
Apr 22 2016 20:51
So could it be simply replaced by PixelCount?
Cool
TheAustrian
@TheAustrian
Apr 22 2016 20:52
Yes, though I'm not sure if dividing two integers will result in a float value. It might just round to 1
marksev1
@marksev1
Apr 22 2016 20:56
Aaa gotcha
Then better to just use floats and input the number of pixels (not sure yet how many i'm gonna have)
TheAustrian
@TheAustrian
Apr 22 2016 20:57
Maybe if you use i/PixelCount*1.0fit will result in a float and be easily changeable
marksev1
@marksev1
Apr 22 2016 20:58
Cool thanks so far TheAustrian. Have a nice evening!
TheAustrian
@TheAustrian
Apr 22 2016 20:58
You too ;)