Ryo Od / Mbed 2 deprecated ExioController_Test

Dependencies:   ExioController MCP23S17 mbed-rtos mbed

Revision:
13:1688ed45cccd
Parent:
12:5f0db7a87485
Child:
14:3a2c33129716
--- a/main.cpp	Fri Nov 04 14:17:33 2016 +0000
+++ b/main.cpp	Fri Nov 04 14:30:54 2016 +0000
@@ -12,10 +12,11 @@
 // MExioMcp23s17(int hardwareaddress, SPI& spi, PinName nCs, PinName nReset);
 ExioMcp23s17 Exio(0x00, Spi, PD_2, PA_13);
 
-/*
+
 bool state = false;
 uint8_t count = 0;
 
+/*
 // トグル動作
 void pa6Falled() {
     state = !state;
@@ -27,6 +28,7 @@
 }
 */
 
+/*
 void TestExioMcp23s17DebounceIn()
 {
     printf("\r\n\n*** ExioMcp23s17DebouceIn test ***\r\n");
@@ -75,16 +77,17 @@
         printf("\r\n");
     } 
 }    
+*/
 
 int main()
 {
-    TestExioMcp23s17DebounceIn();
+    //TestExioMcp23s17DebounceIn();
     
-    /*
     printf("\r\n\n*** ExioMcp23s17Controller test ***\r\n");
     
     Exio.reset();
-
+    
+    /*
     ExioMcp23s17PinDetect PinA6(&Exio, ExioPortA, 6);
     ExioMcp23s17PinDetect PinA7(&Exio, ExioPortA, 7);
     
@@ -96,6 +99,7 @@
     PinA7.attach_asserted(&pa7Falled);
     PinA7.setAssertValue(0);
     PinA7.setSampleFrequency();
+    */
     
     // set PORTA[0:1], PORTA[2:3] as a Rotary Encoder
     //    ExioMcp23s17RotaryEncoder(
@@ -103,9 +107,7 @@
     //    int min = 0, int max = 100, int val = 50
     //);
     ExioMcp23s17RotaryEncoder RotEnc1(&Exio, ExioPortA, 0, 1, 0, 100, 50);
-    RotEnc1.setInterval(500);
     ExioMcp23s17RotaryEncoder RotEnc2(&Exio, ExioPortA, 2, 3, 0, 100, 50);
-    RotEnc2.setInterval(500);
 
     // set PORTB[0:7] as debouce inputs
     ExioMcp23s17DebounceIn* psw[8];
@@ -113,16 +115,25 @@
         psw[i] = new ExioMcp23s17DebounceIn(&Exio, ExioPortB, i);
         psw[i]->mode(PullUp);
     }
+    
+    RotEnc1.setInterval(500);
+    RotEnc2.setInterval(500);
+    for (int i = 0; i < 8; i++) {
+        psw[i]->set_debounce_us(1000);
+    }
   
     while (true) {
         int reVal1, reVal2;
         reVal1 = RotEnc1.getVal();
         reVal2 = RotEnc2.getVal();
-        printf("state:%d count:%d RE1:%d RE2:%d\r\n", state, count, reVal1, reVal2);
+        printf("state:%d count:%d RE1:%d RE2:%d  ", state, count, reVal1, reVal2);
+        for (int i = 0; i < 8; i++) {
+            printf("%d ", psw[i]->read());
+        }
+        printf("\r\n");
 
         Thread::wait(10);
     }
     
-    delete[] psw;
-    */
+    //delete[] psw;
 }