2019-07-21 15:01:43 +01:00
|
|
|
/*
|
|
|
|
Node MCU/ESP8266 Sketch to emulate Argo Ulisse 13 DCI remote
|
|
|
|
Controls Argo Ulisse 13 DCI A/C
|
|
|
|
Copyright 2017 Schmolders
|
|
|
|
Copyright 2019 crankyoldgit
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "ir_Argo.h"
|
|
|
|
#include <algorithm>
|
2019-11-02 11:21:18 +00:00
|
|
|
#include <cstring>
|
2019-07-21 15:01:43 +01:00
|
|
|
#ifndef UNIT_TEST
|
|
|
|
#include <Arduino.h>
|
|
|
|
#endif // UNIT_TEST
|
|
|
|
#include "IRremoteESP8266.h"
|
2019-11-02 11:21:18 +00:00
|
|
|
#include "IRtext.h"
|
2019-07-21 15:01:43 +01:00
|
|
|
#include "IRutils.h"
|
|
|
|
|
|
|
|
// Constants
|
|
|
|
// using SPACE modulation. MARK is always const 400u
|
|
|
|
const uint16_t kArgoHdrMark = 6400;
|
|
|
|
const uint16_t kArgoHdrSpace = 3300;
|
|
|
|
const uint16_t kArgoBitMark = 400;
|
|
|
|
const uint16_t kArgoOneSpace = 2200;
|
|
|
|
const uint16_t kArgoZeroSpace = 900;
|
|
|
|
const uint32_t kArgoGap = kDefaultMessageGap; // Made up value. Complete guess.
|
|
|
|
|
|
|
|
using irutils::addBoolToString;
|
|
|
|
using irutils::addIntToString;
|
|
|
|
using irutils::addLabeledString;
|
|
|
|
using irutils::addModeToString;
|
|
|
|
using irutils::addTempToString;
|
2019-11-02 11:21:18 +00:00
|
|
|
using irutils::setBit;
|
|
|
|
using irutils::setBits;
|
2019-07-21 15:01:43 +01:00
|
|
|
|
|
|
|
#if SEND_ARGO
|
|
|
|
// Send an Argo A/C message.
|
|
|
|
//
|
|
|
|
// Args:
|
|
|
|
// data: An array of kArgoStateLength bytes containing the IR command.
|
|
|
|
//
|
2020-04-09 09:25:50 +01:00
|
|
|
// Status: BETA / Probably works.
|
2019-07-21 15:01:43 +01:00
|
|
|
|
|
|
|
void IRsend::sendArgo(const unsigned char data[], const uint16_t nbytes,
|
|
|
|
const uint16_t repeat) {
|
|
|
|
// Check if we have enough bytes to send a proper message.
|
|
|
|
if (nbytes < kArgoStateLength) return;
|
|
|
|
// TODO(kaschmo): validate
|
|
|
|
sendGeneric(kArgoHdrMark, kArgoHdrSpace, kArgoBitMark, kArgoOneSpace,
|
|
|
|
kArgoBitMark, kArgoZeroSpace, 0, 0, // No Footer.
|
|
|
|
data, nbytes, 38, false, repeat, kDutyDefault);
|
|
|
|
}
|
|
|
|
#endif // SEND_ARGO
|
|
|
|
|
|
|
|
IRArgoAC::IRArgoAC(const uint16_t pin, const bool inverted,
|
|
|
|
const bool use_modulation)
|
|
|
|
: _irsend(pin, inverted, use_modulation) { this->stateReset(); }
|
|
|
|
|
|
|
|
void IRArgoAC::begin(void) { _irsend.begin(); }
|
|
|
|
|
|
|
|
#if SEND_ARGO
|
|
|
|
void IRArgoAC::send(const uint16_t repeat) {
|
2019-11-02 11:21:18 +00:00
|
|
|
_irsend.sendArgo(getRaw(), kArgoStateLength, repeat);
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
#endif // SEND_ARGO
|
|
|
|
|
|
|
|
uint8_t IRArgoAC::calcChecksum(const uint8_t state[], const uint16_t length) {
|
|
|
|
// Corresponds to byte 11 being constant 0b01
|
|
|
|
// Only add up bytes to 9. byte 10 is 0b01 constant anyway.
|
|
|
|
// Assume that argo array is MSB first (left)
|
|
|
|
return sumBytes(state, length - 2, 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IRArgoAC::validChecksum(const uint8_t state[], const uint16_t length) {
|
|
|
|
return ((state[length - 2] >> 2) + (state[length - 1] << 6)) ==
|
|
|
|
IRArgoAC::calcChecksum(state, length);
|
|
|
|
}
|
|
|
|
|
|
|
|
void IRArgoAC::checksum(void) {
|
|
|
|
uint8_t sum = IRArgoAC::calcChecksum(argo, kArgoStateLength);
|
|
|
|
// Append sum to end of array
|
|
|
|
// Set const part of checksum bit 10
|
|
|
|
argo[10] = 0b00000010;
|
|
|
|
argo[10] += sum << 2; // Shift up 2 bits and append to byte 10
|
|
|
|
argo[11] = sum >> 6; // Shift down 6 bits and add in two LSBs of bit 11
|
|
|
|
}
|
|
|
|
|
|
|
|
void IRArgoAC::stateReset(void) {
|
|
|
|
for (uint8_t i = 0; i < kArgoStateLength; i++) argo[i] = 0x0;
|
|
|
|
|
|
|
|
// Argo Message. Store MSB left.
|
|
|
|
// Default message:
|
|
|
|
argo[0] = 0b10101100; // LSB first (as sent) 0b00110101; //const preamble
|
|
|
|
argo[1] = 0b11110101; // LSB first: 0b10101111; //const preamble
|
|
|
|
// Keep payload 2-9 at zero
|
|
|
|
argo[10] = 0b00000010; // Const 01, checksum 6bit
|
|
|
|
argo[11] = 0b00000000; // Checksum 2bit
|
|
|
|
|
|
|
|
this->off();
|
|
|
|
this->setTemp(20);
|
|
|
|
this->setRoomTemp(25);
|
|
|
|
this->setMode(kArgoAuto);
|
|
|
|
this->setFan(kArgoFanAuto);
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t* IRArgoAC::getRaw(void) {
|
|
|
|
this->checksum(); // Ensure correct bit array before returning
|
|
|
|
return argo;
|
|
|
|
}
|
|
|
|
|
|
|
|
void IRArgoAC::setRaw(const uint8_t state[]) {
|
2019-11-02 11:21:18 +00:00
|
|
|
memcpy(argo, state, kArgoStateLength);
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
|
2019-11-02 11:21:18 +00:00
|
|
|
void IRArgoAC::on(void) { setPower(true); }
|
2019-07-21 15:01:43 +01:00
|
|
|
|
2019-11-02 11:21:18 +00:00
|
|
|
void IRArgoAC::off(void) { setPower(false); }
|
2019-07-21 15:01:43 +01:00
|
|
|
|
|
|
|
void IRArgoAC::setPower(const bool on) {
|
2019-11-02 11:21:18 +00:00
|
|
|
setBit(&argo[9], kArgoPowerBitOffset, on);
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
|
2019-11-02 11:21:18 +00:00
|
|
|
bool IRArgoAC::getPower(void) { return GETBIT8(argo[9], kArgoPowerBitOffset); }
|
2019-07-21 15:01:43 +01:00
|
|
|
|
|
|
|
void IRArgoAC::setMax(const bool on) {
|
2019-11-02 11:21:18 +00:00
|
|
|
setBit(&argo[9], kArgoMaxBitOffset, on);
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
|
2019-11-02 11:21:18 +00:00
|
|
|
bool IRArgoAC::getMax(void) { return GETBIT8(argo[9], kArgoMaxBitOffset); }
|
2019-07-21 15:01:43 +01:00
|
|
|
|
|
|
|
// Set the temp in deg C
|
|
|
|
// Sending 0 equals +4
|
|
|
|
void IRArgoAC::setTemp(const uint8_t degrees) {
|
|
|
|
uint8_t temp = std::max(kArgoMinTemp, degrees);
|
2019-11-02 11:21:18 +00:00
|
|
|
// delta 4 degrees. "If I want 12 degrees, I need to send 8"
|
|
|
|
temp = std::min(kArgoMaxTemp, temp) - kArgoTempDelta;
|
2019-07-21 15:01:43 +01:00
|
|
|
// Settemp = Bit 6,7 of byte 2, and bit 0-2 of byte 3
|
|
|
|
// mask out bits
|
|
|
|
// argo[13] & 0x00000100; // mask out ON/OFF Bit
|
2019-11-02 11:21:18 +00:00
|
|
|
setBits(&argo[2], kArgoTempLowOffset, kArgoTempLowSize, temp);
|
|
|
|
setBits(&argo[3], kArgoTempHighOffset, kArgoTempHighSize,
|
|
|
|
temp >> kArgoTempLowSize);
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t IRArgoAC::getTemp(void) {
|
2019-11-02 11:21:18 +00:00
|
|
|
return ((GETBITS8(argo[3], kArgoTempHighOffset,
|
|
|
|
kArgoTempHighSize) << kArgoTempLowSize) |
|
|
|
|
GETBITS8(argo[2], kArgoTempLowOffset, kArgoTempLowSize)) +
|
|
|
|
kArgoTempDelta;
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Set the speed of the fan
|
|
|
|
void IRArgoAC::setFan(const uint8_t fan) {
|
2019-11-02 11:21:18 +00:00
|
|
|
setBits(&argo[3], kArgoFanOffset, kArgoFanSize, std::min(fan, kArgoFan3));
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
|
2019-11-02 11:21:18 +00:00
|
|
|
uint8_t IRArgoAC::getFan(void) {
|
|
|
|
return GETBITS8(argo[3], kArgoFanOffset, kArgoFanSize);
|
|
|
|
}
|
2019-07-21 15:01:43 +01:00
|
|
|
|
|
|
|
void IRArgoAC::setFlap(const uint8_t flap) {
|
|
|
|
flap_mode = flap;
|
|
|
|
// TODO(kaschmo): set correct bits for flap mode
|
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t IRArgoAC::getFlap(void) { return flap_mode; }
|
|
|
|
|
|
|
|
uint8_t IRArgoAC::getMode(void) {
|
2019-11-02 11:21:18 +00:00
|
|
|
return GETBITS8(argo[2], kArgoModeOffset, kArgoModeSize);
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void IRArgoAC::setMode(const uint8_t mode) {
|
|
|
|
switch (mode) {
|
|
|
|
case kArgoCool:
|
|
|
|
case kArgoDry:
|
|
|
|
case kArgoAuto:
|
|
|
|
case kArgoOff:
|
|
|
|
case kArgoHeat:
|
|
|
|
case kArgoHeatAuto:
|
2019-11-02 11:21:18 +00:00
|
|
|
setBits(&argo[2], kArgoModeOffset, kArgoModeSize, mode);
|
2019-07-21 15:01:43 +01:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
this->setMode(kArgoAuto);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void IRArgoAC::setNight(const bool on) {
|
2019-11-02 11:21:18 +00:00
|
|
|
setBit(&argo[9], kArgoNightBitOffset, on);
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
|
2019-11-02 11:21:18 +00:00
|
|
|
bool IRArgoAC::getNight(void) { return GETBIT8(argo[9], kArgoNightBitOffset); }
|
2019-07-21 15:01:43 +01:00
|
|
|
|
|
|
|
void IRArgoAC::setiFeel(const bool on) {
|
2019-11-02 11:21:18 +00:00
|
|
|
setBit(&argo[9], kArgoIFeelBitOffset, on);
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
|
2019-11-02 11:21:18 +00:00
|
|
|
bool IRArgoAC::getiFeel(void) { return GETBIT8(argo[9], kArgoIFeelBitOffset); }
|
2019-07-21 15:01:43 +01:00
|
|
|
|
|
|
|
void IRArgoAC::setTime(void) {
|
|
|
|
// TODO(kaschmo): use function call from checksum to set time first
|
|
|
|
}
|
|
|
|
|
|
|
|
void IRArgoAC::setRoomTemp(const uint8_t degrees) {
|
|
|
|
uint8_t temp = std::min(degrees, kArgoMaxRoomTemp);
|
2019-11-02 11:21:18 +00:00
|
|
|
temp = std::max(temp, kArgoTempDelta) - kArgoTempDelta;
|
|
|
|
setBits(&argo[3], kArgoRoomTempLowOffset, kArgoRoomTempLowSize, temp);
|
|
|
|
setBits(&argo[4], kArgoRoomTempHighOffset, kArgoRoomTempHighSize,
|
|
|
|
temp >> kArgoRoomTempLowSize);
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
uint8_t IRArgoAC::getRoomTemp(void) {
|
2019-11-02 11:21:18 +00:00
|
|
|
return ((GETBITS8(argo[4], kArgoRoomTempHighOffset,
|
|
|
|
kArgoRoomTempHighSize) << kArgoRoomTempLowSize) |
|
|
|
|
GETBITS8(argo[3], kArgoRoomTempLowOffset, kArgoRoomTempLowSize)) +
|
|
|
|
kArgoTempDelta;
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// Convert a standard A/C mode into its native mode.
|
|
|
|
uint8_t IRArgoAC::convertMode(const stdAc::opmode_t mode) {
|
|
|
|
switch (mode) {
|
|
|
|
case stdAc::opmode_t::kCool:
|
|
|
|
return kArgoCool;
|
|
|
|
case stdAc::opmode_t::kHeat:
|
|
|
|
return kArgoHeat;
|
|
|
|
case stdAc::opmode_t::kDry:
|
|
|
|
return kArgoDry;
|
|
|
|
case stdAc::opmode_t::kOff:
|
|
|
|
return kArgoOff;
|
|
|
|
// No fan mode.
|
|
|
|
default:
|
|
|
|
return kArgoAuto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert a standard A/C Fan speed into its native fan speed.
|
|
|
|
uint8_t IRArgoAC::convertFan(const stdAc::fanspeed_t speed) {
|
|
|
|
switch (speed) {
|
|
|
|
case stdAc::fanspeed_t::kMin:
|
|
|
|
case stdAc::fanspeed_t::kLow:
|
|
|
|
return kArgoFan1;
|
|
|
|
case stdAc::fanspeed_t::kMedium:
|
|
|
|
return kArgoFan2;
|
|
|
|
case stdAc::fanspeed_t::kHigh:
|
|
|
|
case stdAc::fanspeed_t::kMax:
|
|
|
|
return kArgoFan3;
|
|
|
|
default:
|
|
|
|
return kArgoFanAuto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert a standard A/C Fan speed into its native fan speed.
|
|
|
|
uint8_t IRArgoAC::convertSwingV(const stdAc::swingv_t position) {
|
|
|
|
switch (position) {
|
|
|
|
case stdAc::swingv_t::kHighest:
|
|
|
|
return kArgoFlapFull;
|
|
|
|
case stdAc::swingv_t::kHigh:
|
|
|
|
return kArgoFlap5;
|
|
|
|
case stdAc::swingv_t::kMiddle:
|
|
|
|
return kArgoFlap4;
|
|
|
|
case stdAc::swingv_t::kLow:
|
|
|
|
return kArgoFlap3;
|
|
|
|
case stdAc::swingv_t::kLowest:
|
|
|
|
return kArgoFlap1;
|
|
|
|
default:
|
|
|
|
return kArgoFlapAuto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert a native mode to it's common equivalent.
|
|
|
|
stdAc::opmode_t IRArgoAC::toCommonMode(const uint8_t mode) {
|
|
|
|
switch (mode) {
|
|
|
|
case kArgoCool: return stdAc::opmode_t::kCool;
|
|
|
|
case kArgoHeat: return stdAc::opmode_t::kHeat;
|
|
|
|
case kArgoDry: return stdAc::opmode_t::kDry;
|
|
|
|
// No fan mode.
|
|
|
|
default: return stdAc::opmode_t::kAuto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert a native fan speed to it's common equivalent.
|
|
|
|
stdAc::fanspeed_t IRArgoAC::toCommonFanSpeed(const uint8_t speed) {
|
|
|
|
switch (speed) {
|
|
|
|
case kArgoFan3: return stdAc::fanspeed_t::kMax;
|
|
|
|
case kArgoFan2: return stdAc::fanspeed_t::kMedium;
|
|
|
|
case kArgoFan1: return stdAc::fanspeed_t::kMin;
|
|
|
|
default: return stdAc::fanspeed_t::kAuto;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert the A/C state to it's common equivalent.
|
|
|
|
stdAc::state_t IRArgoAC::toCommon(void) {
|
|
|
|
stdAc::state_t result;
|
|
|
|
result.protocol = decode_type_t::ARGO;
|
|
|
|
result.power = this->getPower();
|
|
|
|
result.mode = this->toCommonMode(this->getMode());
|
|
|
|
result.celsius = true;
|
|
|
|
result.degrees = this->getTemp();
|
|
|
|
result.fanspeed = this->toCommonFanSpeed(this->getFan());
|
|
|
|
result.turbo = this->getMax();
|
|
|
|
result.sleep = this->getNight() ? 0 : -1;
|
|
|
|
// Not supported.
|
|
|
|
result.model = -1; // Not supported.
|
|
|
|
result.swingv = stdAc::swingv_t::kOff;
|
|
|
|
result.swingh = stdAc::swingh_t::kOff;
|
|
|
|
result.light = false;
|
|
|
|
result.filter = false;
|
|
|
|
result.econo = false;
|
|
|
|
result.quiet = false;
|
|
|
|
result.clean = false;
|
|
|
|
result.beep = false;
|
|
|
|
result.clock = -1;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Convert the internal state into a human readable string.
|
2019-11-02 11:21:18 +00:00
|
|
|
String IRArgoAC::toString(void) {
|
2019-07-21 15:01:43 +01:00
|
|
|
String result = "";
|
|
|
|
result.reserve(100); // Reserve some heap for the string to reduce fragging.
|
2019-11-02 11:21:18 +00:00
|
|
|
result += addBoolToString(getPower(), kPowerStr, false);
|
|
|
|
result += addIntToString(getMode(), kModeStr);
|
|
|
|
result += kSpaceLBraceStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
switch (getMode()) {
|
|
|
|
case kArgoAuto:
|
2019-11-02 11:21:18 +00:00
|
|
|
result += kAutoStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
break;
|
|
|
|
case kArgoCool:
|
2019-11-02 11:21:18 +00:00
|
|
|
result += kCoolStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
break;
|
|
|
|
case kArgoHeat:
|
2019-11-02 11:21:18 +00:00
|
|
|
result += kHeatStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
break;
|
|
|
|
case kArgoDry:
|
2019-11-02 11:21:18 +00:00
|
|
|
result += kDryStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
break;
|
|
|
|
case kArgoHeatAuto:
|
2019-11-25 20:43:39 +00:00
|
|
|
result += kHeatStr;
|
|
|
|
result += ' ';
|
|
|
|
result += kAutoStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
break;
|
|
|
|
case kArgoOff:
|
2019-11-02 11:21:18 +00:00
|
|
|
result += kOffStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
break;
|
|
|
|
default:
|
2019-11-02 11:21:18 +00:00
|
|
|
result += kUnknownStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
2019-11-02 11:21:18 +00:00
|
|
|
result += ')';
|
|
|
|
result += addIntToString(getFan(), kFanStr);
|
|
|
|
result += kSpaceLBraceStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
switch (getFan()) {
|
|
|
|
case kArgoFanAuto:
|
2019-11-02 11:21:18 +00:00
|
|
|
result += kAutoStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
break;
|
|
|
|
case kArgoFan3:
|
2019-11-02 11:21:18 +00:00
|
|
|
result += kMaxStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
break;
|
|
|
|
case kArgoFan1:
|
2019-11-02 11:21:18 +00:00
|
|
|
result += kMinStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
break;
|
|
|
|
case kArgoFan2:
|
2019-11-02 11:21:18 +00:00
|
|
|
result += kMedStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
break;
|
|
|
|
default:
|
2019-11-02 11:21:18 +00:00
|
|
|
result += kUnknownStr;
|
2019-07-21 15:01:43 +01:00
|
|
|
}
|
2019-11-02 11:21:18 +00:00
|
|
|
result += ')';
|
2019-07-21 15:01:43 +01:00
|
|
|
result += addTempToString(getTemp());
|
2019-11-25 20:43:39 +00:00
|
|
|
result += kCommaSpaceStr;
|
|
|
|
result += kRoomStr;
|
|
|
|
result += ' ';
|
2019-07-21 15:01:43 +01:00
|
|
|
result += addTempToString(getRoomTemp(), true, false);
|
2019-11-02 11:21:18 +00:00
|
|
|
result += addBoolToString(getMax(), kMaxStr);
|
|
|
|
result += addBoolToString(getiFeel(), kIFeelStr);
|
|
|
|
result += addBoolToString(getNight(), kNightStr);
|
2019-07-21 15:01:43 +01:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
#if DECODE_ARGO
|
|
|
|
// Decode the supplied Argo message.
|
|
|
|
//
|
|
|
|
// Args:
|
|
|
|
// results: Ptr to the data to decode and where to store the decode result.
|
2020-02-29 12:51:16 +00:00
|
|
|
// offset: The starting index to use when attempting to decode the raw data.
|
|
|
|
// Typically/Defaults to kStartOffset.
|
2019-07-21 15:01:43 +01:00
|
|
|
// nbits: The number of data bits to expect. Typically kArgoBits.
|
|
|
|
// strict: Flag indicating if we should perform strict matching.
|
|
|
|
// Returns:
|
|
|
|
// boolean: True if it can decode it, false if it can't.
|
|
|
|
//
|
2020-04-09 09:25:50 +01:00
|
|
|
// Status: BETA / Probably works.
|
2019-07-21 15:01:43 +01:00
|
|
|
//
|
|
|
|
// Note:
|
|
|
|
// This decoder is based soley off sendArgo(). We have no actual captures
|
|
|
|
// to test this against. If you have one of these units, please let us know.
|
2020-02-29 12:51:16 +00:00
|
|
|
bool IRrecv::decodeArgo(decode_results *results, uint16_t offset,
|
|
|
|
const uint16_t nbits,
|
2019-07-21 15:01:43 +01:00
|
|
|
const bool strict) {
|
|
|
|
if (strict && nbits != kArgoBits) return false;
|
|
|
|
|
|
|
|
// Match Header + Data
|
|
|
|
if (!matchGeneric(results->rawbuf + offset, results->state,
|
|
|
|
results->rawlen - offset, nbits,
|
|
|
|
kArgoHdrMark, kArgoHdrSpace,
|
|
|
|
kArgoBitMark, kArgoOneSpace,
|
|
|
|
kArgoBitMark, kArgoZeroSpace,
|
|
|
|
0, 0, // Footer (None, allegedly. This seems very wrong.)
|
2019-08-30 19:41:01 +01:00
|
|
|
true, _tolerance, 0, false)) return false;
|
2019-07-21 15:01:43 +01:00
|
|
|
|
|
|
|
// Compliance
|
|
|
|
// Verify we got a valid checksum.
|
|
|
|
if (strict && !IRArgoAC::validChecksum(results->state)) return false;
|
|
|
|
// Success
|
|
|
|
results->decode_type = decode_type_t::ARGO;
|
|
|
|
results->bits = nbits;
|
|
|
|
// No need to record the state as we stored it as we decoded it.
|
|
|
|
// As we use result->state, we don't record value, address, or command as it
|
|
|
|
// is a union data type.
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
#endif // DECODE_ARGO
|