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.
Revision 2:72d7f93f2881, committed 2013-09-14
- Comitter:
- Reiko
- Date:
- Sat Sep 14 17:16:32 2013 +0000
- Parent:
- 1:83b43784d90c
- Commit message:
- Made code shorter
Changed in this revision
| qed.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/qed.cpp Sat Aug 31 15:54:44 2013 +0000
+++ b/qed.cpp Sat Sep 14 17:16:32 2013 +0000
@@ -4,13 +4,7 @@
: interruptA(channelA), interruptB(channelB) {
pulses = 0;
-
- //Workout what the current state is.
- int chanA = interruptA.read();
- int chanB = interruptB.read();
-
- //2-bit state.
- currState = (chanA << 1) | (chanB);
+ currState = (interruptA.read() << 1) | (interruptB.read());
prevState = currState;
interruptA.rise(this, &QED::decode);
@@ -26,20 +20,14 @@
}
void QED::decode() {
-
- int change = 0;
- int chanA = interruptA.read();
- int chanB = interruptB.read();
-
- currState = (chanA << 1) | (chanB);
-
- change = (prevState & PREV_MASK) ^ ((currState & CURR_MASK) >> 1);
+ currState = (interruptA.read() << 1) | (interruptB.read());
+
+ int change = (prevState & PREV_MASK) ^ ((currState & CURR_MASK) >> 1);
if (change == 0) {
change = -1;
}
- pulses -= change;
-
+ pulses -= change;
prevState = currState;
}
\ No newline at end of file
