These are chat archives for Makuna/NeoPixelBus

3rd
Sep 2016
sticilface
@sticilface
Sep 03 2016 14:07
@makuna. get this when compiling versions after c2bb0fe855e3f9d2762920ccfffc87b032d3d722
In file included from /Users/amelvin/Documents/Arduino/libraries/NeoPixelBus/src/NeoPixelBus.h:39:0,
                 from /Users/amelvin/git/MyMelvanimate/MyMelvanimate/MyMelvanimate.ino:24:
/Users/amelvin/Documents/Arduino/libraries/NeoPixelBus/src/internal/DotStarColorFeatures.h: In static member function 'static void DotStarLbgrFeature::applyPixelColor(uint8_t*, uint16_t, DotStar4Elements::ColorObject)':
/Users/amelvin/Documents/Arduino/libraries/NeoPixelBus/src/internal/DotStarColorFeatures.h:144:38: error: 'min' was not declared in this scope
         *p++ = 0xE0 | min(color.W, 31); // upper three bits are always 111
                                      ^
/Users/amelvin/Documents/Arduino/libraries/NeoPixelBus/src/internal/DotStarColorFeatures.h:144:38: note: suggested alternative:
In file included from /Users/amelvin/Arduino/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/memory:62:0,
                 from /Applications/Arduino.app/Contents/Java/hardware/esp8266com/esp8266/cores/esp8266/FS.h:24,
                 from /Users/amelvin/git/MyMelvanimate/MyMelvanimate/MyMelvanimate.ino:17:
/Users/amelvin/Arduino/esp8266/tools/xtensa-lx106-elf/xtensa-lx106-elf/include/c++/4.8.2/bits/stl_algobase.h:239:5: note:   'std::min'
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
Michael Miller
@Makuna
Sep 03 2016 15:50
@sticilface You are including something before "NeoPixelBus.h" that is redefining the standard Arduino min macro.
What IDE version are you using?
sticilface
@sticilface
Sep 03 2016 15:50
latest
both
/ 2.3.0
Michael Miller
@Makuna
Sep 03 2016 15:53
Did you try one of the samples?
Generally the solution is to reorder headers such that the Arduino.h is right about NeoPixelBus.h should solve it for this problem.
sticilface
@sticilface
Sep 03 2016 15:55
above sorry?
above neopixel bus
or right above it
Michael Miller
@Makuna
Sep 03 2016 15:55
At least minimize the headers between them until it goes away, once you find the culprit, then ask the library writer to fix his header.
sticilface
@sticilface
Sep 03 2016 15:56
ok so the examples compile...
but.....
i was wondering if u can bring back the silent pin for dmx and uart methods
or at least have both
Michael Miller
@Makuna
Sep 03 2016 15:57
Enter a "issue" to track it, shouldn't be a big problem to do that.
sticilface
@sticilface
Sep 03 2016 15:57
my lib makes use of the fact u can set a pin... even if it doesn't work... and there is 'easy' way for me to work out which method has been set and therefore which version of the bus constructor to call
plus... Neo800KbpsMethod silently converts to Neo800KbpsMethod on esp but not other platforms..
cool.. i will make an issue
Michael Miller
@Makuna
Sep 03 2016 16:03
I think you misstyped something in the last post, Neo800KbpsMethod is typed twice.
sticilface
@sticilface
Sep 03 2016 16:07
oh yeah sorry... i meant the DMA method
ok... i've found the offending lib....
sticilface
@sticilface
Sep 03 2016 16:12
#include <ESP8266WiFi.h>
#include <NeoPixelBus.h>
#include <NeoPixelAnimator.h>

causes the min error

#include <NeoPixelBus.h>
#include <NeoPixelAnimator.h>
#include <ESP8266WiFi.h>

does not

any chance we can 'fix' that

Michael Miller
@Makuna
Sep 03 2016 16:24
THEY have to fix it. Their header file can't redefine or undefined min and max in the public scope; otherwise it will break the users sketch that uses them.
Makuna/NeoPixelBus#128 has the pin fix for you; I will make a new version with these soon but I wanted to capture other issues this weekend before the next release.
sticilface
@sticilface
Sep 03 2016 16:33
no worries :) thanks
Michael Miller
@Makuna
Sep 03 2016 16:34
Mmm, I typed something before but it didn't show above!
For all platforms, there is a default method, for esp its NeoEsp8266Dma800KbpsMethod, for AVR its NeoAvr800KbpsMethod; they all are exposed by the full name or the convenient common name of just Neo800KbpsMethod.
sticilface
@sticilface
Sep 03 2016 16:38
i did know that... so back to this min thing... where is the undef happening... its not in the main file... is it one in the sdk?
sticilface
@sticilface
Sep 03 2016 17:00
these min max things are just a huge pain in the ass... i've rearranged the headers so neopixelbus is first and it is still erroring
sticilface
@sticilface
Sep 03 2016 17:12

I'm guessing it might be this causing it actually...

#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif

in adafruit_GFX lib... which i know ur gonna say... u've got matrix support... but unfortunately yours is compile time only... ii've set everything up so that the use can change the matrix on the fly for any given effect... arghhh!!!

Michael Miller
@Makuna
Sep 03 2016 17:19
You need to remember that if something is to change dynamically, you can allocate them rather than make them global static. All that code to allow them to be dynamic is truly wasted program space; just call "new".
Why are they redefining it!!! Its part of Arduino.h already. wow, just wow.
sticilface
@sticilface
Sep 03 2016 17:22
oh.. i think i might have figured it out
#ifndef _GLIBCXX_VECTOR
// arduino is not compatible with std::vector
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#endif

#define _min(a,b) ((a)<(b)?(a):(b))
#define _max(a,b) ((a)>(b)?(a):(b))
if u use vector... min is not min anymore..
i've changed your code to _min.... which then works
Michael Miller
@Makuna
Sep 03 2016 17:24
In Esp8266WiFiMulti.h, there is a undef min and undef max; I suspect this is the real culprit; this is why the header include order is the real only solution.
#include "ESP8266WiFi.h"
#undef min
#undef max
#include <vector>
This file is included in Esp8266Wifi.h; that is one convoluted include tree, one includes the other which includes the other.
The "REAL" problem is that Arduino should never have defined min and max as macros. They should have been inline functions. As macros they replace any "text" anywhere that matches it and case and word. As inline functions they are just functions.
sticilface
@sticilface
Sep 03 2016 17:31
so.. what do you think for a solution then
reorder the headers in your sketch. if you can't, after any header that undefs min or max, add them back like Adafruit did.
sticilface
@sticilface
Sep 03 2016 17:35
or..... if u can change min to _min... it simply works :)
or would that break it for other platforms
ugh.. this is a mess
i've used this in adafruit lib
#ifndef _min
#define _min(a,b) (((a) < (b)) ? (a) : (b))
#endif
but i guess this doesn't resolve the actual problem
Michael Miller
@Makuna
Sep 03 2016 17:44
arduino/Arduino#2069
cross platform is the problem.
There is the issue tracking fixing Arduino, until they do this "terrible" work arounds are required.
sticilface
@sticilface
Sep 03 2016 17:55

how about...

#ifndef min
#define min(a,b) (((a) < (b)) ? (a) : (b))
#endif

at least this way.... if some other lib has undefined it... it will still work... as you define it... ?

works and keeps compatibility
and mostly does nothing...
Michael Miller
@Makuna
Sep 03 2016 18:10
yup, you may need one for max at some point.
sticilface
@sticilface
Sep 03 2016 18:18
i was thinking if u insert it into your header..
Michael Miller
@Makuna
Sep 03 2016 18:24
I will consider it
I think I will just not use min and replace it with it with the < ? :
sticilface
@sticilface
Sep 03 2016 18:35
given the mess that all of this is that sounds like a very sensible idea! and u only use it twice
Michael Miller
@Makuna
Sep 03 2016 18:46
Pushed the changes
sticilface
@sticilface
Sep 03 2016 19:51
thats great. thanks