Go to the source code of this file.
#define CLAMP (a, l, u) ((a) < l ? l : ((a) > u ? u : (a)))
Clamp a number between an upper and lower bound.
#define MIN (a, b) (((a) < (b)) ? (a) : (b))
Find the smaller of two numbers.
#define MAX (a, b) (((a) > (b)) ? (a) : (b))
Find the larger of two numbers.
#define ABS (a) (((a) < (0)) ? -(a) : (a))
Find the absolute value of a number.
#define IS_ARRAY (arr) ((void*)&(arr) == &(arr)[0])
Return the number of elements in a fixed length array. This does not work for pointers.
#define STATIC_EXP (e) (0 * sizeof(struct { int ARRAY_SIZE_FAILED : (2 * (e)-1); }))
Helper macro to determine the number of elements in an array. Should not be used directly.
#define ARRAY_SIZE (arr) (sizeof(arr) / sizeof((arr)[0]) + STATIC_EXP (IS_ARRAY (arr)))
#define POS_MODULO_ADD (a, b, d) ((a + (b % d) + d) % d)
Returns (a + b) % d, but with negative values converted to equivalent positive values. The resulting value will always be in the range [0, d), assuming d > 0.
#define RUN_TIMER_EVERY (timer, period, elapsed, timer_code)
Run timer_code every period, using tracking it with timer.
#define NUM_FRAME_TIMES 60
#define DRAW_FPS_COUNTER (font)
◆ CLAMP
#define CLAMP
(
a,
l,
u ) ((a) < l ? l : ((a) > u ? u : (a)))
Clamp a number between an upper and lower bound.
Parameters
a A number to clamp between an upper and lower bound
l The lower bound, inclusive
u The upper bound, inclusive
Returns The clamped number
◆ MIN
#define MIN
(
a,
b ) (((a) < (b)) ? (a) : (b))
Find the smaller of two numbers.
Parameters
a A number to compare
b Another number to compare
Returns The smaller of the two numbers
◆ MAX
#define MAX
(
a,
b ) (((a) > (b)) ? (a) : (b))
Find the larger of two numbers.
Parameters
a A number to compare
b Another number to compare
Returns The larger of the two numbers
◆ ABS
#define ABS
(
a )
(((a) < (0)) ? -(a) : (a))
Find the absolute value of a number.
Parameters
a A number to find the absolute value of
Returns The absolute value fo the number
◆ IS_ARRAY
#define IS_ARRAY
(
arr )
((void*)&(arr) == &(arr)[0])
Return the number of elements in a fixed length array. This does not work for pointers.
See https://stackoverflow.com/a/19455169
Parameters
arr An array to find the number of elements in
Returns The the number of elements in an array (not the byte size!) Helper macro to determine the number of elements in an array. Should not be used directly
◆ STATIC_EXP
#define STATIC_EXP
(
e )
(0 * sizeof(struct { int ARRAY_SIZE_FAILED : (2 * (e)-1); }))
Helper macro to determine the number of elements in an array. Should not be used directly.
◆ ARRAY_SIZE
◆ POS_MODULO_ADD
#define POS_MODULO_ADD
(
a,
b,
d ) ((a + (b % d) + d) % d)
Returns (a + b) % d, but with negative values converted to equivalent positive values. The resulting value will always be in the range [0, d), assuming d > 0.
The first modulo, (b % d) will return e.g. -90 for (-270 % 360)
Parameters
a One number to sum
b Another number to sum
d The number to mod the sum by
Returns (a + b) % d
◆ RUN_TIMER_EVERY
#define RUN_TIMER_EVERY
(
timer,
period,
elapsed,
timer_code )
Value: do \
{ \
timer += (elapsed); \
while (timer > (period)) \
{ \
timer -= (period); \
{ \
timer_code \
} \
} \
} while (0)
Run timer_code every period, using tracking it with timer.
Parameters
timer The accumulator variable, must persist between calls
period The period at which timer_code should be run
elapsed The time elapsed since this was last called
timer_code The code to execute every period
◆ NUM_FRAME_TIMES
#define NUM_FRAME_TIMES 60
◆ DRAW_FPS_COUNTER
#define DRAW_FPS_COUNTER
(
font )
Value: do \
{ \
static uint32_t frameTimesIdx = 0; \
\
uint32_t tElapsed = frameTimes[frameTimesIdx] - frameTimes[startIdx]; \
if (0 != tElapsed) \
{ \
char tmp[16]; \
snprintf(tmp, sizeof (tmp) - 1, "%" PRIu32, fps); \
fillDisplayArea(34, 1, 51, 3 + font.height,
c000 ); \
drawText(&font,
c555 , tmp, 35, 2); \
} \
frameTimes[frameTimesIdx] = esp_timer_get_time(); \
} while (0)
#define NUM_FRAME_TIMES
Definition macros.h:103
@ c555
r = 5, g = 5, b = 5
Definition palette.h:239
@ c000
r = 0, g = 0, b = 0
Definition palette.h:24