Thomas Buck vor 13 Jahren
Ursprung
Commit
7939aca900
1 geänderte Dateien mit 116 neuen und 62 gelöschten Zeilen
  1. 116
    62
      Cube Control/cubeWorker.java

+ 116
- 62
Cube Control/cubeWorker.java Datei anzeigen

@@ -21,68 +21,115 @@
21 21
  * along with LED-Cube.  If not, see <http://www.gnu.org/licenses/>.
22 22
  */
23 23
 
24
+/*
25
+ * This class handles one animation file. This file can contain
26
+ * many animations, but has to be only 1Mbit in size (128*1024 Byte).
27
+ */
28
+
24 29
 public class cubeWorker {
25
-    final int UP = 0;
30
+
31
+// --------------------
32
+// Definitions
33
+// --------------------
34
+
35
+	final int UP = 0;
26 36
     final int DOWN = 1;
27
-    cubeWorker() {
28 37
 
29
-    }
38
+// --------------------
39
+// Fields
40
+// --------------------
30 41
 
31
-    // Adds a new Animation
32
-    // Returns id if ok, -1 if error or not enough space for
33
-    // another animation
34
-    public int addAnimation() {
42
+// --------------------
35 43
 
36
-           return -1;
37
-    }
38
-    
39
-    // Removes an animation
40
-    public void removeAnimation(int index) {
44
+	cubeWorker() {
41 45
 
42 46
     }
43
-    
44
-    // Returns how many animations are defined
47
+
48
+// --------------------
49
+// Misc. Methods
50
+// --------------------
51
+
52
+	// Returns how many animations are defined
45 53
     public int numOfAnimations() {
46 54
 
47 55
            return 3;
48
-    }
56
+    }   
49 57
     
50
-    // Selects an animation, on which the frame specific functions operate
51
-    // Returns -1 if it does not exist
58
+    // Returns how many frames are in the current animation
59
+    public int numOfFrames() {
60
+
61
+           return 3;
62
+    }
63
+
64
+	// Tells how many Frames you can add until you reached 1 Mbit...
65
+    public int framesRemaining() {
66
+
67
+           return 0;
68
+    }
69
+
70
+
71
+// --------------------
72
+// Animation Specific
73
+// --------------------
74
+
75
+	// Selects an animation on wich the animation specific functions operate
76
+    // Returns -1 if it does not exist, else its index
52 77
     public int selectAnimation(int index) {
53
-           System.out.println("Animation " + index + " selected");
54
-           return -1;
78
+           System.out.println("Animation " + index + " selected.");
79
+           
80
+		   return index;
55 81
     }
56
-    
57
-    public String getAnimationName(int index) {
58 82
 
59
-           return "TestAnim";
83
+	// Adds a new Animation
84
+    // Returns id if ok, -1 if error or not enough space for
85
+    // another animation
86
+    public int addAnimation() {
87
+
88
+           return -1;
60 89
     }
61 90
     
62
-    public void setAnimationName(int index, String s) {
91
+    // Removes an animation
92
+    public void removeAnimation() {
63 93
 
64 94
     }
65 95
     
66
-    public void moveAnimation(int dir){
67
-      if (dir == UP){
68
-        //animation moved up
69
-      } else if (dir == DOWN){
70
-        //animation moved down
71
-      }
96
+	public String getAnimationName() {
97
+
98
+           return "TestAnim";
72 99
     }
73
-    
74
-    // Returns how many frames are in the current animation
75
-    public int numOfFrames() {
76 100
 
77
-           return 3;
101
+	public void setAnimationName(String s) {
102
+
78 103
     }
79
-    
80
-    public String getFrameName(int index) {
104
+
105
+	public void moveAnimation(int dir) {
106
+		if (dir == UP){
107
+    		//animation moved up
108
+		
109
+		} else if (dir == DOWN){
110
+			//animation moved down
111
+
112
+		}
113
+	}
114
+
115
+// --------------------
116
+// Frame Specific
117
+// --------------------
118
+	
119
+	// Selects an animation on wich the frame specific functions operate
120
+    // Returns -1 if it does not exist, else its index
121
+	public int selectFrame(int index) {
122
+		System.out.println("Frame " + index + " selected.");
123
+
124
+		return index;
125
+	}
126
+
127
+	public String getFrameName() {
81 128
 
82 129
            return "Test";
83 130
     }
84 131
 
85
-    public void setFrameName(int index, String s) {
132
+    public void setFrameName(String s) {
86 133
 
87 134
     }
88 135
     
@@ -93,29 +140,35 @@ public class cubeWorker {
93 140
            return -1;
94 141
     }
95 142
     
96
-    // Remove a frame
97
-    public void removeFrame(int index) {
143
+    // Remove the frame
144
+    public void removeFrame() {
98 145
 
99 146
     }
100 147
     
101 148
     // Returns array with 64 bytes with led values
102
-    public byte[] getFrame(int index) {
149
+    public byte[] getFrame() {
103 150
 
104 151
            return null;
105 152
     }
106 153
     
107
-    public void setFrame(int index, byte[] data) {
154
+    public void setFrame(byte[] data) {
108 155
 
109 156
     }
110
-    
111
-    public void moveFrame(int dir){
112
-      if (dir == UP){
113
-        //animation moved up
114
-      } else if (dir == DOWN){
115
-        //animation moved down
116
-      }
117
-    }
118
-    
157
+
158
+	public void moveFrame(int dir){
159
+		if (dir == UP){
160
+    		// frame moved up
161
+      
162
+		} else if (dir == DOWN){
163
+			// frame moved down
164
+
165
+		}
166
+	}
167
+
168
+// --------------------
169
+// File Specific
170
+// --------------------
171
+
119 172
     // Loads an animation file into this object
120 173
     public int loadState(String path) {
121 174
 
@@ -127,6 +180,16 @@ public class cubeWorker {
127 180
            System.out.println("Saving to " + path);
128 181
            return 0;
129 182
     }
183
+
184
+	// Returns true if last saved state != current state
185
+    public boolean changedStateSinceSave() {
186
+
187
+           return true;
188
+    }
189
+
190
+// --------------------
191
+// Serial Port Specific
192
+// --------------------
130 193
     
131 194
     // sends state of object to led cube
132 195
     public int uploadState(String port) {
@@ -139,22 +202,13 @@ public class cubeWorker {
139 202
 
140 203
            return 0;
141 204
     }
142
-    
143
-    // Tells how many Frames you can add until you reached 1 Mbit...
144
-    public int framesRemaining() {
145
-
146
-           return 0;
147
-    }
148
-    
205
+        
149 206
     public String[] getSerialPorts() {
150 207
 
151
-           String[] sPorts = {"Select serial port..."};
208
+           String[] sPorts = { "Select serial port..." }; // Has to be the first entry
152 209
            return sPorts;
153 210
     }
154
-    
155
-    // Returns true if last saved state != current state
156
-    public boolean changedStateSinceSave() {
157 211
 
158
-           return true;
159
-    }
212
+// --------------------
213
+
160 214
 }

Laden…
Abbrechen
Speichern