Add debug compile features using defines DEBUG_TASMOTA_DRIVER and DEBUG_TASMOTA_SENSOR. See example in xdrv_09_timers.ino

Add debug compile features using defines DEBUG_TASMOTA_DRIVER and DEBUG_TASMOTA_SENSOR. See example in xdrv_09_timers.ino (#6186)
This commit is contained in:
Theo Arends 2019-08-08 15:17:39 +02:00
parent 301f2c626d
commit 7336b2807f
5 changed files with 34 additions and 4 deletions

View File

@ -1,6 +1,7 @@
/*********************************************************************************************\
* 6.6.0.4 20190806
* Add support for CHIRP soil moisture sensor by Christian Baars
* Add debug compile features using defines DEBUG_TASMOTA_DRIVER and DEBUG_TASMOTA_SENSOR. See example in xdrv_09_timers.ino
*
* 6.6.0.3 20190725
* Change filename of configuration backup from using FriendlyName1 to Hostname solving diacritic issues (#2422)

View File

@ -493,9 +493,11 @@
//#define USE_HRE // Add support for Badger HR-E Water Meter (+1k4 code)
/*********************************************************************************************\
* Debug features are only supported in development branch
* Debug features
\*********************************************************************************************/
//#define DEBUG_TASMOTA_DRIVER // Enable driver debug messages
//#define DEBUG_TASMOTA_SENSOR // Enable sensor debug messages
//#define USE_DEBUG_DRIVER // Use xdrv_99_debug.ino providing commands CpuChk, CfgXor, CfgDump, CfgPeek and CfgPoke
/*********************************************************************************************\

View File

@ -517,4 +517,16 @@ void KNX_CB_Action(message_t const &msg, void *arg);
#undef USE_MQTT_TLS_CA_CERT
#endif
#ifdef DEBUG_TASMOTA_DRIVER
#define DEBUG_DRIVER_LOG(...) AddLog_Debug(__VA_ARGS__)
#else
#define DEBUG_DRIVER_LOG(...)
#endif
#ifdef DEBUG_TASMOTA_SENSOR
#define DEBUG_SENSOR_LOG(...) AddLog_Debug(__VA_ARGS__)
#else
#define DEBUG_SENSOR_LOG(...)
#endif
#endif // _SONOFF_POST_H_

View File

@ -1511,6 +1511,16 @@ void AddLog_P2(uint32_t loglevel, PGM_P formatP, ...)
AddLog(loglevel);
}
void AddLog_Debug(PGM_P formatP, ...)
{
va_list arg;
va_start(arg, formatP);
vsnprintf_P(log_data, sizeof(log_data), formatP, arg);
va_end(arg);
AddLog(LOG_LEVEL_DEBUG);
}
void AddLogBuffer(uint32_t loglevel, uint8_t *buffer, uint32_t count)
{
snprintf_P(log_data, sizeof(log_data), PSTR("DMP:"));

View File

@ -282,9 +282,14 @@ void TimerEverySecond(void)
}
#endif
if (xtimer.arm) {
set_time += timer_window[i]; // Add random time offset
if (set_time < 0) { set_time = 0; } // Stay today;
if (set_time > 1439) { set_time = 1439; }
set_time += timer_window[i]; // Add random time offset
if (set_time < 0) { set_time = abs(timer_window[i]); } // After midnight and within negative window so stay today but allow positive randomness;
if (set_time > 1439) { set_time = 1439; } // Stay today
if (0 == i) {
DEBUG_DRIVER_LOG(PSTR("TIM: Timer 1 XTimerTime %d, Window %d, SetTime %d"), xtimer.time, timer_window[i], set_time);
}
if (time == set_time) {
if (xtimer.days & days) {
Settings.timer[i].arm = xtimer.repeat;