アナログポート から スイッチを3つ認識するライブラリです。 6つのアナログポートを同時に認識して、18個のSWまで認識できます。

Dependents:   kitchenTimer LPC1114FN28_kitchenTimer_Clock

Files at this revision

API Documentation at this revision

Comitter:
suupen
Date:
Mon Nov 25 05:50:21 2013 +0000
Parent:
0:ba027616fdf1
Commit message:
The Library was modified for use in the LPC1114FN28.
;
;
;
;

Changed in this revision

SwAnalog.cpp Show annotated file Show diff for this revision Revisions of this file
SwAnalog.h Show annotated file Show diff for this revision Revisions of this file
--- a/SwAnalog.cpp	Sun Feb 12 00:50:23 2012 +0000
+++ b/SwAnalog.cpp	Mon Nov 25 05:50:21 2013 +0000
@@ -12,6 +12,7 @@
 // syokika
 //======================================================================
 
+#ifdef LPC1768
     SwAnalog::SwAnalog(PinName adinput0, PinName adinput1, PinName adinput2, PinName adinput3, PinName adinput4,
                          PinName adinput5
                          ):
@@ -32,9 +33,27 @@
     
     
     // sw ninsiki syuki 10[ms]
-    swCheckTimer.attach_us(this, &SwAnalog::input, Z_matchcycle); 
+//  swCheckTimer.attach_us(this, &SwAnalog::input, Z_matchcycle); 
         
 }
+#else // ~LPC1768
+    SwAnalog::SwAnalog(PinName adinput0, PinName adinput1
+                         ):
+                         _adinput0(adinput0),   _adinput1(adinput1)
+                         {
+       
+    //---------------------------------
+    // touroku sareta Sw Suu wo kakunin
+    //---------------------------------
+    if(adinput0 != NC){D_swPinSuu = 1;}
+    if(adinput1 != NC){D_swPinSuu = 2;}
+   
+    
+    // sw ninsiki syuki 10[ms]
+  swCheckTimer.attach_us(this, &SwAnalog::input, Z_matchcycle); 
+        
+}
+#endif // LPC1768
 
 //=================================================
 // analog input data wo sw data ni henkan
@@ -66,7 +85,7 @@
 void SwAnalog::input(void){
     // genzai level input
     switch(D_swPinSuu){
-
+#ifdef LPC1768
     case 6:
         adInput(_adinput5, 5);
         //break;
@@ -79,6 +98,7 @@
     case 3:
         adInput(_adinput2, 2);
         //break;        
+#endif // LPC1768
     case 2:
         adInput(_adinput1, 1);
         //break;        
@@ -179,3 +199,4 @@
 
     return (ans);
 }
+
--- a/SwAnalog.h	Sun Feb 12 00:50:23 2012 +0000
+++ b/SwAnalog.h	Mon Nov 25 05:50:21 2013 +0000
@@ -32,11 +32,13 @@
 
 #include "mbed.h"
 
+//#define LPC1768
+
 /** SWANALOG control class, based on a "mbed function"
 *
 * 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.
@@ -114,10 +116,15 @@
     *
     * Recognition of the SW period is 10ms
     */
+  
+#ifdef LPC1768
     SwAnalog(PinName adinput0  = NC, PinName adinput1  = NC, PinName adinput2 = NC, PinName adinput3  = NC, PinName adinput4  = NC,
               PinName adinput5  = NC
               );
-
+#else // ~LPC1768
+   SwAnalog(PinName adinput0  = NC, PinName adinput1  = NC
+              );
+#endif // LPC1768
     /** refresh edge data
     *
     * @param none 
@@ -158,6 +165,7 @@
     * @param  ....
     * @param adinput5 : Z_sw16 tp Z_sw18
     */
+#ifdef LPC1768
     enum{
         Z_sw0,  // adinput1 no sw
         Z_sw1,
@@ -183,9 +191,20 @@
         Z_sw16,
         Z_sw17
         };
-    
+#else // ~LPC1768
+    enum{
+        Z_sw0,  // adinput1 no sw
+        Z_sw1,
+        Z_sw2,
+        
+        Z_sw3,  // adinput2 no sw
+        Z_sw4,
+        Z_sw5
+    };
+#endif // LPC1768
 //protected:    
-private:
+
+#ifdef LPC1768
    AnalogIn _adinput0;
    AnalogIn _adinput1;
    AnalogIn _adinput2;
@@ -193,7 +212,10 @@
    AnalogIn _adinput4;
 
    AnalogIn _adinput5;
-   
+#else // ~LPC1768
+   AnalogIn _adinput0;
+   AnalogIn _adinput1;
+#endif   
    
    Ticker swCheckTimer;