Skip to content

Commit

Permalink
factor out pin mapping
Browse files Browse the repository at this point in the history
  • Loading branch information
phooky committed Oct 4, 2011
1 parent 7c6ffeb commit 8277cf4
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions OWSascroller/OWSascroller.pde
Expand Up @@ -45,6 +45,10 @@ typedef enum {
SCROLLING
} Mode;

inline int rowPin(const int row) {
return ROW_START_PIN - row;
}

Mode mode = SCROLLING;
Direction dir = LEFT;

Expand Down Expand Up @@ -158,14 +162,14 @@ int onRow = -1;
// Handle descending pin order
inline void rowOff() {
if (onRow != -1) {
digitalWrite(ROW_START_PIN - onRow,LOW);
digitalWrite(rowPin(onRow),LOW);
onRow = -1;
}
}


inline void rowOn(int row) {
digitalWrite(ROW_START_PIN - row,HIGH);
digitalWrite(rowPin(onRow),HIGH);
onRow = row;
}

Expand All @@ -179,8 +183,8 @@ void setup() {
// DATA 2: A2
// DATA 3: A3
for (int i = 0; i < columns; i++) {
pinMode(i+ROW_START_PIN,OUTPUT);
digitalWrite(i+ROW_START_PIN,LOW);
pinMode(rowPin(i),OUTPUT);
digitalWrite(rowPin(i),LOW);
}
onRow = -1;

Expand Down

0 comments on commit 8277cf4

Please sign in to comment.