Thread Safety and RTOS usage
masterTo use MultiButton in a multi-threaded RTOS environment, define MULTIBUTTON_THREAD_SAFE and provide implementation for MULTIBUTTON_LOCK() and MULTIBUTTON_UNLOCK() using your RTOS mutexes.
Important: Callbacks are executed outside of the lock. This means it is safe to call button_stop() or button_start() from within a callback without causing a deadlock. You can use standard mutexes (no need for recursive locks).
#define MULTIBUTTON_THREAD_SAFE
#define MULTIBUTTON_LOCK() osMutexAcquire(btn_mutex, osWaitForever)
#define MULTIBUTTON_UNLOCK() osMutexRelease(btn_mutex)
#include "multi_button.h"