// include third party libraries
#include "WebServer.h"
-// include in-house libs
-#include "PanikSwitch.h" // contains variable types for panik switch
-
// define SD and Ethernet select ports
#define SD_SELECT 4
#define ETHERNET_SELECT 10
#define NONSTOP_VIA_STUD1 14 // is nonstop coming out of studio 1
#define NONSTOP_VIA_STUD2 15 // is nonstop coming out of studio 2
+/* status */
+#define NONSTOP 0
+#define STUDIO1 1
+#define STUDIO2 2
+
+
+/* relay positions */
+typedef enum { RELAY_STATE_OPEN, RELAY_STATE_CLOSED } relayState_t;
/* define an array with led pins,
/* activeSelection is the variable that holds the active output of the switch
it is declared as an attribute that keeps its value between arduino resets
*/
-switchSelection_t activeSelection = 0; // __attribute__ ((section (".noinit")));
+int activeSelection = NONSTOP;
// variables and timers for blinking selection (selected but not confirmed)
-switchSelection_t blinkingSelection = nonstop;
+int blinkingSelection = NONSTOP;
bool blinkingLedState = RELAY_STATE_CLOSED;
unsigned long blinkingStartTime = 0, blinkingAbortTime = 0;
{
if (strcmp(name, "s") == 0) {
digitalWrite(ledsArray[activeSelection], RELAY_STATE_CLOSED);
- blinkingSelection = static_cast<switchSelection_t>(atoi(value));
- activeSelection = static_cast<switchSelection_t>(atoi(value));
+ blinkingSelection = atoi(value);
+ activeSelection = atoi(value);
response_status = POST_OK;
notify_udp();
// setup function
void setup()
{
- blinkingSelection = activeSelection = nonstop;
+ blinkingSelection = activeSelection = NONSTOP;
// open serial communication for debugging
Serial.begin(9600);
#endif
digitalWrite(ledsArray[blinkingSelection], RELAY_STATE_CLOSED);
blinkingSelection++;
+ if (blinkingSelection > STUDIO2) {
+ blinkingSelection = NONSTOP;
+ }
blinkingStartTime = millis(),
blinkingAbortTime = millis();
blinkingLedState = RELAY_STATE_OPEN;
digitalWrite(ledsArray[activeSelection], RELAY_STATE_OPEN);
// update audio channel relays
- if (activeSelection == nonstop)
+ if (activeSelection == NONSTOP)
{
digitalWrite(RELAY_NONSTOP_OR_STUD, RELAY_STATE_CLOSED);
digitalWrite(RELAY_STUD1_OR_STUD2, RELAY_STATE_CLOSED);
}
- else if (activeSelection == studio1)
+ else if (activeSelection == STUDIO1)
{
digitalWrite(RELAY_NONSTOP_OR_STUD, RELAY_STATE_OPEN);
digitalWrite(RELAY_STUD1_OR_STUD2, RELAY_STATE_CLOSED);
}
- else if (activeSelection == studio2)
+ else if (activeSelection == STUDIO2)
{
digitalWrite(RELAY_NONSTOP_OR_STUD, RELAY_STATE_OPEN);
digitalWrite(RELAY_STUD1_OR_STUD2, RELAY_STATE_OPEN);