From 168665f8646036fe12a723b78b009fada1bb3a03 Mon Sep 17 00:00:00 2001 From: Ahmet Inan Date: Tue, 3 Feb 2015 14:51:07 +0100 Subject: [PATCH] enlarge grey area for cnt, removed from calibration detection we are now better at dealing with spurious sync pulses caused by noise, so allow an attenuated control channel. --- app/src/main/rs/calibration_detector.rsh | 13 +++++-------- app/src/main/rs/decoder.rs | 4 ++-- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/src/main/rs/calibration_detector.rsh b/app/src/main/rs/calibration_detector.rsh index 02d87ab..c51ccdc 100644 --- a/app/src/main/rs/calibration_detector.rsh +++ b/app/src/main/rs/calibration_detector.rsh @@ -20,7 +20,7 @@ limitations under the License. #include "constants.rsh" #include "state.rsh" -static int calibration_detected(float dat_value, float dat_amp, float cnt_amp, int cnt_quantized) +static int calibration_detected(float dat_value, int cnt_quantized) { static int progress, countdown; static int leader_counter, break_counter; @@ -28,11 +28,8 @@ static int calibration_detected(float dat_value, float dat_amp, float cnt_amp, i progress = countdown ? progress : 0; countdown -= !!countdown; - int cnt_active = dat_amp < cnt_amp; - int dat_active = !cnt_active; - int leader_quantized = round(filter(&leader_lowpass, dat_value)); - int leader_level = dat_active && leader_quantized == 0; + int leader_level = leader_quantized == 0; int leader_pulse = !leader_level && leader_counter >= leader_length; leader_counter = leader_level ? leader_counter + 1 : 0; if (leader_pulse) { @@ -47,7 +44,7 @@ static int calibration_detected(float dat_value, float dat_amp, float cnt_amp, i } } - int break_level = cnt_active && cnt_quantized == 0; + int break_level = cnt_quantized == 0; int break_pulse = !break_level && break_counter >= break_length; break_counter = break_level ? break_counter + 1 : 0; if (break_pulse) { @@ -95,9 +92,9 @@ static int calibration_detected(float dat_value, float dat_amp, float cnt_amp, i return -1; } -static int calibration_detector(float dat_value, float dat_amp, float cnt_amp, int cnt_quantized) +static int calibration_detector(float dat_value, int cnt_quantized) { - switch (calibration_detected(dat_value, dat_amp, cnt_amp, cnt_quantized)) { + switch (calibration_detected(dat_value, cnt_quantized)) { case 0x88: return mode_robot36; case 0x0c: diff --git a/app/src/main/rs/decoder.rs b/app/src/main/rs/decoder.rs index 739d536..a2feb69 100644 --- a/app/src/main/rs/decoder.rs +++ b/app/src/main/rs/decoder.rs @@ -266,7 +266,7 @@ void decode(int samples) { float cnt_amp = cabs(cnt_baseband); float dat_amp = cabs(dat_baseband); - int cnt_active = dat_amp < 1.1f * cnt_amp; + int cnt_active = dat_amp < 2.0f * cnt_amp; int dat_active = cnt_amp < 2.0f * dat_amp; uchar cnt_level = debug_mode && cnt_active ? 127.5f - 127.5f * cnt_value : 0.0f; uchar dat_level = dat_active ? 127.5f + 127.5f * dat_value : 0.0f; @@ -285,7 +285,7 @@ void decode(int samples) { static int reset_on_first_sync; if (automatic_mode_detection) { - int detected_mode = calibration_detector(dat_value, dat_amp, cnt_amp, cnt_quantized); + int detected_mode = calibration_detector(dat_value, cnt_quantized); if (detected_mode >= 0) { reset_on_first_sync = 1; free_running = 0;