Miguel Angel Caycho
/
Pruebas_Ventilador_Eplimin_01_Backup
para el ventilador
buttons.h
- Committer:
- miguelangel_2511
- Date:
- 2020-04-17
- Revision:
- 3:45299e7882b9
- Parent:
- 0:9d0b9785d3d6
- Child:
- 6:d38287621cca
File content as of revision 3:45299e7882b9:
#ifndef BUTTONS_H_ #define BUTTONS_H_ #include "mbed.h" #include "stdint.h" #include "project_defines.h" /* Object declaration */ extern BusIn buttons; extern DigitalIn push_button; /* Global variable declaration */ extern volatile uint8_t button_state; // debounced button state (bit == 1: button pressed) extern volatile uint8_t button_press; // button press detect /* Functions declaration */ void Buttons_Initialize(void); uint8_t Get_Button_Press(uint8_t button_mask); /*********************************************************************** buttonDebounce: Check if a button has changed and keeps its new value (HIGH or LOW) for 03 periods of time. ************************************************************************/ static inline void Button_Debounce(void){ static unsigned char ct0, ct1; unsigned char k = 0; k = button_state ^ (~buttons); // button changed ? ct1 = (ct0 ^ ct1) & k; // reset or count ct1 ct0 = (~ct0) & k; // reset or count ct0 k &= ct0 & ct1; // count until roll over button_state ^= k; // then toggle debounced state button_press |= button_state & k; // 0->1: button press detect } #endif /* BUTTONS_H_ */