Metrics now include the current effect's name.

This commit is contained in:
Fabian Schlenz 2019-09-25 18:11:03 +02:00
parent d396b68191
commit 36edb94ff0
25 changed files with 51 additions and 30 deletions

View File

@ -1,5 +1,4 @@
#ifndef Effect_H
#define Effect_H
#pragma once
#include "Window.h"
#include "config.h"
@ -11,6 +10,7 @@ protected:
public:
virtual ~Effect() {};
virtual void loop() = 0;
virtual String get_name() = 0;
boolean supports_window = false;
virtual boolean can_be_shown_with_clock() { return false; };
virtual boolean clock_as_mask() { return false; };
@ -20,4 +20,3 @@ public:
virtual void apply_option(String key, String value) {};
};
#endif

View File

@ -5,4 +5,5 @@
class AnalogClockEffect : public Effect {
public:
void loop();
String get_name() override { return "analog_clock"; }
};

View File

@ -8,6 +8,7 @@
class AnimationEffect : public Effect {
private:
Animation *animation;
const char* name;
uint16_t xOffset;
uint16_t yOffset;
public:
@ -17,4 +18,5 @@ public:
~AnimationEffect();
AnimationEffect* setFgColor(uint32_t c);
void loop();
String get_name() override;
};

View File

@ -1,5 +1,4 @@
#ifndef effect_bell_H
#define effect_bell_H
#pragma once
#include "Effect.h"
#include "functions.h"
@ -11,6 +10,6 @@ private:
boolean invert = false;
public:
void loop();
String get_name() override { return "bell"; }
};
#endif

View File

@ -1,5 +1,4 @@
#ifndef effect_big_clock_H
#define effect_big_clock_H
#pragma once
#include "Effect.h"
@ -13,6 +12,6 @@ private:
public:
void loop();
String get_name() override { return "big_clock"; }
};
#endif

View File

@ -12,5 +12,6 @@ public:
boolean supports_window = true;
boolean can_be_shown_with_clock();
void loop();
String get_name() override { return "blur2d"; }
};

View File

@ -13,4 +13,5 @@ public:
~ClockEffect();
void loop();
void loop(boolean invert, CRGB fg_color, CRGB bg_color);
String get_name() override { return "clock"; }
};

View File

@ -1,5 +1,4 @@
#ifndef effect_confetti_H
#define effect_confetti_H
#pragma once
#include "Effect.h"
#include "my_fastled.h"
@ -10,11 +9,12 @@ protected:
public:
void loop();
boolean can_be_shown_with_clock();
String get_name() override { return "confetti"; }
};
class RandomConfettiEffect : public ConfettiEffect {
protected:
CRGB _getColor() override;
String get_name() override { return "random_confetti"; }
};
#endif

View File

@ -1,5 +1,4 @@
#ifndef effect_cycle_H
#define effect_cycle_H
#pragma once
#include "Effect.h"
#include "effects.h"
@ -16,8 +15,7 @@ public:
boolean can_be_shown_with_clock();
boolean clock_as_mask();
String get_name() override;
void loop();
};
#endif

View File

@ -14,4 +14,5 @@ public:
~DvdEffect();
void loop() override;
bool can_be_shown_with_clock() override;
String get_name() override { return "dvd"; }
};

View File

@ -15,11 +15,13 @@ public:
boolean can_be_shown_with_clock();
virtual void loop();
void draw();
String get_name() override { return "single_dynamic"; }
};
class MultiDynamicEffect : public SingleDynamicEffect {
public:
void loop();
String get_name() override { return "multi_dynamic"; }
};
class BigDynamicEffect : public Effect {
@ -29,4 +31,5 @@ public:
void loop();
~BigDynamicEffect();
boolean can_be_shown_with_clock() override;
String get_name() override { return "big_dynamic"; }
};

View File

@ -16,4 +16,5 @@ public:
FireEffect();
~FireEffect();
void loop();
String get_name() override { return "fire"; }
};

View File

@ -57,5 +57,6 @@ public:
boolean supports_window = true;
boolean can_be_shown_with_clock();
void loop();
String get_name() override { return "firework"; }
};

View File

@ -19,4 +19,5 @@ public:
~GolEffect();
void loop();
bool can_be_shown_with_clock();
String get_name() override { return "gol"; }
};

View File

@ -14,5 +14,6 @@ public:
boolean can_be_shown_with_clock();
void loop();
void apply_option(String key, String value) override;
String get_name() override { return "marquee"; }
};

View File

@ -56,14 +56,17 @@ public:
MatrixEffect();
virtual ~MatrixEffect();
void loop();
String get_name() override { return "matrix"; }
};
class RainbowMatrixEffect : public MatrixEffect {
public:
RainbowMatrixEffect();
String get_name() override { return "rainbow_matrix"; }
};
class RandomMatrixEffect : public MatrixEffect {
public:
RandomMatrixEffect();
String get_name() override { return "random_matrix"; }
};

View File

@ -12,4 +12,5 @@ public:
~PixelClockEffect();
void loop();
bool can_be_shown_with_clock();
String get_name() override { return "pixel_clock"; }
};

View File

@ -1,5 +1,4 @@
#ifndef effect_sinematrix3_H
#define effect_sinematrix3_H
#pragma once
#include "prototypes.h"
#include "functions.h"
@ -32,6 +31,6 @@ public:
boolean can_be_shown_with_clock();
boolean clock_as_mask();
void loop();
String get_name() override { return "sinematrix3"; }
};
#endif

View File

@ -28,5 +28,6 @@ public:
boolean supports_window = true;
boolean can_be_shown_with_clock();
void loop();
String get_name() override { return "sines"; }
};

View File

@ -1,5 +1,4 @@
#ifndef effect_snake_H
#define effect_snake_H
#pragma once
#include "Effect.h"
#include "prototypes.h"
@ -22,6 +21,5 @@ public:
boolean valid_position(Coords c);
Coords update_position(Coords c, uint8_t direction);
boolean can_be_shown_with_clock();
String get_name() override { return "snake"; }
};
#endif

View File

@ -1,5 +1,4 @@
#ifndef effect_static_H
#define effect_static_H
#pragma once
#include "Effect.h"
#include "my_fastled.h"
@ -11,6 +10,6 @@ public:
StaticEffect(CRGB col);
boolean supports_window = true;
void loop();
String get_name() override { return "static"; }
};
#endif

View File

@ -1,5 +1,4 @@
#ifndef effect_twirl_H
#define effect_twirl_H
#pragma once
#include "Effect.h"
#include <Arduino.h>
@ -14,6 +13,6 @@ public:
void loop();
boolean can_be_shown_with_clock() override;
boolean clock_as_mask() override;
String get_name() override { return "twirl"; }
};
#endif

View File

@ -2,6 +2,7 @@
#include "functions.h"
AnimationEffect::AnimationEffect(const char* name, uint32_t bg, int x, int y) {
this->name = name;
this->xOffset = x;
this->yOffset = y;
@ -23,3 +24,9 @@ void AnimationEffect::loop() {
this->animation->drawFrame();
this->animation->advance();
}
String AnimationEffect::get_name() {
String s = "animation/";
s += this->name;
return s;
}

View File

@ -47,3 +47,9 @@ void CycleEffect::loop() {
}
}
}
String CycleEffect::get_name() {
String s = "cycle/";
s += effect->get_name();
return s;
}

View File

@ -108,7 +108,7 @@ void loop() {
#if defined(MQTT_ENABLE) && defined(MQTT_REPORT_METRICS)
EVERY_N_SECONDS(15) {
char json[120];
snprintf(json, 120, "{\"free_heap\":%u, \"uptime\":%lu, \"fps\":%d, \"time_per_frame\":%lu}", ESP.getFreeHeap(), millis()/1000, FastLED.getFPS(), metrics_frame_time / metrics_frame_count);
snprintf(json, 120, "{\"effect\":\"%s\",\"heap\":%u, \"up\":%lu, \"fps\":%d, \"frametime\":%lu}", current_effect->get_name().c_str(), ESP.getFreeHeap(), millis()/1000, FastLED.getFPS(), metrics_frame_time / metrics_frame_count);
mqtt_publish("metrics", json);
metrics_frame_count = 0;
metrics_frame_time = 0;