MCPcopy Create free account
hub / github.com/Arduino-IRremote/Arduino-IRremote / matchTicks

Function matchTicks

src/IRReceive.hpp:1267–1291  ·  view source on GitHub ↗

* Match function WITHOUT compensating for marks exceeded or spaces shortened by demodulator hardware * Match is true, if signal value is bigger/equal 75% and less/equal 125% of aMatchValueMicros. * @return true, if values match */

Source from the content-addressed store, hash-verified

1265 * @return true, if values match
1266 */
1267bool matchTicks(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros) {
1268 uint16_t tMeasuredMicros = (aMeasuredTicks * MICROS_PER_TICK);
1269 uint16_t tMatchValueMicrosQuarter = aMatchValueMicros / 4;
1270
1271 TRACE_PRINT(F("Testing (actual vs desired): "));
1272 TRACE_PRINT(tMeasuredMicros);
1273 TRACE_PRINT(F("us vs "));
1274 TRACE_PRINT(aMatchValueMicros);
1275 TRACE_PRINT(F("us: "));
1276 TRACE_PRINT(tMatchValueMicrosQuarter * 3); // rounded value because we divide first
1277 TRACE_PRINT(F(" <= "));
1278 TRACE_PRINT(aMeasuredTicks * MICROS_PER_TICK);
1279 TRACE_PRINT(F(" <= "));
1280 TRACE_PRINT(tMatchValueMicrosQuarter * 5);
1281
1282 bool passed = (tMeasuredMicros >= (tMatchValueMicrosQuarter * 3) && tMeasuredMicros <= (tMatchValueMicrosQuarter * 5));
1283#if defined(LOCAL_TRACE)
1284 if (passed) {
1285 Serial.println(F(" => passed"));
1286 } else {
1287 Serial.println(F(" => FAILED"));
1288 }
1289#endif
1290 return passed;
1291}
1292
1293bool matchTicksWithGreaterRange(uint16_t aMeasuredTicks, uint16_t aMatchValueMicros) {
1294 uint16_t tMeasuredMicros = (aMeasuredTicks * MICROS_PER_TICK);

Callers 3

MATCHFunction · 0.85
matchMarkFunction · 0.85
matchSpaceFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected