Skip to content
This repository has been archived by the owner on Dec 2, 2023. It is now read-only.

Commit

Permalink
Merge branch 'patch-1' of git://github.com/ElectricRCAircraftGuy/Ardu…
Browse files Browse the repository at this point in the history
…ino-IRremote into ElectricRCAircraftGuy-patch-1

merging Arduino-IRremote#258
  • Loading branch information
z3t0 committed Feb 21, 2016
2 parents bbc3697 + a4b6db2 commit ac109b1
Showing 1 changed file with 40 additions and 23 deletions.
63 changes: 40 additions & 23 deletions IRremote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,54 +41,71 @@
//
int MATCH (int measured, int desired)
{
DBG_PRINT("Testing: ");
DBG_PRINT(F("Testing: "));
DBG_PRINT(TICKS_LOW(desired), DEC);
DBG_PRINT(" <= ");
DBG_PRINT(F(" <= "));
DBG_PRINT(measured, DEC);
DBG_PRINT(" <= ");
DBG_PRINTLN(TICKS_HIGH(desired), DEC);
DBG_PRINT(F(" <= "));
DBG_PRINT(TICKS_HIGH(desired), DEC);

return ((measured >= TICKS_LOW(desired)) && (measured <= TICKS_HIGH(desired)));
bool passed = ((measured >= TICKS_LOW(desired)) && (measured <= TICKS_HIGH(desired)));
if (passed)
DBG_PRINTLN(F("?; passed"));
else
DBG_PRINTLN(F("?; FAILED"));
return passed;
}

//+========================================================
// Due to sensor lag, when received, Marks tend to be 100us too long
//
int MATCH_MARK (int measured_ticks, int desired_us)
{
DBG_PRINT("Testing mark ");
DBG_PRINT(F("Testing mark (actual vs desired): "));
DBG_PRINT(measured_ticks * USECPERTICK, DEC);
DBG_PRINT(" vs ");
DBG_PRINT(F("us vs "));
DBG_PRINT(desired_us, DEC);
DBG_PRINT("us");
DBG_PRINT(": ");
DBG_PRINT(TICKS_LOW(desired_us + MARK_EXCESS), DEC);
DBG_PRINT(" <= ");
DBG_PRINT(measured_ticks, DEC);
DBG_PRINT(" <= ");
DBG_PRINTLN(TICKS_HIGH(desired_us + MARK_EXCESS), DEC);
DBG_PRINT(TICKS_LOW(desired_us + MARK_EXCESS) * USECPERTICK, DEC);
DBG_PRINT(F(" <= "));
DBG_PRINT(measured_ticks * USECPERTICK, DEC);
DBG_PRINT(F(" <= "));
DBG_PRINT(TICKS_HIGH(desired_us + MARK_EXCESS) * USECPERTICK, DEC);

return ((measured_ticks >= TICKS_LOW (desired_us + MARK_EXCESS))
&& (measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS)));
bool passed = ((measured_ticks >= TICKS_LOW (desired_us + MARK_EXCESS))
&& (measured_ticks <= TICKS_HIGH(desired_us + MARK_EXCESS)));
if (passed)
DBG_PRINTLN(F("?; passed"));
else
DBG_PRINTLN(F("?; FAILED"));
return passed;
}

//+========================================================
// Due to sensor lag, when received, Spaces tend to be 100us too short
//
int MATCH_SPACE (int measured_ticks, int desired_us)
{
DBG_PRINT("Testing space ");
DBG_PRINT(F("Testing space (actual vs desired): "));
DBG_PRINT(measured_ticks * USECPERTICK, DEC);
DBG_PRINT(" vs ");
DBG_PRINT(F("us vs "));
DBG_PRINT(desired_us, DEC);
DBG_PRINT("us");
DBG_PRINT(": ");
DBG_PRINT(TICKS_LOW(desired_us - MARK_EXCESS), DEC);
DBG_PRINT(" <= ");
DBG_PRINT(measured_ticks, DEC);
DBG_PRINT(" <= ");
DBG_PRINTLN(TICKS_HIGH(desired_us - MARK_EXCESS), DEC);
DBG_PRINT(TICKS_LOW(desired_us - MARK_EXCESS) * USECPERTICK, DEC);
DBG_PRINT(F(" <= "));
DBG_PRINT(measured_ticks * USECPERTICK, DEC);
DBG_PRINT(F(" <= "));
DBG_PRINT(TICKS_HIGH(desired_us - MARK_EXCESS) * USECPERTICK, DEC);

return ((measured_ticks >= TICKS_LOW (desired_us - MARK_EXCESS))
&& (measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS)));
bool passed = ((measured_ticks >= TICKS_LOW (desired_us - MARK_EXCESS))
&& (measured_ticks <= TICKS_HIGH(desired_us - MARK_EXCESS)));
if (passed)
DBG_PRINTLN(F("?; passed"));
else
DBG_PRINTLN(F("?; FAILED"));
return passed;
}

//+=============================================================================
Expand Down

0 comments on commit ac109b1

Please sign in to comment.