A simple WIP that logs data from a Grove sensor, and can send and receive information over USB and SMS.

Dependencies:   DHT DS_1337 SDFileSystem USBDevice mbed

Committer:
Joseph Radford
Date:
Sun Apr 10 15:47:33 2016 +1000
Revision:
0:2df78a4443cd
Initial commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Joseph Radford 0:2df78a4443cd 1 #ifndef __TIMERS_H__
Joseph Radford 0:2df78a4443cd 2 #define __TIMERS_H__
Joseph Radford 0:2df78a4443cd 3
Joseph Radford 0:2df78a4443cd 4 #include "mbed.h"
Joseph Radford 0:2df78a4443cd 5
Joseph Radford 0:2df78a4443cd 6 /*!
Joseph Radford 0:2df78a4443cd 7 * \brief The MyTimers class creates a Ticker and decrements a collection of unsigned longs that act as timers across the program
Joseph Radford 0:2df78a4443cd 8 *
Joseph Radford 0:2df78a4443cd 9 * \sa eTimerType is used to link external callers with a collection of unsigned longs which are decremented
Joseph Radford 0:2df78a4443cd 10 * each ms by \sa run().
Joseph Radford 0:2df78a4443cd 11 * This acts as a collection of timers.
Joseph Radford 0:2df78a4443cd 12 * This collection can be set by \sa SetTimer and retrieved by \sa GetTimer.
Joseph Radford 0:2df78a4443cd 13 */
Joseph Radford 0:2df78a4443cd 14 class MyTimers
Joseph Radford 0:2df78a4443cd 15 {
Joseph Radford 0:2df78a4443cd 16 public:
Joseph Radford 0:2df78a4443cd 17 MyTimers();
Joseph Radford 0:2df78a4443cd 18 ~MyTimers();
Joseph Radford 0:2df78a4443cd 19
Joseph Radford 0:2df78a4443cd 20 ///< eTimerType identifies each of the timers in program, and is used to set and get a timer
Joseph Radford 0:2df78a4443cd 21 typedef enum
Joseph Radford 0:2df78a4443cd 22 {
Joseph Radford 0:2df78a4443cd 23 tmr_GroveMeasure, ///< Used in GroveDht22 handler
Joseph Radford 0:2df78a4443cd 24 tmr_GprsPower, ///< Used to power the SIM900 on and off
Joseph Radford 0:2df78a4443cd 25 tmr_GprsRxTx, ///< Timeout waiting for a response from the SIM900 over the serial line
Joseph Radford 0:2df78a4443cd 26 tmr_SdWaitError, ///< Sd card has hit an error, wait before retrying
Joseph Radford 0:2df78a4443cd 27 tmr_MeasFlash ///< Flash once every 2 seconds for heartbeat
Joseph Radford 0:2df78a4443cd 28 } eTimerType;
Joseph Radford 0:2df78a4443cd 29
Joseph Radford 0:2df78a4443cd 30 //! run is called each time Ticker fires, which is every 1ms, and decrements all timers if necessary
Joseph Radford 0:2df78a4443cd 31 void run();
Joseph Radford 0:2df78a4443cd 32
Joseph Radford 0:2df78a4443cd 33 /*!
Joseph Radford 0:2df78a4443cd 34 * \brief SetTimer sets the value of the timer
Joseph Radford 0:2df78a4443cd 35 * \param timertype identifies the timer whose value we want to set
Joseph Radford 0:2df78a4443cd 36 * \param time_ms is the value the timer will be set to, to start counting down from, in ms
Joseph Radford 0:2df78a4443cd 37 */
Joseph Radford 0:2df78a4443cd 38 void SetTimer(eTimerType timertype, unsigned long time_ms);
Joseph Radford 0:2df78a4443cd 39
Joseph Radford 0:2df78a4443cd 40 /*!
Joseph Radford 0:2df78a4443cd 41 * \brief GetTimer gets the value of a timer
Joseph Radford 0:2df78a4443cd 42 * \param timertype identifies the timer whose value we want to get
Joseph Radford 0:2df78a4443cd 43 * \return the value of the timer
Joseph Radford 0:2df78a4443cd 44 */
Joseph Radford 0:2df78a4443cd 45 unsigned long GetTimer(eTimerType timertype);
Joseph Radford 0:2df78a4443cd 46
Joseph Radford 0:2df78a4443cd 47 private:
Joseph Radford 0:2df78a4443cd 48 unsigned long groveMeasureTimer; ///< current value of timer for \sa tmr_GroveMeasure
Joseph Radford 0:2df78a4443cd 49 unsigned long gprsPowerTimer; ///< current value of timer for \sa tmr_GprsPower
Joseph Radford 0:2df78a4443cd 50 unsigned long gprsRxTxTimer; ///< current value of timer for \sa tmr_GprsRxTx
Joseph Radford 0:2df78a4443cd 51 unsigned long sdWaitErrorTimer; ///< current value of timer for \sa tmr_SdWaitError
Joseph Radford 0:2df78a4443cd 52 unsigned long measFlashTimer; ///< current value of timer for \sa tmr_MeasFlash
Joseph Radford 0:2df78a4443cd 53
Joseph Radford 0:2df78a4443cd 54 Ticker *m_tick; ///< Used to call \a run a function periodically
Joseph Radford 0:2df78a4443cd 55 };
Joseph Radford 0:2df78a4443cd 56
Joseph Radford 0:2df78a4443cd 57 #endif