Buffered Test

Dependencies:   ExioBufferdController MCP23S17 mbed-rtos mbed

Revision:
11:325c5e9d28e2
Parent:
10:5d1a09afe152
Child:
13:219ff2cfa3c3
--- a/main.cpp	Fri Nov 04 23:37:24 2016 +0000
+++ b/main.cpp	Sat Nov 05 00:04:17 2016 +0000
@@ -226,9 +226,12 @@
     
     // Reset MCP23S17 (初期化時にreset()が必要)
     Exio.reset();
-    
+
+    // ExioInBuffer
+    ExioInBuffer inBufferA(&Exio, ExioPortA);    
+    ExioInBuffer inBufferB(&Exio, ExioPortB);
+
     // PinDetect
-    ExioInBuffer inBufferA(&Exio, ExioPortA);
     ExioBufferedPinDetect pinA6(&inBufferA, 6);
     ExioBufferedPinDetect pinA7(&inBufferA, 7);
     
@@ -239,7 +242,9 @@
     pinA7.setAssertValue(0);
     
     // DebounceIn
-    ExioInBuffer inBufferB(&Exio, ExioPortB);
+    ExioBufferedDebounceIn pinA4(&inBufferA, 4);
+    ExioBufferedDebounceIn pinA5(&inBufferA, 5);
+    
     ExioBufferedDebounceIn inB[] = {
         ExioBufferedDebounceIn(&inBufferB, 0),
         ExioBufferedDebounceIn(&inBufferB, 1),
@@ -251,6 +256,10 @@
         ExioBufferedDebounceIn(&inBufferB, 7)
     };
     
+    // Rotary Encoder
+    ExioBufferedRotaryEncoder re1(&inBufferA, 0, 1);
+    ExioBufferedRotaryEncoder re2(&inBufferA, 2, 3);
+    
     // Start Timers for polling MCP23S17
     inBufferA.run(5);
     inBufferB.run(10);
@@ -260,16 +269,26 @@
     pinA7.setSampleFrequency(10000);
     
     // Start Timers for DebounceIn
+    pinA4.set_debounce_us(10000);
+    pinA5.set_debounce_us(10000);
     for (int i = 0; i < 8; i++) {
         inB[i].set_debounce_us(10000);
-        inB[i].set_debounce_us(10000);
     }
+    
+    // Start Timers for RotaryEncoder
+    re1.setInterval(1000);
+    re2.setInterval(1000);
 
     while(true) {
+        int va4 = pinA4.read();
+        int va5 = pinA5.read();
+        int vre1 = re1.getVal();
+        int vre2 = re2.getVal();
+        printf(" A4:%d A5:%d state:%d count:%d RE1:%d RE2:%d  ", va4, va5, state, count, vre1, vre2);
         for (int i = 0; i < 8; i++) {
-            int va = inB[i].read();
-            printf("%d ", va);
+            int vb = inB[i].read();
+            printf("%d ", vb);
         }
-        printf(" %d %d  \r\n", state, count);
+        printf("\r\n");
     }
-}
\ No newline at end of file
+}