suu pen / Mbed 2 deprecated SwAnalogInputLibraryExampleProgram

Dependencies:   SwAnalog_LPC1768 mbed

Fork of SwAnalogInputLibraryExampleProgram by suu pen

Files at this revision

API Documentation at this revision

Comitter:
suupen
Date:
Sun Dec 22 09:27:26 2013 +0000
Parent:
0:7ce3de2c24c3
Commit message:
This program is used to verify the operations of the library SW recognize an analog port.

Changed in this revision

SwAnalog.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 7ce3de2c24c3 -r c4d2d6df69ce SwAnalog.lib
--- a/SwAnalog.lib	Sun Feb 12 00:52:09 2012 +0000
+++ b/SwAnalog.lib	Sun Dec 22 09:27:26 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/suupen/code/SwAnalog/#ba027616fdf1
+http://mbed.org/users/suupen/code/SwAnalog_LPC1768/#3cdb536ed157
diff -r 7ce3de2c24c3 -r c4d2d6df69ce main.cpp
--- a/main.cpp	Sun Feb 12 00:52:09 2012 +0000
+++ b/main.cpp	Sun Dec 22 09:27:26 2013 +0000
@@ -1,11 +1,11 @@
-//********************************************************************
+// ********************************************************************
 // 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  |----|
 //    |   ---------   |   ---------   |   ---------   |   ---------    |
@@ -13,17 +13,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"
@@ -35,27 +38,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 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);
+
+        //===========================================
+        // SW level action
+        //===========================================        
+        // sw0 : OFF:LED1=ON   ON:LED1=OFF
+        led1 = sw.checkLevel(sw0);
         
-        // tact action (sw2 level = off : led3 = on)
-        led3 = sw.checkLevel(2);
+        // sw1 : OFF:LED2=OFF  ON:LED2=ON
+        led2 = !sw.checkLevel(sw1);
         
-        // 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;
+        //===========================================
+        // 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;
         }
     }
+        
+ 
 }
diff -r 7ce3de2c24c3 -r c4d2d6df69ce mbed.bld
--- a/mbed.bld	Sun Feb 12 00:52:09 2012 +0000
+++ b/mbed.bld	Sun Dec 22 09:27:26 2013 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/b4b9f287a47e
+http://mbed.org/users/mbed_official/code/mbed/builds/b4b9f287a47e
\ No newline at end of file