Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

i want to run normal program with class type of program #2

Open
LedArts opened this issue Feb 17, 2017 · 14 comments
Open

i want to run normal program with class type of program #2

LedArts opened this issue Feb 17, 2017 · 14 comments

Comments

@LedArts
Copy link

LedArts commented Feb 17, 2017

Can i run "class" code with normal example code.
i try but only one of them is running. what should i do please tell me.

class example
class colorWipe: public animation {
public:
colorWipe(void) { w = random(256); }
virtual void init(void);
virtual void show(void);
private:
byte w;
int index;
bool fwd;
};

void colorWipe::init(void) {
int p = random(2, 4);
w += p*16 + 1;
fwd = random(2);
index = 0;
if (!fwd) index = strip.numPixels() - 1;
}

void colorWipe::show(void) {
uint32_t color = Wheel(w);
if (fwd) {
if (index > int(strip.numPixels())) { // Start new sequence with the new color
init();
complete = true;
return;
}
strip.setPixelColor(index++, color);
} else {
if (index < 0) { // Start new sequence with the new color
init();
complete = true;
return;
}
strip.setPixelColor(index--, color);
}
complete = false;
}

//Normal example

void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c); //turn every third pixel on
}
strip.show();

delay(wait);

for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}

//only mgr.show is running in this loop
void loop() {
mgr.show();
theaterChase(strip.Color(127, 127, 127), 50); // White
theaterChase(strip.Color(127, 0, 0), 50); // Red
theaterChase(strip.Color(0, 0, 127), 50); // Blue
}
//what should i do please tell me.

@sfrwmaker
Copy link
Owner

sfrwmaker commented Feb 17, 2017 via email

@LedArts
Copy link
Author

LedArts commented Feb 17, 2017

thank you sir,
but i want to add more effects in your code but i don't know how to convert that in class type
can u tell me how to convert this example like your code

void loop() {
theaterChase(strip.Color(127, 127, 127), 50); // White
theaterChase(strip.Color(127, 0, 0), 50); // Red
theaterChase(strip.Color(0, 0, 127), 50); // Blue
}
void theaterChase(uint32_t c, uint8_t wait) {
for (int j=0; j<10; j++) { //do 10 cycles of chasing
for (int q=0; q < 3; q++) {
for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, c); //turn every third pixel on
}
strip.show();

delay(wait);

for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
strip.setPixelColor(i+q, 0); //turn every third pixel off
}
}
}
}

@sfrwmaker
Copy link
Owner

sfrwmaker commented Feb 18, 2017 via email

@LedArts
Copy link
Author

LedArts commented Feb 18, 2017

yes u r right sir...
this is the simple one that's why i choose this to learn how to convert it class type or fit in u r program please tell me.....how can i run this with u r program.

@sfrwmaker
Copy link
Owner

sfrwmaker commented Mar 5, 2017 via email

@LedArts
Copy link
Author

LedArts commented Mar 6, 2017

thank you so much sir........

i have one more request sir can u provide me lots of neo pixel examples which is written in regular type like gives in neo pixal library examples.

@LedArts
Copy link
Author

LedArts commented Mar 6, 2017

i have this examples which is given in this link
https://www.tweaking4all.com/hardware/arduino/adruino-led-strip-effects/

but i need more........

@sfrwmaker
Copy link
Owner

sfrwmaker commented Mar 6, 2017 via email

@LedArts
Copy link
Author

LedArts commented Mar 7, 2017

ok thank you sir,
but if u update any programs please tell me in future.

@LedArts
Copy link
Author

LedArts commented Mar 9, 2017

hello sir, i try the theater chase function but only one color(Green) is running. what should i do for other colors.
// --------------------------------------------- Theatre-style crawling lights from neopixel example ----------------------
class theatChase: public animation {
public:
theaterChase(void) { min_p = 3; max_p = 8; show_time = 3; }
virtual void init(void);
virtual void show(void);
private:
byte w; // color wheel index
byte color_period; // color period shift
char color_shift;
byte stp;
};

void theatChase::init(void) {
w = random(265);
color_period = random(5, 20);
color_shift = color_period;
stp = 0;
}

void theatChase::show(void) {
int n = strip.numPixels();
for (int i = 0; i < n; i += 3)
strip.setPixelColor(i + stp, 0); // turn off previous state pixels

if (++stp >= 3) stp = 0;
uint32_t color = Wheel(w);
for (int i = 0; i < n; i += 3)
strip.setPixelColor(i + stp, color);
if (--color_shift <= 0) {
color_shift = color_period;
++w;
}
}

@sfrwmaker
Copy link
Owner

sfrwmaker commented Mar 10, 2017 via email

@LedArts
Copy link
Author

LedArts commented Mar 10, 2017

sir still not working properly i also decrease the speed and increase the show time but only two colors are running.
please you try it and check.
thank you

@sfrwmaker
Copy link
Owner

sfrwmaker commented Mar 10, 2017 via email

@LedArts
Copy link
Author

LedArts commented Mar 21, 2017

thank you so much sir,........
sir if you make any new program or any update about program please tell me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants