Skip to content
Snippets Groups Projects
Commit 94f5523e authored by Lucas Stratmann's avatar Lucas Stratmann
Browse files

Updated GUI

parent 8751d8a2
Branches
No related tags found
No related merge requests found
Showing
with 63 additions and 26 deletions
No preview for this file type
No preview for this file type
res/PM24_Potentiometer.png

14.2 KiB | W: | H:

res/PM24_Potentiometer.png

13.6 KiB | W: | H:

res/PM24_Potentiometer.png
res/PM24_Potentiometer.png
res/PM24_Potentiometer.png
res/PM24_Potentiometer.png
  • 2-up
  • Swipe
  • Onion skin
res/PM26_Taster.png

21 KiB | W: | H:

res/PM26_Taster.png

19.2 KiB | W: | H:

res/PM26_Taster.png
res/PM26_Taster.png
res/PM26_Taster.png
res/PM26_Taster.png
  • 2-up
  • Swipe
  • Onion skin
res/PM31_RGB_LED.png

19.5 KiB | W: | H:

res/PM31_RGB_LED.png

18 KiB | W: | H:

res/PM31_RGB_LED.png
res/PM31_RGB_LED.png
res/PM31_RGB_LED.png
res/PM31_RGB_LED.png
  • 2-up
  • Swipe
  • Onion skin
res/Play.png

2.08 KiB

res/Reload.png

576 B

res/Reset.png

708 B

res/Stop.png

725 B

...@@ -44,7 +44,7 @@ public class Simulator implements Runnable { ...@@ -44,7 +44,7 @@ public class Simulator implements Runnable {
private boolean createSubClasses() { private boolean createSubClasses() {
gui = new GUI(); gui = new GUI();
arduino = new Arduino(); arduino = new Arduino(gui);
gui.connectPins(arduino); gui.connectPins(arduino);
guiThread = new Thread(gui); guiThread = new Thread(gui);
...@@ -150,8 +150,16 @@ public class Simulator implements Runnable { ...@@ -150,8 +150,16 @@ public class Simulator implements Runnable {
testSetup.add(new CodeDelay(2000)); testSetup.add(new CodeDelay(2000));
testLoop.add(new CodeDigitalWrite(0, true)); testLoop.add(new CodeDigitalWrite(0, true));
testLoop.add(new CodeDelay(500)); testLoop.add(new CodeDelay(500));
testLoop.add(new CodeDigitalWrite(1, true));
testLoop.add(new CodeDelay(500));
testLoop.add(new CodeDigitalWrite(2, true));
testLoop.add(new CodeDelay(500));
testLoop.add(new CodeDigitalWrite(1, false));
testLoop.add(new CodeDelay(500));
testLoop.add(new CodeDigitalWrite(0, false)); testLoop.add(new CodeDigitalWrite(0, false));
testLoop.add(new CodeDelay(500)); testLoop.add(new CodeDelay(500));
testLoop.add(new CodeDigitalWrite(2, false));
testLoop.add(new CodeDelay(500));
System.out.println("Main Entry"); System.out.println("Main Entry");
Simulator simu = Simulator.getInstance(); Simulator simu = Simulator.getInstance();
...@@ -164,6 +172,7 @@ public class Simulator implements Runnable { ...@@ -164,6 +172,7 @@ public class Simulator implements Runnable {
System.out.println("Send Stop"); System.out.println("Send Stop");
simu.reset(); simu.reset();
System.out.println("Reset Done"); System.out.println("Reset Done");
Thread.sleep(5000);
// simu.stopSimu(); // simu.stopSimu();
// System.out.println("Stopped"); // System.out.println("Stopped");
......
...@@ -5,6 +5,8 @@ package tec.letsgoing.ardublock.simulator.arduino; ...@@ -5,6 +5,8 @@ package tec.letsgoing.ardublock.simulator.arduino;
import java.util.Vector; import java.util.Vector;
import tec.letsgoing.ardublock.simulator.view.GUI;
/** /**
* @author Lucas * @author Lucas
* *
...@@ -13,8 +15,10 @@ public class Arduino { ...@@ -13,8 +15,10 @@ public class Arduino {
private Vector<Variable> vars; private Vector<Variable> vars;
private Pin[] pins = new Pin[20]; private Pin[] pins = new Pin[20];
private GUI gui;
public Arduino() { public Arduino(GUI _gui) {
gui = _gui;
for (int i = 0; i < 20; i++) { for (int i = 0; i < 20; i++) {
pins[i] = new Pin(); pins[i] = new Pin();
} }
...@@ -83,4 +87,8 @@ public class Arduino { ...@@ -83,4 +87,8 @@ public class Arduino {
return true; return true;
} }
public void serialPrint(String content) {
gui.serialPrint(content);
}
} }
...@@ -18,6 +18,7 @@ public class CodeDelay extends SimCode { ...@@ -18,6 +18,7 @@ public class CodeDelay extends SimCode {
} }
public void run(Arduino ArduinoClass) { public void run(Arduino ArduinoClass) {
ArduinoClass.serialPrint("Sleep for: " + duration);
// TODO Auto-generated method stub // TODO Auto-generated method stub
try { try {
Thread.sleep(duration); Thread.sleep(duration);
......
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
package tec.letsgoing.ardublock.simulator.view; package tec.letsgoing.ardublock.simulator.view;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Container; import java.awt.Container;
import java.awt.Font;
import java.util.Vector; import java.util.Vector;
import javax.swing.BoxLayout;
import javax.swing.JButton; import javax.swing.JButton;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
...@@ -27,8 +30,9 @@ import tec.letsgoing.ardublock.simulator.view.modules.RGB; ...@@ -27,8 +30,9 @@ import tec.letsgoing.ardublock.simulator.view.modules.RGB;
* @author Lucas * @author Lucas
* *
*/ */
//TODO Rotate Modules
public class GUI extends JFrame implements Runnable { public class GUI extends JFrame implements Runnable {
private Vector<String> serialprint; private Vector<String> serialprint = new Vector<String>();
private Modul[] modules = new Modul[4]; private Modul[] modules = new Modul[4];
private volatile boolean stopFlag = false; private volatile boolean stopFlag = false;
private JTextArea serialLog = new JTextArea(); private JTextArea serialLog = new JTextArea();
...@@ -47,8 +51,12 @@ public class GUI extends JFrame implements Runnable { ...@@ -47,8 +51,12 @@ public class GUI extends JFrame implements Runnable {
JScrollPane scrollPane = new JScrollPane(serialLog); JScrollPane scrollPane = new JScrollPane(serialLog);
DefaultCaret caret = (DefaultCaret) serialLog.getCaret(); DefaultCaret caret = (DefaultCaret) serialLog.getCaret();
caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE); caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
serialLog.setRows(5); serialLog.setRows(8);
serialLog.setAutoscrolls(true); serialLog.setAutoscrolls(true);
serialLog.setForeground(Color.white);
serialLog.setBackground(Color.black);
serialLog.setFont(new Font("Arial", Font.BOLD, 15));
for (int i = 0; i < 105; i++) { for (int i = 0; i < 105; i++) {
serialLog.append(Integer.toString(i) + "\n"); serialLog.append(Integer.toString(i) + "\n");
} }
...@@ -59,6 +67,10 @@ public class GUI extends JFrame implements Runnable { ...@@ -59,6 +67,10 @@ public class GUI extends JFrame implements Runnable {
modulPanel.add(modules[2].getPane(), BorderLayout.WEST); modulPanel.add(modules[2].getPane(), BorderLayout.WEST);
modulPanel.add(modules[3].getPane(), BorderLayout.NORTH); modulPanel.add(modules[3].getPane(), BorderLayout.NORTH);
JPanel controlPanel = new JPanel();
controlPanel.setLayout(new BoxLayout(controlPanel, BoxLayout.Y_AXIS));
// TODO make ControlButtons
mainPane.add(modulPanel, BorderLayout.CENTER); mainPane.add(modulPanel, BorderLayout.CENTER);
mainPane.add(new JButton("Controls"), BorderLayout.LINE_END); mainPane.add(new JButton("Controls"), BorderLayout.LINE_END);
mainPane.add(scrollPane, BorderLayout.PAGE_END); mainPane.add(scrollPane, BorderLayout.PAGE_END);
...@@ -88,6 +100,12 @@ public class GUI extends JFrame implements Runnable { ...@@ -88,6 +100,12 @@ public class GUI extends JFrame implements Runnable {
serialprint.remove(0); serialprint.remove(0);
} }
String tmp = "";
for (int i = 0; i < serialprint.size(); i++) {
tmp = tmp + serialprint.get(i) + "\n";
}
serialLog.setText(tmp);
return true; return true;
} }
......
...@@ -38,24 +38,25 @@ public class RGB extends Modul { ...@@ -38,24 +38,25 @@ public class RGB extends Modul {
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
Graphics2D ga = (Graphics2D) g; Graphics2D ga = (Graphics2D) g;
ga.setPaint(new Color(redValue/4, greenValue/4, blueValue/4, 200)); int transparancy = (int) (Math.max(redValue, Math.max(greenValue, blueValue)) * 0.8);
ga.setPaint(new Color(redValue, greenValue, blueValue, transparancy));
ga.fillOval(0, 0, 70, 70); ga.fillOval(0, 0, 70, 70);
} }
}; };
ledlabel.setLocation(185, 110); ledlabel.setLocation(115, 185);
ledlabel.setSize(200, 200); ledlabel.setSize(200, 200);
layerpane.add(ledlabel, 0); layerpane.add(ledlabel, 0);
} }
public void updateModul(Pin pin) { public void updateModul(Pin pin) {
if (pin == pins.get(0)) if (pin == pins.get(0))
redValue = pin.getValue(); redValue = pin.getValue() / 4;
if (pin == pins.get(1)) if (pin == pins.get(1))
blueValue = pin.getValue(); blueValue = pin.getValue() / 4;
if (pin == pins.get(2)) if (pin == pins.get(2))
greenValue = pin.getValue(); greenValue = pin.getValue() / 4;
System.out.println("New Values: " + redValue + " " + blueValue + " " + greenValue); System.out.println("New Values: " + redValue + " " + blueValue + " " + greenValue);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment