Przeglądaj źródła

Loading an animation file now rebuilds frame list.

Thomas Buck 12 lat temu
rodzic
commit
0dce607e4e
3 zmienionych plików z 42 dodań i 18 usunięć
  1. 6
    7
      CubeControl/Frame.java
  2. 24
    11
      CubeFirmware/main.c
  3. 12
    0
      Example.txt

+ 6
- 7
CubeControl/Frame.java Wyświetl plik

@@ -300,10 +300,9 @@ public class Frame extends JFrame implements ListSelectionListener, ChangeListen
300 300
 		int frameHeight = 646;
301 301
 		setSize(frameWidth, frameHeight);
302 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 306
 		Container cp = getContentPane();
308 307
 		cp.setLayout(null);
309 308
 		Font font = new Font("Dialog", Font.PLAIN, 13);
@@ -651,7 +650,7 @@ public class Frame extends JFrame implements ListSelectionListener, ChangeListen
651 650
 	
652 651
 		animPath.setBounds(417, 281, 228, 20);
653 652
 		animPath.setEditable(false);
654
-		animPath.setText("Load/Save an animation file...");
653
+		animPath.setText("Select an animation file...");
655 654
 		animPath.setFont(font);
656 655
 		cp.add(animPath);
657 656
 		
@@ -675,8 +674,8 @@ public class Frame extends JFrame implements ListSelectionListener, ChangeListen
675 674
 						animListModel.addElement(worker.getAnimation(i).getName());
676 675
 					}
677 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 Wyświetl plik

@@ -77,6 +77,15 @@ uint8_t refreshAnimationCount = 1;
77 77
 uint8_t lastButtonState = 0;
78 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 89
 int main(void) {
81 90
 	uint8_t *audioData = NULL;
82 91
 	uint8_t *imageData = NULL;
@@ -95,6 +104,8 @@ int main(void) {
95 104
 	DDRC = 0xFF; // Latch Enable
96 105
 	DDRA = 0xFF; // Latch Data
97 106
 
107
+	setImage(defaultImage); // Display something
108
+
98 109
 #ifdef DEBUG
99 110
 	// Kill animation counter in debug mode
100 111
 	// => Don't preserve animations while power down
@@ -141,18 +152,20 @@ int main(void) {
141 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 Wyświetl plik

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

Ładowanie…
Anuluj
Zapisz