Edson Manoel da Silva / Mbed 2 deprecated Pedometer

Dependencies:   MMA8452 N5110 PowerControl mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.h Source File

main.h

Go to the documentation of this file.
00001 /**
00002 @file main.h
00003 @brief Header file containing functions prototypes and global variables.
00004 @brief Implementation of a Pedometer using the accelerometer MMA8452Q, Nokia 5110 display and the mbed LPC1768.
00005 @brief Revision 1.5.
00006 @author Edson Manoel da Silva
00007 @date   May 2015
00008 */
00009 #ifndef MAIN_H
00010 #define MAIN_H
00011 
00012 #include "mbed.h"
00013 #include "MMA8452.h"
00014 #include "N5110.h"
00015 #include "PowerControl/EthernetPowerControl.h" 
00016 
00017 
00018 //   
00019 /**  
00020 @namespace lcd
00021 @brief GPIO output for Nokia 5110 Display
00022 @brief  VCC (p7),SCE(p8),RST(p9),D/C(p10),MOSI(p11),SCLK(p13),LED(p26)
00023 */
00024 N5110 lcd(p7,p8,p9,p10,p11,p13,p26);
00025 
00026 /**  
00027 @namespace mma8452
00028 @brief GPIO output for mma8452 accelerometer sensor
00029 @brief SDA(p28), SCL(p27)
00030 */
00031 MMA8452 mma8452(p28,p27);
00032 
00033 /**  
00034 @namespace leds
00035 @brief Debug leds
00036 */
00037 BusOut leds(LED4,LED3,LED2,LED1);
00038 
00039 /**  
00040 @namespace buzzer
00041 @brief PWM for the buzzer
00042 */
00043 PwmOut buzzer(p21);
00044 
00045 /**  
00046 @namespace serial
00047 @brief Serial interface
00048 */
00049 Serial serial(USBTX,USBRX);
00050 
00051 /**  
00052 @namespace timer1
00053 @brief First timer used
00054 */
00055 Timeout timer1;
00056 
00057 /**  
00058 @namespace timer2
00059 @brief Second timer used
00060 */
00061 Timeout timer2;
00062 
00063 /**  
00064 @namespace timer3
00065 @brief Chronometer timer
00066 */
00067 Ticker timer3;
00068 
00069 /**  
00070 @namespace local
00071 @brief Create Local File System
00072 */
00073 LocalFileSystem local("local"); // create local filesystem
00074 
00075 /**  
00076 @namespace I1
00077 @brief Create the interrupt for Transient Detection
00078 @brief I1(p15)
00079 */
00080 InterruptIn I1(p15);
00081 
00082 /**  
00083 @namespace I2
00084 @brief Create the interrupt for Pulse(Tap) Detection
00085 @brief I2(p16)
00086 */
00087 InterruptIn I2(p16);
00088 
00089 /**  
00090 @namespace mma8452
00091 @brief Accleration structure declared in MMA8452 class
00092 */
00093 Acceleration acceleration;  
00094 
00095 /**  
00096 @namespace mma8452
00097 @brief Accleration average structure declared in MMA8452 class
00098 */
00099 Acceleration acc_avg;
00100 
00101 unsigned char second  = 0; /*!< second flag set in TimerExpired3 */
00102 unsigned char minute  = 0; /*!< minute flag set in TimerExpired3 */
00103 unsigned char hour  = 0;/*!< hour flag set in TimerExpired3 */
00104 unsigned char state  = 0;/*!< state variable for the FSM */
00105 unsigned char I1_flag  = 0;/*!< Interrupt flag set in Transient Detection Interrupt */
00106 unsigned char I2_flag  = 0;/*!< Interrupt flag set in Pulse(Tap) Detection Interrupt */
00107 unsigned char timerFlag1  = 0;/*!< Interrupt flag set in Timer1 */
00108 unsigned char timerFlag2  = 0;/*!< Interrupt flag set in Timer2 */
00109 unsigned char aux =0;/*!< Auxiliar for checking if the user stopped using the device */
00110 
00111 char Int_SourceSystem  =0;/*!< Variable used to read the MMA8452Q Interrupt Source Register */
00112 char Int_SourceTrans =0;/*!< Variable used to clear the MMA8452Q Interrupt Registers */
00113 
00114 unsigned char length ;/*!< Variable used to check the string length to be printed in the LCD */
00115 char buffer [14];/*!< Buffer used for printing strings on the display */
00116 
00117 unsigned int step  = 0;/*!< Variable used to ccalculate the steps */
00118 float km  = 0;/*!< Variable used to ccalculate the kilometers */
00119 //float km_day[30] = {0,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6,7,8,1,2,3,4,5,6};
00120 float km_day [30] = {};/*!< Variable used to ccalculate the kilometers per day */
00121 
00122 float acc_vector  = 0;/*!< Variable for check if a step was performed */
00123 double sub_x  = 0;/*!< Variable used for calibration */
00124 double sub_y  = 0;/*!< Variable used for calibration */
00125 double sub_z  = 0;/*!< Variable used for calibration */
00126 
00127 /**
00128 Set a flag to alert that a Transient Detection Interrupt has ocurred
00129 */
00130 void Interrupt();
00131 
00132 /**
00133 Set a flag to alert that a Pulse Detection Interrupt has ocurred
00134 */
00135 void Interrupt2();
00136 
00137 /**
00138 Blind the LEDS for state machine error alert
00139 */
00140 void error();
00141 
00142 /**
00143 Set a flag to alert that a Timer1 Interrupt has ocurred
00144 */
00145 void TimerExpired1();
00146 
00147 /**
00148 Set a flag to alert that a Timer2 Interrupt has ocurred
00149 */
00150 void TimerExpired2();
00151 
00152 /**
00153 Performs the calculation for the chronometer time
00154 */
00155 void TimerExpired3();
00156 
00157 /**
00158 Saves the data collected in the stepping count to the flash disk
00159 @param date - the date of the data
00160 @param data1 - steps
00161 @param data2 - Kilometer
00162 */
00163 void writeDataToFile(char *date,int data1,float data2);
00164 #endif