受け取りのコントローラのプログラム

Dependencies:   TextLCD mbed MultiSerial Pswitch_Lib

Revision:
3:cfd7cd361088
Parent:
2:7820849bf534
Child:
4:39edc16ee5c3
--- a/main.cpp	Thu Sep 04 22:17:32 2014 +0000
+++ b/main.cpp	Mon Sep 08 02:39:40 2014 +0000
@@ -15,7 +15,6 @@
 volatile uint8_t count=0;
 
 void SetUp();
-bool GetBit(uint8_t n, uint8_t bit);
 uint8_t LinkBit(bool eight, bool seven, bool six, bool five, bool fore, bool three, bool two, bool one);
 void illumination();
 
@@ -40,10 +39,16 @@
     while(1) {
         
         YLED=!Toggle;
+        if(Toggle){
+            
+            EXdata[0] = LinkBit(!CrossKey[YELLOW][LEFT], !CrossKey[RED][LEFT], !CrossKey[GREEN][LEFT], !CrossKey[BLUE][LEFT], 
+                                !CrossKey[YELLOW][RIGHT], !CrossKey[RED][RIGHT], !CrossKey[GREEN][RIGHT], !CrossKey[BLUE][RIGHT]);
+            EXdata[1] = LinkBit(0, 0, 0, 0, !SideKey[INDEX][LEFT], !SideKey[MIDDLE][LEFT], !SideKey[INDEX][RIGHT], !SideKey[MIDDLE][RIGHT]);
+        }else{
+            
+            EXdata[0] = EXdata[1] = 0x00;
+        }
         
-        EXdata[0] = LinkBit(!CrossKey[YELLOW][LEFT], !CrossKey[RED][LEFT], !CrossKey[GREEN][LEFT], !CrossKey[BLUE][LEFT], 
-                            !CrossKey[YELLOW][RIGHT], !CrossKey[RED][RIGHT], !CrossKey[GREEN][RIGHT], !CrossKey[BLUE][RIGHT]);
-        EXdata[1] = LinkBit(0, 0, 0, 0, !SideKey[INDEX][LEFT], !SideKey[MIDDLE][LEFT], !SideKey[INDEX][RIGHT], !SideKey[MIDDLE][RIGHT]);
     }
 }
 
@@ -71,9 +76,6 @@
     
     flick.attach(illumination, INTERVAL);
 }
-bool GetBit(uint8_t n, uint8_t bit){//整数nのbitビット目は1か0か.
-    return (n>>(bit-1))%2;
-}
 uint8_t LinkBit(bool eight, bool seven, bool six, bool five, bool fore, bool three, bool two, bool one){//0と1を集めて整数を作る
     return 0x80*eight + 0x40*seven + 0x20*six + 0x10*five + 0x08*fore + 0x04*three + 0x02*two + 0x01*one;
 }