Browse Source

Fixed movement

Thomas Buck 13 years ago
parent
commit
3ced36bdf2

+ 8
- 0
CubeControl/AFrame.java View File

36
 	private short[] data = new short[64];
36
 	private short[] data = new short[64];
37
 	private short duration = 1;
37
 	private short duration = 1;
38
 	private String name = "Frame";
38
 	private String name = "Frame";
39
+	private static int lastIndex = 1;
40
+
41
+	/**
42
+	 * Give it a nice name.
43
+	 */
44
+	public AFrame() {
45
+		name = "Frame " + lastIndex++;
46
+	}
39
 
47
 
40
 	/**
48
 	/**
41
 	 * Gets the Name of this Frame
49
 	 * Gets the Name of this Frame

+ 2
- 0
CubeControl/Animation.java View File

36
 public class Animation {
36
 public class Animation {
37
 	AFrame frames[] = new AFrame[1];
37
 	AFrame frames[] = new AFrame[1];
38
 	private String name = "Animation";
38
 	private String name = "Animation";
39
+	private static int lastIndex = 1;
39
 
40
 
40
 	/**
41
 	/**
41
 	 * Create an empty frame in this new animation.
42
 	 * Create an empty frame in this new animation.
42
 	 */
43
 	 */
43
 	public Animation() {
44
 	public Animation() {
44
 		frames[0] = new AFrame();
45
 		frames[0] = new AFrame();
46
+		name = "Animation " + lastIndex++;
45
 	}
47
 	}
46
 
48
 
47
 	/**
49
 	/**

+ 2
- 1
CubeControl/Frame.java View File

430
 					frameListModel.set(i, frameListModel.get(i + 1));
430
 					frameListModel.set(i, frameListModel.get(i + 1));
431
 					frameListModel.set(i + 1, tmp);
431
 					frameListModel.set(i + 1, tmp);
432
 					frameList.setSelectedIndex(i + 1);
432
 					frameList.setSelectedIndex(i + 1);
433
-					worker.getAnimation(animList.getSelectedIndex()).moveFrameDown(frameList.getSelectedIndex());
433
+					worker.getAnimation(animList.getSelectedIndex()).moveFrameDown(i);
434
 				}
434
 				}
435
 			}
435
 			}
436
 		});
436
 		});
886
 					String[] sPorts = HelperUtility.getPorts();
886
 					String[] sPorts = HelperUtility.getPorts();
887
 					f.jComboBox1.removeAllItems();
887
 					f.jComboBox1.removeAllItems();
888
 					for (int i = 0; i < sPorts.length; i++) {
888
 					for (int i = 0; i < sPorts.length; i++) {
889
+						System.out.println("Port " + i + ": " + sPorts[i]);
889
 						f.jComboBox1.addItem(sPorts[i]);
890
 						f.jComboBox1.addItem(sPorts[i]);
890
 					}
891
 					}
891
 				}
892
 				}

+ 11
- 11
CubeControl/HelperUtility.java View File

77
 			inChannel.close();
77
 			inChannel.close();
78
 			outChannel.close();
78
 			outChannel.close();
79
 			System.load(fileOut.toString());
79
 			System.load(fileOut.toString());
80
-			System.out.println("Loaded Serial Library from " + fileOut.toString());
80
+			System.out.println("Loaded Serial Library!");
81
 		} catch (Exception e) {
81
 		} catch (Exception e) {
82
 			System.out.println("Failed to load Serial Library:");
82
 			System.out.println("Failed to load Serial Library:");
83
 			e.printStackTrace();
83
 			e.printStackTrace();
113
 	 *         others
113
 	 *         others
114
 	 */
114
 	 */
115
 	public static String[] getPorts() {
115
 	public static String[] getPorts() {
116
-		String[] ports = { "No serial ports!" };
117
 		String portLines = getPortsOS();
116
 		String portLines = getPortsOS();
118
 		if (portLines == null) {
117
 		if (portLines == null) {
118
+			String[] ports = { "Select serial port..." };
119
+			return ports;
120
+		} else {
121
+			StringTokenizer sT = new StringTokenizer(portLines, "\n");
122
+			int size = sT.countTokens();
123
+			String[] ports = new String[size];
124
+			for (int i = 0; i < size; i++) {
125
+				ports[i] = sT.nextToken();
126
+			}
119
 			return ports;
127
 			return ports;
120
 		}
128
 		}
121
-		StringTokenizer sT = new StringTokenizer(portLines, "\n");
122
-		int size = sT.countTokens();
123
-		ports = new String[size];
124
-		for (int i = 0; i < size; i++) {
125
-			ports[i] = sT.nextToken();
126
-		}
127
-		return ports;
128
 	}
129
 	}
129
 
130
 
130
 	/**
131
 	/**
137
 		try {
138
 		try {
138
 			if (os.indexOf("windows") > -1) {
139
 			if (os.indexOf("windows") > -1) {
139
 				return getThePorts("COM");
140
 				return getThePorts("COM");
140
-			} else if (os.indexOf("max") > -1) {
141
+			} else if (os.indexOf("mac") > -1) {
141
 				return getThePorts("tty.");
142
 				return getThePorts("tty.");
142
 			} else {
143
 			} else {
143
 				return getThePorts("tty");
144
 				return getThePorts("tty");
146
 			// Unsatisfied linker error:
147
 			// Unsatisfied linker error:
147
 			// Serial.dll was probably not found
148
 			// Serial.dll was probably not found
148
 			System.out.println("Exception: " + e.toString());
149
 			System.out.println("Exception: " + e.toString());
149
-		} finally {
150
 			return null;
150
 			return null;
151
 		}
151
 		}
152
 	}
152
 	}

+ 0
- 1
CubeControl/cubeWorker.java View File

53
 	 */
53
 	 */
54
 	public cubeWorker(Frame parent) {
54
 	public cubeWorker(Frame parent) {
55
 		animations[0] = new Animation();
55
 		animations[0] = new Animation();
56
-		animations[0].setName("Animation 1");
57
 		parentFrame = parent;
56
 		parentFrame = parent;
58
 	}
57
 	}
59
 
58
 

+ 3
- 1
CubeControl/libSerial/serialHelper.c View File

57
 
57
 
58
 	string = (char *)malloc((length + 1) * sizeof(char));
58
 	string = (char *)malloc((length + 1) * sizeof(char));
59
 	if (string == NULL) {
59
 	if (string == NULL) {
60
-		// printf("JNI: Not enough memory!\n");
60
+		printf("JNI: Not enough memory!\n");
61
 		return (*env)->NewStringUTF(env, NULL);
61
 		return (*env)->NewStringUTF(env, NULL);
62
 	}
62
 	}
63
 
63
 
73
 	}
73
 	}
74
 	string[lengthabs] = '\0';
74
 	string[lengthabs] = '\0';
75
 
75
 
76
+	// printf("JNI: %s\n", string);
77
+
76
 	jstring ret = (*env)->NewStringUTF(env, string);
78
 	jstring ret = (*env)->NewStringUTF(env, string);
77
 	return ret;
79
 	return ret;
78
 }
80
 }

Loading…
Cancel
Save