Year Two Project ELEC 2645: Embedded Systems Project Portable Weather Station

Dependencies:   BMP180 ConfigFile N5110 PowerControl beep mbed

Committer:
OHstin
Date:
Mon May 11 15:25:52 2015 +0000
Revision:
0:da2b8c7a1ec1
Completed Weather Station

Who changed what in which revision?

UserRevisionLine numberNew contents of line
OHstin 0:da2b8c7a1ec1 1 /**
OHstin 0:da2b8c7a1ec1 2 @file Inputs.h
OHstin 0:da2b8c7a1ec1 3 @brief All the necessary inputs for the weather application are stored in this file\n
OHstin 0:da2b8c7a1ec1 4 @brief Inputs in this case are buttons.\n
OHstin 0:da2b8c7a1ec1 5 @brief A timer was also implemented that would compensate for multiple interrupts when buttons are pressed\n
OHstin 0:da2b8c7a1ec1 6 @author Augustine K Kizito\n
OHstin 0:da2b8c7a1ec1 7 @date April 2015
OHstin 0:da2b8c7a1ec1 8 */
OHstin 0:da2b8c7a1ec1 9 #ifndef INPUTS_H
OHstin 0:da2b8c7a1ec1 10 #define INPUTS_H
OHstin 0:da2b8c7a1ec1 11
OHstin 0:da2b8c7a1ec1 12 #include "ConfigFile.h"
OHstin 0:da2b8c7a1ec1 13
OHstin 0:da2b8c7a1ec1 14
OHstin 0:da2b8c7a1ec1 15 //Button Objects
OHstin 0:da2b8c7a1ec1 16 InterruptIn upButton(p17); // up Button
OHstin 0:da2b8c7a1ec1 17 InterruptIn downButton(p18); // down Button
OHstin 0:da2b8c7a1ec1 18 InterruptIn enterButton(p16); // enter Button
OHstin 0:da2b8c7a1ec1 19 InterruptIn backButton(p15); // back Button
OHstin 0:da2b8c7a1ec1 20
OHstin 0:da2b8c7a1ec1 21 LocalFileSystem local("local"); // create local file system object
OHstin 0:da2b8c7a1ec1 22 ConfigFile cfg; // create ConfigFile object
OHstin 0:da2b8c7a1ec1 23
OHstin 0:da2b8c7a1ec1 24 // timer that is used to observe and prevent multiple interrupts
OHstin 0:da2b8c7a1ec1 25 Timer debounce;
OHstin 0:da2b8c7a1ec1 26
OHstin 0:da2b8c7a1ec1 27 void debounceReset() // resets the debounce timer
OHstin 0:da2b8c7a1ec1 28 {
OHstin 0:da2b8c7a1ec1 29 debounce.reset(); // reset the timer
OHstin 0:da2b8c7a1ec1 30
OHstin 0:da2b8c7a1ec1 31 }
OHstin 0:da2b8c7a1ec1 32
OHstin 0:da2b8c7a1ec1 33 // ticker that resets the debounce every 20 minutes to prevent
OHstin 0:da2b8c7a1ec1 34 // program from freezing
OHstin 0:da2b8c7a1ec1 35 Ticker rdb;
OHstin 0:da2b8c7a1ec1 36 void debounceInit()
OHstin 0:da2b8c7a1ec1 37 {
OHstin 0:da2b8c7a1ec1 38 rdb.attach(&debounceReset,1200.0); // call debounce reset after 20 minutes
OHstin 0:da2b8c7a1ec1 39 }
OHstin 0:da2b8c7a1ec1 40 //void debounceReset(); // resets the debounce timer
OHstin 0:da2b8c7a1ec1 41 //rdb.attach(&debounceReset,1200.0); // call debounce reset after 20 minutes
OHstin 0:da2b8c7a1ec1 42
OHstin 0:da2b8c7a1ec1 43 bool debounceSuccess()// checks if debouncing was successful
OHstin 0:da2b8c7a1ec1 44 {
OHstin 0:da2b8c7a1ec1 45
OHstin 0:da2b8c7a1ec1 46 if (debounce.read_ms() > 200) { // check if the debounce timer is more than 200ms
OHstin 0:da2b8c7a1ec1 47 return true;
OHstin 0:da2b8c7a1ec1 48 }
OHstin 0:da2b8c7a1ec1 49
OHstin 0:da2b8c7a1ec1 50 else {
OHstin 0:da2b8c7a1ec1 51 return false;
OHstin 0:da2b8c7a1ec1 52 }
OHstin 0:da2b8c7a1ec1 53 }
OHstin 0:da2b8c7a1ec1 54
OHstin 0:da2b8c7a1ec1 55
OHstin 0:da2b8c7a1ec1 56
OHstin 0:da2b8c7a1ec1 57
OHstin 0:da2b8c7a1ec1 58 #endif