PGO6_VoteController (Astrid Vanneste)

Dependencies:   MQTT

Fork of PGO6_VoteController_template by Jens de hoog

debounce_button.h

Committer:
AstridVanneste
Date:
2018-10-11
Revision:
6:60b968c8f35c
Parent:
5:ba94770ce1c7

File content as of revision 6:60b968c8f35c:

#include "mbed.h"

/**
    Due to the imperfect design of the buttons, a press on the button is registered multple times.
    The debouncer module makes sure that these false positives of the button are going to be ignored.
    
    Also, this module provides a multiclick service which allows the user to press the button multiple times 
    within a certain time frame. Therefore, multiple actions can be mapped to a single button.
    
*/

extern volatile bool button1_pressed;           // Used in the main loop
extern volatile bool button1_enabled;           // Used for debouncing
extern volatile int multiclick_state;           // Counts how many clicks occured in the time slot, used in main loop
extern volatile bool button1_busy;              // Informs the mainloop that the user is clicking the button => busy multiclick
extern volatile int internal_click_count;       // Counts how many clicks occured in the time slot

extern Timeout debounce_time;
extern Timeout multiclick_time;

void button1_multiclick_reset_cb(void);         // Resets the amount of clicks, but stores this value for the usage in the main loop
void button1_enabled_cb(void);                  // Enables the button again after a timeout, used for debouncing the button 
void button1_onpressed_cb(void);                // Callback which is called when the user presses the button
void init_debouncer();