Skip to content

Commit

Permalink
Use a constant for buffer lengths
Browse files Browse the repository at this point in the history
Scary magic numbers
  • Loading branch information
dustin committed Dec 20, 2014
1 parent ec6b7f6 commit 8588c81
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 7 deletions.
5 changes: 2 additions & 3 deletions DS2406.cpp
Expand Up @@ -8,7 +8,7 @@ OneWireSwitch::OneWireSwitch(OneWire *b, uint8_t *addr) {
}

bool OneWireSwitch::getSwitchState(int port) {
uint8_t status[10];
uint8_t status[DS2406_STATE_BUF_LEN];
readStatus(status);
return (status[7] & port) == 0;
}
Expand Down Expand Up @@ -37,9 +37,8 @@ void OneWireSwitch::readStatus(uint8_t *buffer) {
bus->write(0, 1);
bus->write(0, 1);

for(int i = 0; i<10; i++) {
for(int i = 0; i<DS2406_STATE_BUF_LEN; i++) {
buffer[i] = bus->read();
}
bus->reset();
}

2 changes: 2 additions & 0 deletions DS2406.h
Expand Up @@ -10,6 +10,8 @@
#define PIO_A 0x20
#define PIO_B 0x40

#define DS2406_STATE_BUF_LEN 10

// Represents a single 1wire switch on an MLan.
class OneWireSwitch {

Expand Down
2 changes: 0 additions & 2 deletions examples/Hello/Hello.pde
Expand Up @@ -24,5 +24,3 @@ void loop(void)

delay(1000);
}


2 changes: 0 additions & 2 deletions examples/SearchAndBlink/SearchAndBlink.pde
Expand Up @@ -97,5 +97,3 @@ void loop(void)
}
delay(1000);
}


0 comments on commit 8588c81

Please sign in to comment.