Misc

Button

Functions to handle on/off switch.

Functions

void button_init()

Initialize button and configure interrupts

bool button_pressed_for_3s()

Check if button was pressed for 3 seconds

Returns:

true if pressed for at least 3 seconds

Helper

General helper functions.

Functions

float interpolate(const float a[], const float b[], size_t size, float value_a)

Interpolation in a look-up table. Values of a must be monotonically increasing/decreasing

Returns:

interpolated value of array b at position value_a

const char *byte2bitstr(uint8_t b)

Convert byte to bit-string

Attention: Uses static buffer, not thread-safe

Returns:

pointer to bit-string (8 characters + null-byte)

bool is_empty(uint8_t *buf, size_t size)

Check if a buffer is entirely zeroed.

Parameters:
  • buf – A pointer to the buffer (uint8_t*) to be checked.

  • size – The size of the buffer in bytes.

Returns:

true if the buffer is entirely zeroed, false if not.