Converted Serial.printf in extra classes to ESP_LOGI and ESP_LOGW

Changed Serial.printf() diagnostic messages to either ESP_LOGI() or ESP_LOGW() macros in Blinker, PWM (LedPin and ServoPin), Pixel, and RFControl class
This commit is contained in:
Gregg 2023-05-12 21:32:21 -05:00
parent 7bc885dd26
commit de97faee37
9 changed files with 41 additions and 13 deletions

View File

@ -55,6 +55,9 @@ void setup() {
// homeSpan.setLogLevel(-1);
homeSpan.enableOTA();
homeSpan.setStatusPin(13);
homeSpan.setStatusAutoOff(20);
homeSpan.begin(Category::Lighting,"HomeSpan LED");
new SpanAccessory();

View File

@ -134,7 +134,7 @@ void Blinker::check(){
if(pauseDuration==0 || isPaused || (millis()-pauseTime)<pauseDuration)
return;
Serial.print("Pausing LED\n");
ESP_LOGI(BLINKER_TAG,"Pausing LED");
off();
}

View File

@ -30,6 +30,8 @@
#include <Arduino.h>
#include <driver/timer.h>
[[maybe_unused]] static const char* BLINKER_TAG = "Blinker";
////////////////////////////////
// Blinkable Interface //
////////////////////////////////

View File

@ -35,6 +35,8 @@
#include "PwmPin.h"
#include "Blinker.h"
[[maybe_unused]] static const char* PIXEL_TAG = "Pixel";
////////////////////////////////////////////
// Single-Wire RGB/RGBW NeoPixels //
////////////////////////////////////////////

View File

@ -52,7 +52,7 @@ LedC::LedC(uint8_t pin, uint16_t freq, boolean invert){
timerList[nTimer][nMode]->duty_resolution=(ledc_timer_bit_t)res;
if(ledc_timer_config(timerList[nTimer][nMode])!=0){
Serial.printf("\n*** ERROR: Frequency=%d Hz is out of allowed range ---",freq);
ESP_LOGW(PWM_TAG,"Frequency=%d Hz is out of allowed range ---",freq);
delete timerList[nTimer][nMode];
timerList[nTimer][nMode]=NULL;
return;
@ -82,10 +82,12 @@ LedC::LedC(uint8_t pin, uint16_t freq, boolean invert){
LedPin::LedPin(uint8_t pin, float level, uint16_t freq, boolean invert) : LedC(pin, freq, invert){
if(!channel)
Serial.printf("\n*** ERROR: Can't create LedPin(%d) - no open PWM channels and/or Timers ***\n\n",pin);
if(!channel){
ESP_LOGW(PWM_TAG,"Can't create LedPin(%d) - no open PWM channels and/or Timers",pin);
return;
}
else
Serial.printf("LedPin=%d: mode=%d, channel=%d, timer=%d, freq=%d Hz, resolution=%d bits %s\n",
ESP_LOGI(PWM_TAG,"LedPin=%d: mode=%d, channel=%d, timer=%d, freq=%d Hz, resolution=%d bits %s",
channel->gpio_num,
channel->speed_mode,
channel->channel,
@ -222,9 +224,9 @@ void LedPin::HSVtoRGB(float h, float s, float v, float *r, float *g, float *b ){
ServoPin::ServoPin(uint8_t pin, double initDegrees, uint16_t minMicros, uint16_t maxMicros, double minDegrees, double maxDegrees) : LedC(pin, 50){
if(!channel)
Serial.printf("\n*** ERROR: Can't create ServoPin(%d) - no open PWM channels and/or Timers ***\n\n",pin);
ESP_LOGW(PWM_TAG,"Can't create ServoPin(%d) - no open PWM channels and/or Timers",pin);
else
Serial.printf("ServoPin=%d: mode=%d channel=%d, timer=%d, freq=%d Hz, resolution=%d bits\n",
ESP_LOGI(PWM_TAG,"ServoPin=%d: mode=%d channel=%d, timer=%d, freq=%d Hz, resolution=%d bits",
channel->gpio_num,
channel->speed_mode,
channel->channel,

View File

@ -46,6 +46,8 @@
#include <driver/ledc.h>
#include "Blinker.h"
[[maybe_unused]] static const char* PWM_TAG = "PwmPin";
#define DEFAULT_PWM_FREQ 5000
/////////////////////////////////////

View File

@ -36,7 +36,7 @@ RFControl::RFControl(uint8_t pin, boolean refClock, boolean installDriver){
#else
if(nChannels==RMT_CHANNEL_MAX){
#endif
Serial.printf("\n*** ERROR: Can't create RFControl(%d) - no open channels ***\n\n",pin);
ESP_LOGW(RFControl_TAG,"Can't create RFControl(%d) - no open channels",pin);
return;
}
@ -139,17 +139,17 @@ void RFControl::enableCarrier(uint32_t freq, float duty){
uint32_t lowTime=period*(1.0-duty)+0.5;
if(highTime>0xFFFF || lowTime>0xFFFF){
Serial.printf("\n*** ERROR: Can't enable carrier frequency=%d Hz for RF Control pin=%d, duty=%0.2f. Frequency is too low!\n\n",freq,config->gpio_num,duty);
ESP_LOGW(RFControl_TAG,"Can't enable carrier frequency=%d Hz for RF Control pin=%d, duty=%0.2f. Frequency is too low!",freq,config->gpio_num,duty);
return;
}
if(highTime==0){
Serial.printf("\n*** ERROR: Can't enable carrier frequency=%d Hz for RF Control pin=%d, duty=%0.2f. Duty is too low or frequency is too high!\n\n",freq,config->gpio_num,duty);
ESP_LOGW(RFControl_TAG,"Can't enable carrier frequency=%d Hz for RF Control pin=%d, duty=%0.2f. Duty is too low or frequency is too high!",freq,config->gpio_num,duty);
return;
}
if(lowTime==0){
Serial.printf("\n*** ERROR: Can't enable carrier frequency=%d Hz for RF Control pin=%d, duty=%0.2f. Duty is too high or frequency is too high!\n\n",freq,config->gpio_num,duty);
ESP_LOGW(RFControl_TAG,"Can't enable carrier frequency=%d Hz for RF Control pin=%d, duty=%0.2f. Duty is too high or frequency is too high!",freq,config->gpio_num,duty);
return;
}

View File

@ -36,6 +36,8 @@
#include "driver/rmt.h"
#include <vector>
[[maybe_unused]] static const char* RFControl_TAG = "RFControl";
using std::vector;
class RFControl {

View File

@ -38,9 +38,24 @@ void setup() {
Serial.println("\n\nHomeSpan LED Fade Test\n");
LedPin red(33,0);
LedPin green(32,0);
LedPin red(14,0);
LedPin green(14,0);
LedPin blue(14,0);
LedPin blue2(14,0,1000);
LedPin blue3(14,0,2000);
LedPin blue4(14,0,3000);
LedPin blue5(14,0,60000);
LedPin blue6(14,0,5000);
LedPin blue7(14,0,6000);
LedPin blue8(14,0,7000);
LedPin blue9(14,0,8000);
LedPin blue10(14,0,8000);
LedPin blue11(14,0,8000);
LedPin blue12(14,0,8000);
LedPin blue13(14,0,8000);
LedPin blue14(14,0,5000);
LedPin blue15(14,0,5000);
LedPin blue16(14,0,15000);
int redLevel=0;