para el ventilador

Dependencies:   QEI FastPWM

Committer:
miguelangel_2511
Date:
Mon Apr 20 11:39:30 2020 +0000
Revision:
6:d38287621cca
Parent:
5:bd5fc0510e7b
Child:
7:f4e248182d31
La pantalla TFT fue reemplazada por una pantalla Nextion que se comunica por el puerto serial (UART). El control de la pantalla sigue realizandose a traves de un encoder.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
miguelangel_2511 0:9d0b9785d3d6 1 #include "mbed.h"
miguelangel_2511 0:9d0b9785d3d6 2 #include "stdint.h"
miguelangel_2511 0:9d0b9785d3d6 3 #include "project_defines.h"
miguelangel_2511 0:9d0b9785d3d6 4 #include "buttons.h"
miguelangel_2511 0:9d0b9785d3d6 5 #include "encoder_interface.h"
miguelangel_2511 6:d38287621cca 6 #include "nextion_interface.h"
miguelangel_2511 0:9d0b9785d3d6 7 #include "stepper_motor_driver.h"
miguelangel_2511 0:9d0b9785d3d6 8 #include "ventilator.h"
miguelangel_2511 0:9d0b9785d3d6 9
miguelangel_2511 0:9d0b9785d3d6 10
miguelangel_2511 0:9d0b9785d3d6 11 // ******************************
miguelangel_2511 0:9d0b9785d3d6 12 // OBJECT CONSTRUCTION
miguelangel_2511 0:9d0b9785d3d6 13 // ******************************
miguelangel_2511 0:9d0b9785d3d6 14
miguelangel_2511 3:45299e7882b9 15 Ticker ticker_int_10us; // Ticker interrupt
miguelangel_2511 0:9d0b9785d3d6 16
miguelangel_2511 0:9d0b9785d3d6 17
miguelangel_2511 0:9d0b9785d3d6 18 // ******************************
miguelangel_2511 0:9d0b9785d3d6 19 // GLOBAL VARIABLES
miguelangel_2511 0:9d0b9785d3d6 20 // ******************************
miguelangel_2511 0:9d0b9785d3d6 21
miguelangel_2511 0:9d0b9785d3d6 22
miguelangel_2511 0:9d0b9785d3d6 23
miguelangel_2511 0:9d0b9785d3d6 24 // ******************************
miguelangel_2511 0:9d0b9785d3d6 25 // FUNCTION DECLARATION
miguelangel_2511 0:9d0b9785d3d6 26 // ******************************
miguelangel_2511 0:9d0b9785d3d6 27 void Ticker_ISR(void); // ISR that is called when the timer reaches the set value
miguelangel_2511 0:9d0b9785d3d6 28
miguelangel_2511 0:9d0b9785d3d6 29
miguelangel_2511 0:9d0b9785d3d6 30 int main(void) {
miguelangel_2511 3:45299e7882b9 31 Buttons_Initialize();
miguelangel_2511 3:45299e7882b9 32 ticker_int_10us.attach(&Ticker_ISR, 0.01);
miguelangel_2511 6:d38287621cca 33 Nextion_Interface_Initialize();
miguelangel_2511 1:aa5df1878126 34 Stepper_Driver_Init();
miguelangel_2511 5:bd5fc0510e7b 35 //Stepper_Calculate_Period_Ramp();
miguelangel_2511 1:aa5df1878126 36
miguelangel_2511 0:9d0b9785d3d6 37 while(1){
miguelangel_2511 1:aa5df1878126 38 Stepper_Driver_State_Machine();
miguelangel_2511 6:d38287621cca 39 Nextion_Encoder_Interaction();
miguelangel_2511 0:9d0b9785d3d6 40 }
miguelangel_2511 0:9d0b9785d3d6 41
miguelangel_2511 0:9d0b9785d3d6 42 return 0;
miguelangel_2511 0:9d0b9785d3d6 43 }
miguelangel_2511 0:9d0b9785d3d6 44
miguelangel_2511 0:9d0b9785d3d6 45
miguelangel_2511 0:9d0b9785d3d6 46
miguelangel_2511 0:9d0b9785d3d6 47 // Ticker Interrupt Service Routine
miguelangel_2511 3:45299e7882b9 48 void Ticker_ISR(void){
miguelangel_2511 1:aa5df1878126 49
miguelangel_2511 0:9d0b9785d3d6 50 static uint8_t conta_10ms = 0;
miguelangel_2511 0:9d0b9785d3d6 51
miguelangel_2511 0:9d0b9785d3d6 52 Button_Debounce();
miguelangel_2511 0:9d0b9785d3d6 53
miguelangel_2511 0:9d0b9785d3d6 54 conta_10ms++;
miguelangel_2511 0:9d0b9785d3d6 55
miguelangel_2511 0:9d0b9785d3d6 56 if(conta_10ms == 2){
miguelangel_2511 0:9d0b9785d3d6 57 conta_10ms = 0;
miguelangel_2511 0:9d0b9785d3d6 58 Encoder_Read();
miguelangel_2511 0:9d0b9785d3d6 59 }
miguelangel_2511 3:45299e7882b9 60
miguelangel_2511 3:45299e7882b9 61 }