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

8 Commits

Author SHA1 Message Date
Teufelchen1
96e748d959 sys/phydat: Remove deprecated print function
Co-authored-by: Marian Buschsieweke <maribu@users.noreply.github.com>
2024-04-03 15:29:19 +02:00
Marian Buschsieweke
3c287c058d
sys/phydat: Fix unit confusion
Previously, `UNIT_G` was used for g-force with the correct symbol `g`,
`UNIT_GR` for gram (as in kilogram) with the incorrect symbol `G` (which
would be correct for Gauss), and `UNIT_GS` for Gauss with symbol `Gs`
(which is an uncommon but correct symbol).

To avoid confusion between G-Force, Gauss, and Gram the units have been
renamed to `UNIT_G_FORCE`, `UNIT_GRAM`, and `UNIT_GAUSS`. In addition,
gram now uses the correct symbol `g` and Gauss uses `G`.
2023-02-23 16:44:24 +01:00
chrysn
206bea0a1d phydat: Add Tesla unit
While this is equivalent to the existing Gs (1 T = 10^-4 Gs), this is
the SI (and thus preferred) unit.
2022-01-25 13:46:08 +01:00
Bas Stottelaar
4cce485b6f tests/*: realign ENABLE_DEBUG 2020-10-23 11:27:48 +02:00
Hauke Petersen
3c07a3f751 tests: added unittests for phydat 2020-05-20 15:29:24 +02:00
Benjamin Valentin
4918dfe590 tests: make use of ARRAY_SIZE macro 2019-08-06 19:43:54 +02: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
Joakim Nohlgård
f4fce5b2d2 unittests: Add test for phydat (phydat_fit) 2018-03-22 15:21:01 +01:00