Skip to content

Commit

Permalink
Servo index mapping for Photon and P1 (Photon RedBoard)
Browse files Browse the repository at this point in the history
  • Loading branch information
rwaldron committed Oct 4, 2015
1 parent 49b0e10 commit e0de891
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions firmware/voodoospark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,12 +211,25 @@ Servo servos[8];
servo object.
*/
int ToServoIndex(int pin) {
// D0, D1
if (pin == 0 || pin == 1) return pin;
// A0, A1
if (pin == 10 || pin == 11) return pin - 8;
// A4, A5, A6, A7
if (pin >= 14) return pin - 10;
#if PLATFORM_ID == PLATFORM_PHOTON_PRODUCTION || \
PLATFORM_ID == PLATFORM_P1
// Pin: D0, D1, D2, D3
// Index: 0, 1, 2, 3
if (pin == 0 || pin == 1 || pin == 2 || pin == 3) return pin;
// Pin: A4, A5
// Index: 4, 5
if (pin >= 14) return pin - 10;
#else
// Pin: D0, D1
// Index: 0, 1
if (pin == 0 || pin == 1) return pin;
// Pin: A0, A1
// Index: 2, 3
if (pin == 10 || pin == 11) return pin - 8;
// Pin: A4, A5, A6, A7
// Index: 4, 5, 6, 7
if (pin >= 14) return pin - 10;
#endif
}

void send(int action, int pinOrPort, int pinOrPortValue) {
Expand Down

0 comments on commit e0de891

Please sign in to comment.