Update commands.cpp
This commit is contained in:
parent
5a17fbfb57
commit
ec7912f319
|
|
@ -2,50 +2,34 @@
|
|||
|
||||
namespace esphome {
|
||||
namespace panasonic_heatpump {
|
||||
const uint8_t PanasonicCommand::InitialRequest[INIT_REQUEST_SIZE] = {
|
||||
0x31, 0x05, 0x10, 0x01, 0x00, 0x00, 0x00, 0xB9};
|
||||
const uint8_t PanasonicCommand::InitialRequest[INIT_REQUEST_SIZE] = {0x31, 0x05, 0x10, 0x01, 0x00, 0x00, 0x00, 0xB9};
|
||||
const uint8_t PanasonicCommand::InitialResponse[INIT_RESPONSE_SIZE] = {
|
||||
0x31, 0x30, 0x01, 0x10, 0x1E, 0x6C, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x3C};
|
||||
0x31, 0x30, 0x01, 0x10, 0x1E, 0x6C, 0xC8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C};
|
||||
const uint8_t PanasonicCommand::PollingMessage[DATA_MESSAGE_SIZE] = {
|
||||
0x71, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x12};
|
||||
0x71, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12};
|
||||
const uint8_t PanasonicCommand::PollingExtraMessage[DATA_MESSAGE_SIZE] = {
|
||||
0x71, 0x6C, 0x01, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x01};
|
||||
0x71, 0x6C, 0x01, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01};
|
||||
const uint8_t PanasonicCommand::CommandMessage[DATA_MESSAGE_SIZE] = {
|
||||
0xF1, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x92};
|
||||
0xF1, 0x6C, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
||||
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x92};
|
||||
|
||||
uint8_t PanasonicCommand::calcChecksum(std::vector<uint8_t>& data,
|
||||
int length) {
|
||||
uint8_t PanasonicCommand::calcChecksum(std::vector<uint8_t>& data, int length) {
|
||||
uint8_t checksum = 0;
|
||||
for (int i = 0; i < length; i++) {
|
||||
checksum += data[i];
|
||||
|
|
@ -54,9 +38,13 @@ uint8_t PanasonicCommand::calcChecksum(std::vector<uint8_t>& data,
|
|||
return checksum;
|
||||
}
|
||||
|
||||
uint8_t PanasonicCommand::setMultiply2(size_t input) { return input * 0b10; }
|
||||
uint8_t PanasonicCommand::setMultiply2(size_t input) {
|
||||
return input * 0b10;
|
||||
}
|
||||
|
||||
uint8_t PanasonicCommand::setMultiply4(size_t input) { return input * 0b100; }
|
||||
uint8_t PanasonicCommand::setMultiply4(size_t input) {
|
||||
return input * 0b100;
|
||||
}
|
||||
|
||||
uint8_t PanasonicCommand::setPlus1Multiply4(size_t input) {
|
||||
return (input + 1) * 0b100;
|
||||
|
|
@ -74,7 +62,9 @@ uint8_t PanasonicCommand::setPlus1Multiply64(size_t input) {
|
|||
return (input + 1) * 0b1000000;
|
||||
}
|
||||
|
||||
uint8_t PanasonicCommand::setPlus1(size_t input) { return input + 1; }
|
||||
uint8_t PanasonicCommand::setPlus1(size_t input) {
|
||||
return input + 1;
|
||||
}
|
||||
|
||||
uint8_t PanasonicCommand::setPlus128(size_t input) {
|
||||
return input + 0b10000000;
|
||||
|
|
@ -82,30 +72,30 @@ uint8_t PanasonicCommand::setPlus128(size_t input) {
|
|||
|
||||
uint8_t PanasonicCommand::setOperationMode(size_t input) {
|
||||
switch (input) {
|
||||
case 0:
|
||||
return 0b100001; // 0x21 = tank
|
||||
case 1:
|
||||
return 0b010010; // 0x12 = heat
|
||||
case 2:
|
||||
return 0b100010; // 0x22 = heat+tank
|
||||
case 3:
|
||||
return 0b010011; // 0x13 = cool
|
||||
case 4:
|
||||
return 0b100011; // 0x23 = cool+tank
|
||||
case 5:
|
||||
return 0b011000; // 0x18 = auto
|
||||
case 6:
|
||||
return 0b101000; // 0x28 = auto+tank
|
||||
case 7:
|
||||
return 0b011001; // 0x19 = auto-heat
|
||||
case 8:
|
||||
return 0b101001; // 0x29 = auto-heat+tank
|
||||
case 9:
|
||||
return 0b011010; // 0x1A = auto-cool
|
||||
case 10:
|
||||
return 0b101010; // 0x2A = auto-cool+tank
|
||||
default:
|
||||
return 0; // do nothing
|
||||
case 0:
|
||||
return 0b100001; // 0x21 = tank
|
||||
case 1:
|
||||
return 0b010010; // 0x12 = heat
|
||||
case 2:
|
||||
return 0b100010; // 0x22 = heat+tank
|
||||
case 3:
|
||||
return 0b010011; // 0x13 = cool
|
||||
case 4:
|
||||
return 0b100011; // 0x23 = cool+tank
|
||||
case 5:
|
||||
return 0b011000; // 0x18 = auto
|
||||
case 6:
|
||||
return 0b101000; // 0x28 = auto+tank
|
||||
case 7:
|
||||
return 0b011001; // 0x19 = auto-heat
|
||||
case 8:
|
||||
return 0b101001; // 0x29 = auto-heat+tank
|
||||
case 9:
|
||||
return 0b011010; // 0x1A = auto-cool
|
||||
case 10:
|
||||
return 0b101010; // 0x2A = auto-cool+tank
|
||||
default:
|
||||
return 0; // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -131,25 +121,24 @@ uint8_t PanasonicCommand::temp2hex(float temp) {
|
|||
return hextemp;
|
||||
}
|
||||
|
||||
uint8_t PanasonicCommand::setByte6(uint8_t byte6, int val, int base,
|
||||
int bit) {
|
||||
uint8_t PanasonicCommand::setByte6(uint8_t byte6, int val, int base, int bit) {
|
||||
return (byte6 & ~(base << bit)) | (val << bit);
|
||||
}
|
||||
|
||||
uint8_t PanasonicCommand::setDemandControl(size_t input) {
|
||||
switch (input) {
|
||||
case 0:
|
||||
return 0xEB;
|
||||
case 1:
|
||||
return 0xB8;
|
||||
case 2:
|
||||
return 0x85;
|
||||
case 3:
|
||||
return 0x52;
|
||||
case 4:
|
||||
return 0x2B;
|
||||
default:
|
||||
return 0; // do nothing
|
||||
case 0:
|
||||
return 0xEB;
|
||||
case 1:
|
||||
return 0xB8;
|
||||
case 2:
|
||||
return 0x85;
|
||||
case 3:
|
||||
return 0x52;
|
||||
case 4:
|
||||
return 0x2B;
|
||||
default:
|
||||
return 0; // do nothing
|
||||
}
|
||||
}
|
||||
} // namespace panasonic_heatpump
|
||||
|
|
|
|||
Loading…
Reference in New Issue