mirror of
https://github.com/anklimov/lighthub
synced 2026-01-29 17:49:06 +03:00
Encoder support
This commit is contained in:
@@ -155,24 +155,31 @@ void Input::encoderPoll() {
|
|||||||
|
|
||||||
void Input::attachInterruptPinIrq(int realPin, int irq) {
|
void Input::attachInterruptPinIrq(int realPin, int irq) {
|
||||||
pinMode(realPin, INPUT);
|
pinMode(realPin, INPUT);
|
||||||
|
int real_irq;
|
||||||
|
#if defined(__AVR__)
|
||||||
|
real_irq = irq;
|
||||||
|
#endif
|
||||||
|
#if defined(__SAM3X8E__)
|
||||||
|
real_irq = realPin;
|
||||||
|
#endif
|
||||||
switch(irq){
|
switch(irq){
|
||||||
case 0:
|
case 0:
|
||||||
attachInterrupt(realPin, onEncoderChanged0, RISING);
|
attachInterrupt(real_irq, onEncoderChanged0, RISING);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
attachInterrupt(realPin, onEncoderChanged1, RISING);
|
attachInterrupt(real_irq, onEncoderChanged1, RISING);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
attachInterrupt(realPin, onEncoderChanged2, RISING);
|
attachInterrupt(real_irq, onEncoderChanged2, RISING);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
attachInterrupt(realPin, onEncoderChanged3, RISING);
|
attachInterrupt(real_irq, onEncoderChanged3, RISING);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
attachInterrupt(realPin, onEncoderChanged4, RISING);
|
attachInterrupt(real_irq, onEncoderChanged4, RISING);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
attachInterrupt(realPin, onEncoderChanged5, RISING);
|
attachInterrupt(real_irq, onEncoderChanged5, RISING);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
Serial.print(F("Incorrect irq:"));Serial.println(irq);
|
Serial.print(F("Incorrect irq:"));Serial.println(irq);
|
||||||
|
|||||||
Reference in New Issue
Block a user