mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2026-09-18 19:13:58 +00:00
Analyzer
This commit is contained in:
@ -11,25 +11,8 @@ constexpr uint32_t kBitTakts = kBitActiveTakts + kBitPauseTakts;
|
||||
constexpr uint32_t kBitTimeUs = kBitTakts * kCarrierPeriodUs;
|
||||
constexpr uint32_t kToleranceUs = 300U;
|
||||
|
||||
/** Синхронно с IR_config.h: IR_SHORT_LOW_GLITCH_REJECT (1 = включено, как на железе). */
|
||||
#ifndef IRFOX_SHORT_LOW_GLITCH_REJECT
|
||||
#define IRFOX_SHORT_LOW_GLITCH_REJECT 1
|
||||
#endif
|
||||
#ifndef IRFOX_RISE_INCLUSIVE_AROUND
|
||||
#define IRFOX_RISE_INCLUSIVE_AROUND 1
|
||||
#endif
|
||||
#ifndef IRFOX_RISE_GRAY_SINGLE_BIT_FALLBACK
|
||||
#define IRFOX_RISE_GRAY_SINGLE_BIT_FALLBACK 0
|
||||
#endif
|
||||
#ifndef IRFOX_GLITCH_REJECT_PHASE_NUDGE
|
||||
#define IRFOX_GLITCH_REJECT_PHASE_NUDGE 1
|
||||
#endif
|
||||
#ifndef IRFOX_MICRO_GAP_RISE_REJECT
|
||||
#define IRFOX_MICRO_GAP_RISE_REJECT 1
|
||||
#endif
|
||||
#ifndef IRFOX_IN_MARK_DOUBLE_FALL_IGNORE
|
||||
#define IRFOX_IN_MARK_DOUBLE_FALL_IGNORE 0
|
||||
#endif
|
||||
/** Мин. длительность плато (мкс) для потокового анти-глитча в анализаторе; согласовано с IR_INPUT_MIN_PULSE_US. */
|
||||
constexpr uint32_t kMinFilteredPulseUs = 10U;
|
||||
|
||||
constexpr uint8_t kBitPerByte = 8U;
|
||||
constexpr uint8_t kMsgBytes = 1;
|
||||
@ -45,32 +28,31 @@ constexpr uint8_t kDataByteSizeMax =
|
||||
constexpr uint8_t kPreambPulse = 3;
|
||||
constexpr uint8_t kPreambFronts = kPreambPulse * 2U;
|
||||
|
||||
/** Отброс ложного подъёма после микро-LOW в паузе (как расширенный IR_DecoderRaw::tick). */
|
||||
#ifndef IRFOX_SHORT_LOW_GLITCH_REJECT
|
||||
#define IRFOX_SHORT_LOW_GLITCH_REJECT 1
|
||||
#endif
|
||||
#ifndef IRFOX_GLITCH_REJECT_PHASE_NUDGE
|
||||
#define IRFOX_GLITCH_REJECT_PHASE_NUDGE 1
|
||||
#endif
|
||||
#ifndef IRFOX_MICRO_GAP_RISE_REJECT
|
||||
#define IRFOX_MICRO_GAP_RISE_REJECT 1
|
||||
#endif
|
||||
|
||||
inline uint32_t irTimeoutUs(uint32_t riseSyncTimeUs)
|
||||
{
|
||||
const uint32_t riseMax = riseSyncTimeUs + kToleranceUs;
|
||||
return riseMax * (8U + kSyncBits + 1U);
|
||||
}
|
||||
|
||||
/** Как IR_DecoderRaw.h: aroundRise(t) → riseTimeMin < t && t < riseTimeMax (ветка STM32DMA). */
|
||||
inline bool aroundRisePeriod(uint32_t periodUs, uint32_t riseSyncTimeUs)
|
||||
{
|
||||
const uint32_t lo = riseSyncTimeUs > kToleranceUs ? riseSyncTimeUs - kToleranceUs : 0U;
|
||||
const uint32_t hi = riseSyncTimeUs + kToleranceUs;
|
||||
#if IRFOX_RISE_INCLUSIVE_AROUND
|
||||
return lo <= periodUs && periodUs <= hi;
|
||||
#else
|
||||
return lo < periodUs && periodUs < hi;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Синхронно с IR_config.h: IR_RISE_GRAY_SINGLE_BIT_FALLBACK. */
|
||||
inline bool riseGraySingleBitFallback(uint32_t periodUs, uint32_t riseSyncTimeUs)
|
||||
{
|
||||
const uint32_t hi = riseSyncTimeUs + kToleranceUs;
|
||||
const uint32_t twice = riseSyncTimeUs * 2U;
|
||||
return periodUs > hi && periodUs <= twice;
|
||||
}
|
||||
|
||||
/** Синхронно с IR_config.h: IR_GLITCH_REJECT_PHASE_NUDGE. */
|
||||
inline void irfoxGlitchPhaseNudgeUs(double edge_us, uint32_t rise_sync_us, double& prev_rise_us)
|
||||
{
|
||||
#if IRFOX_GLITCH_REJECT_PHASE_NUDGE
|
||||
|
||||
Reference in New Issue
Block a user