mirror of
https://github.com/merbanan/rtl_433.git
synced 2026-05-24 17:55:13 -04:00
change pulse_detect to use pwm_precise for sync bits
This commit is contained in:
@@ -584,24 +584,24 @@ void pulse_analyzer(pulse_data_t *data, uint32_t samp_rate)
|
||||
device.long_limit = hist_pulses.bins[0].mean; // Bit period equal to pulse length (NRZ)
|
||||
device.reset_limit = hist_pulses.bins[0].mean*1024; // No limit to run of zeros...
|
||||
} else if(hist_pulses.bins_count == 3) {
|
||||
fprintf(stderr, "Pulse Width Modulation with startbit/delimiter\n");
|
||||
device.modulation = OOK_PULSE_PWM_TERNARY;
|
||||
device.short_limit = (hist_pulses.bins[0].mean + hist_pulses.bins[1].mean) / 2; // Set limit between two lowest pulse widths
|
||||
device.long_limit = (hist_pulses.bins[1].mean + hist_pulses.bins[2].mean) / 2; // Set limit between two next lowest pulse widths
|
||||
device.reset_limit = hist_gaps.bins[hist_gaps.bins_count-1].max +1; // Set limit above biggest gap
|
||||
fprintf(stderr, "Pulse Width Modulation with sync/delimiter\n");
|
||||
// Re-sort to find lowest pulse count index (is probably delimiter)
|
||||
histogram_sort_count(&hist_pulses);
|
||||
if (hist_pulses.bins[0].mean < device.short_limit) { device.demod_arg = 0; } // Shortest pulse is delimiter
|
||||
else if (hist_pulses.bins[0].mean < device.long_limit) { device.demod_arg = 1; } // Middle pulse is delimiter
|
||||
else { device.demod_arg = 2; } // Longest pulse is delimiter
|
||||
int p1 = hist_pulses.bins[1].mean;
|
||||
int p2 = hist_pulses.bins[2].mean;
|
||||
device.modulation = OOK_PULSE_PWM_PRECISE;
|
||||
device.short_limit = p1 < p2 ? p1 : p2; // Set to shorter pulse width
|
||||
device.long_limit = p1 < p2 ? p2 : p1; // Set to longer pulse width
|
||||
device.sync_width = hist_pulses.bins[0].mean; // Set to lowest count pulse width
|
||||
device.reset_limit = hist_gaps.bins[hist_gaps.bins_count-1].max +1; // Set limit above biggest gap
|
||||
} else {
|
||||
fprintf(stderr, "No clue...\n");
|
||||
}
|
||||
|
||||
// Demodulate (if detected)
|
||||
if(device.modulation) {
|
||||
fprintf(stderr, "Attempting demodulation... short_limit: %.0f, long_limit: %.0f, reset_limit: %.0f, demod_arg: %u\n",
|
||||
device.short_limit, device.long_limit, device.reset_limit, device.demod_arg);
|
||||
fprintf(stderr, "Attempting demodulation... short_limit: %.0f, long_limit: %.0f, reset_limit: %.0f, sync_width: %.0f\n",
|
||||
device.short_limit, device.long_limit, device.reset_limit, device.sync_width);
|
||||
switch(device.modulation) {
|
||||
case FSK_PULSE_PCM:
|
||||
pulse_demod_pcm(data, &device);
|
||||
@@ -614,9 +614,9 @@ void pulse_analyzer(pulse_data_t *data, uint32_t samp_rate)
|
||||
data->gap[data->num_pulses-1] = device.reset_limit + 1; // Be sure to terminate package
|
||||
pulse_demod_pwm(data, &device);
|
||||
break;
|
||||
case OOK_PULSE_PWM_TERNARY:
|
||||
case OOK_PULSE_PWM_PRECISE:
|
||||
data->gap[data->num_pulses-1] = device.reset_limit + 1; // Be sure to terminate package
|
||||
pulse_demod_pwm_ternary(data, &device);
|
||||
pulse_demod_pwm_precise(data, &device);
|
||||
break;
|
||||
case OOK_PULSE_MANCHESTER_ZEROBIT:
|
||||
data->gap[data->num_pulses-1] = device.reset_limit + 1; // Be sure to terminate package
|
||||
|
||||
Reference in New Issue
Block a user