@@ -37,9 +37,10 @@ struct context {
37
37
int * channel_unit ;
38
38
float * channel_scale ;
39
39
uint16_t * channel_offset ;
40
- uint8_t * channel_bits ;
41
40
double * channel_mmin ;
42
41
double * channel_mmax ;
42
+ uint32_t ref_min ;
43
+ uint32_t ref_max ;
43
44
uint64_t mask ;
44
45
uint64_t pre_data ;
45
46
uint64_t index ;
@@ -89,7 +90,6 @@ static int init(struct sr_output *o, GHashTable *options)
89
90
ctx -> channel_unit = g_malloc (sizeof (int ) * ctx -> num_enabled_channels );
90
91
ctx -> channel_scale = g_malloc (sizeof (float ) * ctx -> num_enabled_channels );
91
92
ctx -> channel_offset = g_malloc (sizeof (uint16_t ) * ctx -> num_enabled_channels );
92
- ctx -> channel_bits = g_malloc (sizeof (uint8_t ) * ctx -> num_enabled_channels );
93
93
ctx -> channel_mmax = g_malloc (sizeof (double ) * ctx -> num_enabled_channels );
94
94
ctx -> channel_mmin = g_malloc (sizeof (double ) * ctx -> num_enabled_channels );
95
95
@@ -108,7 +108,6 @@ static int init(struct sr_output *o, GHashTable *options)
108
108
(range >= 5000 ) ? 1000 : 1 ;
109
109
ctx -> channel_scale [i ] = range / ctx -> channel_unit [i ];
110
110
ctx -> channel_offset [i ] = ch -> hw_offset ;
111
- ctx -> channel_bits [i ] = ch -> bits ;
112
111
ctx -> channel_mmax [i ] = ch -> map_max ;
113
112
ctx -> channel_mmin [i ] = ch -> map_min ;
114
113
i ++ ;
@@ -199,7 +198,7 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
199
198
const struct sr_datafeed_dso * dso ;
200
199
const struct sr_datafeed_analog * analog ;
201
200
const struct sr_config * src ;
202
- GSList * l ;
201
+ GSList * l ;
203
202
struct context * ctx ;
204
203
int idx ;
205
204
uint64_t i , j ;
@@ -220,7 +219,11 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
220
219
ctx -> samplerate = g_variant_get_uint64 (src -> data );
221
220
else if (src -> key == SR_CONF_LIMIT_SAMPLES )
222
221
ctx -> limit_samples = g_variant_get_uint64 (src -> data );
223
- }
222
+ else if (src -> key == SR_CONF_REF_MIN )
223
+ ctx -> ref_min = g_variant_get_uint32 (src -> data );
224
+ else if (src -> key == SR_CONF_REF_MAX )
225
+ ctx -> ref_max = g_variant_get_uint32 (src -> data );
226
+ }
224
227
break ;
225
228
case SR_DF_LOGIC :
226
229
logic = packet -> payload ;
@@ -261,9 +264,9 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
261
264
for (j = 0 ; j < ctx -> num_enabled_channels ; j ++ ) {
262
265
idx = ctx -> channel_index [j ];
263
266
p = dso -> data + i * ctx -> num_enabled_channels + idx * ((ctx -> num_enabled_channels > 1 ) ? 1 : 0 );
264
- g_string_append_printf (* out , "%0.3f " , (ctx -> channel_offset [j ] - * p ) *
267
+ g_string_append_printf (* out , "%0.5f " , (ctx -> channel_offset [j ] - * p ) *
265
268
ctx -> channel_scale [j ] /
266
- (( 1 << ctx -> channel_bits [ j ]) - 2.0 ));
269
+ (ctx -> ref_max - ctx -> ref_min ));
267
270
g_string_append_c (* out , ctx -> separator );
268
271
}
269
272
@@ -285,8 +288,9 @@ static int receive(const struct sr_output *o, const struct sr_datafeed_packet *p
285
288
for (j = 0 ; j < ctx -> num_enabled_channels ; j ++ ) {
286
289
idx = ctx -> channel_index [j ];
287
290
p = analog -> data + i * ctx -> num_enabled_channels + idx * ((ctx -> num_enabled_channels > 1 ) ? 1 : 0 );
288
- g_string_append_printf (* out , "%0.2f" ,
289
- ctx -> channel_mmin [j ] + (255.0 - * p ) / 255.0 * (ctx -> channel_mmax [j ] - ctx -> channel_mmin [j ]));
291
+ g_string_append_printf (* out , "%0.5f" , (ctx -> channel_offset [j ] - * p ) *
292
+ (ctx -> channel_mmax [j ] - ctx -> channel_mmin [j ]) /
293
+ (ctx -> ref_max - ctx -> ref_min ));
290
294
g_string_append_c (* out , ctx -> separator );
291
295
}
292
296
0 commit comments