para el ventilador

Dependencies:   QEI FastPWM

Committer:
miguelangel_2511
Date:
Sat Apr 11 22:53:05 2020 +0000
Revision:
0:9d0b9785d3d6
Child:
3:45299e7882b9
Se completo el codigo para la pantalla principal de la interfaz grafica y se iniciaron las primeras pruebas con el motor de pasos.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
miguelangel_2511 0:9d0b9785d3d6 1 #ifndef BUTTONS_H_
miguelangel_2511 0:9d0b9785d3d6 2 #define BUTTONS_H_
miguelangel_2511 0:9d0b9785d3d6 3
miguelangel_2511 0:9d0b9785d3d6 4 #include "mbed.h"
miguelangel_2511 0:9d0b9785d3d6 5 #include "stdint.h"
miguelangel_2511 0:9d0b9785d3d6 6 #include "project_defines.h"
miguelangel_2511 0:9d0b9785d3d6 7
miguelangel_2511 0:9d0b9785d3d6 8 /* Object declaration */
miguelangel_2511 0:9d0b9785d3d6 9 extern BusIn buttons;
miguelangel_2511 0:9d0b9785d3d6 10
miguelangel_2511 0:9d0b9785d3d6 11 /* Global variable declaration */
miguelangel_2511 0:9d0b9785d3d6 12 extern volatile uint8_t button_state; // debounced button state (bit == 1: button pressed)
miguelangel_2511 0:9d0b9785d3d6 13 extern volatile uint8_t button_press; // button press detect
miguelangel_2511 0:9d0b9785d3d6 14
miguelangel_2511 0:9d0b9785d3d6 15 /* Functions declaration */
miguelangel_2511 0:9d0b9785d3d6 16 void Buttons_Initialize(void);
miguelangel_2511 0:9d0b9785d3d6 17 uint8_t Get_Button_Press(uint8_t button_mask);
miguelangel_2511 0:9d0b9785d3d6 18
miguelangel_2511 0:9d0b9785d3d6 19
miguelangel_2511 0:9d0b9785d3d6 20
miguelangel_2511 0:9d0b9785d3d6 21 /***********************************************************************
miguelangel_2511 0:9d0b9785d3d6 22 buttonDebounce: Check if a button has changed and keeps its new value
miguelangel_2511 0:9d0b9785d3d6 23 (HIGH or LOW) for 03 periods of time.
miguelangel_2511 0:9d0b9785d3d6 24 ************************************************************************/
miguelangel_2511 0:9d0b9785d3d6 25
miguelangel_2511 0:9d0b9785d3d6 26 static inline void Button_Debounce(void){
miguelangel_2511 0:9d0b9785d3d6 27 static unsigned char ct0, ct1;
miguelangel_2511 0:9d0b9785d3d6 28 unsigned char k = 0;
miguelangel_2511 0:9d0b9785d3d6 29
miguelangel_2511 0:9d0b9785d3d6 30 k = button_state ^ (~buttons); // button changed ?
miguelangel_2511 0:9d0b9785d3d6 31 ct1 = (ct0 ^ ct1) & k; // reset or count ct1
miguelangel_2511 0:9d0b9785d3d6 32 ct0 = (~ct0) & k; // reset or count ct0
miguelangel_2511 0:9d0b9785d3d6 33 k &= ct0 & ct1; // count until roll over
miguelangel_2511 0:9d0b9785d3d6 34 button_state ^= k; // then toggle debounced state
miguelangel_2511 0:9d0b9785d3d6 35 button_press |= button_state & k; // 0->1: button press detect
miguelangel_2511 0:9d0b9785d3d6 36
miguelangel_2511 0:9d0b9785d3d6 37 }
miguelangel_2511 0:9d0b9785d3d6 38
miguelangel_2511 0:9d0b9785d3d6 39
miguelangel_2511 0:9d0b9785d3d6 40 #endif /* BUTTONS_H_ */