diff options
-rw-r--r-- | device-functions.c | 17 |
1 files changed, 17 insertions, 0 deletions
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", |