Browse Source

Loading an animation file now rebuilds frame list.

Thomas Buck 12 years ago
parent
commit
0dce607e4e
3 changed files with 42 additions and 18 deletions
  1. 6
    7
      CubeControl/Frame.java
  2. 24
    11
      CubeFirmware/main.c
  3. 12
    0
      Example.txt

+ 6
- 7
CubeControl/Frame.java View File

300
 		int frameHeight = 646;
300
 		int frameHeight = 646;
301
 		setSize(frameWidth, frameHeight);
301
 		setSize(frameWidth, frameHeight);
302
 		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
302
 		Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
303
-		// int x = (d.width - getSize().width) / 2;
304
-		// int y = (d.height - getSize().height) / 2;
305
-		// setLocation(x, y);
306
-		setLocation(50, 50);
303
+		int x = (d.width - frameWidth) / 2;
304
+		int y = (d.height - frameHeight) / 2;
305
+		setLocation(x, y);
307
 		Container cp = getContentPane();
306
 		Container cp = getContentPane();
308
 		cp.setLayout(null);
307
 		cp.setLayout(null);
309
 		Font font = new Font("Dialog", Font.PLAIN, 13);
308
 		Font font = new Font("Dialog", Font.PLAIN, 13);
651
 	
650
 	
652
 		animPath.setBounds(417, 281, 228, 20);
651
 		animPath.setBounds(417, 281, 228, 20);
653
 		animPath.setEditable(false);
652
 		animPath.setEditable(false);
654
-		animPath.setText("Load/Save an animation file...");
653
+		animPath.setText("Select an animation file...");
655
 		animPath.setFont(font);
654
 		animPath.setFont(font);
656
 		cp.add(animPath);
655
 		cp.add(animPath);
657
 		
656
 		
675
 						animListModel.addElement(worker.getAnimation(i).getName());
674
 						animListModel.addElement(worker.getAnimation(i).getName());
676
 					}
675
 					}
677
 					animList.setModel(animListModel);
676
 					animList.setModel(animListModel);
678
-					frameListModel.clear();
679
-					frameList.setModel(frameListModel);
677
+					animList.setSelectedIndex(0);
678
+					rebuildFrameList();
680
 				}
679
 				}
681
 			}
680
 			}
682
 		});
681
 		});

+ 24
- 11
CubeFirmware/main.c View File

77
 uint8_t lastButtonState = 0;
77
 uint8_t lastButtonState = 0;
78
 char buffer[11];
78
 char buffer[11];
79
 
79
 
80
+uint8_t defaultImage[64] = 	{	0xe7, 0xc3, 0xa5, 0x18, 0x18, 0xa5, 0xc3, 0xe7,
81
+								0x81, 0x81, 0x00, 0x18, 0x18, 0x00, 0x81, 0x81,
82
+								0x81, 0x00, 0x81, 0x18, 0x18, 0x81, 0x00, 0x81,
83
+								0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00,
84
+								0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00,
85
+								0x81, 0x00, 0x81, 0x18, 0x18, 0x81, 0x00, 0x81,
86
+								0x81, 0x81, 0x00, 0x18, 0x18, 0x00, 0x81, 0x81,
87
+								0xe7, 0xc3, 0xa5, 0x18, 0x18, 0xa5, 0xc3, 0xe7 };
88
+
80
 int main(void) {
89
 int main(void) {
81
 	uint8_t *audioData = NULL;
90
 	uint8_t *audioData = NULL;
82
 	uint8_t *imageData = NULL;
91
 	uint8_t *imageData = NULL;
95
 	DDRC = 0xFF; // Latch Enable
104
 	DDRC = 0xFF; // Latch Enable
96
 	DDRA = 0xFF; // Latch Data
105
 	DDRA = 0xFF; // Latch Data
97
 
106
 
107
+	setImage(defaultImage); // Display something
108
+
98
 #ifdef DEBUG
109
 #ifdef DEBUG
99
 	// Kill animation counter in debug mode
110
 	// Kill animation counter in debug mode
100
 	// => Don't preserve animations while power down
111
 	// => Don't preserve animations while power down
141
 				i = 0;
152
 				i = 0;
142
 			}
153
 			}
143
 
154
 
144
-			if (isFinished() > length) {
145
-				// Load next image
146
-				if (i < (count - 1)) {
147
-					i++;
148
-				} else {
149
-					i = 0;
155
+			if (count > 0) {
156
+				if (isFinished() > length) {
157
+					// Load next image
158
+					if (i < (count - 1)) {
159
+						i++;
160
+					} else {
161
+						i = 0;
162
+					}
163
+
164
+					imageData = getFrame(i);
165
+					length = imageData[64];
166
+					setImage(imageData);
167
+					free(imageData);
150
 				}
168
 				}
151
-
152
-				imageData = getFrame(i);
153
-				length = imageData[64];
154
-				setImage(imageData);
155
-				free(imageData);
156
 			}
169
 			}
157
 		}
170
 		}
158
 
171
 

+ 12
- 0
Example.txt View File

1
+1
2
+Logo
3
+Logo
4
+e7c3a51818a5c3e7
5
+8181001818008181
6
+8100811818810081
7
+000000ffff000000
8
+000000ffff000000
9
+8100811818810081
10
+8181001818008181
11
+e7c3a51818a5c3e7
12
+01

Loading…
Cancel
Save