Permalink
Browse files
Splitted duckscript stop() into stop() and stopAll()
- Loading branch information
Showing
with
15 additions
and
12 deletions.
-
+1
−1
esp_duck/cli.cpp
-
+11
−8
esp_duck/duckscript.cpp
-
+1
−1
esp_duck/duckscript.h
-
+2
−2
esp_duck/esp_duck.ino
|
@@ -258,7 +258,7 @@ namespace cli { |
|
|
|
|
|
duckscript::stop(arg.getValue()); |
|
|
|
|
|
String response = "> stopped \"" + arg.getValue() + "\""; |
|
|
String response = "> stopped " + arg.getValue(); |
|
|
print(response); |
|
|
}); |
|
|
|
|
|
|
@@ -36,13 +36,13 @@ namespace duckscript { |
|
|
|
|
|
if (!f) { |
|
|
debugln("File error"); |
|
|
stop(); |
|
|
stopAll(); |
|
|
return; |
|
|
} |
|
|
|
|
|
if (!f.available()) { |
|
|
debugln("Reached end of file"); |
|
|
stop(); |
|
|
stopAll(); |
|
|
return; |
|
|
} |
|
|
|
|
@@ -74,14 +74,14 @@ namespace duckscript { |
|
|
|
|
|
void repeat() { |
|
|
if (!prevMessage) { |
|
|
stop(); |
|
|
stopAll(); |
|
|
} else { |
|
|
debugln("Repeating last message"); |
|
|
com::send(prevMessage, prevMessageLen); |
|
|
} |
|
|
} |
|
|
|
|
|
void stop() { |
|
|
void stopAll() { |
|
|
if (running) { |
|
|
if (f) f.close(); |
|
|
running = false; |
|
@@ -90,10 +90,13 @@ namespace duckscript { |
|
|
} |
|
|
|
|
|
void stop(String fileName) { |
|
|
if (running && f && (fileName == currentScript())) { |
|
|
f.close(); |
|
|
running = false; |
|
|
debugln("Stopped script"); |
|
|
if (fileName.length() == 0) stopAll(); |
|
|
else { |
|
|
if (running && f && (fileName == currentScript())) { |
|
|
f.close(); |
|
|
running = false; |
|
|
debugln("Stopped script"); |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
@@ -14,7 +14,7 @@ namespace duckscript { |
|
|
|
|
|
void nextLine(); |
|
|
void repeat(); |
|
|
void stop(); |
|
|
void stopAll(); |
|
|
void stop(String fileName); |
|
|
|
|
|
bool isRunning(); |
|
|
|
@@ -25,7 +25,7 @@ void setup() { |
|
|
webserver::begin(); |
|
|
|
|
|
com::onDone(duckscript::nextLine); |
|
|
com::onError(duckscript::stop); |
|
|
com::onError(duckscript::stopAll); |
|
|
com::onRepeat(duckscript::repeat); |
|
|
|
|
|
if (spiffs::freeBytes() > 0) com::send(MSG_STARTED); |
|
@@ -49,4 +49,4 @@ void loop() { |
|
|
webserver::update(); |
|
|
|
|
|
debug_update(); |
|
|
} |
|
|
}
|
0 comments on commit
566ca87