diff options
author | Mike <mjc@avtechpulse.com> | 2000-01-01 00:07:56 +0900 |
---|---|---|
committer | Mike <mjc@avtechpulse.com> | 2000-01-01 00:07:56 +0900 |
commit | d476aebf54714ff2ea2d80873b55979dd577be88 (patch) | |
tree | 50f7c608d72fdee6932bc1c423d83811ea88c803 /device-functions.c | |
parent | 660d2eba32d5cd0e101f0096aa6c4cfc27c4ba4e (diff) |
added get_bounded_float function
Diffstat (limited to 'device-functions.c')
-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", |