Using at Craft Club

Dependencies:   FatFileSystem mbed

Files at this revision

API Documentation at this revision

Comitter:
Quoli
Date:
Tue Jan 27 17:06:52 2015 +0000
Parent:
0:606b230e5b4a
Commit message:
Using at Craft Club

Changed in this revision

FATFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
L2CAP.cpp Show annotated file Show diff for this revision Revisions of this file
Output.cpp Show annotated file Show diff for this revision Revisions of this file
TestShell.cpp 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
--- a/FATFileSystem.lib	Sat Apr 10 00:30:24 2010 +0000
+++ b/FATFileSystem.lib	Tue Jan 27 17:06:52 2015 +0000
@@ -1,1 +1,1 @@
-http://mbed.org/users/mbed_unsupported/code/fatfilesystem/
\ No newline at end of file
+http://mbed.org/users/mbed_unsupported/code/fatfilesystem/#333d6e93e58f
--- a/L2CAP.cpp	Sat Apr 10 00:30:24 2010 +0000
+++ b/L2CAP.cpp	Tue Jan 27 17:06:52 2015 +0000
@@ -206,7 +206,12 @@
     int cc = data[8];
     printf(L2CAP_ComandCodeStr(cc));
     int result = LE16(data+16);
-    printf(" Result %d\n",result);
+    //printf("\n");
+    //for(int i= 0; i < len; i++)
+    //{
+    //    printf("data[%d] = %d\n",i,data[i]);
+    //}
+    //printf(" Result %d\n",result);
     switch (cc)
     {
         case L2CAP_COMMAND_REJ:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Output.cpp	Tue Jan 27 17:06:52 2015 +0000
@@ -0,0 +1,155 @@
+#include "mbed.h"
+
+//各キー格納用
+int Key_A = 0;
+int Key_B = 0;
+int Key_Up = 0;
+int Key_Down = 0;
+int Key_Left = 0;
+int Key_Right = 0;
+
+int Key_1 = 0;
+int Key_2 = 0;
+
+int Key_Home = 0;
+int Key_Plus = 0;
+int Key_Minus = 0;
+
+//テスト用
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+DigitalOut led3(LED3);
+DigitalOut led4(LED4);
+
+//PWM出力用
+PwmOut pwm1(p21);   
+PwmOut pwm2(p22);
+PwmOut pwm3(p23);
+PwmOut pwm4(p24);
+PwmOut pwm5(p25);
+PwmOut pwm6(p26);
+
+void setup ()// 最初の処理
+{
+    pwm1.period(0.010);     //PWMの周期指定 10[ms]に指定
+    pwm2.period(0.010);
+    pwm3.period(0.010);
+    pwm4.period(0.010);
+    pwm5.period(0.010);
+    pwm6.period(0.010);
+}
+
+void Button(int pad){
+    
+    //HomeKeyの感知
+    if (pad >= 0x8000){
+        Key_Home = 1;
+        pad -= 0x8000;
+    }
+    else{
+        Key_Home = 0;
+    }
+    
+    //マイナスKeyの感知
+    if (pad >= 0x1000){
+        Key_Minus = 1;
+        pad -= 0x1000;
+    }
+    else{
+        Key_Minus =0;
+    }
+    
+    //AKeyの感知
+    if (pad >= 0x0800){
+        Key_A = 1;
+        pad -= 0x0800;
+    }
+    else{
+        Key_A =0;
+    }
+    
+    //BKeyの感知
+    if (pad >= 0x0400){
+        Key_B = 1;
+        pad -= 0x0400;
+    }
+    else{
+        Key_B =0;
+    }
+    
+    //1Keyの感知
+    if (pad >= 0x0200){
+        Key_1 = 1;
+        pad -= 0x0200;
+    }
+    else{
+        Key_1 =0;
+    }
+    
+    //2Keyの感知
+    if (pad >= 0x0100){
+        Key_2 = 1;
+        pad -= 0x0100;
+    }
+    else{
+        Key_2 =0;
+    }
+    
+    //PlusKeyの感知
+    if (pad >= 0x0010){
+        Key_Plus = 1;
+        pad -= 0x0010;
+    }
+    else{
+        Key_Plus =0;
+    }
+    
+    //UpKeyの感知
+    if (pad >= 0x0008){
+        Key_Up = 1;
+        pad -= 0x0008;
+    }
+    else{
+        Key_Up =0;
+    }
+    
+    //DownKeyの感知
+    if (pad >= 0x0004){
+        Key_Down = 1;
+        pad -= 0x0004;
+    }
+    else{
+        Key_Down =0;
+    }
+    
+    //RightKeyの感知
+    if (pad >= 0x0002){
+        Key_Right = 1;
+        pad -= 0x0002;
+    }
+    else{
+        Key_Right =0;
+    }
+    
+    //LeftKeyの感知
+    if (pad >= 0x0001){
+        Key_Left = 1;
+        pad -= 0x0001;
+    }
+    else{
+        Key_Left =0;
+    }
+}
+
+ void PWM_Control(int pad,int x,int y,int z)
+{
+    Button(pad);
+    
+    if (Key_A == 1){
+        pwm1 = 0.5;
+        pwm4 = 0.5;
+    }
+    //デバッグ表示用
+    //printf("A %d B %d + %d - %d U %d D %d L %d R %d 1 %d 2 %d \n",Key_A,Key_B,Key_Plus,Key_Minus,Key_Up,Key_Down,Key_Left,Key_Right,Key_1,Key_2);
+    //printf("WII %04X %d %d %d\n",pad,x,y,z);
+}
\ No newline at end of file
--- a/TestShell.cpp	Sat Apr 10 00:30:24 2010 +0000
+++ b/TestShell.cpp	Tue Jan 27 17:06:52 2015 +0000
@@ -29,6 +29,7 @@
 #include "Utils.h"
 #include "USBHost.h"
 #include "hci.h"
+void PWM_Control(int pad,int x,int y,int z);
 
 void printf(const BD_ADDR* addr)
 {
@@ -131,7 +132,7 @@
                     int x = (d[2] & 0x60) >> 5 | d[4] << 2;
                     int y = (d[3] & 0x20) >> 4 | d[5] << 2;
                     int z = (d[3] & 0x40) >> 5 | d[6] << 2;
-                    printf("WII %04X %d %d %d\n",pad,x,y,z);
+                    PWM_Control(pad,x,y,z);
                 }
                 break;
                 default:
--- a/main.cpp	Sat Apr 10 00:30:24 2010 +0000
+++ b/main.cpp	Tue Jan 27 17:06:52 2015 +0000
@@ -111,10 +111,12 @@
     return c;
 }
 
+void setup();
 void TestShell();
 
 int main()
 {
+    setup();
     pc.baud(460800);
     printf("BlueUSB\nNow get a bunch of usb or bluetooth things and plug them in\n");
     TestShell();