phydat.h File Reference

Generic data container for physical data interface. More...

Detailed Description

Generic data container for physical data interface.

Author
Hauke Petersen hauke.nosp@m..pet.nosp@m.ersen.nosp@m.@fu-.nosp@m.berli.nosp@m.n.de

Definition in file phydat.h.

#include <stddef.h>
#include <stdint.h>
#include "kernel_defines.h"
+ Include dependency graph for phydat.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  phydat_t
 Generic data structure for expressing physical values. More...
 

Macros

#define PHYDAT_DIM   (3U)
 The fixed number of dimensions we work with. More...
 
#define PHYDAT_SCALE_STR_MAXLEN   (sizeof("*E-128\0"))
 The maximum length of a scaling string.
 
#define PHYDAT_MIN   (INT16_MIN)
 Minimum value for phydat_t::val.
 
#define PHYDAT_MAX   (INT16_MAX)
 Maximum value for phydat_t::val.
 

Enumerations

enum  {
  UNIT_UNDEF, UNIT_NONE, UNIT_TEMP_C, UNIT_TEMP_F,
  UNIT_TEMP_K, UNIT_LUX, UNIT_M, UNIT_M2,
  UNIT_M3, UNIT_G, UNIT_DPS, UNIT_GR,
  UNIT_A, UNIT_V, UNIT_W, UNIT_GS,
  UNIT_DBM, UNIT_COULOMB, UNIT_F, UNIT_OHM,
  UNIT_PH, UNIT_BAR, UNIT_PA, UNIT_CD,
  UNIT_BOOL, UNIT_CTS, UNIT_PERCENT, UNIT_PERMILL,
  UNIT_PPM, UNIT_PPB, UNIT_TIME, UNIT_DATE,
  UNIT_GPM3, UNIT_CPM3
}
 Definition of physical units and comparable data types. More...
 

Functions

void phydat_dump (phydat_t *data, uint8_t dim)
 Dump the given data container to STDIO. More...
 
const char * phydat_unit_to_str (uint8_t unit)
 Convert the given unit to a string. More...
 
const char * phydat_unit_to_str_verbose (uint8_t unit)
 Return a string representation for every unit, including non-physical units like 'none' or 'time'. More...
 
char phydat_prefix_from_scale (int8_t scale)
 Convert the given scale factor to an SI prefix. More...
 
void phydat_fit (phydat_t *dat, const int32_t *values, unsigned int dim)
 Scale integer value(s) to fit into a phydat_t. More...
 
size_t phydat_to_json (const phydat_t *data, size_t dim, char *buf)
 Convert the given phydat_t structure into a JSON string. More...