pachas

Dependencies:   mbed QEI FastPWM

main.cpp

Committer:
miguelangel_2511
Date:
2020-04-11
Revision:
0:9d0b9785d3d6
Child:
1:aa5df1878126

File content as of revision 0:9d0b9785d3d6:

#include "mbed.h"
#include "stdint.h"
#include "project_defines.h"
#include "buttons.h"
#include "encoder_interface.h"
#include "tft_interface.h"
#include "stepper_motor_driver.h"
#include "ventilator.h"


// ******************************
//      OBJECT CONSTRUCTION
// ******************************

//Ticker interrupt
Ticker ticker_int_10ms; // Ticker interrupt

Serial pc(USBTX, USBRX);


// ******************************
//      GLOBAL VARIABLES
// ******************************



// ******************************
//      FUNCTION DECLARATION
// ******************************
void Ticker_ISR(void); // ISR that is called when the timer reaches the set value


int main(void) {
    
    stepper_en = 0;
    stepper_dir = 0;
    stepper_pulse.period(STEPPER_PULSE_PERIOD);
    stepper_pulse.write(STEPPER_PULSE_DUTY_CYCLE);
    
    Buttons_Initialize();
    // Allocate an interrupt service routine for Timer interrupt
    ticker_int_10ms.attach(&Ticker_ISR, 0.01);
    TFT_Interface_Initialize();
/*
    tft->set_font((unsigned char*) Arial28x28);
    tft->set_font_zoom(2,3);
    if(gas_input == AIR_INPUT){
        tft->locate(350,VALUES_ROW2_Y_POS );
        tft->printf("Aire");
    }else{
        tft->locate(390,VALUES_ROW2_Y_POS );
        tft->printf("O");     
    }
 */   

    while(1){     
       //TFT_Encoder_Interaction();
       if(stepper_motor_state == STEPPER_MOTOR_GO_HOME){ 
            Stepper_Motor_Go_Home();
        }
        
        if(stepper_motor_state == STEPPER_MOTOR_GO_AHEAD){ 
            Stepper_Motor_Go_Ahead();
        }      
    }
  
    return 0;
}



// Ticker Interrupt Service Routine
void Ticker_ISR(void){
   /* 
    static uint8_t conta_10ms = 0;
    
    Button_Debounce();
    
    conta_10ms++;
    
    if(conta_10ms == 2){
        conta_10ms = 0;
        Encoder_Read();
    }
    */
}