/*
 * btn.h
 *
 *  Created on: Oct 13, 2024
 *      Author: true
 */

#ifndef USER_UI_BTN_H_
#define USER_UI_BTN_H_


#include <stdint.h>



#define BTN_COUNT       5       // total buttons in system
#define MENU_BTN_COUNT  4       // buttons used for menu, must be the first buttons
#define HOLD_PERIOD     5       // period in milliseconds for each "hold" tick internally



typedef struct BtnSub {
    uint16_t hold;              // initial hold
    uint16_t repeat;            // repeated hold
    void (*cb_push)(uint8_t);
    void (*cb_hold)(uint8_t);
    void (*cb_release)(uint8_t);
} BtnSub;



extern BtnSub btn[BTN_COUNT];

extern uint8_t btn_pushed;
extern uint8_t btn_held;



void btn_intr();
void btn_commit_hold();

int8_t btn_get_idx(uint8_t map_idx);



#endif /* USER_UI_BTN_H_ */
