| 120 | return ret; |
| 121 | } |
| 122 | inline int32_t readAndReset() { |
| 123 | if (interrupts_in_use < 2) { |
| 124 | noInterrupts(); |
| 125 | update(&encoder); |
| 126 | } else { |
| 127 | noInterrupts(); |
| 128 | } |
| 129 | int32_t ret = encoder.position; |
| 130 | encoder.position = 0; |
| 131 | interrupts(); |
| 132 | return ret; |
| 133 | } |
| 134 | inline void write(int32_t p) { |
| 135 | noInterrupts(); |
| 136 | encoder.position = p; |