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

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

This graph shows which files directly or indirectly include this file:

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)
 

Variables

static constexpr float PI_F = 3.1415926535f
 

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), \
)(x)
Definition units.h:143
Definition units.h:145
UNIT_FUNC_MODIFIERS kilograms_t kilograms_from_pounds(pounds_t lb)
Definition units.h:157
UNIT_FUNC_MODIFIERS kilograms_t kilograms_from_grams(grams_t g)
Definition units.h:152

◆ meters_from

#define meters_from ( x)
Value:
_Generic((x), \
)(x)
Definition units.h:39
Definition units.h:42
Definition units.h:41
Definition units.h:43
Definition units.h:40
UNIT_FUNC_MODIFIERS meters_t meters_from_miles(miles_t mi)
Definition units.h:73
UNIT_FUNC_MODIFIERS meters_t meters_from_millimeters(millimeters_t mm)
Definition units.h:58
UNIT_FUNC_MODIFIERS meters_t meters_from_feet(feet_t ft)
Definition units.h:68
UNIT_FUNC_MODIFIERS meters_t meters_from_centimeters(centimeters_t cm)
Definition units.h:53
UNIT_FUNC_MODIFIERS meters_t meters_from_inches(inches_t in)
Definition units.h:63

◆ seconds_from

#define seconds_from ( x)
Value:
_Generic((x), \
)(x)
Definition units.h:90
Definition units.h:89
Definition units.h:86
Definition units.h:88
UNIT_FUNC_MODIFIERS seconds_t seconds_from_minutes(minutes_t min)
Definition units.h:104
UNIT_FUNC_MODIFIERS seconds_t seconds_from_hours(hours_t hr)
Definition units.h:109
UNIT_FUNC_MODIFIERS seconds_t seconds_from_days(days_t d)
Definition units.h:114
UNIT_FUNC_MODIFIERS seconds_t seconds_from_milliseconds(milliseconds_t ms)
Definition units.h:99

◆ UNIT_FUNC_MODIFIERS

#define UNIT_FUNC_MODIFIERS   [[nodiscard, gnu::always_inline]] static inline

Function Documentation

◆ bar_from_pascals()

UNIT_FUNC_MODIFIERS bar_t bar_from_pascals ( pascals_t p)

◆ celsius_from()

◆ degrees_from()

◆ fahrenheit_from()

◆ kilograms_from_grams()

UNIT_FUNC_MODIFIERS kilograms_t kilograms_from_grams ( grams_t g)

◆ kilograms_from_pounds()

UNIT_FUNC_MODIFIERS kilograms_t kilograms_from_pounds ( pounds_t lb)

◆ kph_from_mps()

UNIT_FUNC_MODIFIERS kph_t kph_from_mps ( mps_t m)

◆ meters_from_centimeters()

UNIT_FUNC_MODIFIERS meters_t meters_from_centimeters ( centimeters_t cm)

◆ meters_from_feet()

UNIT_FUNC_MODIFIERS meters_t meters_from_feet ( feet_t ft)

◆ meters_from_inches()

UNIT_FUNC_MODIFIERS meters_t meters_from_inches ( inches_t in)

◆ meters_from_miles()

UNIT_FUNC_MODIFIERS meters_t meters_from_miles ( miles_t mi)

◆ meters_from_millimeters()

UNIT_FUNC_MODIFIERS meters_t meters_from_millimeters ( millimeters_t mm)

◆ mph_from_mps()

UNIT_FUNC_MODIFIERS mph_t mph_from_mps ( mps_t m)

◆ mps_from_kph()

UNIT_FUNC_MODIFIERS mps_t mps_from_kph ( kph_t k)

◆ mps_from_mph()

UNIT_FUNC_MODIFIERS mps_t mps_from_mph ( mph_t m)

◆ pascals_from_bar()

UNIT_FUNC_MODIFIERS pascals_t pascals_from_bar ( bar_t b)

◆ pascals_from_psi()

UNIT_FUNC_MODIFIERS pascals_t pascals_from_psi ( psi_t p)

◆ psi_from_pascals()

UNIT_FUNC_MODIFIERS psi_t psi_from_pascals ( pascals_t p)

◆ radians_from()

◆ seconds_from_days()

UNIT_FUNC_MODIFIERS seconds_t seconds_from_days ( days_t d)

◆ seconds_from_hours()

UNIT_FUNC_MODIFIERS seconds_t seconds_from_hours ( hours_t hr)

◆ seconds_from_milliseconds()

UNIT_FUNC_MODIFIERS seconds_t seconds_from_milliseconds ( milliseconds_t ms)

◆ seconds_from_minutes()

UNIT_FUNC_MODIFIERS seconds_t seconds_from_minutes ( minutes_t min)

Variable Documentation

◆ PI_F

float PI_F = 3.1415926535f
staticconstexpr