Skip to content

Commit

Permalink
Rename pulse_demod to pulse_slicer
Browse files Browse the repository at this point in the history
  • Loading branch information
zuckschwerdt committed Mar 3, 2022
1 parent 8dffa04 commit dd1c970
Show file tree
Hide file tree
Showing 12 changed files with 70 additions and 71 deletions.
30 changes: 15 additions & 15 deletions include/pulse_demod.h → include/pulse_slicer.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/** @file
Pulse demodulation functions.
Pulse slicer functions.
Binary demodulators (PWM/PPM/Manchester/...) using a pulse data structure as input
Binary slicers (PWM/PPM/Manchester/...) using a pulse data structure as input
Copyright (C) 2015 Tommy Vestermark
Expand All @@ -11,8 +11,8 @@
(at your option) any later version.
*/

#ifndef INCLUDE_PULSE_DEMOD_H_
#define INCLUDE_PULSE_DEMOD_H_
#ifndef INCLUDE_PULSE_SLICER_H_
#define INCLUDE_PULSE_SLICER_H_

#include "pulse_detect.h"
#include "r_device.h"
Expand All @@ -35,7 +35,7 @@
/// - reset_limit: Maximum gap size before End Of Message [us].
/// - tolerance: Maximum deviation from nominal widths (optional, default 25%) [us]
/// @return number of events processed
int pulse_demod_pcm(const pulse_data_t *pulses, r_device *device);
int pulse_slicer_pcm(const pulse_data_t *pulses, r_device *device);

/// Demodulate a Pulse Position Modulation signal.
///
Expand All @@ -53,7 +53,7 @@ int pulse_demod_pcm(const pulse_data_t *pulses, r_device *device);
/// - gap_limit: Maximum gap size before new row of bits [us]
/// - tolerance: Maximum deviation from nominal widths (optional, raw if 0) [us]
/// @return number of events processed
int pulse_demod_ppm(const pulse_data_t *pulses, r_device *device);
int pulse_slicer_ppm(const pulse_data_t *pulses, r_device *device);

/// Demodulate a Pulse Width Modulation signal.
///
Expand All @@ -72,7 +72,7 @@ int pulse_demod_ppm(const pulse_data_t *pulses, r_device *device);
/// - sync_width: Nominal width of sync pulse (optional) [us]
/// - tolerance: Maximum deviation from nominal widths (optional, raw if 0) [us]
/// @return number of events processed
int pulse_demod_pwm(const pulse_data_t *pulses, r_device *device);
int pulse_slicer_pwm(const pulse_data_t *pulses, r_device *device);

/// Demodulate a Manchester encoded signal with a hardcoded zerobit in front.
///
Expand All @@ -90,7 +90,7 @@ int pulse_demod_pwm(const pulse_data_t *pulses, r_device *device);
/// - long_width: Not used
/// - reset_limit: Maximum gap size before End Of Message [us].
/// @return number of events processed
int pulse_demod_manchester_zerobit(const pulse_data_t *pulses, r_device *device);
int pulse_slicer_manchester_zerobit(const pulse_data_t *pulses, r_device *device);

/// Demodulate a Differential Manchester Coded signal.
///
Expand All @@ -113,7 +113,7 @@ int pulse_demod_manchester_zerobit(const pulse_data_t *pulses, r_device *device)
/// - reset_limit: Maximum gap size before End Of Message [us].
/// - tolerance: Maximum deviation from nominal widths [us]
/// @return number of events processed
int pulse_demod_dmc(const pulse_data_t *pulses, r_device *device);
int pulse_slicer_dmc(const pulse_data_t *pulses, r_device *device);

/// Demodulate a raw Pulse Interval and Width Modulation signal.
///
Expand All @@ -127,7 +127,7 @@ int pulse_demod_dmc(const pulse_data_t *pulses, r_device *device);
/// - reset_limit: Maximum gap size before End Of Message [us].
/// - tolerance: Maximum deviation from nominal widths [us]
/// @return number of events processed
int pulse_demod_piwm_raw(const pulse_data_t *pulses, r_device *device);
int pulse_slicer_piwm_raw(const pulse_data_t *pulses, r_device *device);

/// Demodulate a differential Pulse Interval and Width Modulation signal.
///
Expand All @@ -141,11 +141,11 @@ int pulse_demod_piwm_raw(const pulse_data_t *pulses, r_device *device);
/// - reset_limit: Maximum gap size before End Of Message [us].
/// - tolerance: Maximum deviation from nominal widths [us]
/// @return number of events processed
int pulse_demod_piwm_dc(const pulse_data_t *pulses, r_device *device);
int pulse_slicer_piwm_dc(const pulse_data_t *pulses, r_device *device);

int pulse_demod_nrzs(const pulse_data_t *pulses, r_device *device);
int pulse_slicer_nrzs(const pulse_data_t *pulses, r_device *device);

int pulse_demod_osv1(const pulse_data_t *pulses, r_device *device);
int pulse_slicer_osv1(const pulse_data_t *pulses, r_device *device);

/// Simulate demodulation using a given signal code string.
///
Expand All @@ -156,6 +156,6 @@ int pulse_demod_osv1(const pulse_data_t *pulses, r_device *device);
/// @param code The pulse sequence to demodulate in text format
/// @param device Device params are disregarded.
/// @return number of events processed
int pulse_demod_string(const char *code, r_device *device);
int pulse_slicer_string(const char *code, r_device *device);

#endif /* INCLUDE_PULSE_DEMOD_H_ */
#endif /* INCLUDE_PULSE_SLICER_H_ */
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ add_library(r_433 STATIC
output_trigger.c
output_udp.c
pulse_analyzer.c
pulse_demod.c
pulse_detect.c
pulse_detect_fsk.c
pulse_slicer.c
r_api.c
r_util.c
raw_output.c
Expand Down
2 changes: 1 addition & 1 deletion src/devices/infactory.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ Observed On-Off-Key (OOK) data pattern:
- syncPost after dataPtr has a '0' pulse length of ca. 16000us
This analysis is the reason for the new r_device definitions below.
NB: pulse_demod_ppm does not use .gap_limit if .tolerance is set.
NB: pulse_slicer_ppm does not use .gap_limit if .tolerance is set.
*/

r_device infactory = {
Expand Down
4 changes: 2 additions & 2 deletions src/devices/maverick_et73x.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ r_device maverick_et73x = {
.short_width = 230,
.long_width = 0, //not used
.reset_limit = 4000,
//.reset_limit = 6000, // if pulse_demod_manchester_zerobit implements gap_limit
//.gap_limit = 1000, // if pulse_demod_manchester_zerobit implements gap_limit
//.reset_limit = 6000, // if pulse_slicer_manchester_zerobit implements gap_limit
//.gap_limit = 1000, // if pulse_slicer_manchester_zerobit implements gap_limit
.decode_fn = &maverick_et73x_callback,
.fields = output_fields,
};
2 changes: 1 addition & 1 deletion src/devices/new_template.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ static char *output_fields[] = {
*
* The function used to turn the received signal into bits.
* See:
* - pulse_demod.h for descriptions
* - pulse_slicer.h for descriptions
* - r_device.h for the list of defined names
*
* This device is disabled and hidden, it can not be enabled.
Expand Down
12 changes: 6 additions & 6 deletions src/pulse_analyzer.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
*/

#include "pulse_analyzer.h"
#include "pulse_demod.h"
#include "pulse_slicer.h"
#include "util.h"
#include <stdio.h>
#include <stdlib.h>
Expand Down Expand Up @@ -433,34 +433,34 @@ void pulse_analyzer(pulse_data_t *data, int package_type)
case FSK_PULSE_PCM:
fprintf(stderr, "Use a flex decoder with -X 'n=name,m=FSK_PCM,s=%.0f,l=%.0f,r=%.0f'\n",
device.short_width, device.long_width, device.reset_limit);
pulse_demod_pcm(data, &device);
pulse_slicer_pcm(data, &device);
break;
case OOK_PULSE_PPM:
fprintf(stderr, "Use a flex decoder with -X 'n=name,m=OOK_PPM,s=%.0f,l=%.0f,g=%.0f,r=%.0f'\n",
device.short_width, device.long_width,
device.gap_limit, device.reset_limit);
data->gap[data->num_pulses - 1] = device.reset_limit / to_us + 1; // Be sure to terminate package
pulse_demod_ppm(data, &device);
pulse_slicer_ppm(data, &device);
break;
case OOK_PULSE_PWM:
fprintf(stderr, "Use a flex decoder with -X 'n=name,m=OOK_PWM,s=%.0f,l=%.0f,r=%.0f,g=%.0f,t=%.0f,y=%.0f'\n",
device.short_width, device.long_width, device.reset_limit,
device.gap_limit, device.tolerance, device.sync_width);
data->gap[data->num_pulses - 1] = device.reset_limit / to_us + 1; // Be sure to terminate package
pulse_demod_pwm(data, &device);
pulse_slicer_pwm(data, &device);
break;
case FSK_PULSE_PWM:
fprintf(stderr, "Use a flex decoder with -X 'n=name,m=FSK_PWM,s=%.0f,l=%.0f,r=%.0f,g=%.0f,t=%.0f,y=%.0f'\n",
device.short_width, device.long_width, device.reset_limit,
device.gap_limit, device.tolerance, device.sync_width);
data->gap[data->num_pulses - 1] = device.reset_limit / to_us + 1; // Be sure to terminate package
pulse_demod_pwm(data, &device);
pulse_slicer_pwm(data, &device);
break;
case OOK_PULSE_MANCHESTER_ZEROBIT:
fprintf(stderr, "Use a flex decoder with -X 'n=name,m=OOK_MC_ZEROBIT,s=%.0f,l=%.0f,r=%.0f'\n",
device.short_width, device.long_width, device.reset_limit);
data->gap[data->num_pulses - 1] = device.reset_limit / to_us + 1; // Be sure to terminate package
pulse_demod_manchester_zerobit(data, &device);
pulse_slicer_manchester_zerobit(data, &device);
break;
default:
fprintf(stderr, "Unsupported\n");
Expand Down
1 change: 0 additions & 1 deletion src/pulse_detect.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

#include "pulse_detect.h"
#include "rfraw.h"
#include "pulse_demod.h"
#include "pulse_detect_fsk.h"
#include "baseband.h"
#include "util.h"
Expand Down
38 changes: 19 additions & 19 deletions src/pulse_demod.c → src/pulse_slicer.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
(at your option) any later version.
*/

#include "pulse_demod.h"
#include "pulse_slicer.h"
#include "bitbuffer.h"
#include "util.h"
#include <stdio.h>
Expand Down Expand Up @@ -52,7 +52,7 @@ static int account_event(r_device *device, bitbuffer_t *bits, char const *demod_
return ret;
}

int pulse_demod_pcm(const pulse_data_t *pulses, r_device *device)
int pulse_slicer_pcm(const pulse_data_t *pulses, r_device *device)
{
float samples_per_us = pulses->sample_rate / 1.0e6;
int s_short = device->short_width * samples_per_us;
Expand Down Expand Up @@ -246,7 +246,7 @@ int pulse_demod_pcm(const pulse_data_t *pulses, r_device *device)
return events;
}

int pulse_demod_ppm(const pulse_data_t *pulses, r_device *device)
int pulse_slicer_ppm(const pulse_data_t *pulses, r_device *device)
{
float samples_per_us = pulses->sample_rate / 1.0e6;

Expand Down Expand Up @@ -325,7 +325,7 @@ int pulse_demod_ppm(const pulse_data_t *pulses, r_device *device)
return events;
}

int pulse_demod_pwm(const pulse_data_t *pulses, r_device *device)
int pulse_slicer_pwm(const pulse_data_t *pulses, r_device *device)
{
float samples_per_us = pulses->sample_rate / 1.0e6;

Expand Down Expand Up @@ -438,7 +438,7 @@ int pulse_demod_pwm(const pulse_data_t *pulses, r_device *device)
return events;
}

int pulse_demod_manchester_zerobit(const pulse_data_t *pulses, r_device *device)
int pulse_slicer_manchester_zerobit(const pulse_data_t *pulses, r_device *device)
{
float samples_per_us = pulses->sample_rate / 1.0e6;

Expand Down Expand Up @@ -517,15 +517,15 @@ int pulse_demod_manchester_zerobit(const pulse_data_t *pulses, r_device *device)
return events;
}

static inline int pulse_demod_get_symbol(const pulse_data_t *pulses, unsigned int n)
static inline int pulse_slicer_get_symbol(const pulse_data_t *pulses, unsigned int n)
{
if (n % 2 == 0)
return pulses->pulse[n / 2];
else
return pulses->gap[n / 2];
}

int pulse_demod_dmc(const pulse_data_t *pulses, r_device *device)
int pulse_slicer_dmc(const pulse_data_t *pulses, r_device *device)
{
float samples_per_us = pulses->sample_rate / 1.0e6;

Expand All @@ -551,12 +551,12 @@ int pulse_demod_dmc(const pulse_data_t *pulses, r_device *device)
int events = 0;

for (unsigned int n = 0; n < pulses->num_pulses * 2; ++n) {
int symbol = pulse_demod_get_symbol(pulses, n);
int symbol = pulse_slicer_get_symbol(pulses, n);

if (abs(symbol - s_short) < s_tolerance) {
// Short - 1
bitbuffer_add_bit(&bits, 1);
symbol = pulse_demod_get_symbol(pulses, ++n);
symbol = pulse_slicer_get_symbol(pulses, ++n);
if (abs(symbol - s_short) > s_tolerance) {
if (symbol >= s_reset - s_tolerance) {
// Don't expect another short gap at end of message
Expand All @@ -565,7 +565,7 @@ int pulse_demod_dmc(const pulse_data_t *pulses, r_device *device)
else if (bits.num_rows > 0 && bits.bits_per_row[bits.num_rows - 1] > 0) {
bitbuffer_add_row(&bits);
/*
fprintf(stderr, "Detected error during pulse_demod_dmc(): %s\n",
fprintf(stderr, "Detected error during pulse_slicer_dmc(): %s\n",
device->name);
*/
}
Expand All @@ -585,7 +585,7 @@ int pulse_demod_dmc(const pulse_data_t *pulses, r_device *device)
return events;
}

int pulse_demod_piwm_raw(const pulse_data_t *pulses, r_device *device)
int pulse_slicer_piwm_raw(const pulse_data_t *pulses, r_device *device)
{
float samples_per_us = pulses->sample_rate / 1.0e6;

Expand Down Expand Up @@ -616,7 +616,7 @@ int pulse_demod_piwm_raw(const pulse_data_t *pulses, r_device *device)
int events = 0;

for (unsigned int n = 0; n < pulses->num_pulses * 2; ++n) {
int symbol = pulse_demod_get_symbol(pulses, n);
int symbol = pulse_slicer_get_symbol(pulses, n);
w = symbol * f_short + 0.5;
if (symbol > s_long) {
bitbuffer_add_row(&bits);
Expand All @@ -631,7 +631,7 @@ int pulse_demod_piwm_raw(const pulse_data_t *pulses, r_device *device)
&& bits.bits_per_row[bits.num_rows - 1] > 0) {
bitbuffer_add_row(&bits);
/*
fprintf(stderr, "Detected error during pulse_demod_piwm_raw(): %s\n",
fprintf(stderr, "Detected error during pulse_slicer_piwm_raw(): %s\n",
device->name);
*/
}
Expand All @@ -647,7 +647,7 @@ int pulse_demod_piwm_raw(const pulse_data_t *pulses, r_device *device)
return events;
}

int pulse_demod_piwm_dc(const pulse_data_t *pulses, r_device *device)
int pulse_slicer_piwm_dc(const pulse_data_t *pulses, r_device *device)
{
float samples_per_us = pulses->sample_rate / 1.0e6;

Expand All @@ -673,7 +673,7 @@ int pulse_demod_piwm_dc(const pulse_data_t *pulses, r_device *device)
int events = 0;

for (unsigned int n = 0; n < pulses->num_pulses * 2; ++n) {
int symbol = pulse_demod_get_symbol(pulses, n);
int symbol = pulse_slicer_get_symbol(pulses, n);
if (abs(symbol - s_short) < s_tolerance) {
// Short - 1
bitbuffer_add_bit(&bits, 1);
Expand All @@ -687,7 +687,7 @@ int pulse_demod_piwm_dc(const pulse_data_t *pulses, r_device *device)
&& bits.bits_per_row[bits.num_rows - 1] > 0) {
bitbuffer_add_row(&bits);
/*
fprintf(stderr, "Detected error during pulse_demod_piwm_dc(): %s\n",
fprintf(stderr, "Detected error during pulse_slicer_piwm_dc(): %s\n",
device->name);
*/
}
Expand All @@ -703,7 +703,7 @@ int pulse_demod_piwm_dc(const pulse_data_t *pulses, r_device *device)
return events;
}

int pulse_demod_nrzs(const pulse_data_t *pulses, r_device *device)
int pulse_slicer_nrzs(const pulse_data_t *pulses, r_device *device)
{
float samples_per_us = pulses->sample_rate / 1.0e6;

Expand Down Expand Up @@ -763,7 +763,7 @@ int pulse_demod_nrzs(const pulse_data_t *pulses, r_device *device)
* bit is discarded.
*/

int pulse_demod_osv1(const pulse_data_t *pulses, r_device *device)
int pulse_slicer_osv1(const pulse_data_t *pulses, r_device *device)
{
float samples_per_us = pulses->sample_rate / 1.0e6;

Expand Down Expand Up @@ -854,7 +854,7 @@ int pulse_demod_osv1(const pulse_data_t *pulses, r_device *device)
return events;
}

int pulse_demod_string(const char *code, r_device *device)
int pulse_slicer_string(const char *code, r_device *device)
{
int events = 0;
bitbuffer_t bits = {0};
Expand Down
Loading

0 comments on commit dd1c970

Please sign in to comment.