8 IrWidgetAggregating::IrWidgetAggregating(
size_t captureLength,
13 :
IrWidget(captureLength, pullup, markExcess, beginningTimeout, endingTimeout) {
26 beginningTimeout, endingTimeout);
39 uint8_t tccr0b = TCCR0B;
44 register uint16_t aggThreshold =
period * 2;
45 register uint8_t icesn_val = _BV(
CAT2(ICES,
CAP_TIM));
56 register uint8_t tifr;
57 register uint8_t calShiftM1 = 1;
58 register uint8_t calCount = 1 << (calShiftM1 + 1);
59 register uint8_t aggCount = 0;
61 register uint16_t val;
62 register uint16_t prevVal = 0;
64 register uint32_t aggVal = 0;
65 register uint32_t diffVal;
75 if (millis() >= timeForBeginTimeout) {
82 TCCR0B &= ~(_BV(CS02) | _BV(CS01) | _BV(CS00));
112 *pCapDat = packTimeVal(aggVal);
128 diffVal = ((val - prevVal) & 0xffff) | ((uint32_t) ovlCnt << 16);
132 if (diffVal < aggThreshold) {
140 if (aggCount == calCount) {
141 aggThreshold = aggVal >> calShiftM1;
143 calCount = calCount << 1;
147 *pCapDat = packTimeVal(aggVal);
150 *pCapDat = packTimeVal(diffVal);
165 period = aggThreshold >> 1;
uint16_t milliseconds_t
Type for durations in milli seconds.
boolean timeouted
True if last receive ended with a timeout.
uint16_t frequency_t
Type for modulation frequency in Hz.
milliseconds_t beginningTimeout