Some of the errors above are because you seem to have put setup() and loop() function into a C++ file (a-rainbow2.cpp) instead of a sketch (.ino file) or a C file. In C/C++ compilers a function call to a C function has a different low-level calling pattern than that for a C++ method. Since the setup() and loop() functions are already defined in the main function in the Particle source code as C functions, you should put your setup() and loop() functions in a C or sketch (.ino) file.
That was (would have been) the answer to my first "provocative" question. But unfortunately there are two (maybe three) Particle IDEs - Particle Dev and Particle Build (aka Web IDE) and Particle CLI, which isn't really an IDE but a build tool.
But I assume it's Build, which would bring me back to the prototypes. In Build I'd go for commenting these two prototypes (even if the comment suggests different)
// Prototypes for local build, ok to leave in for Build IDE
void rainbow(uint8_t wait);
uint32_t Wheel(byte WheelPos);
@bko, the mentioned file a-rainbow.cpp might actually be the output file the wiring preprocessor produced from the .ino file and I've not found a way to add C file in Build. But the redeclaration errors and the missing String declaration suggest a file issue.
So this might bring us back to two seperate files containing setup()/loop().
@dcdenison, could you provide a screenshot of your Build window?
When I build your code as is with Build it's fine.
And this code in that project produces these errors
Could you check what target (device and system version) youāve selected?
When I compile that code targeted at Core 0.5.2, I get exactly zero errors.
Hold a sec! It wasnāt exactly the same code. I missed the two includes at the top when I copied your code from above.
Once I added the #include "application.h" I got the same errors.
Just remove that line and try again - the preprocessor seems to play some tricks on you
Hi, added BulldogLowellās code, above. Worked great. Very cool. Thanks!
Rainbow and Black worked perfectly.
Only one function stumped us: chase. One of the classic NeoPixel moves. We tried a lot of variations, but were just not able to get those pixels to chase each other around the ring. : )
Code below, any suggestions appreciated.
void chase(uint8_t wait)
{
static int lastUpdateMillis = 0;
static int direction = -1;
static int pixelIndex = 0;
if (millis() - lastUpdateMillis >= wait)
{
if (pixelIndex <= 0 or pixelIndex >= 255)
{
direction *= -1;
}
pixelIndex += direction;
for (int i = 0; i < strip.numPixels(); i++)
{
if (pixelIndex = i)
{
strip.setPixelColor(i, 255, 255, 255);
}
else
{
strip.setPixelColor(i, 0, 0, 0);
}
}
strip.show();
lastUpdateMillis = millis();
pixelIndex++;
}
}
Next Iām going to hook it up to a javascript form to control it remotely. Iāll share the code when I get it working.