From 5b3a7469ed1984810297449c42bd72856c6fcccd Mon Sep 17 00:00:00 2001 From: ToniA Date: Thu, 1 Oct 2015 10:23:49 +0300 Subject: [PATCH] Arduino IDE 1.6-style PROGMEM definitions --- CarrierHeatpumpIR.cpp | 27 +++++---- CarrierHeatpumpIR.h | 4 +- FujitsuHeatpumpIR.cpp | 46 +++++++-------- FujitsuHeatpumpIR.h | 8 +-- HeatpumpIR.cpp | 2 +- HeatpumpIR.h | 7 +-- HisenseHeatpumpIR.cpp | 36 +++++++----- HisenseHeatpumpIR.h | 4 +- IRSender.cpp | 10 ++-- IRSender.h | 8 +-- MideaHeatpumpIR.cpp | 41 +++++++------ MideaHeatpumpIR.h | 6 +- MitsubishiHeatpumpIR.cpp | 24 ++++---- MitsubishiHeatpumpIR.h | 6 +- PanasonicCKPHeatpumpIR.cpp | 58 +++++++++---------- PanasonicCKPHeatpumpIR.h | 6 +- PanasonicHeatpumpIR.cpp | 32 +++++----- PanasonicHeatpumpIR.h | 6 +- SamsungHeatpumpIR.cpp | 43 +++++++------- SamsungHeatpumpIR.h | 4 +- examples/HisenseTest/HisenseTest.ino | 26 +++------ .../MideaRelayControl/MideaRelayControl.ino | 5 +- examples/MySensorsNode/MySensorsNode.ino | 13 +++-- examples/simple/simple.ino | 8 ++- 24 files changed, 220 insertions(+), 210 deletions(-) diff --git a/CarrierHeatpumpIR.cpp b/CarrierHeatpumpIR.cpp index a4d6d70..244f03d 100644 --- a/CarrierHeatpumpIR.cpp +++ b/CarrierHeatpumpIR.cpp @@ -10,13 +10,16 @@ CarrierHeatpumpIR::CarrierHeatpumpIR() : HeatpumpIR() } -void CarrierHeatpumpIR::send(IRSender& IR, byte powerModeCmd, byte operatingModeCmd, byte fanSpeedCmd, byte temperatureCmd, byte swingVCmd, byte swingHCmd) +void CarrierHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd) { + (void)swingVCmd; + (void)swingHCmd; + // Sensible defaults for the heat pump mode - byte operatingMode = CARRIER_AIRCON1_MODE_HEAT; - byte fanSpeed = CARRIER_AIRCON1_FAN_AUTO; - byte temperature = 23; + uint8_t operatingMode = CARRIER_AIRCON1_MODE_HEAT; + uint8_t fanSpeed = CARRIER_AIRCON1_FAN_AUTO; + uint8_t temperature = 23; if (powerModeCmd == POWER_OFF) { @@ -79,12 +82,12 @@ void CarrierHeatpumpIR::send(IRSender& IR, byte powerModeCmd, byte operatingMode // Send the Carrier code // Carrier has the LSB and MSB in different format than Panasonic -void CarrierHeatpumpIR::sendCarrier(IRSender& IR, byte operatingMode, byte fanSpeed, byte temperature) +void CarrierHeatpumpIR::sendCarrier(IRSender& IR, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature) { - byte sendBuffer[9] = { 0x4f, 0xb0, 0xc0, 0x3f, 0x80, 0x00, 0x00, 0x00, 0x00 }; // The data is on the last four bytes + uint8_t sendBuffer[9] = { 0x4f, 0xb0, 0xc0, 0x3f, 0x80, 0x00, 0x00, 0x00, 0x00 }; // The data is on the last four uint8_ts - static const prog_uint8_t temperatures[] PROGMEM = { 0x00, 0x08, 0x04, 0x0c, 0x02, 0x0a, 0x06, 0x0e, 0x01, 0x09, 0x05, 0x0d, 0x03, 0x0b }; - byte checksum = 0; + static const uint8_t temperatures[] PROGMEM = { 0x00, 0x08, 0x04, 0x0c, 0x02, 0x0a, 0x06, 0x0e, 0x01, 0x09, 0x05, 0x0d, 0x03, 0x0b }; + uint8_t checksum = 0; // PROGMEM arrays cannot be addressed directly, see http://forum.arduino.cc/index.php?topic=106603.0 sendBuffer[5] = pgm_read_byte(&(temperatures[(temperature-17)])); @@ -145,8 +148,8 @@ void CarrierHeatpumpIR::sendCarrier(IRSender& IR, byte operatingMode, byte fanSp IR.space(CARRIER_AIRCON1_HDR_SPACE); // Payload - for (int i=0; i #include @@ -57,11 +56,11 @@ class HeatpumpIR { protected: HeatpumpIR(); // Cannot create generic heatpump instances - const char PROGMEM* _model; - const char PROGMEM* _info; + const char * _model; + const char * _info; public: - virtual void send(IRSender& IR, byte powerModeCmd, byte operatingModeCmd, byte fanSpeedCmd, byte temperatureCmd, byte swingVCmd, byte swingHCmd); + virtual void send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd); const char PROGMEM* model(); const char PROGMEM* info(); }; diff --git a/HisenseHeatpumpIR.cpp b/HisenseHeatpumpIR.cpp index 542ceb9..e01a092 100644 --- a/HisenseHeatpumpIR.cpp +++ b/HisenseHeatpumpIR.cpp @@ -10,16 +10,19 @@ HisenseHeatpumpIR::HisenseHeatpumpIR() : HeatpumpIR() } -void HisenseHeatpumpIR::send(IRSender& IR, byte powerModeCmd, byte operatingModeCmd , byte fanSpeedCmd , byte temperatureCmd , byte swingVCmd , byte swingHCmd ) +void HisenseHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd , uint8_t fanSpeedCmd , uint8_t temperatureCmd , uint8_t swingVCmd , uint8_t swingHCmd ) { + (void)swingVCmd; + (void)swingHCmd; + // Sensible defaults for the heat pump mode - byte powerMode = HISENSE_AIRCON1_POWER_ON; - byte operatingMode = HISENSE_AIRCON1_MODE_HEAT; - byte fanSpeed = HISENSE_AIRCON1_FAN_AUTO; - byte temperature = 21; - byte swingV=0; - byte swingH=0; + uint8_t powerMode = HISENSE_AIRCON1_POWER_ON; + uint8_t operatingMode = HISENSE_AIRCON1_MODE_HEAT; + uint8_t fanSpeed = HISENSE_AIRCON1_FAN_AUTO; + uint8_t temperature = 21; + uint8_t swingV=0; + uint8_t swingH=0; if (powerModeCmd == POWER_OFF) { @@ -47,7 +50,7 @@ void HisenseHeatpumpIR::send(IRSender& IR, byte powerModeCmd, byte operatingMode operatingMode = HISENSE_AIRCON1_MODE_FAN; if ( fanSpeedCmd == FAN_AUTO ) { fanSpeedCmd = FAN_1; // Fan speed cannot be 'AUTO' in FAN mode - temperatureCmd = 25; // Fixed temperature FAN mode + temperatureCmd = 25; // Fixed temperature FAN mode } break; } @@ -66,7 +69,7 @@ void HisenseHeatpumpIR::send(IRSender& IR, byte powerModeCmd, byte operatingMode break; case FAN_3: fanSpeed = HISENSE_AIRCON1_FAN3; - break; + break; } if ( temperatureCmd > 17 && temperatureCmd < 33) @@ -79,18 +82,21 @@ void HisenseHeatpumpIR::send(IRSender& IR, byte powerModeCmd, byte operatingMode } // Send the Hisense code -void HisenseHeatpumpIR::sendHisense(IRSender& IR, byte powerMode, byte operatingMode, byte fanSpeed, byte temperature, byte swingV ,byte swingH) +void HisenseHeatpumpIR::sendHisense(IRSender& IR, uint8_t powerMode, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature, uint8_t swingV ,uint8_t swingH) { - byte HisenseTemplate[] = { 0x87, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, // Header byte 0-1 + (void)swingV; + (void)swingH; + + uint8_t HisenseTemplate[] = { 0x87, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, // Header uint8_t 0-1 0x00, 0x00, 0x00, 0x0C, 0x00, 0x00, 0x00 }; // - byte i; + uint8_t i; // Set the Fan speed, On/Off. HisenseTemplate[2] = fanSpeed | powerMode; HisenseTemplate[3] = (((temperature - 18) << 4) | operatingMode ) ; - // Calculate the byte checksum EXOR byte 2 to 12 + // Calculate the uint8_t checksum EXOR uint8_t 2 to 12 HisenseTemplate[13] = HisenseTemplate[2]; for (i=3; i<13; i++) { HisenseTemplate[13]= HisenseTemplate[i] ^ HisenseTemplate[13]; @@ -105,7 +111,7 @@ void HisenseHeatpumpIR::sendHisense(IRSender& IR, byte powerMode, byte operating // Payload header part for (i=0; i<7; i++) { - IR.sendIRByte(HisenseTemplate[i], HISENSE_AIRCON1_BIT_MARK, HISENSE_AIRCON1_ZERO_SPACE, HISENSE_AIRCON1_ONE_SPACE); + IR.sendIRbyte(HisenseTemplate[i], HISENSE_AIRCON1_BIT_MARK, HISENSE_AIRCON1_ZERO_SPACE, HISENSE_AIRCON1_ONE_SPACE); } // Mesage space @@ -114,7 +120,7 @@ void HisenseHeatpumpIR::sendHisense(IRSender& IR, byte powerMode, byte operating // Payload message part for (; i<14; i++) { - IR.sendIRByte(HisenseTemplate[i], HISENSE_AIRCON1_BIT_MARK, HISENSE_AIRCON1_ZERO_SPACE, HISENSE_AIRCON1_ONE_SPACE); + IR.sendIRbyte(HisenseTemplate[i], HISENSE_AIRCON1_BIT_MARK, HISENSE_AIRCON1_ZERO_SPACE, HISENSE_AIRCON1_ONE_SPACE); } // End mark diff --git a/HisenseHeatpumpIR.h b/HisenseHeatpumpIR.h index 4cc2b01..eb2e69c 100644 --- a/HisenseHeatpumpIR.h +++ b/HisenseHeatpumpIR.h @@ -64,10 +64,10 @@ class HisenseHeatpumpIR : public HeatpumpIR { public: HisenseHeatpumpIR(); - void send(IRSender& IR, byte powerModeCmd, byte operatingModeCmd, byte fanSpeedCmd, byte temperatureCmd, byte swingVCmd, byte swingHCmd); + void send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd); private: - void sendHisense(IRSender& IR, byte powerMode, byte operatingMode, byte fanSpeed, byte temperature, byte swingV, byte swingH); + void sendHisense(IRSender& IR, uint8_t powerMode, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature, uint8_t swingV, uint8_t swingH); }; #endif diff --git a/IRSender.cpp b/IRSender.cpp index 8daffe6..fdf8b58 100644 --- a/IRSender.cpp +++ b/IRSender.cpp @@ -6,7 +6,7 @@ // // For PWM on Arduino, see http://playground.arduino.cc/Main/TimerPWMCheatsheet -IRSender::IRSender(byte pin) +IRSender::IRSender(uint8_t pin) { _pin = pin; } @@ -72,8 +72,8 @@ void IRSender::setFrequency(int frequency) } } -// Send a byte (8 bits) over IR -void IRSender::sendIRByte(byte sendByte, int bitMarkLength, int zeroSpaceLength, int oneSpaceLength) +// Send a uint8_t (8 bits) over IR +void IRSender::sendIRbyte(uint8_t sendByte, int bitMarkLength, int zeroSpaceLength, int oneSpaceLength) { for (int i=0; i<8 ; i++) { @@ -93,8 +93,8 @@ void IRSender::sendIRByte(byte sendByte, int bitMarkLength, int zeroSpaceLength, } // The Carrier IR protocol has the bits in a reverse order (compared to the other heatpumps) -// See http://www.nrtm.org/index.php/2013/07/25/reverse-bits-in-a-byte/ -byte IRSender::bitReverse(byte x) +// See http://www.nrtm.org/index.php/2013/07/25/reverse-bits-in-a-uint8_t/ +uint8_t IRSender::bitReverse(uint8_t x) { // 01010101 | 10101010 x = ((x >> 1) & 0x55) | ((x << 1) & 0xaa); diff --git a/IRSender.h b/IRSender.h index b0028ac..c99bb82 100644 --- a/IRSender.h +++ b/IRSender.h @@ -9,15 +9,15 @@ class IRSender { public: - IRSender(byte pin); + IRSender(uint8_t pin); void setFrequency(int frequency); - void sendIRByte(byte sendByte, int bitMarkLength, int zeroSpaceLength, int oneSpaceLength); - byte bitReverse(byte x); + void sendIRbyte(uint8_t sendByte, int bitMarkLength, int zeroSpaceLength, int oneSpaceLength); + uint8_t bitReverse(uint8_t x); void space(int spaceLength); void mark(int markLength); private: - byte _pin; + uint8_t _pin; }; #endif diff --git a/MideaHeatpumpIR.cpp b/MideaHeatpumpIR.cpp index faec8ed..bf58bab 100644 --- a/MideaHeatpumpIR.cpp +++ b/MideaHeatpumpIR.cpp @@ -10,12 +10,15 @@ MideaHeatpumpIR::MideaHeatpumpIR() : HeatpumpIR() } -void MideaHeatpumpIR::send(IRSender& IR, byte powerModeCmd, byte operatingModeCmd, byte fanSpeedCmd, byte temperatureCmd, byte swingVCmd, byte swingHCmd) +void MideaHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd) { + (void)swingVCmd; + (void)swingHCmd; + // Sensible defaults for the heat pump mode - byte operatingMode = MIDEA_AIRCON1_MODE_HEAT; - byte fanSpeed = MIDEA_AIRCON1_FAN_AUTO; - byte temperature = 23; + uint8_t operatingMode = MIDEA_AIRCON1_MODE_HEAT; + uint8_t fanSpeed = MIDEA_AIRCON1_FAN_AUTO; + uint8_t temperature = 23; switch (powerModeCmd) { @@ -45,8 +48,8 @@ void MideaHeatpumpIR::send(IRSender& IR, byte powerModeCmd, byte operatingModeCm break; case MODE_MAINT: // Maintenance mode ('FP' on the remote) is a special mode on Midea - // Also, this is a switch between 'normal' operation and 'maintenance' operation, - // i.e. if already running on maintenance, the heatpump will go back to normal operation + // Also, this is a switch between 'normal' operation and 'maintenance' operation, + // i.e. if already running on maintenance, the heatpump will go back to normal operation operatingMode = MIDEA_AIRCON1_MODE_FP; break; } @@ -76,14 +79,14 @@ void MideaHeatpumpIR::send(IRSender& IR, byte powerModeCmd, byte operatingModeCm } // Send the Midea code -void MideaHeatpumpIR::sendMidea(IRSender& IR, byte operatingMode, byte fanSpeed, byte temperature) +void MideaHeatpumpIR::sendMidea(IRSender& IR, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature) { - byte sendBuffer[3] = { 0x4D, 0x00, 0x00 }; // First byte is always 0x4D + uint8_t sendBuffer[3] = { 0x4D, 0x00, 0x00 }; // First uint8_t is always 0x4D - static const prog_uint8_t temperatures[] PROGMEM = {0, 8, 12, 4, 6, 14, 10, 2, 3, 11, 9, 1, 5, 13 }; + static const uint8_t temperatures[] PROGMEM = {0, 8, 12, 4, 6, 14, 10, 2, 3, 11, 9, 1, 5, 13 }; - static const prog_uint8_t OffMsg[] PROGMEM = {0x4D, 0xDE, 0x07 }; - static const prog_uint8_t FPMsg[] PROGMEM = {0xAD, 0xAF, 0xB5 }; + static const uint8_t OffMsg[] PROGMEM = {0x4D, 0xDE, 0x07 }; + static const uint8_t FPMsg[] PROGMEM = {0xAD, 0xAF, 0xB5 }; if (operatingMode == MIDEA_AIRCON1_MODE_OFF) { @@ -112,7 +115,7 @@ void MideaHeatpumpIR::sendMidea(IRSender& IR, byte operatingMode, byte fanSpeed, } // Send the Midea raw code -void MideaHeatpumpIR::sendMidearaw(IRSender& IR, byte sendBuffer[]) +void MideaHeatpumpIR::sendMidearaw(IRSender& IR, uint8_t sendBuffer[]) { // 40 kHz PWM frequency IR.setFrequency(40); @@ -121,24 +124,24 @@ void MideaHeatpumpIR::sendMidearaw(IRSender& IR, byte sendBuffer[]) IR.mark(MIDEA_AIRCON1_HDR_MARK); IR.space(MIDEA_AIRCON1_HDR_SPACE); - // Six bytes, every second byte is a bitwise not of the previous byte + // Six uint8_ts, every second uint8_t is a bitwise not of the previous uint8_t for (int i=0; i<3; i++) { - IR.sendIRByte(sendBuffer[i], MIDEA_AIRCON1_BIT_MARK, MIDEA_AIRCON1_ZERO_SPACE, MIDEA_AIRCON1_ONE_SPACE); - IR.sendIRByte(~sendBuffer[i], MIDEA_AIRCON1_BIT_MARK, MIDEA_AIRCON1_ZERO_SPACE, MIDEA_AIRCON1_ONE_SPACE); + IR.sendIRbyte(sendBuffer[i], MIDEA_AIRCON1_BIT_MARK, MIDEA_AIRCON1_ZERO_SPACE, MIDEA_AIRCON1_ONE_SPACE); + IR.sendIRbyte(~sendBuffer[i], MIDEA_AIRCON1_BIT_MARK, MIDEA_AIRCON1_ZERO_SPACE, MIDEA_AIRCON1_ONE_SPACE); } // Pause IR.mark(MIDEA_AIRCON1_BIT_MARK); IR.space(MIDEA_AIRCON1_MSG_SPACE); - // Header, two last bytes repeated + // Header, two last uint8_ts repeated IR.mark(MIDEA_AIRCON1_HDR_MARK); IR.space(MIDEA_AIRCON1_HDR_SPACE); - // Six bytes, every second byte is a bitwise not of the previous byte + // Six uint8_ts, every second uint8_t is a bitwise not of the previous uint8_t for (int i=0; i<3; i++) { - IR.sendIRByte(sendBuffer[i], MIDEA_AIRCON1_BIT_MARK, MIDEA_AIRCON1_ZERO_SPACE, MIDEA_AIRCON1_ONE_SPACE); - IR.sendIRByte(~sendBuffer[i], MIDEA_AIRCON1_BIT_MARK, MIDEA_AIRCON1_ZERO_SPACE, MIDEA_AIRCON1_ONE_SPACE); + IR.sendIRbyte(sendBuffer[i], MIDEA_AIRCON1_BIT_MARK, MIDEA_AIRCON1_ZERO_SPACE, MIDEA_AIRCON1_ONE_SPACE); + IR.sendIRbyte(~sendBuffer[i], MIDEA_AIRCON1_BIT_MARK, MIDEA_AIRCON1_ZERO_SPACE, MIDEA_AIRCON1_ONE_SPACE); } // End mark diff --git a/MideaHeatpumpIR.h b/MideaHeatpumpIR.h index d3490fe..20602a3 100644 --- a/MideaHeatpumpIR.h +++ b/MideaHeatpumpIR.h @@ -37,11 +37,11 @@ class MideaHeatpumpIR : public HeatpumpIR { public: MideaHeatpumpIR(); - void send(IRSender& IR, byte powerModeCmd, byte operatingModeCmd, byte fanSpeedCmd, byte temperatureCmd, byte swingVCmd, byte swingHCmd); + void send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd); private: - void sendMidea(IRSender& IR, byte operatingMode, byte fanSpeed, byte temperature); - void sendMidearaw(IRSender& IR, byte sendBuffer[]); + void sendMidea(IRSender& IR, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature); + void sendMidearaw(IRSender& IR, uint8_t sendBuffer[]); }; #endif diff --git a/MitsubishiHeatpumpIR.cpp b/MitsubishiHeatpumpIR.cpp index fb0cbb4..7823e57 100644 --- a/MitsubishiHeatpumpIR.cpp +++ b/MitsubishiHeatpumpIR.cpp @@ -31,16 +31,16 @@ MitsubishiFEHeatpumpIR::MitsubishiFEHeatpumpIR() : MitsubishiHeatpumpIR() } -void MitsubishiHeatpumpIR::send(IRSender& IR, byte powerModeCmd, byte operatingModeCmd, byte fanSpeedCmd, byte temperatureCmd, byte swingVCmd, byte swingHCmd) +void MitsubishiHeatpumpIR::send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd) { // Sensible defaults for the heat pump mode - byte powerMode = MITSUBISHI_AIRCON1_MODE_ON; - byte operatingMode = MITSUBISHI_AIRCON1_MODE_HEAT; - byte fanSpeed = MITSUBISHI_AIRCON1_FAN_AUTO; - byte temperature = 23; - byte swingV = MITSUBISHI_AIRCON1_VS_AUTO; - byte swingH = MITSUBISHI_AIRCON1_HS_SWING; + uint8_t powerMode = MITSUBISHI_AIRCON1_MODE_ON; + uint8_t operatingMode = MITSUBISHI_AIRCON1_MODE_HEAT; + uint8_t fanSpeed = MITSUBISHI_AIRCON1_FAN_AUTO; + uint8_t temperature = 23; + uint8_t swingV = MITSUBISHI_AIRCON1_VS_AUTO; + uint8_t swingH = MITSUBISHI_AIRCON1_HS_SWING; if (powerModeCmd == 0) { @@ -155,12 +155,12 @@ void MitsubishiHeatpumpIR::send(IRSender& IR, byte powerModeCmd, byte operatingM sendMitsubishi(IR, powerMode, operatingMode, fanSpeed, temperature, swingV, swingH); } -void MitsubishiHeatpumpIR::sendMitsubishi(IRSender& IR, byte powerMode, byte operatingMode, byte fanSpeed, byte temperature, byte swingV, byte swingH) +void MitsubishiHeatpumpIR::sendMitsubishi(IRSender& IR, uint8_t powerMode, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature, uint8_t swingV, uint8_t swingH) { - byte MitsubishiTemplate[] = { 0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x48, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00 }; + uint8_t MitsubishiTemplate[] = { 0x23, 0xCB, 0x26, 0x01, 0x00, 0x20, 0x48, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x10, 0x40, 0x00, 0x00 }; // 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 - byte checksum = 0x00; + uint8_t checksum = 0x00; // Set the operatingmode on the template message MitsubishiTemplate[5] = powerMode; @@ -197,8 +197,8 @@ void MitsubishiHeatpumpIR::sendMitsubishi(IRSender& IR, byte powerMode, byte ope IR.space(MITSUBISHI_AIRCON1_HDR_SPACE); // Data - for (int i=0; i>= 1; + Samsunguint8_t >>= 1; } } @@ -139,7 +142,7 @@ void SamsungHeatpumpIR::sendSamsung(IRSender& IR, byte powerMode, byte operating // Payload header part for (int i=0; i<7; i++) { - IR.sendIRByte(SamsungTemplate[i], SAMSUNG_AIRCON1_BIT_MARK, SAMSUNG_AIRCON1_ZERO_SPACE, SAMSUNG_AIRCON1_ONE_SPACE); + IR.sendIRbyte(SamsungTemplate[i], SAMSUNG_AIRCON1_BIT_MARK, SAMSUNG_AIRCON1_ZERO_SPACE, SAMSUNG_AIRCON1_ONE_SPACE); } // Pause + new header @@ -151,7 +154,7 @@ void SamsungHeatpumpIR::sendSamsung(IRSender& IR, byte powerMode, byte operating // Payload power message part for (int i=7; i<14; i++) { - IR.sendIRByte(SamsungTemplate[i], SAMSUNG_AIRCON1_BIT_MARK, SAMSUNG_AIRCON1_ZERO_SPACE, SAMSUNG_AIRCON1_ONE_SPACE); + IR.sendIRbyte(SamsungTemplate[i], SAMSUNG_AIRCON1_BIT_MARK, SAMSUNG_AIRCON1_ZERO_SPACE, SAMSUNG_AIRCON1_ONE_SPACE); } // Pause + new header @@ -163,7 +166,7 @@ void SamsungHeatpumpIR::sendSamsung(IRSender& IR, byte powerMode, byte operating // Payload data message part for (int i=14; i<21; i++) { - IR.sendIRByte(SamsungTemplate[i], SAMSUNG_AIRCON1_BIT_MARK, SAMSUNG_AIRCON1_ZERO_SPACE, SAMSUNG_AIRCON1_ONE_SPACE); + IR.sendIRbyte(SamsungTemplate[i], SAMSUNG_AIRCON1_BIT_MARK, SAMSUNG_AIRCON1_ZERO_SPACE, SAMSUNG_AIRCON1_ONE_SPACE); } // End mark diff --git a/SamsungHeatpumpIR.h b/SamsungHeatpumpIR.h index aab79fd..c33e661 100644 --- a/SamsungHeatpumpIR.h +++ b/SamsungHeatpumpIR.h @@ -33,10 +33,10 @@ class SamsungHeatpumpIR : public HeatpumpIR { public: SamsungHeatpumpIR(); - void send(IRSender& IR, byte powerModeCmd, byte operatingModeCmd, byte fanSpeedCmd, byte temperatureCmd, byte swingVCmd, byte swingHCmd); + void send(IRSender& IR, uint8_t powerModeCmd, uint8_t operatingModeCmd, uint8_t fanSpeedCmd, uint8_t temperatureCmd, uint8_t swingVCmd, uint8_t swingHCmd); private: - void sendSamsung(IRSender& IR, byte powerMode, byte operatingMode, byte fanSpeed, byte temperature, byte swingV); + void sendSamsung(IRSender& IR, uint8_t powerMode, uint8_t operatingMode, uint8_t fanSpeed, uint8_t temperature, uint8_t swingV); }; #endif diff --git a/examples/HisenseTest/HisenseTest.ino b/examples/HisenseTest/HisenseTest.ino index b4a5481..3215480 100644 --- a/examples/HisenseTest/HisenseTest.ino +++ b/examples/HisenseTest/HisenseTest.ino @@ -1,47 +1,40 @@ +#include #include IRSender irSender(3); // IR led on Duemilanove digital pin 3 -HisenseHeatpumpIR *heatpumpIR; +HisenseHeatpumpIR *heatpumpIR; void setup() { - Serial.begin(9600); delay(500); heatpumpIR = new HisenseHeatpumpIR(); Serial.println(F("Starting")); - - - } void loop() { - int i = 0; - prog_char* buf; + const char* buf; - - // Send the same IR command to all supported heatpumps Serial.print(F("Sending IR to ")); // Print the model - buf = (prog_char*)heatpumpIR->model(); + buf = heatpumpIR->model(); // 'model' is a PROGMEM pointer, so need to write a byte at a time while (char modelChar = pgm_read_byte(buf++)) { Serial.print(modelChar); } Serial.print(F(", info: ")); - // Print the info - buf = (prog_char*)heatpumpIR->info(); + // Print the info + buf = heatpumpIR->info(); // 'info' is a PROGMEM pointer, so need to write a byte at a time while (char infoChar = pgm_read_byte(buf++)) { Serial.print(infoChar); } - Serial.println(); + Serial.println(); - heatpumpIR->send(irSender, POWER_ON, MODE_HEAT, FAN_3, 30, VDIR_AUTO, HDIR_AUTO); delay(1500); heatpumpIR->send(irSender, POWER_ON, MODE_DRY, FAN_2, 20, VDIR_AUTO, HDIR_AUTO); @@ -50,7 +43,6 @@ void loop() delay(1500); heatpumpIR->send(irSender, POWER_ON, MODE_COOL, FAN_1, 18, VDIR_AUTO, HDIR_AUTO); delay(2500); - heatpumpIR->send(irSender, POWER_OFF, NULL, NULL, NULL, NULL, NULL); + heatpumpIR->send(irSender, POWER_OFF, MODE_COOL, FAN_1, 18, VDIR_AUTO, HDIR_AUTO); delay(1500); - -} +} \ No newline at end of file diff --git a/examples/MideaRelayControl/MideaRelayControl.ino b/examples/MideaRelayControl/MideaRelayControl.ino index efd577d..80a5bdb 100644 --- a/examples/MideaRelayControl/MideaRelayControl.ino +++ b/examples/MideaRelayControl/MideaRelayControl.ino @@ -1,3 +1,4 @@ +#include #include // https://github.com/ToniA/arduino-heatpumpir #include // http://playground.arduino.cc/Code/Button @@ -34,8 +35,8 @@ const byte heatpumpOff = 0; const byte heatpumpNormal = 1; const byte heatpumpMaintenance = 2; -Button relay1 = Button(11,PULLUP); // Heatpump ON-OFF state -Button relay2 = Button(12,PULLUP); // FP mode (maintenance heating at 8 degrees C) ON-OFF state +Button relay1 = Button(11, INPUT_PULLUP); // Heatpump ON-OFF state +Button relay2 = Button(12, INPUT_PULLUP); // FP mode (maintenance heating at 8 degrees C) ON-OFF state IRSender irSender(9); // IR led on Duemilanove digital pin 9 diff --git a/examples/MySensorsNode/MySensorsNode.ino b/examples/MySensorsNode/MySensorsNode.ino index 366e79c..a5b303b 100644 --- a/examples/MySensorsNode/MySensorsNode.ino +++ b/examples/MySensorsNode/MySensorsNode.ino @@ -1,3 +1,5 @@ +#include + // HeatpumpIR libraries #include #include @@ -85,8 +87,7 @@ void loop() // Handle incoming messages from the MySensors Gateway void incomingMessage(const MyMessage &message) { - const char *irData; - long irCommand; + const char *irData; // V_IR type message if (message.type==V_IR_SEND) { @@ -156,10 +157,10 @@ libraries\HeatpumpIR\HeatpumpIR.h for the constants byte fan = (irCommand & 0x00000F00) >> 8; byte temp = (irCommand & 0x000000FF); - prog_char* buf; + const char* buf; Serial.print(F("Model: ")); - buf = (prog_char*)heatpumpIR[model]->model(); + buf = heatpumpIR[model]->model(); // 'model' is a PROGMEM pointer, so need to write a byte at a time while (char modelChar = pgm_read_byte(buf++)) { @@ -188,14 +189,14 @@ libraries\HeatpumpIR\HeatpumpIR.h for the constants if (model == 0) { Serial.println(F("Scheduling timer cancellation on Panasonic CKP heatpump...")); - panasonicCKPTimer = timer.after(120000, panasonicCancelTimer, (void *)NULL); // Called after 2 minutes + panasonicCKPTimer = timer.after(120000, panasonicCancelTimer); // Called after 2 minutes } } } // Cancel the timer on the Panasonic CKP heatpump -void panasonicCancelTimer(void *context) +void panasonicCancelTimer() { PanasonicCKPHeatpumpIR *panasonicCKPHeatpumpIR = new PanasonicCKPHeatpumpIR(); diff --git a/examples/simple/simple.ino b/examples/simple/simple.ino index b5d0808..229c936 100644 --- a/examples/simple/simple.ino +++ b/examples/simple/simple.ino @@ -1,3 +1,5 @@ +#include + #include #include #include @@ -25,13 +27,13 @@ void setup() void loop() { int i = 0; - prog_char* buf; + const char* buf; do { // Send the same IR command to all supported heatpumps Serial.print(F("Sending IR to ")); - buf = (prog_char*)heatpumpIR[i]->model(); + buf = heatpumpIR[i]->model(); // 'model' is a PROGMEM pointer, so need to write a byte at a time while (char modelChar = pgm_read_byte(buf++)) { @@ -39,7 +41,7 @@ void loop() } Serial.print(F(", info: ")); - buf = (prog_char*)heatpumpIR[i]->info(); + buf = heatpumpIR[i]->info(); // 'info' is a PROGMEM pointer, so need to write a byte at a time while (char infoChar = pgm_read_byte(buf++)) {