Clicks mouse

Dependencies:   mbed USBDevice

Files at this revision

API Documentation at this revision

Comitter:
tadhgjones
Date:
Thu Dec 17 13:38:13 2020 +0000
Commit message:
Mouse Click

Changed in this revision

USBDevice.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
diff -r 000000000000 -r 7e0200844583 USBDevice.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Thu Dec 17 13:38:13 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/sparkfun/code/USBDevice/#2af474687369
diff -r 000000000000 -r 7e0200844583 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Dec 17 13:38:13 2020 +0000
@@ -0,0 +1,62 @@
+// USB Device demo - control mouse pointer with buttons
+
+#include "mbed.h"
+#include "USBMouse.h"
+
+// USB Mouse object
+USBMouse mouse;
+
+// Define buttons
+DigitalIn button_click(p5);
+DigitalIn button_scrollup(p6);
+DigitalIn button_scrolldown(p7);
+
+
+DigitalOut myled(LED1);
+
+Timer timer1;
+
+int main() {
+    int x;
+    int y;
+    int z;
+    
+ 
+    while (1) {
+        y = 1;
+        z = 1;
+        x = -1;
+        
+
+        if ( button_scrolldown ) {
+            x = 0;
+        }
+        
+        if ( button_click ) {
+            z = 0;
+        }
+        
+        if ( button_scrollup ) {
+            y = 0;
+        }
+
+        // Click mouse
+        
+        timer1.start();
+        if (timer1.read_ms()>=100) {
+            mouse.click(z); //cliicks
+            timer1.stop();
+            timer1.reset();
+        }
+        
+        mouse.scroll(y); //scrolls up
+        mouse.scroll(x); //scrolls down
+        
+        mouse.release(1);
+
+
+
+        // Wait for next cycle
+        
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 7e0200844583 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu Dec 17 13:38:13 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/65be27845400
\ No newline at end of file