| ??? 07/27/00 20:08 Read: times |
#4023 - RE: Rotary knob and INT in C |
> If I go UP slowly the increment is sometime by 2 ?
> If I do DOWN sometimes the increment is by 1 ! This sounds like you are missing one of the state transitions and assume things are increasing. If you need some logic that determins the direction of travel -- possibly by looking at the direction just before the transition was missed. This might be harder if you slept. Also, You should make your reads of A and B atomic (one operation.) Read the whole port and extract the pieces from that. I would also go in a loop and only use the paired values when they match a previous read. This is even _before_ doing real debouncing code. Do something like... int getAB() { int sample1 = in(portX) & A_B; int sample2; while ( (sample2= in(portX) & A_B) != sample1 ) sample1 = sample2; return sample1; } <>< Lance. |
| Topic | Author | Date |
| Rotary knob and INT in C | 01/01/70 00:00 | |
| RE: Rotary knob and INT in C | 01/01/70 00:00 | |
| RE: Rotary knob and INT in C | 01/01/70 00:00 | |
| RE: Rotary knob and INT in C | 01/01/70 00:00 | |
| RE: Rotary knob and INT in C | 01/01/70 00:00 | |
| RE: Rotary knob and INT in C | 01/01/70 00:00 | |
| RE: Rotary knob and INT in C | 01/01/70 00:00 | |
| RE: Rotary knob and INT in C | 01/01/70 00:00 | |
| RE: Rotary knob and INT in C | 01/01/70 00:00 | |
| RE: Rotary knob and INT in C | 01/01/70 00:00 | |
| RE: Rotary knob and INT in C | 01/01/70 00:00 | |
| RE: Rotary knob and INT in C | 01/01/70 00:00 | |
RE: Rotary knob and INT in C | 01/01/70 00:00 |



