improved calibration header detection

"gray" area doesn't work very well with the calibration detection code
pull/6/head
Ahmet Inan 2014-12-13 20:31:06 +01:00
rodzic 8d36624e94
commit 3d6f915b75
2 zmienionych plików z 12 dodań i 6 usunięć

Wyświetl plik

@ -20,7 +20,7 @@ limitations under the License.
#include "constants.rsh"
#include "state.rsh"
static int calibration_detected(float dat_value, int dat_active, int cnt_active, int cnt_quantized)
static int calibration_detected(float dat_value, float dat_amp, float cnt_amp, int cnt_quantized)
{
static int progress, countdown;
static int leader_counter, break_counter;
@ -28,6 +28,9 @@ static int calibration_detected(float dat_value, int dat_active, int cnt_active,
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_pulse = !leader_level && leader_counter >= leader_length;
@ -98,9 +101,9 @@ static int calibration_detected(float dat_value, int dat_active, int cnt_active,
return -1;
}
static int calibration_detector(float dat_value, int dat_active, int cnt_active, int cnt_quantized)
static int calibration_detector(float dat_value, float dat_amp, float cnt_amp, int cnt_quantized)
{
switch (calibration_detected(dat_value, dat_active, cnt_active, cnt_quantized)) {
switch (calibration_detected(dat_value, dat_amp, cnt_amp, cnt_quantized)) {
case 0x88:
return mode_robot36;
case 0x0c:

Wyświetl plik

@ -177,8 +177,11 @@ void decode(int samples) {
float cnt_value = demodulate(&cnt_fmd, cnt_baseband);
float dat_value = demodulate(&dat_fmd, dat_baseband);
int cnt_active = cabs(dat_baseband) < 4.0f * cabs(cnt_baseband);
int dat_active = cabs(cnt_baseband) < 4.0f * cabs(dat_baseband);
float cnt_amp = cabs(cnt_baseband);
float dat_amp = cabs(dat_baseband);
int cnt_active = dat_amp < 4.0f * cnt_amp;
int dat_active = cnt_amp < 4.0f * dat_amp;
uchar cnt_level = save_cnt && cnt_active ? 127.5f - 127.5f * cnt_value : 0.0f;
uchar dat_level = save_dat && dat_active ? 127.5f + 127.5f * dat_value : 0.0f;
value_buffer[hpos + prev_hpos] = cnt_level | dat_level;
@ -191,7 +194,7 @@ void decode(int samples) {
sync_counter = sync_level ? sync_counter + 1 : 0;
if (*current_mode != mode_debug) {
int detected_mode = calibration_detector(dat_value, dat_active, cnt_active, cnt_quantized);
int detected_mode = calibration_detector(dat_value, dat_amp, cnt_amp, cnt_quantized);
if (detected_mode >= 0) {
free_running = 0;
reset_buffer();