button procedure library

Dependents:   MIDI_CW Gemphet8

Files at this revision

API Documentation at this revision

Comitter:
ChuckTimber
Date:
Tue Aug 12 02:51:42 2014 +0000
Parent:
5:04236df532fb
Commit message:
Modified document.

Changed in this revision

button.cpp Show annotated file Show diff for this revision Revisions of this file
button.h Show annotated file Show diff for this revision Revisions of this file
--- a/button.cpp	Sat Aug 09 07:02:10 2014 +0000
+++ b/button.cpp	Tue Aug 12 02:51:42 2014 +0000
@@ -1,40 +1,18 @@
-#include "button.h"
-#include "mbed.h"
 /**
  *  @file       button.cpp
  *  Project     button handling Library
  *  @brief      button handling library for mbed
- *  @version    1.02
+ *  @version    1.03
  *  @author     Chuck Timber
- *  @date       07/08/2014
+ *  @date       12/08/2014
  */
-/** class to handle button input 
+
+#include "button.h"
+#include "mbed.h"
+
+/* class to handle button input 
  *   The class use DigitalIn and Ticker
  *
- * Example:
- * @code
- * // Button sample
- * #include "mbed.h"
- * #include "button.h"
- * 
- * BTN btn(dp13);
- * 
- * int main()
- * {
- *     int mode = 0;
- *     int value;
- * 
- *     btn.CMD = 0;
- *     while(1) {
- *         if(btn.CMD) {
- *             mode++;
- *             btn.CMD = 0;
- *             srand( time(NULL) );
- *         }
- *         if (mode % 2) value = rand();
- *     }
- * }
- * @endcode
  */
 
 using namespace mbed;
--- a/button.h	Sat Aug 09 07:02:10 2014 +0000
+++ b/button.h	Tue Aug 12 02:51:42 2014 +0000
@@ -1,19 +1,26 @@
+/**
+ *  @file       button.h
+ *  Project     button handling Library
+ *  @brief      button handling library for mbed
+ *  @version    1.03
+ *  @author     Chuck Timber
+ *  @date       12/08/2014
+ */
+
 #ifndef MBED_BUTTON_H
 #define MBED_BUTTON_H
 
 #include "mbed.h"
 
-/**
- *  @file       button.h
- *  Project     button handling Library
- *  @brief      button handling library for mbed
- *  @version    1.0
- *  @author     Chuck Timber
- *  @date       07/08/2014
+/** @defines
  */
+#define BTN_SAMPLING_PERIOD 0.01
 
-/** class to handle button input 
- *   The class use DigitalIn and Ticker
+namespace mbed
+{
+
+/** Class: BTN
+ *  A class handles button input procedure, which uses DigitalIn and Ticker
  *
  * Refered to: http://elm-chan.org/docs/tec/te03.html
  *
@@ -22,14 +29,14 @@
  * // Button sample
  * #include "mbed.h"
  * #include "button.h"
- * 
+ *
  * BTN btn(dp13);
- * 
+ *
  * int main()
  * {
  *     int mode = 0;
  *     int value;
- * 
+ *
  *     btn.CMD = 0;
  *     while(1) {
  *         if(btn.CMD) {
@@ -42,20 +49,26 @@
  * }
  * @endcode
  */
-
-#define BTN_SAMPLING_PERIOD 0.01
-
-namespace mbed {
-
-/** Class: BTN
- *  A class handles button input procedure, which uses DigitalIn and Ticker
- */
-class BTN {
+class BTN
+{
 
 public:
+    unsigned char CMD;   /*!< CMD represents that the button has been pressed.
+                          *   @retval 1 - button has been pressed
+                          */
+
+    unsigned char STAT;  /*!< STAT represents that the button is being pressed.
+                          *   @retval 1 - button is being pressed
+                          */
+
+    /** constructor
+     *
+     *  @param pin - button pin number (DigitalIn), the pin is PullUp internally
+     */
     BTN(PinName pin);
-    unsigned char CMD;
-    unsigned char STAT;
+
+    /// destructor
+    virtual ~BTN() { };
 
 private:
     /** sample_btn input and process */