amélioration de breath

This commit is contained in:
Julien Cabillot 2017-04-21 01:51:16 +02:00 committed by Cabillot Julien
parent fe64dc5594
commit 948edfe2ec

View File

@ -41,7 +41,7 @@ void setup()
ledEffect = LED_EFFECT_ERROR; ledEffect = LED_EFFECT_ERROR;
ledState = false; ledState = false;
*/ */
LEDS.addLeds<LED_CHIPSET,LED_PIN, LED_COLOR_ORDER>(leds, LED_NUM).setCorrection(TypicalSMD5050); LEDS.addLeds<LED_CHIPSET,LED_PIN, LED_COLOR_ORDER>(leds, LED_NUM).setCorrection(TypicalSMD5050);
ledBlackAll(); ledBlackAll();
FastLED.setBrightness(brightness); FastLED.setBrightness(brightness);
@ -324,17 +324,14 @@ void ledError()
*/ */
void ledFullColor() void ledFullColor()
{ {
fill_solid(leds, LED_NUM, color);
// TODO : il fadrait pas faire 0 -> 255 mais plutot 20 (ou plus) -> brightness
// Source : http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/ // Source : http://sean.voisen.org/blog/2011/10/breathing-led-with-arduino/
// Augmenter 2000 augmente la fréquence (c'est en fait sin((temps / 1000) * Pi/2) float breath = (exp(sin(millis() / 2000.0 * map(speed, 0, 255, 50, 300)/100 * PI)) - 0.3678794) * 108.4;
// 0.36787944 ?? censé correspondre au minimum
// 108.4 ?? censé correspondre au maximum // En dessous de 3 les leds paraissent éteintes
int breath = (exp(sin(millis() / 2000.0 * PI)) - 0.3678794) * 108.4; breath = map(breath, 0, 255, 3, brightness);
//Serial.print(breath);
//Serial.println(" / 255");
FastLED.setBrightness(breath); FastLED.setBrightness(breath);
FastLED.delay(100 / speed); fill_solid(leds, LED_NUM, color);
FastLED.delay(1);
} }
///////////////////// FastLED-3.1.5/examples/ColorPalette ///////////////////// ///////////////////// FastLED-3.1.5/examples/ColorPalette /////////////////////