1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
Commit Graph

12 Commits

Author SHA1 Message Date
Marian Buschsieweke
a04001d781
sys/phydat: Added unit decibel-milliwatts 2018-11-06 11:07:01 +01:00
Marian Buschsieweke
fe46cae00d
sys/phydat: New phydat_fit API
The current phydat_fit implementation the following limitations:
- The API is way more complicated to use than needed
- It doesn't perform any rounding
- It uses `long` in a place where actual width (or better range) of the type
  is pretty important.

This commit addresses these limitations and uses lookup-tables to reduce the
number of divisions required.

Before this commit code using it looked like this:
``` C
long values[] = { 100000, 2000000, 30000000 };
phydat_t dat = { .scale = 42, .unit = UNIT_V };
phydat_fit(&dat, values[0], 0, phydat_fit(&dat, values[1], 1, phydat_fit(&dat, values[2], 2, 0)));
```

Now it can be used like this:
``` C
int32_t values[] = { 100000, 2000000, 30000000 };
phydat_t dat = { .unit = UNIT_V, .scale = 42 };
phydat_fit(&dat, values, 3);
```
2018-10-24 13:05:51 +02:00
d4bfb0f0a3 sys/phydat: add counts unit 2018-10-15 11:44:04 +02:00
25b90317f3 sys/phydat: add ppb unit support 2018-06-11 15:46:46 +02:00
Joakim Nohlgård
63f49f22d8 sys/phydat: Add phydat_fit
Fits larger values into the 16 bit integers used by phydat and update
scale accordingly.
2018-03-22 15:21:01 +01:00
Joakim Nohlgård
7f89435dc7 sys/phydat: Introduce PHYDAT_MIN, PHYDAT_MAX 2018-02-28 08:33:01 +01:00
Joakim Nohlgård
56f44729d7 sys/phydat: rename phydat_scale_to_str -> phydat_prefix_from_scale
Correct some outdated documentation and make the name represent what the
function does today.
2018-02-26 15:41:36 +01:00
0fcc7d3834 cleanup: apply headerguard script output 2017-05-24 17:54:02 +02:00
e2e3704973 sys/phydat: adding illuminance unit (Lux) 2016-06-06 11:04:11 +02:00
Hauke Petersen
2a4b7cbc91 sys/phydat: dump function can handle fixed floats 2016-03-29 15:23:04 +02:00
Hauke Petersen
6134dc80fd sys/phydat: fixed typos in documentation 2015-12-01 14:34:59 +01:00
Hauke Petersen
786895a378 sys: added module for handling physical data 2015-11-30 20:33:53 +01:00