uniformisation du code
This commit is contained in:
parent
e9377a2be5
commit
99319782aa
@ -24,7 +24,6 @@ WiFiClient espClient;
|
|||||||
char message_buff[100];
|
char message_buff[100];
|
||||||
PubSubClient client(espClient);
|
PubSubClient client(espClient);
|
||||||
|
|
||||||
///////////////////////////////////////////////
|
|
||||||
|
|
||||||
void setup()
|
void setup()
|
||||||
{
|
{
|
||||||
@ -55,10 +54,10 @@ void setup()
|
|||||||
client.loop();
|
client.loop();
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////// ColorPalette
|
//////////////////////////////// ColorPalette ///////////////////////////////
|
||||||
currentPalette = RainbowColors_p;
|
currentPalette = RainbowColors_p;
|
||||||
currentBlending = LINEARBLEND;
|
currentBlending = LINEARBLEND;
|
||||||
/////////////////////////////////////////////////////////////
|
//////////////////////////////// ColorPalette ///////////////////////////////
|
||||||
|
|
||||||
Serial.println("End of setup");
|
Serial.println("End of setup");
|
||||||
}
|
}
|
||||||
@ -130,7 +129,6 @@ void callbackMQTT(char* topic, byte* payload, unsigned int length)
|
|||||||
// Si on ne repasse pas tout à noir, cela peut faire des effets surprenants
|
// Si on ne repasse pas tout à noir, cela peut faire des effets surprenants
|
||||||
ledBlackAll();
|
ledBlackAll();
|
||||||
ledEffect = msgString;
|
ledEffect = msgString;
|
||||||
// TODO : a vraiment tester
|
|
||||||
client.publish(MQTT_LED_EFFECT_STATE, message_buff, true);
|
client.publish(MQTT_LED_EFFECT_STATE, message_buff, true);
|
||||||
} else if (stopic == MQTT_LED_BRIGHTNESS_COMMAND) {
|
} else if (stopic == MQTT_LED_BRIGHTNESS_COMMAND) {
|
||||||
brightness = msgString.toInt();
|
brightness = msgString.toInt();
|
||||||
@ -157,8 +155,6 @@ void ledBlackAll()
|
|||||||
FastLED.show();
|
FastLED.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : faudra sortir toutes ces fonctions dans un autre fichier
|
|
||||||
|
|
||||||
void ledCylon()
|
void ledCylon()
|
||||||
{
|
{
|
||||||
// Effet cylon : on allume une led, on attends, on eteinds, on passe à la suivante
|
// Effet cylon : on allume une led, on attends, on eteinds, on passe à la suivante
|
||||||
@ -248,14 +244,19 @@ void ledError()
|
|||||||
void ledFullColor()
|
void ledFullColor()
|
||||||
{
|
{
|
||||||
fill_solid(leds, LED_NUM, color);
|
fill_solid(leds, LED_NUM, color);
|
||||||
int breath = (exp(sin(millis() / 2000.0 * PI)) - 0.36787944) * 108.4;
|
// TODO : il fadrait pas faire 0 -> 255 mais plutot 20 -> brightness
|
||||||
|
// 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)
|
||||||
|
// 0.36787944 ?? censé correspondre au minimum
|
||||||
|
// 108.4 ?? censé correspondre au maximum
|
||||||
|
int breath = (exp(sin(millis() / 2000.0 * PI)) - 0.3678794) * 108.4;
|
||||||
|
Serial.print(breath);
|
||||||
|
Serial.println(" / 255");
|
||||||
FastLED.setBrightness(breath);
|
FastLED.setBrightness(breath);
|
||||||
FastLED.delay(100 / speed);
|
FastLED.delay(100 / speed);
|
||||||
}
|
}
|
||||||
|
|
||||||
///////////////////////////////// ColorPalette
|
///////////////////// FastLED-3.1.5/examples/ColorPalette /////////////////////
|
||||||
|
|
||||||
|
|
||||||
void ledColorPattern()
|
void ledColorPattern()
|
||||||
{
|
{
|
||||||
ChangePalettePeriodically();
|
ChangePalettePeriodically();
|
||||||
@ -279,7 +280,6 @@ void FillLEDsFromPaletteColors(uint8_t colorIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// There are several different palettes of colors demonstrated here.
|
// There are several different palettes of colors demonstrated here.
|
||||||
//
|
//
|
||||||
// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
|
// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
|
||||||
@ -330,7 +330,6 @@ void SetupBlackAndWhiteStripedPalette()
|
|||||||
currentPalette[4] = CRGB::White;
|
currentPalette[4] = CRGB::White;
|
||||||
currentPalette[8] = CRGB::White;
|
currentPalette[8] = CRGB::White;
|
||||||
currentPalette[12] = CRGB::White;
|
currentPalette[12] = CRGB::White;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// This function sets up a palette of purple and green stripes.
|
// This function sets up a palette of purple and green stripes.
|
||||||
@ -344,14 +343,12 @@ void SetupPurpleAndGreenPalette()
|
|||||||
green, green, black, black,
|
green, green, black, black,
|
||||||
purple, purple, black, black,
|
purple, purple, black, black,
|
||||||
green, green, black, black,
|
green, green, black, black,
|
||||||
purple, purple, black, black );
|
purple, purple, black, black
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
///////////////////// FastLED-3.1.5/examples/ColorPalette /////////////////////
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////////
|
/////////////////// FastLED-3.1.5/examples/ColorTemperature ///////////////////
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////// ColorTemperature
|
|
||||||
void colorTemp()
|
void colorTemp()
|
||||||
{
|
{
|
||||||
// draw a generic, no-name rainbow
|
// draw a generic, no-name rainbow
|
||||||
@ -377,10 +374,9 @@ void colorTemp()
|
|||||||
FastLED.show();
|
FastLED.show();
|
||||||
FastLED.delay(8);
|
FastLED.delay(8);
|
||||||
}
|
}
|
||||||
////////////////////////////////////////////////////////////////////
|
/////////////////// FastLED-3.1.5/examples/ColorTemperature ///////////////////
|
||||||
|
|
||||||
|
//////////////////////// FastLED-3.1.5/examples/Fire202 ///////////////////////
|
||||||
///////////////////////////////////////////////Fire202
|
|
||||||
void fire()
|
void fire()
|
||||||
{
|
{
|
||||||
// Array of temperature readings at each simulation cell
|
// Array of temperature readings at each simulation cell
|
||||||
@ -416,7 +412,7 @@ void fire()
|
|||||||
|
|
||||||
FastLED.delay(1000 / speed);
|
FastLED.delay(1000 / speed);
|
||||||
}
|
}
|
||||||
/////////////////////////////////////////////
|
//////////////////////// FastLED-3.1.5/examples/Fire202 ///////////////////////
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// MQTT
|
// MQTT
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user