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:
- 25:d7418ded06aa
- Parent:
- 24:d4b944e1e6cd
- Child:
- 26:f6aa46b550c3
diff -r d4b944e1e6cd -r d7418ded06aa main.cpp
--- a/main.cpp Fri Apr 14 18:05:09 2017 +0000
+++ b/main.cpp Fri Apr 14 19:03:16 2017 +0000
@@ -54,16 +54,18 @@
const int deadzone = 1;
const int mouseMoveMult = 1;
const double mouseMovePwr = 1.2;
-const int MOVEMENT_CAP = 20;
+const int MOVEMENT_CAP = 20; //working on the computer with 20
+const int VALUES_TO_TOSS = 6;
+int tossedValuesCounter = VALUES_TO_TOSS;
//click state
-const int CLICK_DEAD_ZONE = 40;
+const int CLICK_DEAD_ZONE = 50;
int clickBaseX;
int clickBaseY;
int clickDurCount = 0;
bool readingClick = false;
-int minLeftClickDur = 0;
-int maxLeftClickDur = 100;
+int minLeftClickDur = 10;
+int maxLeftClickDur = 50;
@@ -138,11 +140,14 @@
//click
if(toLeftClick){
//send command to
- mouseCommand(0x01, 0 , 0);
+ //mouseCommand(0, clickBaseX - onex[0] , clickBaseY - oney[0]);
+ mouseCommand(0x01, 0, 0);
- } else if (toRightClick){
- mouseCommand(0x02, 0 , 0);
- }
+ }
+ //TODO: right click
+ //else if (toRightClick){
+// mouseCommand(0x02, 0 , 0);
+// }
//fip clicking to false
toLeftClick = false;
@@ -270,24 +275,36 @@
}
- } else if (currx != 1023 && curry != 1023 && prevx == 1023 && prevy == 1023 ){
+ } // rising edge
+ else if (currx != 1023 && curry != 1023 && prevx == 1023 && prevy == 1023 ){
//finger has been placed on surface
+
+ //tossedValuesCounter = VALUES_TO_TOSS;
//set reading click to true
readingClick = true;
+
+
//save initial location
clickBaseX = currx;
clickBaseY = curry;
- } else if (currx == 1023 && curry == 1023 && readingClick){
+ //} else if (currx == 1023 && curry == 1023 && readingClick){
+ } else if (currx == 1023 && curry == 1023 && prevx == 1023 && prevy == 1023 && readingClick){
//stable click and finger was removed
//if within bounds, you want to click
if(clickDurCount > minLeftClickDur && clickDurCount < maxLeftClickDur){
//set state to indicate left click
toLeftClick = true;
- pc.printf("********LEFT mouse click \n");
+ // pc.printf("********LEFT mouse click \n");
+
+
+ //toss out accumulations of diffs
+ updatex[0] = 0;
+ updatey[0] = 0;
+
}
@@ -330,7 +347,16 @@
//>>>>>>>>>>>>>>>>>Begin unfinished code for moving
- oneFingerResponse(onex[0], oney[0], prevX, prevY);
+ //if(tossedValuesCounter > 0){
+// tossedValuesCounter -= 1;
+// }else{
+// oneFingerResponse(onex[0], oney[0], prevX, prevY);
+// }
+ if(!readingClick){
+ oneFingerResponse(onex[0], oney[0], prevX, prevY);
+ }
+
+
updateClickState(onex[0], oney[0], prevX, prevY);

