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 11:cd450ce343a8, committed 2017-04-01
- Comitter:
- jennabarton
- Date:
- Sat Apr 01 22:13:22 2017 +0000
- Parent:
- 10:d67a15ba5748
- Child:
- 12:e127fa20d609
- Commit message:
- implemented x,y mvmt for point 1
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Sat Apr 01 21:49:47 2017 +0000 +++ b/main.cpp Sat Apr 01 22:13:22 2017 +0000 @@ -115,19 +115,34 @@ oney[0] = point1y + ((s & 0xC0) << 2); - //>>>>>>>>>>>>>>>>>Begin unfinished code for moving averages - - int change = 50; + //>>>>>>>>>>>>>>>>>Begin unfinished code for moving + + int deadzone = 5; //look at delta btwn prev val and current //TODO: moving average if((prevX != 1023 || prevY != 1023) && (onex[0] != 1023 && oney[0] != 1023)){ - if(onex[0] - prevX > 5){ - //move right - mouseCommand(0,(char) change,0); - } else if ((onex[0] - prevX) < -5){ - //move left - mouseCommand(0,(char) -1*change,0); + int diffX = onex[0] - prevX; + int diffY = -1*(oney[0] - prevY); + + //fix diffX + if(diffX > deadzone){ + diffX -= deadzone; + } else if (diffX < -1*deadzone){ + diffX += deadzone; + } else{ + diffX = 0; } + //fix diffY + if(diffY > deadzone){ + diffY -= deadzone; + } else if (diffX < -1*deadzone){ + diffY += deadzone; + } else{ + diffY = 0; + } + + //move x and y + mouseCommand(0, (char) diffX, (char) diffY); } //update prev values