Skip to content

Commit

Permalink
Tidying up
Browse files Browse the repository at this point in the history
  • Loading branch information
johnmckerrell committed Apr 5, 2013
1 parent 5d228c1 commit dc60a72
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 6 deletions.
15 changes: 9 additions & 6 deletions YAHMS_Controller.cpp
Expand Up @@ -69,8 +69,11 @@ Serial.flush();
for (confi = 9; confi < 13; ++confi) {
configSize = (256 * configSize) + EEPROM.read(confi);
}
Serial.print("configSize");
Serial.println(configSize);

int controlBlockValues[8];
int controlBlockValuesSize = 8;
int intVal = -1;
int intIndex = 0;
byte c = '\0';
Expand All @@ -94,15 +97,15 @@ Serial.flush();
memset(controlBlockValues,-1,sizeof(controlBlockValues));
}
} else if (c == '*' && lineMode == 'C') {
if (intIndex < sizeof(controlBlockValues)) {
if (intIndex < controlBlockValuesSize) {
controlBlockValues[intIndex] = -1;
}
intVal = -1;
++intIndex;
} else if (intVal != -1) {
switch(lineMode) {
case 'C':
if (intIndex < sizeof(controlBlockValues)) {
if (intIndex < controlBlockValuesSize) {
controlBlockValues[intIndex] = intVal;
}
break;
Expand All @@ -115,7 +118,7 @@ Serial.flush();
case 'C':
// Check that the length of the time block is greater than zero
// and that the pin that's being turned on is zero or more
for (int f = 0, fl = sizeof(controlBlockValues); f < fl; ++f) { Serial.print(controlBlockValues[f]); Serial.print(":"); }
Serial.print("C:"); for (int f = 0, fl = controlBlockValuesSize; f < fl; ++f) { Serial.print(controlBlockValues[f]); Serial.print(":"); }
Serial.println();

if (controlBlockValues[CB_LEN] > 0 && controlBlockValues[CB_PIN] >= 0) {
Expand Down Expand Up @@ -154,15 +157,15 @@ Serial.flush();
pinState = controlBlockValues[CB_STATE] ? 1 : 0;
#ifdef LOGGING
ACTIVE_CONTROL_BLOCK.print(Serial);
for (int f = 0, fl = sizeof(controlBlockValues); f < fl; ++f) { Serial.print(controlBlockValues[f]); Serial.print(":"); }
for (int f = 0, fl = controlBlockValuesSize; f < fl; ++f) { Serial.print(controlBlockValues[f]); Serial.print(":"); }
Serial.println();
#endif
}
} else if (controlBlockValues[CB_HOUR] == hour(t)) {
pinState = controlBlockValues[CB_STATE] ? 1 : 0;
#ifdef LOGGING
ACTIVE_CONTROL_BLOCK.print(Serial);
for (int f = 0, fl = sizeof(controlBlockValues); f < fl; ++f) { Serial.print(controlBlockValues[f]); Serial.print(":"); }
for (int f = 0, fl = controlBlockValuesSize; f < fl; ++f) { Serial.print(controlBlockValues[f]); Serial.print(":"); }
Serial.println();
#endif
}
Expand All @@ -171,7 +174,7 @@ Serial.flush();
pinState = controlBlockValues[CB_STATE] ? 1 : 0;
#ifdef LOGGING
ACTIVE_CONTROL_BLOCK.print(Serial);
for (int f = 0, fl = sizeof(controlBlockValues); f < fl; ++f) { Serial.print(controlBlockValues[f]); Serial.print(":"); }
for (int f = 0, fl = controlBlockValuesSize; f < fl; ++f) { Serial.print(controlBlockValues[f]); Serial.print(":"); }
Serial.println();
#endif
}
Expand Down
18 changes: 18 additions & 0 deletions YAHMS_Controller.h
@@ -1,4 +1,22 @@
#include <Client.h>
#include <Ethernet.h>
#include <IPAddress.h>

#include <SoftwareSerial.h>
#include <XBee.h>

#include <Time.h>

#include <HttpClient.h>
#include <EEPROM.h>

#include <math.h>

extern int currentPinState[];
extern uint8_t * heapptr;
extern uint8_t * stackptr;

void check_mem();

void SetupController();

Expand Down

0 comments on commit dc60a72

Please sign in to comment.