59#define PHYDAT_DIM (3U)
64#define PHYDAT_SCALE_STR_MAXLEN (sizeof("*E-128\0"))
164#define PHYDAT_MIN (INT16_MIN)
169#define PHYDAT_MAX (INT16_MAX)
320 int16_t hour, int16_t minute, int16_t second,
void phydat_unit_print(uint8_t unit)
Print a unit.
#define PHYDAT_DIM
The fixed number of dimensions we work with.
char phydat_prefix_from_scale(int8_t scale)
Convert the given scale factor to an SI prefix.
int64_t phydat_date_time_to_unix(phydat_t *date, phydat_t *time, int32_t offset_seconds)
Convert a date and time contained in phydat structs to a Unix timestamp.
int64_t phydat_unix(int16_t year, int16_t month, int16_t day, int16_t hour, int16_t minute, int16_t second, int32_t offset)
Convert a date and time (per ISO8601) to a Unix timestamp (seconds since 1970).
size_t phydat_to_json(const phydat_t *data, size_t dim, char *buf)
Convert the given phydat_t structure into a JSON string.
ssize_t phydat_unit_write(char *dest, size_t max_size, uint8_t unit)
Write the string representation of the given unit into the given buffer.
void phydat_fit(phydat_t *dat, const int32_t *values, unsigned int dim)
Scale integer value(s) to fit into a phydat_t.
void phydat_dump(phydat_t *data, uint8_t dim)
Dump the given data container to STDIO.
@ UNIT_TEMP_C
degree Celsius
@ UNIT_G_FORCE
gravitational force equivalent
@ UNIT_NONE
data has no physical unit
@ UNIT_UNDEF
unit undefined
@ UNIT_TEMP_F
degree Fahrenheit
@ UNIT_PPB
part per billion
@ UNIT_DATE
the 3 dimensions contain days, months and years
@ UNIT_DPS
degree per second
@ UNIT_PPM
part per million
@ UNIT_GPM3
grams per cubic meter
@ UNIT_DBM
decibel-milliwatts
@ UNIT_PERMILL
out of 1000
@ UNIT_TIME
the three dimensions contain sec, min, and hours
@ UNIT_BOOL
boolean value [0|1]
@ UNIT_CPM3
count per cubic meter
@ UNIT_GRAM
grams - not using the SI unit (kg) here to make scale handling simpler
Common macros and compiler attributes/pragmas configuration.
Generic data structure for expressing physical values.
int8_t scale
the scale factor, 10^*scale*
uint8_t unit
the (physical) unit of the data