// // Created by xemon on 16.11.22. // #ifndef UVEOS_ON_NATION_USERINPUTWATCHBUTTON_H #define UVEOS_ON_NATION_USERINPUTWATCHBUTTON_H #include #include "stdbool.h" #include "stdint.h" #include "GpioPinInterface.h" #include "UserInputButtonEvent.h" #include "UserButtonsInterface.h" typedef struct { tGpioPin pin; bool state; uint32_t begin; uint32_t previousBegin; bool fired; uint16_t buttonId; } tUserInputButtonWatch; typedef struct { tUserInputButtonWatch *watches; uint16_t watchesLimit; uint16_t watchesCount; uint32_t minimalDuration; osMessageQueueId_t eventsOutQueue; } tUserInputButtonWatcher; void UserInputButtonWatcher_Init( tUserInputButtonWatcher *env, tUserInputButtonWatch *watchesMem, uint16_t watchesLimit, size_t eventsQueueLength ); #define UserInputButtonWatcher_InitStatic(ENV, MEM, LEN) UserInputButtonWatcher_Init(ENV, MEM , sizeof(MEM)/sizeof(tUserInputButtonWatch),LEN) bool UserInputButtonWatcher_Add(tUserInputButtonWatcher *env, tGpioPin pin, uint16_t id); void UserInputButtonWatcher_Check(tUserInputButtonWatcher *env); void UserInputButtonWatcher_Clear(tUserInputButtonWatcher *env); void UserInputButtonWatcher_SimulateButton(tUserInputButtonWatcher *env, uint16_t butId); bool UserInputButtonWatcher_GetNext(tUserInputButtonWatcher *env, tUserInputButtonEvent *next, uint32_t timeout); tUserButtonsInterface UserInputButtonWatcher_GetInterface(tUserInputButtonWatcher *env); #endif //UVEOS_ON_NATION_USERINPUTWATCHBUTTON_H