Macros LOG
and LOGln
now will, if debugging is enabled, log to an mqtt topic as well as Serial.
This commit is contained in:
parent
3294a35028
commit
f9fba8a8f9
@ -28,6 +28,7 @@
|
|||||||
#define MQTT_USER "..."
|
#define MQTT_USER "..."
|
||||||
#define MQTT_PASS "..."
|
#define MQTT_PASS "..."
|
||||||
#define MQTT_TOPIC "pitrix/" // MQTT-Topic to listen to. Must not start with a slash, but must end with one."
|
#define MQTT_TOPIC "pitrix/" // MQTT-Topic to listen to. Must not start with a slash, but must end with one."
|
||||||
|
#define MQTT_TOPIC_LOG "pitrix/log"
|
||||||
|
|
||||||
#define HOSTNAME "pitrix-%08X"
|
#define HOSTNAME "pitrix-%08X"
|
||||||
#define OTA_STARTUP_DELAY 10 // How many seconds to wait at startup. Set to 0 to disable.
|
#define OTA_STARTUP_DELAY 10 // How many seconds to wait at startup. Set to 0 to disable.
|
||||||
@ -39,7 +40,7 @@
|
|||||||
#define MONITOR_LOOP_TIME_THRESHOLD 500
|
#define MONITOR_LOOP_TIME_THRESHOLD 500
|
||||||
#define MONITOR_LOOP_TIME_COUNT_MAX 10
|
#define MONITOR_LOOP_TIME_COUNT_MAX 10
|
||||||
|
|
||||||
#define REPORT_FREE_HEAP true
|
#define REPORT_METRICS true
|
||||||
|
|
||||||
#define EFFECT_CYCLE_TIME 300 // Time in seconds between cycling effects.
|
#define EFFECT_CYCLE_TIME 300 // Time in seconds between cycling effects.
|
||||||
|
|
||||||
@ -48,7 +49,7 @@
|
|||||||
#define EFFECT_MATRIX_SPEED_MIN 50
|
#define EFFECT_MATRIX_SPEED_MIN 50
|
||||||
#define EFFECT_MATRIX_SPEED_MAX 135
|
#define EFFECT_MATRIX_SPEED_MAX 135
|
||||||
|
|
||||||
#define EFFECT_SINGLE_DYNAMIC_LOOP_TIME 200
|
#define EFFECT_SINGLE_DYNAMIC_LOOP_TIME 50
|
||||||
#define EFFECT_MULTI_DYNAMIC_LOOP_TIME 1400
|
#define EFFECT_MULTI_DYNAMIC_LOOP_TIME 1400
|
||||||
|
|
||||||
#define EFFECT_CONFETTI_PIXELS_PER_LOOP 2
|
#define EFFECT_CONFETTI_PIXELS_PER_LOOP 2
|
||||||
@ -57,8 +58,8 @@
|
|||||||
#define EFFECT_SNAKE_SLOWDOWN 2
|
#define EFFECT_SNAKE_SLOWDOWN 2
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
#define LOG(x) Serial.print(x);
|
#define LOG(x) mqtt_log(x); Serial.print(x);
|
||||||
#define LOGln(x) Serial.println(x);
|
#define LOGln(x) mqtt_log_ln(x); Serial.println(x);
|
||||||
#else
|
#else
|
||||||
#define LOG(x) do {} while(0);
|
#define LOG(x) do {} while(0);
|
||||||
#define LOGln(x) do {} while(0);
|
#define LOGln(x) do {} while(0);
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define my_mqtt_H
|
#define my_mqtt_H
|
||||||
|
|
||||||
#include <PubSubClient.h>
|
#include <PubSubClient.h>
|
||||||
//extern PubSubClient mqtt_client;
|
#include <Arduino.h>
|
||||||
|
|
||||||
void mqtt_callback(char* complete_topic, byte* pl, unsigned int length);
|
void mqtt_callback(char* complete_topic, byte* pl, unsigned int length);
|
||||||
|
|
||||||
@ -14,4 +14,17 @@ void mqtt_loop();
|
|||||||
|
|
||||||
void mqtt_publish(const char* topic, int number);
|
void mqtt_publish(const char* topic, int number);
|
||||||
|
|
||||||
|
void mqtt_log(const char* message);
|
||||||
|
void mqtt_log(int number);
|
||||||
|
void mqtt_log(long unsigned int number);
|
||||||
|
|
||||||
|
void mqtt_log_ln(const char* message);
|
||||||
|
void mqtt_log_ln(int number);
|
||||||
|
void mqtt_log_ln(long unsigned int number);
|
||||||
|
|
||||||
|
|
||||||
|
void mqtt_log_send(const char* message);
|
||||||
|
|
||||||
|
extern String mqtt_log_str;
|
||||||
|
|
||||||
#endif // mqtt_H
|
#endif // mqtt_H
|
||||||
|
39
src/mqtt.cpp
39
src/mqtt.cpp
@ -72,6 +72,8 @@ void mqtt_loop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String mqtt_log_str = String();
|
||||||
|
|
||||||
void mqtt_publish(const char* topic, int number) {
|
void mqtt_publish(const char* topic, int number) {
|
||||||
char t[127];
|
char t[127];
|
||||||
sprintf(t, MQTT_TOPIC "%s", topic);
|
sprintf(t, MQTT_TOPIC "%s", topic);
|
||||||
@ -79,3 +81,40 @@ void mqtt_publish(const char* topic, int number) {
|
|||||||
sprintf(b, "%d", number);
|
sprintf(b, "%d", number);
|
||||||
mqtt_client.publish(t, b);
|
mqtt_client.publish(t, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void mqtt_log(const char* message) {
|
||||||
|
mqtt_log_str.concat(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
void mqtt_log(int number) {
|
||||||
|
mqtt_log(String(number).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void mqtt_log(long unsigned int number) {
|
||||||
|
mqtt_log(String(number).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void mqtt_log_ln(int number) {
|
||||||
|
mqtt_log_ln(String(number).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void mqtt_log_ln(long unsigned int number) {
|
||||||
|
mqtt_log_ln(String(number).c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
void mqtt_log_ln(const char* message) {
|
||||||
|
if (mqtt_log_str.length()==0) {
|
||||||
|
mqtt_log_send(message);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
mqtt_log_str.concat(message);
|
||||||
|
mqtt_log_send(mqtt_log_str.c_str());
|
||||||
|
mqtt_log_str = String();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void mqtt_log_send(const char* message) {
|
||||||
|
if (mqtt_client.connected()) {
|
||||||
|
mqtt_client.publish(MQTT_TOPIC_LOG, message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -60,9 +60,9 @@ void loop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
EVERY_N_MILLISECONDS(1000 / FPS) {
|
EVERY_N_MILLISECONDS(1000 / FPS) {
|
||||||
LOGln("Core * loop running");
|
//LOGln("Core * loop running");
|
||||||
current_effect->loop();
|
current_effect->loop();
|
||||||
LOGln("Core * loop ran");
|
//LOGln("Core * loop ran");
|
||||||
|
|
||||||
if (current_effect->can_be_shown_with_clock()) {
|
if (current_effect->can_be_shown_with_clock()) {
|
||||||
effect_clock.loop(current_effect->clock_as_mask(), CRGB(0xFFFFFF), CRGB(0x000000));
|
effect_clock.loop(current_effect->clock_as_mask(), CRGB(0xFFFFFF), CRGB(0x000000));
|
||||||
|
Loading…
Reference in New Issue
Block a user