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 "modules.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_T , 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...
 
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. More...
 
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). More...