PER Firmware
Loading...
Searching...
No Matches
units.h File Reference

SI and Imperial unit defs and conversion functions. More...

Go to the source code of this file.

Classes

struct  celsius_t
 
struct  fahrenheit_t
 
struct  meters_t
 
struct  centimeters_t
 
struct  millimeters_t
 
struct  inches_t
 
struct  feet_t
 
struct  miles_t
 
struct  milliseconds_t
 
struct  seconds_t
 
struct  minutes_t
 
struct  hours_t
 
struct  days_t
 
struct  degrees_t
 
struct  radians_t
 
struct  grams_t
 
struct  kilograms_t
 
struct  pounds_t
 
struct  pascals_t
 
struct  psi_t
 
struct  bar_t
 
struct  mps_t
 
struct  kph_t
 
struct  mph_t
 

Macros

#define UNIT_FUNC_MODIFIERS   [[nodiscard, gnu::always_inline]] static inline
 
#define meters_from(x)
 
#define seconds_from(x)
 
#define kilograms_from(x)
 

Functions

UNIT_FUNC_MODIFIERS fahrenheit_t fahrenheit_from (celsius_t c)
 
UNIT_FUNC_MODIFIERS celsius_t celsius_from (fahrenheit_t f)
 
UNIT_FUNC_MODIFIERS meters_t meters_from_centimeters (centimeters_t cm)
 
UNIT_FUNC_MODIFIERS meters_t meters_from_millimeters (millimeters_t mm)
 
UNIT_FUNC_MODIFIERS meters_t meters_from_inches (inches_t in)
 
UNIT_FUNC_MODIFIERS meters_t meters_from_feet (feet_t ft)
 
UNIT_FUNC_MODIFIERS meters_t meters_from_miles (miles_t mi)
 
UNIT_FUNC_MODIFIERS seconds_t seconds_from_milliseconds (milliseconds_t ms)
 
UNIT_FUNC_MODIFIERS seconds_t seconds_from_minutes (minutes_t min)
 
UNIT_FUNC_MODIFIERS seconds_t seconds_from_hours (hours_t hr)
 
UNIT_FUNC_MODIFIERS seconds_t seconds_from_days (days_t d)
 
UNIT_FUNC_MODIFIERS radians_t radians_from (degrees_t deg)
 
UNIT_FUNC_MODIFIERS degrees_t degrees_from (radians_t rad)
 
UNIT_FUNC_MODIFIERS kilograms_t kilograms_from_grams (grams_t g)
 
UNIT_FUNC_MODIFIERS kilograms_t kilograms_from_pounds (pounds_t lb)
 
UNIT_FUNC_MODIFIERS pascals_t pascals_from_psi (psi_t p)
 
UNIT_FUNC_MODIFIERS pascals_t pascals_from_bar (bar_t b)
 
UNIT_FUNC_MODIFIERS psi_t psi_from_pascals (pascals_t p)
 
UNIT_FUNC_MODIFIERS bar_t bar_from_pascals (pascals_t p)
 
UNIT_FUNC_MODIFIERS mps_t mps_from_kph (kph_t k)
 
UNIT_FUNC_MODIFIERS mps_t mps_from_mph (mph_t m)
 
UNIT_FUNC_MODIFIERS kph_t kph_from_mps (mps_t m)
 
UNIT_FUNC_MODIFIERS mph_t mph_from_mps (mps_t m)
 

Detailed Description

SI and Imperial unit defs and conversion functions.

Provides simple type-safe wrappers around physical unit conversions. All types under the hood are structs containing a single float.

Author
Irving Wang (irvin.nosp@m.gw@p.nosp@m.urdue.nosp@m..edu)

Macro Definition Documentation

◆ kilograms_from

#define kilograms_from ( x)
Value:
_Generic((x), \
grams_t: kilograms_from_grams, \
pounds_t: kilograms_from_pounds \
)(x)
Definition units.h:143
Definition units.h:145

◆ meters_from

#define meters_from ( x)
Value:
_Generic((x), \
centimeters_t: meters_from_centimeters, \
millimeters_t: meters_from_millimeters, \
inches_t: meters_from_inches, \
feet_t: meters_from_feet, \
miles_t: meters_from_miles \
)(x)
Definition units.h:39
Definition units.h:42
Definition units.h:41
Definition units.h:43
Definition units.h:40

◆ seconds_from

#define seconds_from ( x)
Value:
_Generic((x), \
milliseconds_t: seconds_from_milliseconds, \
minutes_t: seconds_from_minutes, \
hours_t: seconds_from_hours, \
days_t: seconds_from_days \
)(x)
Definition units.h:90
Definition units.h:89
Definition units.h:86
Definition units.h:88