Skip to content

Commit 5cf69e0

Browse files
author
gemi254
committed
Updated v1.1.2
1 parent 39f90dc commit 5cf69e0

File tree

1 file changed

+21
-21
lines changed

1 file changed

+21
-21
lines changed

examples/ControlAssist-Scope/ControlAssist-Scope.ino

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22
#include <ControlAssist.h> // Control assist class
33

44
#if defined(ESP32)
5-
WebServer server(80);
5+
WebServer server(80);
66
#define ADC_PIN 36
7-
#include <ESPmDNS.h>
7+
#include <ESPmDNS.h>
88
#else
99
ESP8266WebServer server(80);
1010
#define ADC_PIN A0
1111
#include <ESP8266mDNS.h>
1212
#endif
1313

14-
const char st_ssid[]=""; // Put connection SSID here. On empty an AP will be started
15-
const char st_pass[]=""; // Put your wifi passowrd.
14+
const char st_ssid[]=""; // Put connection SSID here. On empty an AP will be started
15+
const char st_pass[]=""; // Put your wifi passowrd.
1616
unsigned long pingMillis = millis(); // Ping millis
1717
bool isPlaying = false;
1818
unsigned long speed = 40; // Read delay
@@ -40,24 +40,24 @@ void setup() {
4040
Serial.begin(115200);
4141
Serial.print("\n\n\n\n");
4242
Serial.flush();
43-
LOG_I("Starting..\n");
43+
LOG_I("Starting..\n");
4444
// Connect WIFI ?
4545
if(strlen(st_ssid)>0){
4646
LOG_E("Connect Wifi to %s.\n", st_ssid);
4747
WiFi.mode(WIFI_STA);
4848
WiFi.begin(st_ssid, st_pass);
4949
uint32_t startAttemptTime = millis();
50-
while (WiFi.status() != WL_CONNECTED && millis() - startAttemptTime < 15000) {
50+
while (WiFi.status() != WL_CONNECTED && millis() - startAttemptTime < 20000) {
5151
Serial.print(".");
5252
delay(500);
5353
Serial.flush();
54-
}
54+
}
5555
Serial.println();
56-
}
56+
}
5757

5858
// Check connection
5959
if(WiFi.status() == WL_CONNECTED ){
60-
LOG_I("Wifi AP SSID: %s connected, use 'http://%s' to connect\n", st_ssid, WiFi.localIP().toString().c_str());
60+
LOG_I("Wifi AP SSID: %s connected, use 'http://%s' to connect\n", st_ssid, WiFi.localIP().toString().c_str());
6161
}else{
6262
LOG_E("Connect failed.\n");
6363
LOG_I("Starting AP.\n");
@@ -66,51 +66,51 @@ void setup() {
6666
String hostName = "ControlAssist_" + mac.substring(6);
6767
WiFi.mode(WIFI_AP_STA);
6868
WiFi.softAP(hostName.c_str(),"",1);
69-
LOG_I("Wifi AP SSID: %s started, use 'http://%s' to connect\n", WiFi.softAPSSID().c_str(), WiFi.softAPIP().toString().c_str());
70-
if (MDNS.begin(hostName.c_str())) LOG_V("AP MDNS responder Started\n");
69+
LOG_I("Wifi AP SSID: %s started, use 'http://%s' to connect\n", WiFi.softAPSSID().c_str(), WiFi.softAPIP().toString().c_str());
70+
if (MDNS.begin(hostName.c_str())) LOG_V("AP MDNS responder Started\n");
7171
}
7272

7373
// Control assist setup
7474
ctrl.setHtmlHeaders(HTML_HEADERS);
75-
ctrl.setHtmlBody(HTML_BODY);
76-
ctrl.setHtmlFooter(HTML_SCRIPT);
75+
ctrl.setHtmlBody(HTML_BODY);
76+
ctrl.setHtmlFooter(HTML_SCRIPT);
7777
// Bind controls
7878
ctrl.bind("on-off",isPlaying, changeOnOff);
7979
ctrl.bind("speed", speed, speedChange);
80-
// Auto send key values on connection
80+
// Auto send key values on connection
8181
ctrl.setAutoSendOnCon("on-off",true);
8282
ctrl.setAutoSendOnCon("speed",true);
8383
// Store key position on adc_val for speed
8484
// Only on last bind call the position will be valid!
85-
adc_pos = ctrl.bind("adc_val");
85+
adc_pos = ctrl.bind("adc_val");
8686
// Add a web server handler on url "/"
8787
ctrl.setup(server);
8888
// Start the server
8989
ctrl.begin();
90-
ctrl.dump();
9190
LOG_V("ControlAssist started.\n");
9291

93-
// Setup webserver
92+
// Setup webserver
9493
server.on("/d", []() {
9594
server.send(200, "text/plain", "Serial dump");
96-
ctrl.dump();
97-
});
95+
ctrl.dump();
96+
});
9897
server.begin();
9998
LOG_V("HTTP server started\n");
10099
#if defined(ESP32)
101100
pinMode(ADC_PIN, INPUT);
102101
#endif
102+
//ctrl.dump();
103103
}
104104

105105
void loop() { // Run repeatedly
106106

107107
if (millis() - pingMillis >= speed){
108-
// Set control at position to value
108+
// Set control at position to value
109109
if(isPlaying)
110110
ctrl.set(adc_pos, analogRead(ADC_PIN), true);
111111
pingMillis = millis();
112112
}
113-
113+
114114
#if not defined(ESP32)
115115
if(MDNS.isRunning()) MDNS.update(); // Handle MDNS
116116
#endif

0 commit comments

Comments
 (0)