Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Goodweather: Adjust timings & minor fixes. #924

Merged
merged 1 commit into from
Sep 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions src/ir_Goodweather.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ IRGoodweatherAc::IRGoodweatherAc(const uint16_t pin, const bool inverted,
const bool use_modulation)
: _irsend(pin, inverted, use_modulation) { stateReset(); }

void IRGoodweatherAc::stateReset(void) {
}
void IRGoodweatherAc::stateReset(void) { remote = kGoodweatherStateInit; }

void IRGoodweatherAc::begin(void) { _irsend.begin(); }

Expand Down Expand Up @@ -419,7 +418,8 @@ bool IRrecv::decodeGoodweather(decode_results* results,
data_result = matchData(&(results->rawbuf[offset]), 8,
kGoodweatherBitMark, kGoodweatherOneSpace,
kGoodweatherBitMark, kGoodweatherZeroSpace,
_tolerance, kMarkExcess, false);
_tolerance + kGoodweatherExtraTolerance,
kMarkExcess, false);
if (data_result.success == false) return false;
DPRINTLN("DEBUG: Normal byte read okay.");
offset += data_result.used;
Expand All @@ -428,7 +428,8 @@ bool IRrecv::decodeGoodweather(decode_results* results,
data_result = matchData(&(results->rawbuf[offset]), 8,
kGoodweatherBitMark, kGoodweatherOneSpace,
kGoodweatherBitMark, kGoodweatherZeroSpace,
_tolerance, kMarkExcess, false);
_tolerance + kGoodweatherExtraTolerance,
kMarkExcess, false);
if (data_result.success == false) return false;
DPRINTLN("DEBUG: Inverted byte read okay.");
offset += data_result.used;
Expand All @@ -442,10 +443,12 @@ bool IRrecv::decodeGoodweather(decode_results* results,
}

// Footer.
if (!matchMark(results->rawbuf[offset++], kGoodweatherBitMark)) return false;
if (!matchMark(results->rawbuf[offset++], kGoodweatherBitMark,
_tolerance + kGoodweatherExtraTolerance)) return false;
if (!matchSpace(results->rawbuf[offset++], kGoodweatherHdrSpace))
return false;
if (!matchMark(results->rawbuf[offset++], kGoodweatherBitMark)) return false;
if (!matchMark(results->rawbuf[offset++], kGoodweatherBitMark,
_tolerance + kGoodweatherExtraTolerance)) return false;
if (offset <= results->rawlen &&
!matchAtLeast(results->rawbuf[offset], kGoodweatherHdrSpace))
return false;
Expand Down
18 changes: 13 additions & 5 deletions src/ir_Goodweather.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@
// Constants

// Timing
const uint16_t kGoodweatherBitMark = 640;
const uint16_t kGoodweatherBitMark = 580;
const uint16_t kGoodweatherOneSpace = 580;
const uint16_t kGoodweatherZeroSpace = 1600;
const uint16_t kGoodweatherHdrMark = 6800;
const uint16_t kGoodweatherHdrSpace = 6800;
const uint16_t kGoodweatherZeroSpace = 1860;
const uint16_t kGoodweatherHdrMark = 6820;
const uint16_t kGoodweatherHdrSpace = 6820;
const uint8_t kGoodweatherExtraTolerance = 12; // +12% extra

// Masks
const uint8_t kGoodweatherBitLight = 8;
Expand All @@ -45,19 +46,24 @@ const uint8_t kGoodweatherBitPower = kGoodweatherBitSleep + 1; // 25
const uint64_t kGoodweatherPowerMask = 0x1ULL << kGoodweatherBitPower;
const uint8_t kGoodweatherBitSwing = kGoodweatherBitPower + 1; // 26
const uint64_t kGoodweatherSwingMask = 0x3ULL << kGoodweatherBitSwing;
const uint8_t kGoodweatherBitFan = kGoodweatherBitSwing + 3; // 29
const uint8_t kGoodweatherBitAirFlow = kGoodweatherBitSwing + 2; // 28
const uint64_t kGoodweatherAirFlowMask = 0x1ULL << kGoodweatherBitAirFlow;
const uint8_t kGoodweatherBitFan = kGoodweatherBitAirFlow + 1; // 29
const uint64_t kGoodweatherFanMask = 0x3ULL << kGoodweatherBitFan;
const uint8_t kGoodweatherBitTemp = kGoodweatherBitFan + 3; // 32
const uint64_t kGoodweatherTempMask = 0xFULL << kGoodweatherBitTemp;
const uint8_t kGoodweatherBitMode = kGoodweatherBitTemp + 5; // 37
const uint64_t kGoodweatherModeMask = 0x7ULL << kGoodweatherBitMode;
const uint8_t kGoodweatherBitEOF = kGoodweatherBitMode + 3; // 40
const uint64_t kGoodweatherEOFMask = 0xFFULL << kGoodweatherBitEOF;

// Modes
const uint8_t kGoodweatherAuto = 0b000;
const uint8_t kGoodweatherCool = 0b001;
const uint8_t kGoodweatherDry = 0b010;
const uint8_t kGoodweatherFan = 0b011;
const uint8_t kGoodweatherHeat = 0b100;
// Swing
const uint8_t kGoodweatherSwingFast = 0b00;
const uint8_t kGoodweatherSwingSlow = 0b01;
const uint8_t kGoodweatherSwingOff = 0b10;
Expand All @@ -82,6 +88,8 @@ const uint8_t kGoodweatherCmdHold = 0x08;
const uint8_t kGoodweatherCmdSleep = 0x09;
const uint8_t kGoodweatherCmdTurbo = 0x0A;
const uint8_t kGoodweatherCmdLight = 0x0B;
// PAD EOF
const uint64_t kGoodweatherStateInit = 0xD50000000000;


// Classes
Expand Down
28 changes: 14 additions & 14 deletions test/ir_Goodweather_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,20 @@ TEST(TestSendGoodweather, SendDataOnly) {
irsend.sendGoodweather(0x0);
EXPECT_EQ(
"f38000d50"
"m6800s6800"
"m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600"
"m640s580m640s580m640s580m640s580m640s580m640s580m640s580m640s580"
"m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600"
"m640s580m640s580m640s580m640s580m640s580m640s580m640s580m640s580"
"m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600"
"m640s580m640s580m640s580m640s580m640s580m640s580m640s580m640s580"
"m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600"
"m640s580m640s580m640s580m640s580m640s580m640s580m640s580m640s580"
"m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600"
"m640s580m640s580m640s580m640s580m640s580m640s580m640s580m640s580"
"m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600m640s1600"
"m640s580m640s580m640s580m640s580m640s580m640s580m640s580m640s580"
"m640s6800m640s100000",
"m6820s6820"
"m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860"
"m580s580m580s580m580s580m580s580m580s580m580s580m580s580m580s580"
"m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860"
"m580s580m580s580m580s580m580s580m580s580m580s580m580s580m580s580"
"m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860"
"m580s580m580s580m580s580m580s580m580s580m580s580m580s580m580s580"
"m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860"
"m580s580m580s580m580s580m580s580m580s580m580s580m580s580m580s580"
"m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860"
"m580s580m580s580m580s580m580s580m580s580m580s580m580s580m580s580"
"m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860m580s1860"
"m580s580m580s580m580s580m580s580m580s580m580s580m580s580m580s580"
"m580s6820m580s100000",
irsend.outputStr());

irsend.reset();
Expand Down