1 #ifndef ServoFeedback_h
2 #define ServoFeedback_h
18 template <u
int8_t NUM_SERVOS>
27 for (uint8_t i = 0; i < NUM_SERVOS; i++)
38 for (uint8_t i = 0 ; i < NUM_SERVOS; i++)
40 uint8_t pin = pgm_read_byte(&fPins[i]);
47 if (fLastRead + 15 < millis())
49 if (fCurrentServo < NUM_SERVOS)
51 uint8_t pin = pgm_read_byte(&fPins[fCurrentServo]);
52 uint16_t val = analogRead(pin);
53 fPos[fCurrentServo] = map(val, 100, 512, 0, 255);
54 if (++fCurrentServo >= NUM_SERVOS)
61 inline uint8_t
getRaw(uint8_t servoNum)
63 return (servoNum <= NUM_SERVOS) ? fPos[servoNum] : 0;
68 return map(
getRaw(servoNum), 0, 254, 0, 180);
73 uint8_t fPos[NUM_SERVOS];
74 uint8_t fCurrentServo;