Skip to content

Commit bcb33f4

Browse files
committed
disable auto mode
1 parent 731dcdb commit bcb33f4

File tree

3 files changed

+29
-12
lines changed

3 files changed

+29
-12
lines changed

SolArduino_atom/SolArduino/SolArduino.ino

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ bool panelsStopped = true; //needed to control timer logic
6767
unsigned long moveTimeout = millis(); //moving timeout timer
6868
const int MOVE_TIMEOUT_DELTA = 4000; // time in milliseconds for the panels to stop moving after having received no command
6969

70+
// Whether automatically requesting angles and auto mode which uses them, are enabled.
71+
const boolean ENABLE_AUTO = false;
72+
7073

7174
void setup () {
7275
//the serial shouldn't be used in final code, but this is always in development...
@@ -75,7 +78,9 @@ void setup () {
7578
setPinModes();
7679
setupEthernet();
7780
setupNTP();
78-
setupNAS();
81+
if (ENABLE_AUTO) {
82+
setupNAS();
83+
}
7984
setupPanels();
8085
}
8186

@@ -84,16 +89,22 @@ void loop () {
8489
ether.packetLoop(ether.packetReceive());
8590
receiveHttpRequests(); //be responsive as a webserver
8691
checkMovingTimeout();
87-
if (responseReceived && (EmergencyState == "") ) { // a check to make sure we don't request angles again before we received the ones we already had requested
88-
if (tableIndex+1 >= TABLE_LENGTH) { //if we are at the end
89-
requestNewTable();
90-
} else if (autoMode && dates[tableIndex+1]<now()) { //if time walked into next part
91-
Serial.println(F("Advancing to next angle"));
92-
tableIndex++;
93-
Serial.println(angles[tableIndex]);
94-
setSolarPanel(angles[tableIndex]);
92+
93+
if (ENABLE_AUTO) {
94+
95+
if (responseReceived && (EmergencyState == "") ) { // a check to make sure we don't request angles again before we received the ones we already had requested
96+
if (tableIndex+1 >= TABLE_LENGTH) { //if we are at the end
97+
requestNewTable();
98+
} else if (autoMode && dates[tableIndex+1]<now()) { //if time walked into next part
99+
Serial.println(F("Advancing to next angle"));
100+
tableIndex++;
101+
Serial.println(angles[tableIndex]);
102+
setSolarPanel(angles[tableIndex]);
103+
}
95104
}
105+
96106
}
107+
97108
//stop always on emergencies
98109
if (!(EmergencyState == "")) {
99110
solarPanelStop();

SolArduino_atom/SolArduino/communication.ino

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ void receiveHttpRequests() {
3737
autoMode = false;
3838
}
3939
else if (strncmp("?panel=auto ", data, 12) == 0) {
40+
if (ENABLE_AUTO) {
4041
Serial.println(F("Auto mode switched on."));
4142
autoMode = true; //solarPanelAuto() is called later, first we handle off the request
4243
int angle = getNextAngle();
@@ -45,6 +46,9 @@ void receiveHttpRequests() {
4546
response += angle;
4647
response += "_degrees.";
4748
acknowledge(response.c_str());
49+
} else {
50+
acknowledge("Sorry, someone has disabled auto mode.");
51+
}
4852
}
4953
else if (strncmp("?panel=manual ", data, 12) == 0){
5054
acknowledge("Auto mode switched off.");

SolArduino_atom/SolArduino/setup.ino

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ void setupNAS() {
6060
void setupPanels() {
6161
solarPanelStop(); //just in case, default is stopped
6262
autoMode = false; // by default, do nothing (safer)
63-
requestNewTable(); //fill the angles and dates arrays
64-
while(!responseReceived) { //wait for response before continuing
65-
ether.packetLoop(ether.packetReceive()); //keep receiving response
63+
if (ENABLE_AUTO) {
64+
requestNewTable(); //fill the angles and dates arrays
65+
while(!responseReceived) { //wait for response before continuing
66+
ether.packetLoop(ether.packetReceive()); //keep receiving response
67+
}
6668
}
6769
}

0 commit comments

Comments
 (0)