Skip to content

Commit

Permalink
Use specified MicrocontrollerModel in e2p layout for calling the flas…
Browse files Browse the repository at this point in the history
…h utility.
  • Loading branch information
breaker27 committed Apr 23, 2016
1 parent 7833b1c commit 254c199
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 6 deletions.
12 changes: 9 additions & 3 deletions tools/shc_e2p_editor/src/main/java/shcee/FlashDialog.java
Expand Up @@ -47,11 +47,13 @@ public class FlashDialog extends JDialog
private JTextField textField;
private int e2pLength;
private String e2pFilename;
private String microcontrollerModel;

public FlashDialog(int e2pLength, String e2pFilename)
public FlashDialog(int e2pLength, String e2pFilename, String microcontrollerModel)
{
this.e2pLength = e2pLength;
this.e2pFilename = e2pFilename;
this.microcontrollerModel = microcontrollerModel;

this.setTitle("Flash e2p file to device");

Expand Down Expand Up @@ -90,7 +92,7 @@ private void addComponents()
panel.add(l1);

panel.add(Box.createRigidArea(new Dimension(0, 10)));
panel.add(new JLabel("#DEVICE# will be replaced by m328p or m168p according to e2p size"));
panel.add(new JLabel("#DEVICE# will be replaced by the microcontroller model defined in the e2p layout or (if not defined) m328p or m168p according to e2p size"));
panel.add(new JLabel("#FILENAME# will be replaced by the e2p filename"));
panel.add(Box.createRigidArea(new Dimension(0, 10)));
panel.add(new JLabel("Default is: " + (Util.runsOnWindows() ? DEFAULT_CMD_WINDOWS : DEFAULT_CMD_LINUX)));
Expand Down Expand Up @@ -155,7 +157,11 @@ private void onButtonFlash()
{
String cmdLineS = textField.getText();

if (e2pLength > 4096)
if (microcontrollerModel != null)
{
cmdLineS = cmdLineS.replace("#DEVICE#", microcontrollerModel);
}
else if (e2pLength > 4096)
{
cmdLineS = cmdLineS.replace("#DEVICE#", "m328p");
}
Expand Down
15 changes: 13 additions & 2 deletions tools/shc_e2p_editor/src/main/java/shcee/ValueEditorPanel.java
Expand Up @@ -166,13 +166,24 @@ protected void onButtonAbout()
"<html><body><b>smarthomatic EEPROM Editor</b><br/>" +
SHCEEMain.version + "<br/>" +
"http://www.smarthomatic.org<br/>" +
"Copyright (c) 2013..2014 Uwe Freese<br/>" +
"Copyright (c) 2013..2016 Uwe Freese<br/>" +
"Licensed under GLP 3 or later.</body></html>", "About", JOptionPane.INFORMATION_MESSAGE);
}

protected void onButtonFlash()
{
new FlashDialog(length, filename);
String microcontrollerModel = null;

for (Block b : blocks)
{
if (b.isVisible() && (b.microcontrollerModel != null))
{
microcontrollerModel = b.microcontrollerModel;
break;
}
}

new FlashDialog(length, filename, microcontrollerModel);
}

protected void onButtonSave()
Expand Down
10 changes: 9 additions & 1 deletion tools/shc_e2p_editor/src/main/java/shcee/editors/Block.java
Expand Up @@ -44,6 +44,7 @@ public class Block extends JPanel
private ArrayList<AbstractEditor> editors;
public String restrictionRefID = null;
public String restrictionValue = null;
public String microcontrollerModel = null;

private static Font titledBorderFont;

Expand Down Expand Up @@ -79,6 +80,13 @@ public Block(Color bgColor, Node root)

if (n.getNodeName().equals("Restriction"))
addRestriction(n);
else if (n.getNodeName().equals("MicrocontrollerModel"))
{
Node textNode = n.getFirstChild();

if (textNode != null)
microcontrollerModel = textNode.getNodeValue();
}
else if (n.getNodeName().equals("UIntValue"))
addElem(new UIntEditor(n, this.getBackground(), -1));
else if (n.getNodeName().equals("IntValue"))
Expand All @@ -94,7 +102,7 @@ else if (n.getNodeName().equals("Reserved"))
else if (n.getNodeName().equals("Array"))
addElem(new ArrayEditor(n, this.getBackground(), -1));
}
}
}

/**
* (Create and) return a font for use at titled borders in editor elements.
Expand Down

0 comments on commit 254c199

Please sign in to comment.