LEDs
This commit is contained in:
@ -10,9 +10,10 @@ import javafx.fxml.FXML;
|
||||
|
||||
import javafx.scene.Scene;
|
||||
import javafx.scene.control.*;
|
||||
import javafx.scene.layout.AnchorPane;
|
||||
import javafx.scene.layout.HBox;
|
||||
import javafx.scene.layout.VBox;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.RadialGradient;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.stage.FileChooser;
|
||||
|
||||
import java.io.File;
|
||||
@ -134,7 +135,7 @@ public class Controller_Frontend {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
Thread.sleep(20); //Verzögerungszeit in Millisekunden
|
||||
Thread.sleep(50); //Verzögerungszeit in Millisekunden
|
||||
}
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
@ -300,16 +301,22 @@ public class Controller_Frontend {
|
||||
|
||||
private static ToggleButtonGroup[] allTRISbuttons;
|
||||
private static ToggleButtonGroup[] allPORTbuttons;
|
||||
private static Circle[] allLEDsA;
|
||||
private static Circle[] allLEDsB;
|
||||
private static ToggleButtonGroup dummy = new ToggleButtonGroup(new ToggleButton(), new ToggleButton());
|
||||
|
||||
public void initialize() {
|
||||
ToggleButtonGroup [] allTRISButtons = {bgTRISA0, bgTRISA1, bgTRISA2, bgTRISA3, bgTRISA4, bgTRISB0, bgTRISB1, bgTRISB2, bgTRISB3, bgTRISB4, bgTRISB5, bgTRISB6, bgTRISB7};
|
||||
ToggleButtonGroup [] allPORTButtons = {bgPORTA0, bgPORTA1, bgPORTA2, bgPORTA3, bgPORTA4, bgPORTB0, bgPORTB1, bgPORTB2, bgPORTB3, bgPORTB4, bgPORTB5, bgPORTB6, bgPORTB7};
|
||||
ToggleButtonGroup [] allTRISButtons = {bgTRISA0, bgTRISA1, bgTRISA2, bgTRISA3, bgTRISA4, dummy, dummy, dummy, bgTRISB0, bgTRISB1, bgTRISB2, bgTRISB3, bgTRISB4, bgTRISB5, bgTRISB6, bgTRISB7};
|
||||
ToggleButtonGroup [] allPORTButtons = {bgPORTA0, bgPORTA1, bgPORTA2, bgPORTA3, bgPORTA4, dummy, dummy, dummy, bgPORTB0, bgPORTB1, bgPORTB2, bgPORTB3, bgPORTB4, bgPORTB5, bgPORTB6, bgPORTB7};
|
||||
Circle[] allLEDsA = {ledA0, ledA1, ledA2, ledA3, ledA4};
|
||||
Circle[] allLEDsB = {ledB0, ledB1, ledB2, ledB3, ledB4, ledB5, ledB6, ledB7};
|
||||
for (int i = 0; i<allPORTButtons.length; i++) {
|
||||
ToggleButtonGroupExt.get().addAlwaysOneSelectedSupport(allTRISButtons[i]);
|
||||
ToggleButtonGroupExt.get().addAlwaysOneSelectedSupport(allPORTButtons[i]);
|
||||
}
|
||||
setTRISbuttons(allTRISButtons);
|
||||
setPORTbuttons(allPORTButtons);
|
||||
IOPorts.setLEDs(allLEDsA, allLEDsB);
|
||||
|
||||
lstContentListView.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
|
||||
|
||||
@ -335,6 +342,50 @@ public class Controller_Frontend {
|
||||
return allPORTbuttons;
|
||||
}
|
||||
|
||||
public static Circle[] getLEDsA() {
|
||||
return allLEDsA;
|
||||
}
|
||||
|
||||
public static Circle[] getLEDsB() {
|
||||
return allLEDsB;
|
||||
}
|
||||
|
||||
|
||||
@FXML
|
||||
private CheckBox ledCheckA;
|
||||
@FXML
|
||||
private CheckBox ledCheckB;
|
||||
@FXML
|
||||
private Circle ledA0;
|
||||
@FXML
|
||||
private Circle ledA1;
|
||||
@FXML
|
||||
private Circle ledA2;
|
||||
@FXML
|
||||
private Circle ledA3;
|
||||
@FXML
|
||||
private Circle ledA4;
|
||||
@FXML
|
||||
private Circle ledB0;
|
||||
@FXML
|
||||
private Circle ledB1;
|
||||
@FXML
|
||||
private Circle ledB2;
|
||||
@FXML
|
||||
private Circle ledB3;
|
||||
@FXML
|
||||
private Circle ledB4;
|
||||
@FXML
|
||||
private Circle ledB5;
|
||||
@FXML
|
||||
private Circle ledB6;
|
||||
@FXML
|
||||
private Circle ledB7;
|
||||
|
||||
@FXML
|
||||
public void toggleLEDs (ActionEvent actionEvent) {
|
||||
IOPorts.setLEDs(new boolean[]{ledCheckA.isSelected(), ledCheckB.isSelected()});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -3,6 +3,10 @@ package fabrik.simulator.pic16f84;
|
||||
import com.gluonhq.charm.glisten.control.ToggleButtonGroup;
|
||||
import javafx.collections.ObservableList;
|
||||
import javafx.scene.control.ToggleButton;
|
||||
import javafx.scene.paint.Color;
|
||||
import javafx.scene.paint.RadialGradient;
|
||||
import javafx.scene.paint.Stop;
|
||||
import javafx.scene.shape.Circle;
|
||||
import javafx.stage.Stage;
|
||||
|
||||
import java.io.IOException;
|
||||
@ -17,6 +21,10 @@ public class IOPorts {
|
||||
|
||||
private static int [] trisLatch = {0xFF, 0xFF};
|
||||
private static int [] dataLatch = new int[2];
|
||||
private static boolean isLEDenabledA = false;
|
||||
private static boolean isLEDenabledB = false;
|
||||
private static Circle[] allLEDsA;
|
||||
private static Circle[] allLEDsB;
|
||||
|
||||
public static void setBit (int address, int bit){
|
||||
if (address < 7) {
|
||||
@ -76,6 +84,22 @@ public class IOPorts {
|
||||
buttonsPORT[i].setDisable(!val);
|
||||
buttonsTRIS[i].getToggles().get(0).setSelected(val);
|
||||
buttonsTRIS[i].getToggles().get(1).setSelected(!val);
|
||||
if(i < 8){
|
||||
if (isLEDenabledA && !val){
|
||||
if (DataRegister.getDirectBit(PORTA, i) == 1)
|
||||
allLEDsA[i].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||
else
|
||||
allLEDsA[i].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||
}
|
||||
}
|
||||
else{
|
||||
if (isLEDenabledB){
|
||||
if (DataRegister.getDirectBit(PORTB, i-8) == 1)
|
||||
allLEDsB[i-8].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.RED), new Stop(1, Color.DARKGRAY)));
|
||||
else
|
||||
allLEDsB[i-8].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -112,6 +136,28 @@ public class IOPorts {
|
||||
refreshTable(parent);
|
||||
}
|
||||
|
||||
public static void setLEDs (boolean[] leds) {
|
||||
boolean isAnowDisabled = isLEDenabledA && !leds[0];
|
||||
isLEDenabledA = leds[0];
|
||||
boolean isBnowDisabled = isLEDenabledB && !leds[1];
|
||||
isLEDenabledB = leds[1];
|
||||
if (isAnowDisabled){
|
||||
for (int i = 0; i < allLEDsA.length; i++){
|
||||
allLEDsA[i].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||
}
|
||||
}
|
||||
if (isBnowDisabled){
|
||||
for (int i = 0; i < allLEDsB.length; i++){
|
||||
allLEDsB[i].setFill(new RadialGradient(0, 0, 0.5, 0.5, 0.7, true, null, new Stop(0, Color.BLACK), new Stop(1, Color.DARKGRAY)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void setLEDs (Circle[] a, Circle[] b){
|
||||
allLEDsA = a;
|
||||
allLEDsB = b;
|
||||
}
|
||||
|
||||
private static void refreshTable(ToggleButtonGroup parent) throws IOException {
|
||||
Stage stage = (Stage) parent.getScene().getWindow();
|
||||
Table.refresh();
|
||||
|
||||
@ -18,6 +18,10 @@
|
||||
<?import javafx.scene.layout.HBox?>
|
||||
<?import javafx.scene.layout.RowConstraints?>
|
||||
<?import javafx.scene.layout.VBox?>
|
||||
<?import javafx.scene.paint.Color?>
|
||||
<?import javafx.scene.paint.RadialGradient?>
|
||||
<?import javafx.scene.paint.Stop?>
|
||||
<?import javafx.scene.shape.Circle?>
|
||||
<?import javafx.scene.text.Font?>
|
||||
<?import javafx.scene.text.Text?>
|
||||
|
||||
@ -46,7 +50,7 @@
|
||||
</HBox>
|
||||
<VBox layoutX="14.0" layoutY="727.0">
|
||||
<children>
|
||||
<Label fx:id="totalExecutionTimeLabel" text="Total Execution Time: 0µs"/>
|
||||
<Label fx:id="totalExecutionTimeLabel" text="Total Execution Time: 0µs" />
|
||||
<CheckBox fx:id="wdtCheck" mnemonicParsing="false" onAction="#toggleWatchdog" text="Watchdog-Timer">
|
||||
<VBox.margin>
|
||||
<Insets top="10.0" />
|
||||
@ -73,10 +77,11 @@
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="10.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="25.0" prefHeight="25.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="10.0" prefHeight="30.0" vgrow="SOMETIMES" />
|
||||
<RowConstraints minHeight="25.0" prefHeight="25.0" vgrow="SOMETIMES" />
|
||||
</rowConstraints>
|
||||
<effect>
|
||||
<Blend />
|
||||
@ -701,6 +706,302 @@
|
||||
</ToggleButtonGroup>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="10.0" layoutY="10.0" GridPane.columnIndex="2" GridPane.rowIndex="7">
|
||||
<children>
|
||||
<Circle fx:id="ledB6" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" GridPane.rowIndex="3">
|
||||
<children>
|
||||
<CheckBox fx:id="ledCheckA" mnemonicParsing="false" onAction="#toggleLEDs" />
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="10.0" layoutY="124.0" GridPane.rowIndex="7">
|
||||
<children>
|
||||
<CheckBox fx:id="ledCheckB" mnemonicParsing="false" onAction="#toggleLEDs"/>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" GridPane.columnIndex="1" GridPane.rowIndex="7">
|
||||
<children>
|
||||
<Circle fx:id="ledB7" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="137.0" layoutY="271.0" GridPane.columnIndex="6" GridPane.rowIndex="3">
|
||||
<children>
|
||||
<Circle fx:id="ledA2" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="10.0" layoutY="10.0" GridPane.columnIndex="5" GridPane.rowIndex="3">
|
||||
<children>
|
||||
<Circle fx:id="ledA3" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="10.0" layoutY="10.0" GridPane.columnIndex="4" GridPane.rowIndex="3">
|
||||
<children>
|
||||
<Circle fx:id="ledA4" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="10.0" layoutY="10.0" GridPane.columnIndex="8" GridPane.rowIndex="7">
|
||||
<children>
|
||||
<Circle fx:id="ledB0" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="10.0" layoutY="10.0" GridPane.columnIndex="7" GridPane.rowIndex="7">
|
||||
<children>
|
||||
<Circle fx:id="ledB1" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="10.0" layoutY="10.0" GridPane.columnIndex="6" GridPane.rowIndex="7">
|
||||
<children>
|
||||
<Circle fx:id="ledB2" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="10.0" layoutY="10.0" GridPane.columnIndex="5" GridPane.rowIndex="7">
|
||||
<children>
|
||||
<Circle fx:id="ledB3" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="10.0" layoutY="10.0" GridPane.columnIndex="4" GridPane.rowIndex="7">
|
||||
<children>
|
||||
<Circle fx:id="ledB4" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="10.0" layoutY="10.0" GridPane.columnIndex="3" GridPane.rowIndex="7">
|
||||
<children>
|
||||
<Circle fx:id="ledB5" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="457.0" layoutY="124.0" GridPane.columnIndex="8" GridPane.rowIndex="3">
|
||||
<children>
|
||||
<Circle fx:id="ledA0" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
<VBox alignment="CENTER" layoutX="10.0" layoutY="10.0" GridPane.columnIndex="7" GridPane.rowIndex="3">
|
||||
<children>
|
||||
<Circle fx:id="ledA1" radius="13.0" stroke="BLACK" strokeType="INSIDE">
|
||||
<fill>
|
||||
<RadialGradient centerX="0.5" centerY="0.5" radius="0.7">
|
||||
<stops>
|
||||
<Stop>
|
||||
<color>
|
||||
<Color />
|
||||
</color>
|
||||
</Stop>
|
||||
<Stop offset="1.0">
|
||||
<color>
|
||||
<Color red="0.66" green="0.66" blue="0.66" />
|
||||
</color>
|
||||
</Stop>
|
||||
</stops>
|
||||
</RadialGradient>
|
||||
</fill>
|
||||
</Circle>
|
||||
</children>
|
||||
</VBox>
|
||||
</children>
|
||||
</GridPane>
|
||||
</children>
|
||||
|
||||
Reference in New Issue
Block a user