diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 0000000..2696786
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 0000000..35eb1dd
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/lib/pi4j-core-1.3.jar b/lib/pi4j-core-1.3.jar
new file mode 100644
index 0000000..61410cc
Binary files /dev/null and b/lib/pi4j-core-1.3.jar differ
diff --git a/lib/pi4j-core-2.0.jar b/lib/pi4j-core-2.0.jar
new file mode 100644
index 0000000..4b4d46e
Binary files /dev/null and b/lib/pi4j-core-2.0.jar differ
diff --git a/lib/pi4j-gpio-extension-1.3.jar b/lib/pi4j-gpio-extension-1.3.jar
new file mode 100644
index 0000000..378e723
Binary files /dev/null and b/lib/pi4j-gpio-extension-1.3.jar differ
diff --git a/lib/slf4j-api-1.7.30.jar b/lib/slf4j-api-1.7.30.jar
new file mode 100644
index 0000000..29ac26f
Binary files /dev/null and b/lib/slf4j-api-1.7.30.jar differ
diff --git a/src/LEDColorController.java b/src/LEDColorController.java
index 5aa3f07..3f563b0 100644
--- a/src/LEDColorController.java
+++ b/src/LEDColorController.java
@@ -1,3 +1,4 @@
+
import com.pi4j.io.gpio.*; // imports the Pi4j that needs to be installed on the raspberry pi
import java.util.concurrent.TimeUnit; // this is a time related operation for sleeping threads
@@ -23,3 +24,4 @@ public static void main(String[] args) throws InterruptedException { // throws I
}
}
}
+
diff --git a/src/NumberSequenceUI.java b/src/NumberSequenceUI.java
index 44a2582..0df3e98 100644
--- a/src/NumberSequenceUI.java
+++ b/src/NumberSequenceUI.java
@@ -6,12 +6,12 @@
import javafx.stage.Stage;
public class NumberSequenceUI extends Application { // NumberSequenceUI uses Application abstract class
+ // !!!This class houses the JavaFX UI!!!
- private int[] sequences = {1, 2, 3}; // Array that stores each light sequence.
- // Numbers are placeholder for the sequence objects.
private Label output = new Label(); // Creates label object that is used to output the array index as text
// Not set since the output text is variable
-
+ SequenceArray sA = new SequenceArray(); // Creates object out of class SequenceArray where the Light Sequences
+ // are stored in an array
@Override
public void start(Stage primaryStage) { // Method and sets up the JavaFX window
@@ -21,42 +21,46 @@ public void start(Stage primaryStage) { // Method and sets up the JavaFX window
Button sequence1Button = new Button("Sequence 1");
Button sequence2Button = new Button("Sequence 2");
Button sequence3Button = new Button("Sequence 3");
+ Button exitAppButton = new Button("Exit");
- // Objects that use method setOnAction that makes the button display the correct index from array "sequences"
+ /* Objects that use method setOnAction that makes the button display the correct index from array "sequences"
+ using the getIndex method from instantiated object sA ("SequenceArray")
+ */
// !!! Need some way to abort the sequence once executed !!!
// !!! Create number generator object to test cancel button !!!
- sequence1Button.setOnAction(e -> displaySequence(0));
- sequence2Button.setOnAction(e -> displaySequence(1));
- sequence3Button.setOnAction(e -> displaySequence(2));
+ sequence1Button.setOnAction(e -> displaySequence(sA.getIndex(0)));
+ sequence2Button.setOnAction(e -> displaySequence(sA.getIndex(1)));
+ sequence3Button.setOnAction(e -> displaySequence(sA.getIndex(2)));
+ exitAppButton.setOnAction(e -> System.exit(0));
/* Vbox object. As I understand, Vbox is a container that will arrange the child (addAll) button vertically */
VBox vbox = new VBox(10); // 10 pixels specified between each button
- vbox.getChildren().addAll(sequence1Button, sequence2Button, sequence3Button, output);
+ vbox.getChildren().addAll(sequence1Button, sequence2Button, sequence3Button, exitAppButton, output);
// adds the display label below the button for output to screen (they are in order descending)
// Creates scene object that takes the vbox object and formats it to a size. Scene = the layout
// within the window
- Scene scene = new Scene(vbox, 60, 150); // (40p W X 100p H)
+ Scene scene = new Scene(vbox, 60, 200); // (40p W X 100p H)
primaryStage.setScene(scene); // Not super clear on this, but it seems to tie everything together in
// the code examples I studied
primaryStage.show(); // Shows everything
}
+ // Method used to display the correct sequence number. Calls the index directly from the button.
+ //The button uses the getIndex method to set and call the correct value
+ //Included a catch in case I modify this in the future and the index is out of bounds
private void displaySequence(int index) {
- // First line makes sure output is valid. Kinda like a catch exception except it heads off the issue.
- // "If the index is greater than or = to 0 and is an index and less than the array (sequences) length"
- //
- if (index >= 0 && index < sequences.length) {
- output.setText("Sequence " + sequences[index]);
- // Outputs the array index to screen in the displayLabel object - this can be used in the
- // future for other output
- } else {
- output.setText("Invalid Selection."); // JIC we add something that is not an index - for testing
+ try {
+ int sequenceValue = index;
+ output.setText("Sequence " + sequenceValue);
+ } catch (IndexOutOfBoundsException e) {
+ output.setText("Invalid Selection."); // Handle invalid index
}
+
+
+
}
-}
-// Not super sure how start and displaySequence get executed from main since
-// I needed ChatGPT to figure out how to tie everything together - N.T.S. Ask Trevor
\ No newline at end of file
+}
diff --git a/src/SequenceArray.java b/src/SequenceArray.java
new file mode 100644
index 0000000..5a06ea1
--- /dev/null
+++ b/src/SequenceArray.java
@@ -0,0 +1,26 @@
+public class SequenceArray {
+ // !!!Class used for storing the array of sequences!!!
+
+ private int[] sequences; // Array that stores each light sequence.
+
+
+ public SequenceArray() {
+ sequences = new int[]{1, 2, 3}; // Initializes the array with placeholders.
+ // I'm not sure how to implement the actual sequences yet though.
+ }
+
+ // Loop that iterates over the array to find an index value.
+ // "Index must be greater than or equal to 0 and no higher then the array length
+ public int getIndex (int index) {
+ if (index >= 0 && index < sequences.length) {
+ return sequences[index];
+ } else {
+ throw new IndexOutOfBoundsException("Index out of bounds");
+ }
+ }
+
+ public int getArrayLength() {
+ return sequences.length;
+ }
+
+}