# include <Adafruit_NeoPixel.h>
# define NLEDS 64
class Hack : public Adafruit_NeoPixel {
public:
// Properly calling the base class constructor using an initializer list
Hack(int a, int b, int c) : Adafruit_NeoPixel(a, b, c) {}
void setReversePixelColor(unsigned char thePixel, unsigned long theColor);
};
// Function to set the reverse pixel color
void Hack::setReversePixelColor(unsigned char thePixel, unsigned long theColor) {
setPixelColor(numPixels() - thePixel - 1, theColor);
}
# define Adafruit_NeoPixel Hack
// Uncomment the following line for normal pixel order
# define setPixelColor setReversePixelColor
Hack strip(NLEDS, 6, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
Serial.println("\nstrip reverse hack\n");
strip.begin(); // Initialize the strip
strip.setPixelColor(0, 0xff0000); // Set some pixels to test
strip.setPixelColor(1, 0x00ff00);
strip.setPixelColor(2, 0x0000ff);
strip.setPixelColor(63, 0xffffff);
strip.show(); // Update the strip
delay(777);
strip.clear(); // Clear the strip after a short delay
}
void loop() {
static byte traveller;
strip.clear(); // Clear the strip at the start of each loop
strip.setPixelColor(traveller & 0x3f, 0xff0000); // Set a single pixel to red
strip.show(); // Update the strip
traveller++; // Increment the traveller variable
delay(166); // Wait before updating again
}
/*
# include <Adafruit_NeoPixel.h>
# define NLEDS 64
class Hack : public Adafruit_NeoPixel {
public:
Hack(int a, int b, int c) {
Adafruit_NeoPixel(a, b, c);
}
void setReversePixelColor(unsigned char, unsigned long);
};
///*
void Hack::setReversePixelColor(unsigned char thePixel, unsigned long theColor)
{
setPixelColor(numPixels() - thePixel - 1, theColor);
}
///* comment the next line for normal pixel order
//# define setPixelColor setReversePixelColor
Hack strip(NLEDS, 6, NEO_GRB + NEO_KHZ800);
void setup() {
Serial.begin(115200);
Serial.println("\nstrip reverse hack\n");
strip.begin();
strip.setPixelColor(0, 0xff0000);
strip.setPixelColor(1, 0x00ff00);
strip.setPixelColor(2, 0x0000ff);
strip.setPixelColor(63, 0xffffff);
strip.show(); delay(777); strip.clear();
}
void loop() {
static byte traveller;
strip.clear();
strip.setPixelColor(traveller & 0x3f, 0xff0000);
strip.show();
traveller++;
delay(166);
}
*/