diff --git a/UML.dia b/UML.dia index 20e248cdf51ce1c929e198ec0f74347722e5031b..d1802d5c058c4756d807f1ece9e04a4b328a7d20 100644 Binary files a/UML.dia and b/UML.dia differ diff --git a/src/tec/letsgoing/ardublock/simulator/arduino/Arduino.java b/src/tec/letsgoing/ardublock/simulator/arduino/Arduino.java index 042542bddd177f4cdb83200ce629b5dca5dac240..74ae33424570aee40e5c332bd32fdc2108a969aa 100644 --- a/src/tec/letsgoing/ardublock/simulator/arduino/Arduino.java +++ b/src/tec/letsgoing/ardublock/simulator/arduino/Arduino.java @@ -135,8 +135,8 @@ public class Arduino { int[] array = { 3, 5, 6, 9, 10, 11 }; for (int i = 0; i < 6; i++) { if (_pin == array[i]) { - pins[_pin].setValue((int) (_value * (1024.0/256.0))); - //System.out.println(_value + " multi " + (int)(_value * (1024.0/256.0))); + pins[_pin].setValue((int) (_value * (1024.0 / 256.0))); + // System.out.println(_value + " multi " + (int)(_value * (1024.0/256.0))); return true; } } diff --git a/src/tec/letsgoing/ardublock/simulator/arduino/Pin.java b/src/tec/letsgoing/ardublock/simulator/arduino/Pin.java index e7c9d26f6e03a50089020e3d840a6ca2fcc621e9..302c6569d007fbead6d3a61eeefe00aebcb57d6b 100644 --- a/src/tec/letsgoing/ardublock/simulator/arduino/Pin.java +++ b/src/tec/letsgoing/ardublock/simulator/arduino/Pin.java @@ -28,10 +28,7 @@ public class Pin extends Observable { } public void setValue(int _value) { - if (_value > 1023) - //TODO: check by Lucas - //_value = 1023; - _value = _value%1024; + _value = _value % 1024; if (_value < 0) _value = 0; value = _value; diff --git a/src/tec/letsgoing/ardublock/simulator/simcode/comm/CodeConnectString.java b/src/tec/letsgoing/ardublock/simulator/simcode/comm/CodeConnectString.java index f6c719574290586f2b17f7a4239d5b6514f72f1f..da736292ee4b0a5e91bb2edd3302f3ec385fbf7c 100644 --- a/src/tec/letsgoing/ardublock/simulator/simcode/comm/CodeConnectString.java +++ b/src/tec/letsgoing/ardublock/simulator/simcode/comm/CodeConnectString.java @@ -26,16 +26,14 @@ public class CodeConnectString extends SimCode { @Override public SimTypeString run(Arduino _arduino, SimCode functionHead) { - if(block1 != null && block2 != null) { - out = "" + block1.run(_arduino, functionHead).toString() + " " + block2.run(_arduino, functionHead).toString(); - } - else if(block1 == null && block2 != null) { + if (block1 != null && block2 != null) { + out = "" + block1.run(_arduino, functionHead).toString() + " " + + block2.run(_arduino, functionHead).toString(); + } else if (block1 == null && block2 != null) { out = "" + block2.run(_arduino, functionHead).toString(); - } - else if(block1 != null && block2 == null) { + } else if (block1 != null && block2 == null) { out = "" + block1.run(_arduino, functionHead).toString(); - } - else { + } else { out = ""; } return new SimTypeString(out); @@ -43,7 +41,7 @@ public class CodeConnectString extends SimCode { @Override public String toString() { - return out; + return out; } } diff --git a/src/tec/letsgoing/ardublock/simulator/simcode/datatypes/SimTypeBool.java b/src/tec/letsgoing/ardublock/simulator/simcode/datatypes/SimTypeBool.java index 890be2a8258b696199d9fe819bb5f8882a9f960d..7c0fcc71f19e85f9b441c05ba6f9a39c64e5933c 100644 --- a/src/tec/letsgoing/ardublock/simulator/simcode/datatypes/SimTypeBool.java +++ b/src/tec/letsgoing/ardublock/simulator/simcode/datatypes/SimTypeBool.java @@ -13,7 +13,7 @@ import tec.letsgoing.ardublock.simulator.simcode.SimCode; * */ public class SimTypeBool extends SimCode { - boolean value = false; + private boolean value = false; private SimCode followBlock; public SimTypeBool(boolean _value) { diff --git a/src/tec/letsgoing/ardublock/simulator/view/GUI.java b/src/tec/letsgoing/ardublock/simulator/view/GUI.java index 1525cc8c2a2eb673b73dd49c8a257949963205c6..332232de1ce3bc43f5883aeac3241ea65e1a4fba 100644 --- a/src/tec/letsgoing/ardublock/simulator/view/GUI.java +++ b/src/tec/letsgoing/ardublock/simulator/view/GUI.java @@ -58,7 +58,7 @@ public class GUI extends JFrame implements Runnable, ActionListener { */ public GUI(Simulator simu) { super("ArduBlock Simulator"); - + // Konstruktor der Module modules[0] = new RGB(new ImageIcon(getToolkit() .getImage(GUI.class.getResource("/tec/letsgoing/ardublock/simulator/img/PM31_RGB_LED.png")))); diff --git a/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java b/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java index 08a6506ad9593393b3d3681d4cb31341d3b37d77..2ae27da4cf54ac300227c7dff1e64c379330496b 100644 --- a/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java +++ b/src/tec/letsgoing/ardublock/simulator/view/modules/RGB.java @@ -15,7 +15,6 @@ import javax.swing.JLabel; import tec.letsgoing.ardublock.simulator.arduino.Arduino; import tec.letsgoing.ardublock.simulator.arduino.Pin; -import tec.letsgoing.ardublock.simulator.simcode.datatypes.SimTypeInt; /** * Modul mit einer RGB LED @@ -45,13 +44,17 @@ public class RGB extends Modul { public void paintComponent(Graphics g) { Graphics2D ga = (Graphics2D) g; int transparancy = (int) (Math.max(redValue, Math.max(greenValue, blueValue)) * 0.9); - int tredValue=0,tgreenValue=0,tblueValue=0; - if (transparancy!=0) { - if(redValue>0)tredValue=map(redValue); - if(greenValue>0)tgreenValue=map(greenValue); - if(blueValue>0)tblueValue=map(blueValue); + int tredValue = 0, tgreenValue = 0, tblueValue = 0; + if (transparancy != 0) { + if (redValue > 0) + tredValue = map(redValue); + if (greenValue > 0) + tgreenValue = map(greenValue); + if (blueValue > 0) + tblueValue = map(blueValue); } - //System.out.println(tredValue+" "+ tgreenValue+" "+ tblueValue+" "+ transparancy); + // System.out.println(tredValue+" "+ tgreenValue+" "+ tblueValue+" "+ + // transparancy); ga.setPaint(new Color(tredValue, tgreenValue, tblueValue, transparancy)); ga.fillOval(0, 0, 73, 73); } @@ -71,13 +74,12 @@ public class RGB extends Modul { */ public void updateModul(Pin pin) { if (pin == pins.get(0)) - redValue = pin.getValue() / 4; + redValue = pin.getValue() / 4; if (pin == pins.get(1)) blueValue = pin.getValue() / 4; if (pin == pins.get(2)) greenValue = pin.getValue() / 4; - - + } /** @@ -99,11 +101,11 @@ public class RGB extends Modul { return true; } - public int map(int v) { - float vL=0,vH=255,tL=200,tH=255; + + private int map(int v) { + float vL = 0, vH = 255, tL = 200, tH = 255; return (int) (((v - vL) / (vH - vL)) * (tH - tL) + tL); } - /** * Funktion, welche die Positionen der Modulpins berechnet (in Pixeln für das