Skip to content
Snippets Groups Projects
Commit f3804344 authored by Leon Dieter's avatar Leon Dieter
Browse files

power_LED error eliminated / null pointer exception is missing

parent a0619178
No related branches found
No related tags found
No related merge requests found
...@@ -135,6 +135,7 @@ public class Simulator implements Runnable, ActionListener{ ...@@ -135,6 +135,7 @@ public class Simulator implements Runnable, ActionListener{
arduino.getPin(20).setValue(1023); // Power ON LED arduino.getPin(20).setValue(1023); // Power ON LED
arduino.setStop(false); arduino.setStop(false);
arduino.getFunction("main").run(arduino, null); arduino.getFunction("main").run(arduino, null);
} }
/** /**
......
...@@ -57,6 +57,14 @@ public class ArduinoUno extends Modul { ...@@ -57,6 +57,14 @@ public class ArduinoUno extends Modul {
@Override @Override
public void updateGUI(int _xscale, int _yscale) { public void updateGUI(int _xscale, int _yscale) {
//Alte label werden entfernt, wenn vorhanden. Da sonst die alten Label bestehen bleiben wrden
if(labelPower != null) {
layerpane.remove(labelPower);
}
if(label13 != null) {
layerpane.remove(label13);
}
this.xscale = _xscale; this.xscale = _xscale;
this.yscale = _yscale; this.yscale = _yscale;
...@@ -72,12 +80,13 @@ public class ArduinoUno extends Modul { ...@@ -72,12 +80,13 @@ public class ArduinoUno extends Modul {
chiplabel.setLocation(locx, locy); chiplabel.setLocation(locx, locy);
layerpane.add(chiplabel, 0); layerpane.add(chiplabel, 0);
// Label für die PowerLED // Label fr die PowerLED
labelPower = new JLabel() { labelPower = new JLabel() {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
Graphics2D ga = (Graphics2D) g; Graphics2D ga = (Graphics2D) g;
int transparancy = 0; int transparancy = 0;
if (ledOn) if (ledOn)
...@@ -87,7 +96,7 @@ public class ArduinoUno extends Modul { ...@@ -87,7 +96,7 @@ public class ArduinoUno extends Modul {
} }
}; };
labelPower.setLocation(((int)(0.5207*xscale))+locx, ((int)(0.13*yscale))+locy); labelPower.setLocation(((int)(0.5207*xscale))+locx, ((int)(0.13*yscale))+locy);
labelPower.setSize(((int)(0.02066*xscale)), ((int)(0.01034*yscale))); labelPower.setSize(((int)(0.02066*xscale)), ((int)(0.01034*yscale)));
layerpane.add(labelPower, 0); layerpane.add(labelPower, 0);
...@@ -129,7 +138,7 @@ public class ArduinoUno extends Modul { ...@@ -129,7 +138,7 @@ public class ArduinoUno extends Modul {
if (pin == pins.get(1)) { if (pin == pins.get(1)) {
led13 = pin.getValue(); led13 = pin.getValue();
} }
} }
public boolean connect(Arduino _arduino) { public boolean connect(Arduino _arduino) {
......
...@@ -140,8 +140,7 @@ public class Button extends Modul implements ActionListener { ...@@ -140,8 +140,7 @@ public class Button extends Modul implements ActionListener {
lastState[pin] = value; lastState[pin] = value;
pins.get(pin).setValue(value); pins.get(pin).setValue(value);
System.out.println("called");
} }
......
...@@ -48,6 +48,11 @@ public class RGB extends Modul { ...@@ -48,6 +48,11 @@ public class RGB extends Modul {
public void updateGUI(int _xscale, int _yscale) { public void updateGUI(int _xscale, int _yscale) {
//Alte label werden entfernt, wenn vorhanden. Da sonst die alten Label bestehen bleiben wrden
if(ledlabel != null) {
layerpane.remove(ledlabel);
}
this.xscale = _xscale; this.xscale = _xscale;
this.yscale = _yscale; this.yscale = _yscale;
...@@ -57,7 +62,7 @@ public class RGB extends Modul { ...@@ -57,7 +62,7 @@ public class RGB extends Modul {
chipIcon_temp = new ImageIcon(chipIcon.getImage().getScaledInstance(((int)(0.3037*xscale)), ((int)(0.304*yscale)), Image.SCALE_SMOOTH)); chipIcon_temp = new ImageIcon(chipIcon.getImage().getScaledInstance(((int)(0.3037*xscale)), ((int)(0.304*yscale)), Image.SCALE_SMOOTH));
chiplabel.setIcon(chipIcon_temp); chiplabel.setIcon(chipIcon_temp);
chiplabel.setSize(((int)(0.3037*xscale)), ((int)(0.304*yscale))); chiplabel.setSize(((int)(0.3037*xscale)), ((int)(0.304*yscale)));
layerpane.add(chiplabel, 1); layerpane.add(chiplabel, 0);
// Erzeuge ein JLabel welches das Leuchten der LED darstellt. // Erzeuge ein JLabel welches das Leuchten der LED darstellt.
ledlabel = new JLabel() { ledlabel = new JLabel() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment