Browse Source

Fixed movement

Thomas Buck 12 years ago
parent
commit
3ced36bdf2

+ 8
- 0
CubeControl/AFrame.java View File

@@ -36,6 +36,14 @@ public class AFrame {
36 36
 	private short[] data = new short[64];
37 37
 	private short duration = 1;
38 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 49
 	 * Gets the Name of this Frame

+ 2
- 0
CubeControl/Animation.java View File

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

+ 2
- 1
CubeControl/Frame.java View File

@@ -430,7 +430,7 @@ public class Frame extends JFrame implements ListSelectionListener {
430 430
 					frameListModel.set(i, frameListModel.get(i + 1));
431 431
 					frameListModel.set(i + 1, tmp);
432 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,6 +886,7 @@ public class Frame extends JFrame implements ListSelectionListener {
886 886
 					String[] sPorts = HelperUtility.getPorts();
887 887
 					f.jComboBox1.removeAllItems();
888 888
 					for (int i = 0; i < sPorts.length; i++) {
889
+						System.out.println("Port " + i + ": " + sPorts[i]);
889 890
 						f.jComboBox1.addItem(sPorts[i]);
890 891
 					}
891 892
 				}

+ 11
- 11
CubeControl/HelperUtility.java View File

@@ -77,7 +77,7 @@ public class HelperUtility {
77 77
 			inChannel.close();
78 78
 			outChannel.close();
79 79
 			System.load(fileOut.toString());
80
-			System.out.println("Loaded Serial Library from " + fileOut.toString());
80
+			System.out.println("Loaded Serial Library!");
81 81
 		} catch (Exception e) {
82 82
 			System.out.println("Failed to load Serial Library:");
83 83
 			e.printStackTrace();
@@ -113,18 +113,19 @@ public class HelperUtility {
113 113
 	 *         others
114 114
 	 */
115 115
 	public static String[] getPorts() {
116
-		String[] ports = { "No serial ports!" };
117 116
 		String portLines = getPortsOS();
118 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 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,7 +138,7 @@ public class HelperUtility {
137 138
 		try {
138 139
 			if (os.indexOf("windows") > -1) {
139 140
 				return getThePorts("COM");
140
-			} else if (os.indexOf("max") > -1) {
141
+			} else if (os.indexOf("mac") > -1) {
141 142
 				return getThePorts("tty.");
142 143
 			} else {
143 144
 				return getThePorts("tty");
@@ -146,7 +147,6 @@ public class HelperUtility {
146 147
 			// Unsatisfied linker error:
147 148
 			// Serial.dll was probably not found
148 149
 			System.out.println("Exception: " + e.toString());
149
-		} finally {
150 150
 			return null;
151 151
 		}
152 152
 	}

+ 0
- 1
CubeControl/cubeWorker.java View File

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

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

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

Loading…
Cancel
Save