Closed LedArts closed 7 years ago
I had a look at my original program and there were no delay statements.
I recommend that you learn how to write your routines so that they don't use blocking delay statements, and that includes FastLED.delay.
sir this is your updated program
and i think your original program is this
/* easing
By: Andrew Tuline Email: atuline@gmail.com
Date: August, 2015
This simple program demonstrates the easing capability of FastLED. The Red LED starts out slow, speeds up and then slows down when it gets to the end.
It uses uint8_t variables:
easeOutVal = ease8InOutQuad(easeInVal); // Start with easeInVal at 0 and then go to 255 for the full easing. ledNum = lerp8by8(0, NUM_LEDS, easeOutVal); // Map it to the number of LED's you have.
Ideas:
*/
// Fixed definitions cannot change on the fly.
// Global variables can be changed on the fly. uint8_t max_bright = 128; // Overall brightness definition. It can be changed on the fly.
struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
int thisdelay = 10;
void setup() { delay(1000); // Power-up safety delay.
LEDS.addLeds<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2801 or APA102 // LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2812
FastLED.setBrightness(max_bright); set_max_power_in_volts_and_milliamps(5, 500); // FastLED Power management set at 5V, 500mA. } // setup()
void loop() { EVERY_N_MILLISECONDS(thisdelay) { // FastLED based non-blocking delay to update/display the sequence. easeMe(); } show_at_max_brightness_for_power(); // Keep this OUTSIDE the loop. } // loop()
void easeMe() {
static uint8_t easeOutVal = 0; static uint8_t easeInVal = 0; static uint8_t lerpVal = 0;
easeOutVal = ease8InOutQuad(easeInVal); easeInVal++;
lerpVal = lerp8by8(0, NUM_LEDS, easeOutVal);
leds[lerpVal] = CRGB::Red; fadeToBlackBy(leds, NUM_LEDS, 16); // 8 bit, 1 = slow, 255 = fast } // loop()
so should i try this?????????? is it work?
but sir both are looking same.
I recommend starting out with something that works and then modifying it slowly.
Make small changes and see how it works out. If it breaks, then you'll need to go back and fix it and move on from there. That's how I learned.
Having a quick look at your code:
1) It's not indented, thus making it harder to read. 2) They are NOT the same. Although you are trying to blend the routines, but you have broken it by adding delay statements in your code. You cannot blend routines AND have delay statements in your code. 3) You have used nested for loops with delay statements. By adding a Serial.println("X"); statement in the top of the loop(), it's obvious that your repeating_pattern() program is taking all the time. The Arduino is not multi-tasking, so the easing() routine will not run while your repeating_pattern() routine is taking all the time. 4) Comment out the repeating_pattern(); statement from your loop and you'll see that the easing section runs fine.
In summary:
Please have a look at my video at:
https://www.youtube.com/watch?v=e7am6PYh4PM
Note the showfps() function in that video. If your fps is below 100, then you need to re-think your routine.
So, please re-write your repeating_pattern() routine so that it does not use delay statements and nested for loops.
ok sir....i will do it as you say.
thank you soooooooo much......
hello, sir i am trying your examples but having trouble to add two example in one program i am giving example please check and solve my problem.
/ easing
*/
include "FastLED.h" // FastLED library. Please use the latest development version.
if FASTLED_VERSION < 3001000
error "Requires FastLED 3.1 or later; check github for latest code."
endif
// Fixed definitions cannot change on the fly.
define LED_DT 6 // Data pin to connect to the strip.
define LED_CK 11 // Clock pin for WS2801 or APA102.
define COLOR_ORDER RGB // It's GRB for WS2812 and BGR for APA102.
define LED_TYPE WS2811 // Using APA102, WS2812, WS2801. Don't forget to change LEDS.addLeds.
define NUM_LEDS 100 // Number of LED's.
// Global variables can be changed on the fly. uint8_t max_bright = 128; // Overall brightness definition. It can be changed on the fly.
struct CRGB leds[NUM_LEDS]; // Initialize our LED array.
int thisdelay = 10;
//---------------------------------------------------------------
uint8_t hue; // Pixel color uint8_t offset; // To keep track of the offset in the pattern uint16_t i; // A pixel position on the strip
// How often does the pattern repeat? Change as needed. static uint16_t repeatEvery = 5;
// Therefore the number of times the pattern will repeat down the strip is: static uint16_t numberOfRepeats = NUM_LEDS/repeatEvery;
//---------------------------------------------------------------
void setup() {
delay(1000); // Power-up safety delay. //LEDS.addLeds<LED_TYPE, LED_DT, LED_CK, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2801 or APA102 LEDS.addLeds<LED_TYPE, LED_DT, COLOR_ORDER>(leds, NUM_LEDS); // Use this for WS2812
FastLED.setBrightness(max_bright); set_max_power_in_volts_and_milliamps(5, 500); // FastLED Power management set at 5V, 500mA.
} // setup()
void loop() {
EVERY_N_MILLISECONDS(thisdelay) { // FastLED based non-blocking delay to update/display the sequence. ease(); }
FastLED.show(); repeating_pattern(); } // loop()
void ease() {
static uint8_t easeOutVal = 0; static uint8_t easeInVal = 0; static uint8_t lerpVal = 0;
easeOutVal = ease8InOutQuad(easeInVal); // Start with easeInVal at 0 and then go to 255 for the full easing. easeInVal++;
lerpVal = lerp8by8(0, NUM_LEDS, easeOutVal); // Map it to the number of LED's you have.
leds[lerpVal] = CRGB::Red; fadeToBlackBy(leds, NUM_LEDS, 16); // 8 bit, 1 = slow fade, 255 = fast fade
} // ease()
void repeating_pattern() {for (offset = 0; offset < repeatEvery; offset++) { // Operate on each repeating pixel set hue = (255/repeatEvery) offset; // Change the hue for each pixel set. for (uint16_t x = 0; x < numberOfRepeats+1; x++) { i = (repeatEvery(x-1)) + repeatEvery + offset; // The pixel number to draw if (i < NUM_LEDS) { // Only draw pixel numbers within NUM_LEDS leds[i] = CHSV(hue,180,255);
} //end offset loop
delay(1000); // pause before clearing FastLED.clear(); // clear the strip FastLED.delay(100); // pause before starting over }
only one example is running (repeating patterns) this is happening in most of your examples please help me.