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.
Diff: trackballer.cpp
- Revision:
- 15:a66aea99500e
- Parent:
- 14:d566efcd787b
diff -r d566efcd787b -r a66aea99500e trackballer.cpp
--- a/trackballer.cpp Sun Feb 20 17:33:59 2011 +0000
+++ b/trackballer.cpp Sun Feb 20 18:05:08 2011 +0000
@@ -62,6 +62,9 @@
void trackballer::getState(float &xPosition, float &yPosition, char &button)
{
+ char heldState = 0x00;
+ char isHeld = 0x00;
+ char exitWhile = 0x00;
_buttonState = _buttonPin->read();
@@ -74,6 +77,8 @@
// if the state has changed, increment the counter
if (_buttonState == 1)
{
+
+
/*
while(_buttonPin->read() == _buttonState)
{
@@ -92,6 +97,40 @@
button = 0x01;
//printf("Number of button pushes: %i\n", _buttonPushCounter);
}
+ else if(_buttonState == 0)
+ {
+ _holdTimer.start();
+ while(_holdTimer.read() < 2.0 && !exitWhile)
+ {
+ heldState = !_buttonPin->read();
+
+ if(heldState == 0)
+ {
+ isHeld = 0x00;
+ exitWhile = 0x01;
+ }
+ else
+ {
+ if(_holdTimer.read() > 1.0)
+ {
+ isHeld = 0x01;
+ exitWhile = 0x01;
+ }
+ }
+
+
+ }
+
+ _holdTimer.stop();
+ _holdTimer.reset();
+
+ if(isHeld)
+ {
+ printf("HELD\n");
+ button = 0x03;
+ return;
+ }
+ }
}
else
{