test

Dependencies:   MMA8451Q RN42 mbed-rtos mbed

Files at this revision

API Documentation at this revision

Comitter:
trisjph
Date:
Mon Dec 16 10:26:46 2013 +0000
Commit message:
inital;

Changed in this revision

MMA8451Q.lib Show annotated file Show diff for this revision Revisions of this file
RN42.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-rtos.lib 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	Mon Dec 16 10:26:46 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/emilmont/code/MMA8451Q/#c4d879a39775
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/RN42.lib	Mon Dec 16 10:26:46 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/trisjph/code/RN42/#30f62fde3cf4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Mon Dec 16 10:26:46 2013 +0000
@@ -0,0 +1,77 @@
+#include "mbed.h"
+#include "rtos.h"
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+#include "MMA8451Q.h"
+#include "RN42.h"
+#define PI 3.14159265
+
+PwmOut led1(LED1);
+MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+AnalogIn ain(PTC2);
+Serial pc(USBTX, USBRX);
+//USBMouseKeyboard key_mouse;
+Mutex BT_mutex;
+//USBHID key_mouse;
+
+void click_thread(void const *args)
+{
+    int press;
+    while(true) {
+        if( (ain.read()>0.3) && (press == 0) ) {
+            press = 1;
+            led1 != led1;
+            pc.printf("%i\n", press);
+            BT_mutex.lock();
+            //key_mouse.press(MOUSE_LEFT);
+            BT_mutex.unlock();
+        } else if ( (ain.read()<0.3) && (press == 1) ) {
+            press = 0;
+            pc.printf("%i\n", press);
+            BT_mutex.lock();
+           // key_mouse.release(MOUSE_LEFT);
+            BT_mutex.unlock();
+        }
+        Thread::wait(100);
+    }
+}
+
+void mouse_thread(void const *args)
+{
+    while(true) {
+
+        BT_mutex.lock();
+        RN42_mouse(-acc.getAccX()*100, acc.getAccY()*100);
+        BT_mutex.unlock();
+        Thread::wait(10);
+    }
+}
+
+void heartbeat_thread(void const *args)
+{
+    int i;
+    led1.period(0.001);
+    while(true) {
+        for(i=0; i<180; i++) {
+            led1 = sin(i*PI/180);
+            Thread::wait(10);
+        }
+    }
+
+}
+
+int main()
+{
+    pc.baud(115200);
+    RN42_init();
+    //RN42_HID();
+    //RN42_connect();
+
+    //Thread click(click_thread);
+    Thread mouse(mouse_thread);
+    Thread heartbeat(heartbeat_thread);
+
+    led1 = 1.0;
+
+    while (true) {
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-rtos.lib	Mon Dec 16 10:26:46 2013 +0000
@@ -0,0 +1,1 @@
+https://mbed.org/users/mbed_official/code/mbed-rtos/#29007aef10a4
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Mon Dec 16 10:26:46 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/a9913a65894f
\ No newline at end of file