ec

Dependencies:   USBDevice mbed

Fork of USBMouse_NavSwitch by jim hamblen

Files at this revision

API Documentation at this revision

Comitter:
Josahty
Date:
Mon Jan 22 18:18:48 2018 +0000
Parent:
5:679a07e00e4c
Commit message:
with scrolling ec;

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 679a07e00e4c -r 5032c1e1b3ce main.cpp
--- a/main.cpp	Mon Jun 26 17:27:42 2017 +0000
+++ b/main.cpp	Mon Jan 22 18:18:48 2018 +0000
@@ -3,6 +3,9 @@
 //USB mouse demo using a 5-way Navigation Switch (Digital Joystick)
 //Needs USB connector breakout with D+, D-, and Gnd to mbed LLP1768
 USBMouse mouse;
+PwmOut myled(LED1);
+AnalogIn mypotentiometer(p18);
+Serial pc(USBTX, USBRX);
 
 class Nav_Switch
 {
@@ -64,6 +67,8 @@
 
 int main()
 {
+    float pot_data = 0;
+    float scroll_amount = 0;
     int16_t x = 0;
     int16_t y = 0;
     uint8_t left_click = 0;
@@ -71,6 +76,7 @@
         //check relative mouse movement
         x=0;
         y=0;
+        scroll_amount = 0;
         if (myNav.up()) x=-1;
         if (myNav.down()) x=1;
         if (myNav.left()) y=1;
@@ -79,7 +85,16 @@
         if (myNav.fire()) left_click = 1;
         if (!myNav.fire())left_click = 0;
         //send a mouse data packet to PC
-        mouse.update(x, y, left_click, 0);
+        myled = mypotentiometer;
+        pot_data = mypotentiometer;
+        
+        if (pot_data < 0.25) {
+            scroll_amount = -1; }
+        else if (pot_data > 0.75) {
+            scroll_amount = 1; }      
+        
+        pc.printf("%f \n\r",scroll_amount);
+        mouse.update(x, y, left_click, scroll_amount);
         wait(0.001);
     }
 }
\ No newline at end of file