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
Revision 24:d4b944e1e6cd, committed 2017-04-14
- Comitter:
- jennabarton
- Date:
- Fri Apr 14 18:05:09 2017 +0000
- Parent:
- 23:db56e04d555b
- Child:
- 25:d7418ded06aa
- Commit message:
- updated deadzones and works
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Thu Apr 13 21:41:19 2017 +0000 +++ b/main.cpp Fri Apr 14 18:05:09 2017 +0000 @@ -52,11 +52,12 @@ //movement const int deadzone = 1; -const int mouseMoveMult = 3; -const double mouseMovePwr = 1.4; +const int mouseMoveMult = 1; +const double mouseMovePwr = 1.2; +const int MOVEMENT_CAP = 20; //click state -const int CLICK_DEAD_ZONE = 20; +const int CLICK_DEAD_ZONE = 40; int clickBaseX; int clickBaseY; int clickDurCount = 0; @@ -164,7 +165,7 @@ short diffY = -1*(curry - prevy); //fix diffX - if(abs(diffX) > 10) { + if(abs(diffX) > MOVEMENT_CAP) { diffX = 0; } else if(diffX > deadzone){ diffX -= deadzone; @@ -174,7 +175,7 @@ diffX = 0; } //fix diffY - if(abs(diffY) > 10) { + if(abs(diffY) > MOVEMENT_CAP) { diffY = 0; } else if(diffY > deadzone){ diffY -= deadzone; @@ -188,8 +189,9 @@ //mouseCommand(0, (char) diffX, (char) diffY); //TODO: this is defaulting to first finger - need to fix this //update target position to move x and y - updatex[0] = diffX; - updatey[0] = diffY; + //accumulates the diff until + updatex[0] = updatex[0] + diffX; + updatey[0] = updatey[0] + diffY; // pc.printf("updating x to : %d", diffX); @@ -302,8 +304,10 @@ //populates onex and oney with values depending on the measured points //NOTE: 1023 means nothing was detected void readCameraData(void){ - - //pc.printf("in read camera data \n"); + //update previous values + //only updates for finger 1 + prevX = onex[0]; + prevY = oney[0]; //request data from camera char out[1]; @@ -330,9 +334,9 @@ updateClickState(onex[0], oney[0], prevX, prevY); - //update prev values - prevX = onex[0]; - prevY = oney[0]; + // //update prev values + // prevX = onex[0]; + // prevY = oney[0]; //<<<<<<<<<<<<<<<<End unfinished code for moving averages @@ -454,7 +458,7 @@ //uncomment below to test infinite print - //keyOut.putc(0x41); +// keyOut.putc(0x41); //uncomment below to infinitely move mouse in a square // double delay = 0.1;