Integrated reboot button
This commit is contained in:
parent
e25a36ba33
commit
8dc7cf2af7
@ -4,7 +4,6 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
|
|
||||||
import javax.management.RuntimeErrorException;
|
|
||||||
import javax.swing.SwingUtilities;
|
import javax.swing.SwingUtilities;
|
||||||
|
|
||||||
import org.luaj.vm2.Globals;
|
import org.luaj.vm2.Globals;
|
||||||
@ -128,7 +127,7 @@ public class WS2812Simulation implements LuaSimulation {
|
|||||||
|
|
||||||
private void setWS2812Layout(File file) {
|
private void setWS2812Layout(File file) {
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
ws2812.setLayout(file);
|
ws2812.setLayout(file, this);
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException("WS2812 Layout: " + file.getAbsolutePath() + " does not exists");
|
throw new RuntimeException("WS2812 Layout: " + file.getAbsolutePath() + " does not exists");
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import org.luaj.vm2.lib.OneArgFunction;
|
|||||||
import org.luaj.vm2.lib.TwoArgFunction;
|
import org.luaj.vm2.lib.TwoArgFunction;
|
||||||
import org.luaj.vm2.lib.ZeroArgFunction;
|
import org.luaj.vm2.lib.ZeroArgFunction;
|
||||||
|
|
||||||
|
import de.c3ma.ollo.LuaSimulation;
|
||||||
import de.c3ma.ollo.mockup.ui.WS2812Layout;
|
import de.c3ma.ollo.mockup.ui.WS2812Layout;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -79,9 +80,9 @@ public class ESP8266Ws2812 extends TwoArgFunction {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLayout(File file) {
|
public void setLayout(File file, LuaSimulation nodemcuSimu) {
|
||||||
if (ESP8266Ws2812.layout == null) {
|
if (ESP8266Ws2812.layout == null) {
|
||||||
ESP8266Ws2812.layout = WS2812Layout.parse(file);
|
ESP8266Ws2812.layout = WS2812Layout.parse(file, nodemcuSimu);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,6 @@ import java.io.BufferedReader;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import javax.swing.BorderFactory;
|
import javax.swing.BorderFactory;
|
||||||
@ -18,7 +17,8 @@ import javax.swing.JButton;
|
|||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.JLabel;
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JPanel;
|
import javax.swing.JPanel;
|
||||||
import javax.swing.SwingUtilities;
|
|
||||||
|
import de.c3ma.ollo.LuaSimulation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* created at 02.01.2018 - 12:57:02<br />
|
* created at 02.01.2018 - 12:57:02<br />
|
||||||
@ -40,14 +40,20 @@ public class WS2812Layout extends JFrame {
|
|||||||
private int mRow = 0;
|
private int mRow = 0;
|
||||||
private Element[][] mElements;
|
private Element[][] mElements;
|
||||||
|
|
||||||
public static WS2812Layout parse(File file) {
|
private LuaSimulation nodemcuSimu;
|
||||||
|
|
||||||
|
public WS2812Layout(LuaSimulation nodemcuSimu) {
|
||||||
|
this.nodemcuSimu = nodemcuSimu;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WS2812Layout parse(File file, LuaSimulation nodemcuSimu) {
|
||||||
WS2812Layout layout = null;
|
WS2812Layout layout = null;
|
||||||
try {
|
try {
|
||||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
BufferedReader br = new BufferedReader(new FileReader(file));
|
||||||
try {
|
try {
|
||||||
String line = br.readLine();
|
String line = br.readLine();
|
||||||
if (line != null) {
|
if (line != null) {
|
||||||
layout = new WS2812Layout();
|
layout = new WS2812Layout(nodemcuSimu);
|
||||||
}
|
}
|
||||||
|
|
||||||
while (line != null) {
|
while (line != null) {
|
||||||
@ -92,15 +98,18 @@ public class WS2812Layout extends JFrame {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
contentPane.add(ledPanel, BorderLayout.CENTER);
|
contentPane.add(ledPanel, BorderLayout.CENTER);
|
||||||
JButton button = new JButton("Do something");
|
final JButton btnReboot = new JButton("Reboot");
|
||||||
button.setActionCommand("Do something");
|
btnReboot.setActionCommand("Reboot simulation");
|
||||||
button.addActionListener(new ActionListener() {
|
btnReboot.addActionListener(new ActionListener() {
|
||||||
public void actionPerformed(ActionEvent ae) {
|
public void actionPerformed(ActionEvent ae) {
|
||||||
JButton but = (JButton) ae.getSource();
|
JButton but = (JButton) ae.getSource();
|
||||||
// FIXME some clever logic
|
if (but.equals(btnReboot)) {
|
||||||
|
System.out.println("[Node] Restart");
|
||||||
|
nodemcuSimu.rebootTriggered();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
contentPane.add(button, BorderLayout.SOUTH);
|
contentPane.add(btnReboot, BorderLayout.SOUTH);
|
||||||
|
|
||||||
setContentPane(contentPane);
|
setContentPane(contentPane);
|
||||||
pack();
|
pack();
|
||||||
|
Loading…
Reference in New Issue
Block a user