Add 2 macro to activate or deactivate LOG messages through DEBUG variable
To activate DEBUG message do : #define DEBUG 1
This commit is contained in:
parent
0773d6a437
commit
056717fe8f
|
@ -6,6 +6,14 @@
|
||||||
|
|
||||||
#include <Arduino.h>
|
#include <Arduino.h>
|
||||||
|
|
||||||
|
#if defined(DEBUG) && (DEBUG > 0)
|
||||||
|
#define LOG(...) Serial.print(__VA_ARGS__)
|
||||||
|
#define LOGLN(...) Serial.println(__VA_ARGS__)
|
||||||
|
#else
|
||||||
|
#define LOG(...)
|
||||||
|
#define LOGLN(...)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef ESP8266
|
#ifdef ESP8266
|
||||||
#include <IRsend.h> // From IRremoteESP8266 library
|
#include <IRsend.h> // From IRremoteESP8266 library
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
|
@ -292,7 +292,7 @@ void MitsubishiHeatpumpIR::sendMitsubishi(IRSender& IR, uint8_t powerMode, uint8
|
||||||
|
|
||||||
// Set the temperature on the template message
|
// Set the temperature on the template message
|
||||||
if (temperature == 10) {
|
if (temperature == 10) {
|
||||||
Serial.println(F("Temp=10 maintenance mode"));
|
LOGLN(F("Temp=10 maintenance mode"));
|
||||||
MitsubishiTemplate[7] = 0x00; // Maintenance mode
|
MitsubishiTemplate[7] = 0x00; // Maintenance mode
|
||||||
MitsubishiTemplate[15] = 0x20; // This seems to be set to 0x20 on maintenance mode
|
MitsubishiTemplate[15] = 0x20; // This seems to be set to 0x20 on maintenance mode
|
||||||
} else {
|
} else {
|
||||||
|
@ -329,7 +329,7 @@ void MitsubishiHeatpumpIR::sendMitsubishi(IRSender& IR, uint8_t powerMode, uint8
|
||||||
#ifdef IR_SEND_TIME
|
#ifdef IR_SEND_TIME
|
||||||
if (_mitsubishiModel == MITSUBISHI_KJ) {
|
if (_mitsubishiModel == MITSUBISHI_KJ) {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.printf("Send time %02d:%02d day %d --> %x\n", sendHour, sendMinute, sendWeekday, (sendHour * 60 + sendMinute)/10);
|
LOGf("Send time %02d:%02d day %d --> %x\n", sendHour, sendMinute, sendWeekday, (sendHour * 60 + sendMinute)/10);
|
||||||
#endif
|
#endif
|
||||||
MitsubishiTemplate[10] = (uint8_t)((sendHour * 60 + sendMinute)/10);
|
MitsubishiTemplate[10] = (uint8_t)((sendHour * 60 + sendMinute)/10);
|
||||||
// Sunday is start if week , value 1
|
// Sunday is start if week , value 1
|
||||||
|
@ -337,7 +337,7 @@ void MitsubishiHeatpumpIR::sendMitsubishi(IRSender& IR, uint8_t powerMode, uint8
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
Serial.printf("Send time %02d:%02d --> %x\n", sendHour, sendMinute, (sendHour * 60 + sendMinute)/6);
|
LOGf("Send time %02d:%02d --> %x\n", sendHour, sendMinute, (sendHour * 60 + sendMinute)/6);
|
||||||
#endif
|
#endif
|
||||||
MitsubishiTemplate[10] = (uint8_t)((sendHour * 60 + sendMinute)/6);
|
MitsubishiTemplate[10] = (uint8_t)((sendHour * 60 + sendMinute)/6);
|
||||||
}
|
}
|
||||||
|
@ -351,7 +351,7 @@ void MitsubishiHeatpumpIR::sendMitsubishi(IRSender& IR, uint8_t powerMode, uint8
|
||||||
sprintf_P(pbyte, PSTR("[%02d]=%02x "), i, (int) MitsubishiTemplate[i]);
|
sprintf_P(pbyte, PSTR("[%02d]=%02x "), i, (int) MitsubishiTemplate[i]);
|
||||||
strcat(IRPacket, pbyte);
|
strcat(IRPacket, pbyte);
|
||||||
}
|
}
|
||||||
Serial.println(IRPacket);
|
LOGLN(IRPacket);
|
||||||
#else
|
#else
|
||||||
// Calculate the checksum
|
// Calculate the checksum
|
||||||
for (int i=0; i<17; i++) {
|
for (int i=0; i<17; i++) {
|
||||||
|
|
|
@ -422,21 +422,21 @@ void MitsubishiHeavyZMPHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint
|
||||||
/* ZMP model has no horizontal swing
|
/* ZMP model has no horizontal swing
|
||||||
*/
|
*/
|
||||||
|
|
||||||
Serial.println("Calling sendHeavy from ZMP with");
|
LOGLN("Calling sendHeavy from ZMP with");
|
||||||
Serial.print(F("PowerMode: "));
|
LOG(F("PowerMode: "));
|
||||||
Serial.println(powerMode);
|
LOGLN(powerMode);
|
||||||
Serial.print(F("OperatingMode: "));
|
LOG(F("OperatingMode: "));
|
||||||
Serial.println(operatingMode);
|
LOGLN(operatingMode);
|
||||||
Serial.print(F("FanSpeed: "));
|
LOG(F("FanSpeed: "));
|
||||||
Serial.println(fanSpeed);
|
LOGLN(fanSpeed);
|
||||||
Serial.print(F("Temperature: "));
|
LOG(F("Temperature: "));
|
||||||
Serial.println(temperature);
|
LOGLN(temperature);
|
||||||
Serial.print(F("swingV: "));
|
LOG(F("swingV: "));
|
||||||
Serial.println(swingV);
|
LOGLN(swingV);
|
||||||
Serial.print(F("swingH: "));
|
LOG(F("swingH: "));
|
||||||
Serial.println(swingH);
|
LOGLN(swingH);
|
||||||
Serial.print(F("cleanMode: "));
|
LOG(F("cleanMode: "));
|
||||||
Serial.println(cleanMode);
|
LOGLN(cleanMode);
|
||||||
sendMitsubishiHeavy(IR, powerMode, operatingMode, fanSpeed, temperature, swingV, swingH, cleanMode);
|
sendMitsubishiHeavy(IR, powerMode, operatingMode, fanSpeed, temperature, swingV, swingH, cleanMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -553,10 +553,10 @@ void MitsubishiHeavyZMPHeatpumpIR::sendMitsubishiHeavy(IRSender& IR, uint8_t pow
|
||||||
|
|
||||||
// Data
|
// Data
|
||||||
for (uint8_t i=0; i<sizeof(MitsubishiHeavyZMPTemplate); i++) {
|
for (uint8_t i=0; i<sizeof(MitsubishiHeavyZMPTemplate); i++) {
|
||||||
Serial.print(F("Byte "));
|
LOG(F("Byte "));
|
||||||
Serial.print(i);
|
LOG(i);
|
||||||
Serial.print(F(": "));
|
LOG(F(": "));
|
||||||
Serial.println(MitsubishiHeavyZMPTemplate[i]);
|
LOGLN(MitsubishiHeavyZMPTemplate[i]);
|
||||||
IR.sendIRbyte(MitsubishiHeavyZMPTemplate[i], MITSUBISHI_HEAVY_BIT_MARK, MITSUBISHI_HEAVY_ZERO_SPACE, MITSUBISHI_HEAVY_ONE_SPACE);
|
IR.sendIRbyte(MitsubishiHeavyZMPTemplate[i], MITSUBISHI_HEAVY_BIT_MARK, MITSUBISHI_HEAVY_ZERO_SPACE, MITSUBISHI_HEAVY_ONE_SPACE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -131,10 +131,10 @@ void MitsubishiMSCHeatpumpIR::sendMitsubishiMSC(IRSender& IR, uint8_t powerMode,
|
||||||
for (int i=0; i<templateSize; i++) {
|
for (int i=0; i<templateSize; i++) {
|
||||||
checksum += MitsubishiTemplate[i];
|
checksum += MitsubishiTemplate[i];
|
||||||
sprintf_P(pbyte, PSTR(",%02x"),(int) MitsubishiTemplate[i]);
|
sprintf_P(pbyte, PSTR(",%02x"),(int) MitsubishiTemplate[i]);
|
||||||
Serial.print(pbyte);
|
LOG(pbyte);
|
||||||
}
|
}
|
||||||
|
|
||||||
Serial.println("");
|
LOGLN("");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// 38 kHz PWM frequency
|
// 38 kHz PWM frequency
|
||||||
|
|
|
@ -128,8 +128,8 @@ void PanasonicCKPHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t op
|
||||||
// Note that the argument to 'timer.after' has to be explicitly cast into 'long'
|
// Note that the argument to 'timer.after' has to be explicitly cast into 'long'
|
||||||
panasonicCancelTimer = timer.after(2L*60L*1000L, sendPanasonicCKPCancelTimer);
|
panasonicCancelTimer = timer.after(2L*60L*1000L, sendPanasonicCKPCancelTimer);
|
||||||
|
|
||||||
Serial.print(F("'Timer cancel' timer ID: "));
|
LOG(F("'Timer cancel' timer ID: "));
|
||||||
Serial.println(panasonicCancelTimer);
|
LOGLN(panasonicCancelTimer);
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ void PanasonicCKPHeatpumpIR::sendPanasonicCKPOnOffTimerCancel(IRSender& IR, bool
|
||||||
// Send the Panasonic CKP timer cancel
|
// Send the Panasonic CKP timer cancel
|
||||||
void PanasonicCKPHeatpumpIR::sendPanasonicCKPCancelTimer(IRSender& IR)
|
void PanasonicCKPHeatpumpIR::sendPanasonicCKPCancelTimer(IRSender& IR)
|
||||||
{
|
{
|
||||||
Serial.println(F("Sending Panasonic CKP timer cancel"));
|
LOGLN(F("Sending Panasonic CKP timer cancel"));
|
||||||
|
|
||||||
sendPanasonicCKPOnOffTimerCancel(IR, false, true);
|
sendPanasonicCKPOnOffTimerCancel(IR, false, true);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue