Skip to content

Commit

Permalink
Merge branch 'js-refactor'
Browse files Browse the repository at this point in the history
  • Loading branch information
Spacehuhn committed Nov 16, 2019
2 parents 6992222 + c9caef5 commit f0612ab
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 174 deletions.
2 changes: 1 addition & 1 deletion esp_duck/cli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ namespace cli {

duckscript::stop(arg.getValue());

String response = "> stopped \"" + arg.getValue() + "\"";
String response = "> stopped " + arg.getValue();
print(response);
});

Expand Down
19 changes: 11 additions & 8 deletions esp_duck/duckscript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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;
Expand All @@ -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");
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion esp_duck/duckscript.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ namespace duckscript {

void nextLine();
void repeat();
void stop();
void stopAll();
void stop(String fileName);

bool isRunning();
Expand Down
4 changes: 2 additions & 2 deletions esp_duck/esp_duck.ino
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -49,4 +49,4 @@ void loop() {
webserver::update();

debug_update();
}
}
18 changes: 12 additions & 6 deletions web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,25 @@ <h2>Scripts <a class="reload" id="scriptsReload">&#x21bb;</a></h2>
<h2>Editor <a class="reload" id="editorReload">&#x21bb;</a></h2>

<label>Filename:</label>
<input type="text" class="smooth" value="/example" id="editorFile">
<input type="text" class="smooth" value="/" id="editorFile">

<textarea class="smooth" id="editor">REM Hello World!</textarea>
<textarea class="smooth" id="editor"></textarea>

<div id="editor-primary-buttons">
<p>
<button class="warn" id="editorRun">run</button>
<button class="success" id="editorSave">save</button>
</p>
</div>

<p id="editorinfo">saved</p>

<button class="danger" id="editorDelete">delete</button>
<button class="primary" id="editorDownload">download</button>
<button class="warn" id="editorStop">stop</button>
<button class="warn" id="editorRun">run</button>
<button class="success" id="editorSave">save</button>
<br>
<button class="primary" id="editorDownload">download</button>
<button class="primary" id="editorAutorun">Enable autorun</button>

<p id="editorinfo">saved</p>

<br>
<hr>
Expand Down
Loading

0 comments on commit f0612ab

Please sign in to comment.