Clean up pulse demod
This commit is contained in:
parent
013b82aaab
commit
21b779edf9
1 changed files with 10 additions and 11 deletions
|
@ -82,7 +82,7 @@ int pulse_demod_pcm(const pulse_data_t *pulses, r_device *device)
|
|||
}
|
||||
// Debug printout
|
||||
if (!device->decode_fn || (device->verbose && events > 0)) {
|
||||
fprintf(stderr, "pulse_demod_pcm(): %s \n", device->name);
|
||||
fprintf(stderr, "%s(): %s \n", __func__, device->name);
|
||||
bitbuffer_print(&bits);
|
||||
}
|
||||
bitbuffer_clear(&bits);
|
||||
|
@ -148,7 +148,7 @@ int pulse_demod_ppm(const pulse_data_t *pulses, r_device *device)
|
|||
}
|
||||
// Debug printout
|
||||
if (!device->decode_fn || (device->verbose && events > 0)) {
|
||||
fprintf(stderr, "pulse_demod_ppm(): %s \n", device->name);
|
||||
fprintf(stderr, "%s(): %s \n", __func__, device->name);
|
||||
bitbuffer_print(&bits);
|
||||
}
|
||||
bitbuffer_clear(&bits);
|
||||
|
@ -243,7 +243,7 @@ int pulse_demod_pwm(const pulse_data_t *pulses, r_device *device)
|
|||
}
|
||||
// Debug printout
|
||||
if (!device->decode_fn || (device->verbose && events > 0)) {
|
||||
fprintf(stderr, "pulse_demod_pwm(): %s \n", device->name);
|
||||
fprintf(stderr, "%s(): %s \n", __func__, device->name);
|
||||
bitbuffer_print(&bits);
|
||||
}
|
||||
bitbuffer_clear(&bits);
|
||||
|
@ -267,13 +267,12 @@ int pulse_demod_manchester_zerobit(const pulse_data_t *pulses, r_device *device)
|
|||
bitbuffer_add_bit(&bits, 0);
|
||||
|
||||
for (unsigned n = 0; n < pulses->num_pulses; ++n) {
|
||||
// Falling edge is on end of pulse
|
||||
// The pulse or gap is too long or too short, thus invalid
|
||||
if (device->s_tolerance > 0
|
||||
&& (pulses->pulse[n] < device->s_short_width - device->s_tolerance
|
||||
|| pulses->pulse[n] > device->s_short_width * 2 + device->s_tolerance
|
||||
|| pulses->gap[n] < device->s_short_width - device->s_tolerance
|
||||
|| pulses->gap[n] > device->s_short_width * 2 + device->s_tolerance)) {
|
||||
// The pulse or gap is too long or too short, thus invalid
|
||||
if (pulses->pulse[n] > device->s_short_width * 1.5
|
||||
&& pulses->pulse[n] <= device->s_short_width * 2 + device->s_tolerance) {
|
||||
// Long last pulse means with the gap this is a [1]10 transition, add a one
|
||||
|
@ -283,6 +282,7 @@ int pulse_demod_manchester_zerobit(const pulse_data_t *pulses, r_device *device)
|
|||
bitbuffer_add_bit(&bits, 0); // Prepare for new message with hardcoded 0
|
||||
time_since_last = 0;
|
||||
}
|
||||
// Falling edge is on end of pulse
|
||||
else if (pulses->pulse[n] + time_since_last > (device->s_short_width * 1.5)) {
|
||||
// Last bit was recorded more than short_width*1.5 samples ago
|
||||
// so this pulse start must be a data edge (falling data edge means bit = 1)
|
||||
|
@ -297,13 +297,12 @@ int pulse_demod_manchester_zerobit(const pulse_data_t *pulses, r_device *device)
|
|||
if (((n == pulses->num_pulses - 1) // No more pulses? (FSK)
|
||||
|| (pulses->gap[n] > device->s_reset_limit)) // Long silence (OOK)
|
||||
&& (bits.num_rows > 0)) { // Only if data has been accumulated
|
||||
int newevents = 0;
|
||||
if (device->decode_fn) {
|
||||
events += account_event(device, device->decode_fn(device, &bits));
|
||||
}
|
||||
// Debug printout
|
||||
if (!device->decode_fn || (device->verbose && events > 0)) {
|
||||
fprintf(stderr, "pulse_demod_manchester_zerobit(): %s \n", device->name);
|
||||
fprintf(stderr, "%s(): %s \n", __func__, device->name);
|
||||
bitbuffer_print(&bits);
|
||||
}
|
||||
bitbuffer_clear(&bits);
|
||||
|
@ -366,7 +365,7 @@ int pulse_demod_dmc(const pulse_data_t *pulses, r_device *device)
|
|||
events += account_event(device, device->decode_fn(device, &bits));
|
||||
}
|
||||
if (!device->decode_fn || (device->verbose && events > 0)) {
|
||||
fprintf(stderr, "pulse_demod_dmc(): %s \n", device->name);
|
||||
fprintf(stderr, "%s(): %s \n", __func__, device->name);
|
||||
bitbuffer_print(&bits);
|
||||
}
|
||||
bitbuffer_clear(&bits);
|
||||
|
@ -418,7 +417,7 @@ int pulse_demod_piwm_raw(const pulse_data_t *pulses, r_device *device)
|
|||
events += account_event(device, device->decode_fn(device, &bits));
|
||||
}
|
||||
if (!device->decode_fn || (device->verbose && events > 0)) {
|
||||
fprintf(stderr, "pulse_demod_piwm_raw(): %s \n", device->name);
|
||||
fprintf(stderr, "%s(): %s \n", __func__, device->name);
|
||||
bitbuffer_print(&bits);
|
||||
}
|
||||
bitbuffer_clear(&bits);
|
||||
|
@ -468,7 +467,7 @@ int pulse_demod_piwm_dc(const pulse_data_t *pulses, r_device *device)
|
|||
events += account_event(device, device->decode_fn(device, &bits));
|
||||
}
|
||||
if (!device->decode_fn || (device->verbose && events > 0)) {
|
||||
fprintf(stderr, "pulse_demod_piwm_dc(): %s \n", device->name);
|
||||
fprintf(stderr, "%s(): %s \n", __func__, device->name);
|
||||
bitbuffer_print(&bits);
|
||||
}
|
||||
bitbuffer_clear(&bits);
|
||||
|
@ -576,7 +575,7 @@ int pulse_demod_string(const char *code, r_device *device)
|
|||
}
|
||||
// Debug printout
|
||||
if (!device->decode_fn || (device->verbose && events > 0)) {
|
||||
fprintf(stderr, "pulse_demod_pcm(): %s \n", device->name);
|
||||
fprintf(stderr, "%s(): %s \n", __func__, device->name);
|
||||
bitbuffer_print(&bits);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue