Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: main.cpp
- Revision:
- 10:d67a15ba5748
- Parent:
- 9:55473409c585
- Child:
- 11:cd450ce343a8
--- a/main.cpp Sat Apr 01 20:34:56 2017 +0000
+++ b/main.cpp Sat Apr 01 21:49:47 2017 +0000
@@ -59,30 +59,21 @@
//TODO: get rid of these b/c they don't work. instead use printc
//
-//void mouseCommand(uint8_t buttons, uint8_t x, uint8_t y) {
-// keyOut.putc(0xFD);
-// keyOut.putc(0x00);
-// keyOut.putc(0x03);
-// keyOut.putc(buttons);
-// keyOut.putc(x);
-// keyOut.putc(y);
-// keyOut.putc(0x00);
-// keyOut.putc(0x00);
-// keyOut.putc(0x00);
-//}
-//
-//void keyCommand(uint8_t modifiers, uint8_t keycode1, uint8_t keycode2 = 0, uint8_t keycode3 = 0,
-// uint8_t keycode4 = 0, uint8_t keycode5 = 0, uint8_t keycode6 = 0) {
-// keyOut.putc(0xFD); // our command
-// keyOut.putc(modifiers); // modifier!
-// keyOut.putc(0x00); // 0x00
-// keyOut.putc(keycode1); // key code #1
-// keyOut.putc(keycode2); // key code #2
-// keyOut.putc(keycode3); // key code #3
-// keyOut.putc(keycode4); // key code #4
-// keyOut.putc(keycode5); // key code #5
-// keyOut.putc(keycode6); // key code #6
-//}
+void mouseCommand(char buttons, char x, char y) {
+ keyOut.putc(0xFD);
+ keyOut.putc(0x00);
+ keyOut.putc(0x03);
+ keyOut.putc(buttons);
+ keyOut.putc(x);
+ keyOut.putc(y);
+ keyOut.putc(0x00);
+ keyOut.putc(0x00);
+ keyOut.putc(0x00);
+
+ //delay for pushing data
+ wait(0.1);
+}
+
// Initialize WiiMote Camera
void initCamera(void){
@@ -126,14 +117,16 @@
//>>>>>>>>>>>>>>>>>Begin unfinished code for moving averages
+ int change = 50;
//look at delta btwn prev val and current
//TODO: moving average
- if(prevX != 1023 || prevY != 1023){
+ if((prevX != 1023 || prevY != 1023) && (onex[0] != 1023 && oney[0] != 1023)){
if(onex[0] - prevX > 5){
- keyOut.putc(0x41);
+ //move right
+ mouseCommand(0,(char) change,0);
} else if ((onex[0] - prevX) < -5){
- keyOut.putc(0x42);
-
+ //move left
+ mouseCommand(0,(char) -1*change,0);
}
}
@@ -222,18 +215,21 @@
//uncomment below to test infinite print
//keyOut.putc(0x41);
-
+
- //uncomment below to infinitely move mouse up
- keyOut.putc(0xFD);
- keyOut.putc(0x00);
- keyOut.putc(0x03);
- keyOut.putc(0x00); //button press
- keyOut.putc(0x00); //x direction
- keyOut.putc(0x50); //y direction
- keyOut.putc(0x00);
- keyOut.putc(0x00);
- keyOut.putc(0x00);
+ //uncomment below to infinitely move mouse up and down
+// double delay = 0.1;
+// int change = 75;
+// mouseCommand(0,0, (char) -1*change);
+// wait(delay);
+// mouseCommand(0,(char) -1*change,0);
+// wait(delay);
+// mouseCommand(0,0, (char) change);
+// wait(delay);
+// mouseCommand(0,(char) change,0);
+// wait(delay);
+ //mouseCommand(0,0,(char) 100);
+ //wait(.05);
}

