In this mode the lamp will shape the light into a bell curve. This is meant to be more asthetically\\r\\n"
" pleasing than the regular colour mode.<\\/p>\\r\\n"
"
\\r\\n"
"
\\r\\n"
"<\\/div>\\r\\n");
- const char *tabScript = PSTR("bellCurveDebunce = Date.now()\\r\\n"
+ }
+
+ virtual const char *getTabScript()
+ {
+ return PSTR("bellCurveDebunce = Date.now()\\r\\n"
"var bellRed = 0\\r\\n"
"var bellGreen = 0\\r\\n"
"var bellBlue = 0\\r\\n"
@@ -123,9 +131,5 @@ public:
" }\\r\\n"
" }\\r\\n"
"}\\r\\n");
-
- String htmlJSON = String("{\"Tab\" : {") + "\"Name\": \"" + modeName + "\", \"tabHtml\" : \"" + tabHtml + "\", \"tabScript\" : \"" + tabScript + "\"}}";
-
- _webSocketServer.broadcastTXT(htmlJSON.c_str());
}
};
diff --git a/Super_Simple_RGB_WiFi_Lamp/ModeClock.ino b/Super_Simple_RGB_WiFi_Lamp/ModeClock.ino
index 18bed98..6068825 100644
--- a/Super_Simple_RGB_WiFi_Lamp/ModeClock.ino
+++ b/Super_Simple_RGB_WiFi_Lamp/ModeClock.ino
@@ -103,10 +103,14 @@ public:
}
}
- virtual void sendWebsiteData(WebSocketsServer &_webSocketServer)
+ virtual const char *getName()
{
- const char *modeName = "Clock";
- const char *tabHtml = PSTR("
Clock Mode<\\/h2>\\r\\n"
+ return "Clock";
+ }
+
+ virtual const char *getTabHtml()
+ {
+ return PSTR("Clock Mode<\\/h2>\\r\\n"
" In this mode the light will display the current time in 12 hr format uisng the\\r\\n"
" top and bottom side of the light. On the top is the current hour, and the bottom is the minute. The left\\r\\n"
" of teh light represents 0 and the right represents either 12hr or 60mins. You can choose the colour of\\r\\n"
@@ -117,7 +121,11 @@ public:
" Hour Colour<\\/button>\\r\\n"
" Minute Colour<\\/button>\\r\\n"
"<\\/div>\\r\\n");
- const char *tabScript = PSTR("clockHourDebunce = Date.now()\\r\\n"
+ }
+
+ virtual const char *getTabScript()
+ {
+ return PSTR("clockHourDebunce = Date.now()\\r\\n"
"clockMinDebunce = Date.now()\\r\\n"
"var currentHourRed = 0\\r\\n"
"var currentHourGreen = 0\\r\\n"
@@ -305,8 +313,5 @@ public:
" }\\r\\n"
" }\\r\\n"
"}\\r\\n");
- String htmlJSON = String("{\"Tab\" : {") + "\"Name\": \"" + modeName + "\", \"tabHtml\" : \"" + tabHtml + "\", \"tabScript\" : \"" + tabScript + "\"}}";
-
- _webSocketServer.broadcastTXT(htmlJSON.c_str());
}
};
diff --git a/Super_Simple_RGB_WiFi_Lamp/ModeColour.ino b/Super_Simple_RGB_WiFi_Lamp/ModeColour.ino
index 097f7d3..d39195e 100644
--- a/Super_Simple_RGB_WiFi_Lamp/ModeColour.ino
+++ b/Super_Simple_RGB_WiFi_Lamp/ModeColour.ino
@@ -19,10 +19,14 @@ public:
settings["Blue"] = colourBlue = settings["Blue"] | colourBlue;
}
- virtual void sendWebsiteData(WebSocketsServer &_webSocketServer)
+ virtual const char *getName()
{
- const char *modeName = "Colour";
- const char *tabHtml = PSTR("Colour Mode<\\/h2>\\r\\n"
+ return "Colour";
+ }
+
+ virtual const char *getTabHtml()
+ {
+ return PSTR("Colour Mode<\\/h2>\\r\\n"
" Here you can set the light to any colour you desire. There are also a couple of buttons for setting the light to different shades of white<\\/p>\\r\\n"
"\\r\\n"
"
\\r\\n"
@@ -43,7 +47,11 @@ public:
"
3000K<\\/button>\\r\\n"
" 4000K<\\/button>\\r\\n"
"<\\/div>\\r\\n");
- const char *tabScript = PSTR("var currentRed = 0;\\r\\n"
+ }
+
+ virtual const char *getTabScript()
+ {
+ return PSTR("var currentRed = 0;\\r\\n"
"var currentGreen = 0;\\r\\n"
"var currentBlue = 0;\\r\\n"
"var colourDebunce = Date.now()\\r\\n"
@@ -154,9 +162,5 @@ public:
" }\\r\\n"
" }\\r\\n"
"}\\r\\n");
-
- String htmlJSON = String("{\"Tab\" : {") + "\"Name\": \"" + modeName + "\", \"tabHtml\" : \"" + tabHtml + "\", \"tabScript\" : \"" + tabScript + "\"}}";
-
- _webSocketServer.broadcastTXT(htmlJSON.c_str());
}
};
diff --git a/Super_Simple_RGB_WiFi_Lamp/ModeNightRider.ino b/Super_Simple_RGB_WiFi_Lamp/ModeNightRider.ino
index 918a3fd..522b694 100644
--- a/Super_Simple_RGB_WiFi_Lamp/ModeNightRider.ino
+++ b/Super_Simple_RGB_WiFi_Lamp/ModeNightRider.ino
@@ -36,14 +36,22 @@ public:
{
}
- virtual void sendWebsiteData(WebSocketsServer &_webSocketServer)
+ virtual const char *getName()
{
- const char *modeName = "Night Rider";
- const char *tabHtml = PSTR("Night Rider Mode<\\/h2>\\r\\n"
+ return "Night Rider";
+ }
+
+ virtual const char *getTabHtml()
+ {
+ return PSTR("Night Rider Mode<\\/h2>\\r\\n"
" Knight Rider. A shadowy flight into the dangerous world of a man who does not exist.\\r\\n"
" Michael Knight: a young loner on a crusade to champion the cause of the innocent,\\r\\n"
" the helpless, the powerless, in a world of criminals who operate above the law.<\\/p>\\r\\n");
- const char *tabScript = PSTR("messageEventList.push(handleNightRiderMessage)\\r\\n"
+ }
+
+ virtual const char *getTabScript()
+ {
+ return PSTR("messageEventList.push(handleNightRiderMessage)\\r\\n"
"\\r\\n"
"function handleNightRiderMessage(jsonMessage) {\\r\\n"
" if (\\\"Night Rider\\\" in jsonMessage) {\\r\\n"
@@ -53,8 +61,5 @@ public:
" }\\r\\n"
" }\\r\\n"
"}\\r\\n");
- String htmlJSON = String("{\"Tab\" : {") + "\"Name\": \"" + modeName + "\", \"tabHtml\" : \"" + tabHtml + "\", \"tabScript\" : \"" + tabScript + "\"}}";
-
- _webSocketServer.broadcastTXT(htmlJSON.c_str());
}
};
diff --git a/Super_Simple_RGB_WiFi_Lamp/ModeRainbow.ino b/Super_Simple_RGB_WiFi_Lamp/ModeRainbow.ino
index 10d5561..3d2e0e7 100644
--- a/Super_Simple_RGB_WiFi_Lamp/ModeRainbow.ino
+++ b/Super_Simple_RGB_WiFi_Lamp/ModeRainbow.ino
@@ -52,10 +52,14 @@ public:
settings["Brightness"] = rainbowBri = settings["Brightness"] | rainbowBri;
}
- virtual void sendWebsiteData(WebSocketsServer &_webSocketServer)
+ virtual const char *getName()
{
- const char *modeName = "Rainbow";
- const char *tabHtml = PSTR("
Rainbow Mode<\\/h2>\\r\\n"
+ return "Rainbow";
+ }
+
+ virtual const char *getTabHtml()
+ {
+ return PSTR("Rainbow Mode<\\/h2>\\r\\n"
" Here you can set the mode to rainbow. This mode produces a rainbow all the way around the light and\\r\\n"
" slowly shifts the colours clockwise. On this page you can set the speed of this as well as the\\r\\n"
" brightness of the light<\\/p>\\r\\n"
@@ -71,8 +75,11 @@ public:
" Rainbow Speed: 10<\\/span> seconds<\\/label>\\r\\n"
" \\r\\n"
"<\\/div>\\r\\n");
+ }
- const char *tabScript = PSTR("var rainbowDebunce = Date.now()\\r\\n"
+ virtual const char *getTabScript()
+ {
+ return PSTR("var rainbowDebunce = Date.now()\\r\\n"
"var rainbowLastMessage = \\\"\\\"\\r\\n"
"\\r\\n"
"messageEventList.push(handleRainbowMessage)\\r\\n"
@@ -171,8 +178,5 @@ public:
" sendMessage(msg)\\r\\n"
" }\\r\\n"
"}\\r\\n");
- String htmlJSON = String("{\"Tab\" : {") + "\"Name\": \"" + modeName + "\", \"tabHtml\" : \"" + tabHtml + "\", \"tabScript\" : \"" + tabScript + "\"}}";
-
- _webSocketServer.broadcastTXT(htmlJSON.c_str());
}
};
diff --git a/Super_Simple_RGB_WiFi_Lamp/Super_Simple_RGB_WiFi_Lamp.ino b/Super_Simple_RGB_WiFi_Lamp/Super_Simple_RGB_WiFi_Lamp.ino
index 5f00748..01b4aa2 100644
--- a/Super_Simple_RGB_WiFi_Lamp/Super_Simple_RGB_WiFi_Lamp.ino
+++ b/Super_Simple_RGB_WiFi_Lamp/Super_Simple_RGB_WiFi_Lamp.ino
@@ -59,7 +59,9 @@ class ModeBase
public:
virtual void render();
virtual void applyConfig(JsonVariant& settings);
- virtual void sendWebsiteData(WebSocketsServer& _webSocketServer);
+ virtual const char *getName();
+ virtual const char *getTabHtml();
+ virtual const char *getTabScript();
};
std::map modes;
diff --git a/Super_Simple_RGB_WiFi_Lamp/Websockets.ino b/Super_Simple_RGB_WiFi_Lamp/Websockets.ino
index efb3aee..63b80c2 100644
--- a/Super_Simple_RGB_WiFi_Lamp/Websockets.ino
+++ b/Super_Simple_RGB_WiFi_Lamp/Websockets.ino
@@ -82,7 +82,8 @@ bool updateClients() {
// Send each of the modes data
for ( auto it = modes.begin(); it != modes.end(); it++ ) {
- it->second->sendWebsiteData(webSocket);
+ String htmlJSON = String("{\"Tab\" : {") + "\"Name\": \"" + it->second->getName() + "\", \"tabHtml\" : \"" + it->second->getTabHtml() + "\", \"tabScript\" : \"" + it->second->getTabScript() + "\"}}";
+ webSocket.broadcastTXT(htmlJSON.c_str());
}
// Get and Send