27 #include "libsigrok-internal.h"
29 #define LOG_PREFIX "conv"
43 float threshold, uint8_t *output, uint64_t count)
48 input = g_try_malloc(
sizeof(
float) * count);
56 for (uint64_t i = 0; i < count; i++)
57 output[i] = (input[i] >= threshold) ? 1 : 0;
80 float lo_thr,
float hi_thr, uint8_t *state, uint8_t *output,
86 input = g_try_malloc(
sizeof(
float) * count);
94 for (uint64_t i = 0; i < count; i++) {
95 if (input[i] < lo_thr)
97 else if (input[i] > hi_thr)
Generic/unspecified error.
The public libsigrok header file to be used by frontends.
struct sr_analog_encoding * encoding
int sr_a2l_threshold(const struct sr_datafeed_analog *analog, float threshold, uint8_t *output, uint64_t count)
Convert analog values to logic values by using a fixed threshold.
int sr_analog_to_float(const struct sr_datafeed_analog *analog, float *outbuf)
Convert an analog datafeed payload to an array of floats.
int sr_a2l_schmitt_trigger(const struct sr_datafeed_analog *analog, float lo_thr, float hi_thr, uint8_t *state, uint8_t *output, uint64_t count)
Convert analog values to logic values by using a Schmitt-trigger algorithm.
Analog datafeed payload for type SR_DF_ANALOG.