Yasuaki Kobayashi / Mbed 2 deprecated Android コントローラー

Dependencies:   MMA8451Q TextLCD mbed

Files at this revision

API Documentation at this revision

Comitter:
NANAPAPA0308
Date:
Fri Oct 10 09:11:23 2014 +0000
Commit message:
Android ???????????????????KL25Z??????????????????????????

Changed in this revision

MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
TextLCD.lib 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
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA8451Q.lib	Fri Oct 10 09:11:23 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TextLCD.lib	Fri Oct 10 09:11:23 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/simon/code/TextLCD/#308d188a2d3a
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Oct 10 09:11:23 2014 +0000
@@ -0,0 +1,86 @@
+#include "mbed.h"
+#include <math.h>
+#include "MMA8451Q.h"
+#include "TextLCD.h"
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+
+
+    //  LCD (RS, E, D4, D5, D6, D7)
+    TextLCD lcd(PTA13, PTD5, PTA4, PTA5, PTC8, PTC9); // LCD Shield for Arduino (DFR00009)
+    //AnalogIn button(PTB0);  // board button
+    PwmOut backlight(PTD0);
+    Serial serial(USBTX,USBRX);
+    DigitalIn BK(PTE5);
+    DigitalIn ACC(PTE4);
+    DigitalIn LIGHT(PTE3);
+    DigitalIn WR(PTE2);
+    DigitalIn WL(PTB11);
+    DigitalIn WIPE(PTB10);
+    int BK1,ACC1,LIGHT1,WR1,WL1,WIPE1;
+    DigitalOut led(LED_RED);
+    int main() {
+    backlight = 1;  // ON: 1, OFF: 0
+    MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+    //if(!BK ){
+    //BK1 = 1;}
+    //else {BK1=0;}
+    
+    PwmOut rled(LED_RED);
+    PwmOut gled(LED_GREEN);
+    PwmOut bled(LED_BLUE);
+    double hnd,hnd1;
+    while (1) {
+        if(!BK ){BK1=1;}
+        else {BK1=0;}
+        if(!ACC ){ACC1=1;}
+        else {ACC1=0;}
+        if(!LIGHT ){LIGHT1=1;}
+        else {LIGHT1=0;}
+        if(!WR ){WR1=1;}
+        else {WR1=0;}
+        if(!WL ){WL1=1;}
+        else {WL1=0;}
+        if(!WIPE ){WIPE1=1;}
+        else {WIPE1=0;}
+        rled = 1.0 - abs(acc.getAccX());
+        gled = 1.0 - abs(acc.getAccY());
+        bled = 1.0 - abs(acc.getAccZ());
+        lcd.locate(0,0);
+        lcd.printf("X=%1.2f", acc.getAccX());  // button value
+        lcd.printf(" ");
+        lcd.locate(8,0);
+        lcd.printf("Y=%1.2f", acc.getAccY());  // button value
+        lcd.printf(" ");
+        lcd.locate(0,1);
+        lcd.printf("Z=%1.2f", acc.getAccZ());  // button value
+        if( acc.getAccX() > 0.99)
+        {hnd1=0.99;}
+        else if(acc.getAccX() < -0.99)
+        {hnd1=-0.99;}
+        else{
+        hnd1 = acc.getAccX();
+        }
+        if( acc.getAccY() < -0.1 )
+        {
+        if( acc.getAccX() < -0.2 )
+        {hnd1=-0.99;}
+        {}
+        }
+        {}
+        if( acc.getAccY() < -0.1 )
+        {
+        if( acc.getAccX() > 0.2 )
+        {hnd1=0.99;}
+        {}
+        }
+        {}
+        
+        
+        hnd = asin(hnd1)/3.14*180;
+        lcd.printf(" ");
+        lcd.locate(8,1);
+        lcd.printf("H=%3.1f", hnd);   // ハンドル
+        serial.printf("{\"x\":%5.2f,\"y\":%5.2f,\"z\":%5.2f,\"hnd\":%3.1f,\"BK1\":%d,\"ACC1\":%d,\"LIGHT1\":%d,\"WR1\":%d,\"WL1\":%d,\"WIPE1\":%d,}\r\n",acc.getAccX(), acc.getAccY(), acc.getAccZ(),hnd,BK1,ACC1,LIGHT1,WR1,WL1,WIPE1);
+        wait(0.3);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Oct 10 09:11:23 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/b3110cd2dd17
\ No newline at end of file