Skip to content

Commit

Permalink
bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tobozo committed Mar 20, 2024
1 parent 904ec12 commit 7160321
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 32 deletions.
74 changes: 48 additions & 26 deletions src/main/java/com/arduino/AppSettingsArduino.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class AppSettingsArduino extends AppSettings {

public AppSettingsArduino(Editor editor) {
this.editor = editor;
this.hasFSPanel = true;
init();
}

Expand All @@ -61,30 +60,6 @@ public void init() {

load();

set("csvDir.path", get("sketchDir.path") );

// check if the board uses a custom partition, could be stored in variants or
// tools folder

String partitionsPath = get("platform.path") + "/tools/partitions";
String csvPath = partitionsPath + "/" + get("build.partitions") + ".csv";
String variantCsvPath = null;

if (BaseNoGui.getBoardPreferences().containsKey("build.custom_partitions")) {
variantCsvPath = get("variant.path") + "/" + get("build.custom_partitions") + ".csv";
} else {
variantCsvPath = get("variant.path") + "/" + get("build.partitions") + ".csv";
}

String searchPaths[] = { get("sketchDir.path") + "/partitions.csv", variantCsvPath, csvPath };

for (int i = 0; i < searchPaths.length; i++) {
if (Files.exists(Paths.get(searchPaths[i]))) {
set("csvFile.path", searchPaths[i] );
break;
}
}

if( debug_ui ) {
prefs.forEach((key, value) -> {
System.out.printf("%-24s : %s\n", key, value );
Expand Down Expand Up @@ -118,8 +93,28 @@ public void build(JProgressBar progressBar, final AppSettings.EventCallback call
new Thread(buildRunner).start();
}


// otherwise, if the Arduino IDE window is resized with the message label
// set to blank, it's preferredSize() will be fukered
private static final String EMPTY =
" " +
" " +
" ";

@Override
public void load() {
this.platformSupported = PreferencesData.get("target_platform").contentEquals("esp32");

if( !this.platformSupported ) {
editor.statusError(" Error: unsupported platform!");
return;
}

this.hasFSPanel = true;


editor.statusNotice(EMPTY);

defaultSketchbookFolder = BaseNoGui.getDefaultSketchbookFolder();
toolsPathBase = BaseNoGui.getToolsPath();
platform = BaseNoGui.getTargetPlatform();
Expand Down Expand Up @@ -147,7 +142,8 @@ public void load() {

String espToolSearchPaths[] = {
PreferencesData.get("runtime.tools.esptool_py.path"), // preferences.txt
get("platform.path") + "/tools", get("platform.path") + "/tools/esptool_py", defaultSketchbookFolder + "/tools",
new File( get("platform.path"), "/tools").getAbsolutePath(),
get("platform.path") + "/tools/esptool_py", defaultSketchbookFolder + "/tools",
defaultSketchbookFolder + "/tools/esptool_py", toolsPathBase, toolsPathBase + "/tools/esptool_py" };

if (!findFile(esptoolCmd, espToolSearchPaths, "esptool")) {
Expand Down Expand Up @@ -189,6 +185,32 @@ public void load() {

findFile(toolExeName, searchPaths, toolBinName);
}

set("csvDir.path", get("sketchDir.path") );

// check if the board uses a custom partition, could be stored in variants or
// tools folder

String partitionsPath = get("platform.path") + "/tools/partitions";
String csvPath = partitionsPath + "/" + get("build.partitions") + ".csv";
String variantCsvPath = null;

if (BaseNoGui.getBoardPreferences().containsKey("build.custom_partitions")) {
variantCsvPath = get("variant.path") + "/" + get("build.custom_partitions") + ".csv";
} else {
variantCsvPath = get("variant.path") + "/" + get("build.partitions") + ".csv";
}

String searchPaths[] = { get("sketchDir.path") + "/partitions.csv", variantCsvPath, csvPath };

for (int i = 0; i < searchPaths.length; i++) {
if (Files.exists(Paths.get(searchPaths[i]))) {
set("csvFile.path", searchPaths[i] );
break;
}
}


}

private String getBootloaderImagePath() {
Expand Down
9 changes: 9 additions & 0 deletions src/main/java/com/arduino/ESP32PartitionTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,22 @@ private void initGUI() {
settings.init();
}

if( !settings.platformSupported ) {
frame.setVisible(false);
System.err.println("Only ESP32 devices are supported!");
return;
}


if (fileManager == null) {
fileManager = new FileManager(contentPane, settings);
}

if( ! ui_loaded ) {
addUI(contentPane);
ui_loaded = true;
} else {
contentPane.reload();
}

frame.setFocusable(true);
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/platformio/AppSettingsStandalone.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public class AppSettingsStandalone extends AppSettings {

public AppSettingsStandalone(String[] args) {
this.args = args;
this.platformSupported = true; // can't verify yet
init();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public JFrameStandalone() {
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

// Size and display the frame
setSize(1024, 640);
setSize(800, 600);
setResizable(false);

// Set frame position to the center of the screen
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public void onFail( Runnable onFail ) {

}

public boolean platformSupported = false;
public boolean debug_settings = true;
public boolean hasFSPanel = false;
private boolean changed = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ public void createPanel() {
consoleLogPanel.setAlignmentY(JPanel.TOP_ALIGNMENT);

//consoleScrollPanel.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
consoleScrollPanel.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
consoleScrollPanel.getVerticalScrollBar().setUnitIncrement(100);

addComponents();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -597,13 +597,13 @@ public void createMergedBin( final AppSettings.EventCallback callbacks ) {
String platformPath = settings.get("platform.path");
String sketchName = settings.get("sketch.name");
String esptoolPath = settings.get("esptool.path");
String bootloaderImage = settings.get("bootloader.path");
String mcu = settings.get("build.mcu");
String flashMode = settings.get("flashMode");
String flashFreq = settings.get("flashFreq");
String pythonCmd = settings.get("pythonCmd");

String bootImage = platformPath + "/tools/partitions/boot_app0.bin";
String bootloaderImage = buildPath + "/" + sketchName + ".ino.bootloader.bin"; // settings.get("bootloader.path");
String partitionsImage = buildPath + "/" + sketchName + ".ino.partitions.bin";
String spiffsImage = buildPath + "/" + sketchName + ".spiffs.bin";
String mergedImage = buildPath + "/" + sketchName + ".merged.bin";
Expand Down
29 changes: 25 additions & 4 deletions src/main/java/com/serifpersia/esp32partitiontool/UI.java
Original file line number Diff line number Diff line change
Expand Up @@ -121,16 +121,35 @@ private void init() {
updatePartitionFlashVisual();
}

public void reload() {
settings.reload();
updateFrame();
}

public void updateFrame() {
if( !settings.platformSupported ) {
System.out.println("Hiding app");
frame.setVisible(false);
return;
}

if( settings.hasFSPanel ) {
frame.setSize(1024, 640);
} else {
frame.setSize(800, 600);
}
fsPanel.setVisible( settings.hasFSPanel );
}

public void setController(UIController controller) {
this.controller = controller;
}

public void setAppSettings( FileManager fileManager, AppSettings settings ) {
this.settings = settings;
if( settings.hasFSPanel ) {
add(fsPanel, BorderLayout.EAST);
fsPanel.attachListeners( this, fileManager );
}
add(fsPanel, BorderLayout.EAST);
fsPanel.attachListeners( this, fileManager );
updateFrame();
}

public void addCSVRow(CSVRow line) {
Expand Down Expand Up @@ -260,6 +279,8 @@ private void createPanels() {
aboutPanel = new AboutPanel();
fsPanel = new FSPanel();

fsPanel.setVisible(false);

csvGenPanel = new JTransparentPanel();

add(csvGenPanel);
Expand Down

0 comments on commit 7160321

Please sign in to comment.