From d476aebf54714ff2ea2d80873b55979dd577be88 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 1 Jan 2000 00:07:56 +0900 Subject: added get_bounded_float function --- device-functions.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'device-functions.c') diff --git a/device-functions.c b/device-functions.c index 79deaf2..24685b9 100644 --- a/device-functions.c +++ b/device-functions.c @@ -60,6 +60,23 @@ static void set_shiftreg_bits(int shiftreg, int start_at_bit, int numbits, int v #define BIT_HIGH 1 #define BIT_LOW 0 + +static float get_bounded_float (float val_in, float default_val) +{ + // limits returned value within +/- 1 order of magnitude + + if (val_in > 10.0 * default_val) { + return default_val; + } + + if (val_in < default_val / 10.0) { + return default_val; + } + + return val_in; +} + + void idn_string(gchar** response) { *response = g_strdup_printf ("AVTECH ELECTROSYSTEMS,%s,SN:%s,v%s", -- cgit