This library has been tested with LPC1768. I can use the analog port of six of p20 from p15 of the LPC1768.

Dependents:   SwAnalogInputLibraryExampleProgram

Fork of SwAnalog by suu pen

このライブラリについては、次のWebを参照してください。
http://mbed.org/users/suupen/code/SwAnalogInputLibraryExampleProgram/wiki/Homepage

Files at this revision

API Documentation at this revision

Comitter:
suupen
Date:
Sun Dec 22 09:05:06 2013 +0000
Parent:
0:ba027616fdf1
Commit message:
This library is used to perform the SW recognized by the analog port

Changed in this revision

SwAnalog.h Show annotated file Show diff for this revision Revisions of this file
diff -r ba027616fdf1 -r 3cdb536ed157 SwAnalog.h
--- a/SwAnalog.h	Sun Feb 12 00:50:23 2012 +0000
+++ b/SwAnalog.h	Sun Dec 22 09:05:06 2013 +0000
@@ -36,14 +36,14 @@
 *
 * Example:
 * @code
-* //********************************************************************
+* // ********************************************************************
 * // SwAnalogInput Library example program
-* //  mbed no analog port de 3hon no sw wo ninsiki suru.
-* //  6hon no analog port (p15 - p20) de 6 * 3 = 18 ko no sw ninsiki ga dekiru.
+* // Per pin analog port, SW recognition There are three possible.
 * //
 * // <schematic>
 * //   -.- mbed VOUT(+3.3[V])
 * //    |                                               |--------------------> mbed p20(ADinput)
+* //    |    8.2[kohm]       3.9[kohm]       2.0[kohm]  |    1.0[kohm]
 * //    |   ---------       ---------       ---------   |   ---------
 * //    .---| Rsw2  |---.---| Rsw1  |---.---| Rsw0  |---.---| Rout  |----|
 * //    |   ---------   |   ---------   |   ---------   |   ---------    |
@@ -51,17 +51,20 @@
 * //    |-----o  o------.-----o  o------.-----o  o------|              -----
 * //           SW2            SW1              SW0                      mbed GND(0[V])
 * // 
-* //  Rsw2 : 8.2[kohm], Rsw1 = 3.9[kohm], Rsw0 = 2.0[kohm], Rout = 1.0[kohm] (R no seido ha +-1[%])
+* //  
+* //  Accuracy of the resistance value that is within ± 1%
 * //
-* // <program no naiyo>
-* //  mbed LED1 : sw0 no level de tento  sw Off = led Off, sw On = led On
-* //  mbed LED2 : sw1 no level de tento  sw Off = led Off, sw On = led On
-* //  mbed LED3 : sw2 no level de tento  sw Off = led Off, sw On = led On
-* //  mbed LED4 : sw0,sw1,sw2 no Off kara On henka de led tento jotai wo hanten.
+* // <Operation details of this program>
+* //  mbed LED1 : When it detects the ON level of the SW0, and turns the LED1.
+* //  mbed LED2 : When it detects the OFF level of the SW1, and turns the LED2.
+* //  mbed LED3 : When it detects the ON edge of SW2, inverting the output to LED3.
+* //  mbed LED4 : When it detects the OFF edge of SW2, inverting the output to LED4.
 * //
 * // 
-* // <rireki>
-* // 2012/02/12 : syohan
+* // <history>
+* // 120212 : first edtion
+* // 131221 : In this edition, I have changed the behavior of the program content
+* // 
 * // *********************************************************************
 *
 * #include "mbed.h"
@@ -73,29 +76,42 @@
 * DigitalOut led4(LED4);
 *
 * SwAnalog sw(p20);  // p20(adinput) :sw0,sw1,sw2
+*
+* enum{
+*        sw0 = 0,
+*        sw1,
+*        sw2
+*    };
 *                   
 * int main() {
-*     while(1) {
-*         // sw level and edge data refresh
-*         sw.refreshEdgeData();
-*         
-*         // tact action (sw0 level = on : led1 = on)
-*         led1 = sw.checkLevel(0);
-*         
-*         // tact action (sw1 level = off : led2 = on)
-*         led2 = sw.checkLevel(1);
-*         
-*         // tact action (sw2 level = off : led3 = on)
-*         led3 = sw.checkLevel(2);
-*         
-*         // toggle action (sw0 to sw3 level Off to On : led4 invert )
-*         if((sw.checkEdgeOn(0) == 1)   // sw0
-*         || (sw.checkEdgeOn(1) == 1)   // sw1
-*         || (sw.checkEdgeOn(2) == 1)   // sw2
-*         ){
-*              led4 = !led4;
-*         }
-*     }
+*    while(1) {
+*        //===========================================
+*        // sw edge data refresh
+*        //===========================================
+*        sw.refreshEdgeData();
+*
+*        //===========================================
+*        // SW level action
+*        //===========================================        
+*        // sw0 : OFF:LED1=ON   ON:LED1=OFF
+*        led1 = sw.checkLevel(sw0);
+*        
+*        // sw1 : OFF:LED2=OFF  ON:LED2=ON
+*        led2 = !sw.checkLevel(sw1);
+*        
+*        //===========================================
+*        // SW edge action
+*        //===========================================
+*        // sw2 on edge : LED3 invert
+*        if(sw.checkEdgeOn(sw2) == 1){
+*            led3 = !led3;
+*        }
+*        
+*        // sw2 off edge : LED4 invert
+*        if(sw.checkEdgeOff(sw2) == 1){
+*            led4 = !led4;
+*        }
+*    }
 * }
 * @endcode
 */