Skip to content

Commit 6c3a7cc

Browse files
igrrkzyapkov
authored andcommitted
Fix ESP8266FS tool
1 parent 2470e5f commit 6c3a7cc

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

make.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ fi
1515
set -e
1616

1717
mkdir -p bin
18-
javac -target 1.7 -cp "$pde_path:$core_path" \
18+
javac -target 1.8 -cp "$pde_path:$core_path" \
1919
-d bin src/ESP8266FS.java
2020

2121
pushd bin

src/ESP8266FS.java

+26-25
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import processing.app.PreferencesData;
3636
import processing.app.Editor;
3737
import processing.app.Base;
38+
import processing.app.BaseNoGui;
3839
import processing.app.Platform;
3940
import processing.app.Sketch;
4041
import processing.app.tools.Tool;
@@ -57,7 +58,7 @@ public void init(Editor editor) {
5758
public String getMenuTitle() {
5859
return "ESP8266 Sketch Data Upload";
5960
}
60-
61+
6162
private int listenOnProcess(String[] arguments){
6263
try {
6364
final Process p = ProcessUtils.exec(arguments);
@@ -79,7 +80,7 @@ public void run() {
7980
return -1;
8081
}
8182
}
82-
83+
8384
private void sysExec(final String[] arguments){
8485
Thread thread = new Thread() {
8586
public void run() {
@@ -96,25 +97,25 @@ public void run() {
9697
};
9798
thread.start();
9899
}
99-
100-
100+
101+
101102
private long getIntPref(String name){
102-
String data = Base.getBoardPreferences().get(name);
103+
String data = BaseNoGui.getBoardPreferences().get(name);
103104
if(data == null || data.contentEquals("")) return 0;
104105
if(data.startsWith("0x")) return Long.parseLong(data.substring(2), 16);
105106
else return Integer.parseInt(data);
106107
}
107-
108+
108109
private void createAndUpload(){
109110
if(!PreferencesData.get("target_platform").contentEquals("esp8266")){
110111
System.err.println();
111112
editor.statusError("SPIFFS Not Supported on "+PreferencesData.get("target_platform"));
112113
return;
113114
}
114-
115-
if(!Base.getBoardPreferences().containsKey("build.spiffs_start") || !Base.getBoardPreferences().containsKey("build.spiffs_end")){
115+
116+
if(!BaseNoGui.getBoardPreferences().containsKey("build.spiffs_start") || !BaseNoGui.getBoardPreferences().containsKey("build.spiffs_end")){
116117
System.err.println();
117-
editor.statusError("SPIFFS Not Defined for "+Base.getBoardPreferences().get("name"));
118+
editor.statusError("SPIFFS Not Defined for "+BaseNoGui.getBoardPreferences().get("name"));
118119
return;
119120
}
120121
long spiStart, spiEnd, spiPage, spiBlock;
@@ -129,9 +130,9 @@ private void createAndUpload(){
129130
editor.statusError(e);
130131
return;
131132
}
132-
133-
TargetPlatform platform = Base.getTargetPlatform();
134-
133+
134+
TargetPlatform platform = BaseNoGui.getTargetPlatform();
135+
135136
File esptool;
136137
if(!PreferencesData.get("runtime.os").contentEquals("windows")) esptool = new File(platform.getFolder()+"/tools", "esptool");
137138
else esptool = new File(platform.getFolder()+"/tools", "esptool.exe");
@@ -140,7 +141,7 @@ private void createAndUpload(){
140141
editor.statusError("SPIFFS Error: esptool not found!");
141142
return;
142143
}
143-
144+
144145
File tool;
145146
if(!PreferencesData.get("runtime.os").contentEquals("windows")) tool = new File(platform.getFolder()+"/tools", "mkspiffs");
146147
else tool = new File(platform.getFolder()+"/tools", "mkspiffs.exe");
@@ -160,34 +161,34 @@ private void createAndUpload(){
160161
}
161162
}
162163
}
163-
164+
164165
String dataPath = dataFolder.getAbsolutePath();
165166
String toolPath = tool.getAbsolutePath();
166167
String esptoolPath = esptool.getAbsolutePath();
167168
String sketchName = editor.getSketch().getName();
168-
String buildPath = Base.getBuildFolder().getAbsolutePath();
169+
String buildPath = BaseNoGui.getBuildFolder().getAbsolutePath();
169170
String imagePath = buildPath+"/"+sketchName+".spiffs.bin";
170171
String serialPort = PreferencesData.get("serial.port");
171-
String resetMethod = Base.getBoardPreferences().get("upload.resetmethod");
172-
String uploadSpeed = Base.getBoardPreferences().get("upload.speed");
173-
String uploadAddress = Base.getBoardPreferences().get("build.spiffs_start");
174-
172+
String resetMethod = BaseNoGui.getBoardPreferences().get("upload.resetmethod");
173+
String uploadSpeed = BaseNoGui.getBoardPreferences().get("upload.speed");
174+
String uploadAddress = BaseNoGui.getBoardPreferences().get("build.spiffs_start");
175+
175176
Object[] options = { "Yes", "No" };
176177
String title = "SPIFFS Create";
177178
String message = "No files have been found in your data folder!\nAre you sure you want to create an empty SPIFFS image?";
178-
179+
179180
if(fileCount == 0 && JOptionPane.showOptionDialog(editor, message, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]) != JOptionPane.YES_OPTION){
180181
System.err.println();
181182
editor.statusError("SPIFFS Warning: mkspiffs canceled!");
182183
return;
183184
}
184-
185+
185186
editor.statusNotice("SPIFFS Creating Image...");
186187
System.out.println("[SPIFFS] data : "+dataPath);
187188
System.out.println("[SPIFFS] size : "+((spiEnd - spiStart)/1024));
188189
System.out.println("[SPIFFS] page : "+spiPage);
189190
System.out.println("[SPIFFS] block : "+spiBlock);
190-
191+
191192
try {
192193
if(listenOnProcess(new String[]{toolPath, "-c", dataPath, "-p", spiPage+"", "-b", spiBlock+"", "-s", (spiEnd - spiStart)+"", imagePath}) != 0){
193194
System.err.println();
@@ -199,18 +200,18 @@ private void createAndUpload(){
199200
editor.statusError("SPIFFS Create Failed!");
200201
return;
201202
}
202-
203+
203204
editor.statusNotice("SPIFFS Uploading Image...");
204205
System.out.println("[SPIFFS] upload : "+imagePath);
205206
System.out.println("[SPIFFS] reset : "+resetMethod);
206207
System.out.println("[SPIFFS] port : "+serialPort);
207208
System.out.println("[SPIFFS] speed : "+uploadSpeed);
208209
System.out.println("[SPIFFS] address: "+uploadAddress);
209210
System.out.println();
210-
211+
211212
sysExec(new String[]{esptoolPath, "-cd", resetMethod, "-cb", uploadSpeed, "-cp", serialPort, "-ca", uploadAddress, "-cf", imagePath});
212213
}
213-
214+
214215
public void run() {
215216
createAndUpload();
216217
}

0 commit comments

Comments
 (0)