ajout fps
This commit is contained in:
parent
aa6e34bdfb
commit
4d946c0ab6
@ -29,6 +29,7 @@ void setup()
|
||||
client.setCallback(callbackMQTT);
|
||||
testConnectMQTT();
|
||||
|
||||
fps = 0;
|
||||
Serial.println("Ready");
|
||||
|
||||
/* MQTT
|
||||
@ -115,6 +116,7 @@ void callbackMQTT(char* topic, byte* payload, unsigned int length)
|
||||
} else if (stopic == MQTT_LED_BRIGHTNESS_COMMAND) {
|
||||
maxBrightness = msgString.toInt();
|
||||
mqttSendBrightnessState();
|
||||
doPrecalcBreath();
|
||||
} else if (stopic == MQTT_LED_COLOR_COMMAND) {
|
||||
// Sample : 134,168,255
|
||||
int red = msgString.substring(0, msgString.indexOf(',')).toInt();
|
||||
@ -193,6 +195,7 @@ void ledDisplay()
|
||||
* Il faut alors remplacer maxBrightness par maxBrightness - 1 dans la dernière partie de l'équation
|
||||
*/
|
||||
float breath = (exp(sin(millis() / 4500.0 * PI)) + 1.2) * ((curbrightness - 1) / (EULER - (1 / EULER)));
|
||||
// float breath = (exp(sin(millis() / 4500.0 * PI)) + 1.2) * precalcBreath
|
||||
|
||||
fill_solid(leds, LED_NUM, color);
|
||||
FastLED.setBrightness(breath);
|
||||
@ -205,13 +208,25 @@ void ledDisplay()
|
||||
Serial.println(maxBrightness);
|
||||
}
|
||||
*/
|
||||
// TODO : il faut voir combien de temps prends le calcul de la formule.
|
||||
// En effet on pourrais precalculer la valeur de fin au moment d'un changement de brightness.
|
||||
fps++;
|
||||
if (SHOW_FPS) {
|
||||
EVERY_N_SECONDS(1) {
|
||||
Serial.print("FPS : ");
|
||||
Serial.println(fps);
|
||||
fps=0;
|
||||
}
|
||||
}
|
||||
FastLED.show();
|
||||
}
|
||||
|
||||
void doPrecalcBreath()
|
||||
{
|
||||
precalcBreath = ((curbrightness - 1) / (EULER - (1 / EULER)));
|
||||
}
|
||||
|
||||
void loop() {
|
||||
// TODO : à voir s'il est plus interressant d'augmenter vite mais graduellement
|
||||
// TODO : ou de manière moins fréquence mais en faisant un saut de palier.
|
||||
// TODO : la solution peut aussi etre un mix des deux
|
||||
EVERY_N_SECONDS(10) {
|
||||
if (curbrightness <= maxBrightness) {
|
||||
curbrightness++;
|
||||
|
||||
@ -1,5 +1,9 @@
|
||||
#define SERIAL_SPEED 115200
|
||||
|
||||
#define SHOW_FPS 1
|
||||
int fps;
|
||||
float precalcBreath;
|
||||
|
||||
// LED
|
||||
#define LED_NUM 30
|
||||
#define LED_PIN 5 // = D1
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user