|
PER Firmware
|
Header-only helpers for embedded C. All macros are type-safe (_Generic dispatched) and force-inlined when applicable. Include them directly:
max.h / min.hInline functions to compute the maximum or minimum of 2, 3, or 4 ints or floats.
abs.hABS(x) returns the absolute value of an int or float.
clamp.hCLAMP(input, lower, upper) saturates a value into [lower, upper]. Works on int, unsigned int, long, unsigned long, and float.
rescale.hRESCALE(input, in_min, in_max, out_min, out_max) linearly maps a value from one range to another. Returns out_min if the input range is zero (no div-by-zero).
countof.hcountof(array) returns the number of elements in a stack/global array. Passing a pointer is rejected at compile time.
vector2.hProvides vector2_t and 2D vector arithmetic, dot and cross products, magnitude, normalization, distance, midpoint, and perpendicular operations.
orientation.hDCM_from_euler converts euler_angles_t angles in radians to a mat3_t direction cosine matrix using the ZYX rotation sequence.