|
@@ -170,21 +170,21 @@ public class cubeWorker {
|
170
|
170
|
}
|
171
|
171
|
|
172
|
172
|
// Returns array with 64 bytes with led values
|
173
|
|
- public byte[] getFrame(int anim, int frame) {
|
|
173
|
+ public short[] getFrame(int anim, int frame) {
|
174
|
174
|
return animations.get(anim).get(frame).getData();
|
175
|
175
|
}
|
176
|
176
|
|
177
|
|
- public void setFrame(byte[] data, int anim, int frame) {
|
|
177
|
+ public void setFrame(short[] data, int anim, int frame) {
|
178
|
178
|
changedState = true;
|
179
|
179
|
animations.get(anim).get(frame).setData(data);
|
180
|
180
|
}
|
181
|
181
|
|
182
|
182
|
// Frame duration in 1/24th of a second
|
183
|
|
- public byte getFrameTime(int anim, int frame) {
|
|
183
|
+ public short getFrameTime(int anim, int frame) {
|
184
|
184
|
return animations.get(anim).get(frame).getTime();
|
185
|
185
|
}
|
186
|
186
|
|
187
|
|
- public void setFrameTime(byte time, int anim, int frame) {
|
|
187
|
+ public void setFrameTime(short time, int anim, int frame) {
|
188
|
188
|
changedState = true;
|
189
|
189
|
animations.get(anim).get(frame).setTime(time);
|
190
|
190
|
}
|
|
@@ -352,9 +352,9 @@ class AnimationUtility {
|
352
|
352
|
private static AFrame readFrame(Scanner sc, int index) {
|
353
|
353
|
AFrame frame = new AFrame();
|
354
|
354
|
frame.setName(sc.nextLine());
|
355
|
|
- byte[] d = {};
|
|
355
|
+ short[] d = {};
|
356
|
356
|
for (int i = 0; i < 8; i++) {
|
357
|
|
- byte[] data = hexConvert(sc.nextLine());
|
|
357
|
+ short[] data = hexConvert(sc.nextLine());
|
358
|
358
|
d = concat(data, d);
|
359
|
359
|
}
|
360
|
360
|
frame.setData(d);
|
|
@@ -363,17 +363,32 @@ class AnimationUtility {
|
363
|
363
|
return frame;
|
364
|
364
|
}
|
365
|
365
|
|
366
|
|
- private static byte[] concat(byte[] a, byte[] b) {
|
367
|
|
- byte[] c = new byte[a.length + b.length];
|
|
366
|
+ private static short[] concat(short[] a, short[] b) {
|
|
367
|
+ short[] c = new short[a.length + b.length];
|
368
|
368
|
System.arraycopy(a, 0, c, 0, a.length);
|
369
|
369
|
System.arraycopy(b, 0, c, a.length, b.length);
|
370
|
370
|
return c;
|
371
|
371
|
}
|
372
|
372
|
|
373
|
|
- private static byte[] hexConvert(String hex) {
|
374
|
|
- hex = hex.replaceAll("\\n", "");
|
375
|
|
- HexBinaryAdapter a = new HexBinaryAdapter();
|
376
|
|
- return a.unmarshal(hex);
|
|
373
|
+ private static short[] hexConvert(String hex) {
|
|
374
|
+ hex = hex.replaceAll("\\n", "");
|
|
375
|
+
|
|
376
|
+ short[] tmp = new short[hex.length()/2];
|
|
377
|
+ for (int i = 0; i < hex.length(); i=i+2){
|
|
378
|
+ char[] tmpString = new char[2];
|
|
379
|
+ tmpString[0] = hex.charAt(i);
|
|
380
|
+ tmpString[1] = hex.charAt(i+1);
|
|
381
|
+ String tmpS = String.copyValueOf(tmpString);
|
|
382
|
+ if(i == 0){
|
|
383
|
+ tmp[0] = Short.parseShort(tmpS, 16);
|
|
384
|
+ } else {
|
|
385
|
+ tmp[i/2] = Short.parseShort(tmpS, 16);
|
|
386
|
+ }
|
|
387
|
+
|
|
388
|
+ }
|
|
389
|
+ return tmp;
|
|
390
|
+
|
|
391
|
+
|
377
|
392
|
}
|
378
|
393
|
|
379
|
394
|
private static void writeAnimation(Animation anim, FileWriter f, boolean last) throws IOException {
|
|
@@ -395,7 +410,7 @@ class AnimationUtility {
|
395
|
410
|
f.write(Integer.toString( (fr.getTime() & 0xff) + 0x100, 16).substring(1) + "\n");
|
396
|
411
|
}
|
397
|
412
|
|
398
|
|
- private static void writeLayer(byte[] l, FileWriter f) throws IOException {
|
|
413
|
+ private static void writeLayer(short[] l, FileWriter f) throws IOException {
|
399
|
414
|
String hex = "";
|
400
|
415
|
for (int i = 0; i < l.length; i++) {
|
401
|
416
|
hex += Integer.toString( (l[i] & 0xff) + 0x100, 16).substring(1);
|
|
@@ -407,8 +422,8 @@ class AnimationUtility {
|
407
|
422
|
}
|
408
|
423
|
|
409
|
424
|
class AFrame {
|
410
|
|
- private byte[] data = new byte[64];
|
411
|
|
- private byte duration = 1;
|
|
425
|
+ private short[] data = new short[64];
|
|
426
|
+ private short duration = 1;
|
412
|
427
|
private String name = "Frame";
|
413
|
428
|
|
414
|
429
|
String getName() {
|
|
@@ -419,23 +434,23 @@ class AFrame {
|
419
|
434
|
name = s;
|
420
|
435
|
}
|
421
|
436
|
|
422
|
|
- void setData(byte[] d) {
|
|
437
|
+ void setData(short[] d) {
|
423
|
438
|
data = d;
|
424
|
439
|
}
|
425
|
440
|
|
426
|
|
- byte[] getData() {
|
|
441
|
+ short[] getData() {
|
427
|
442
|
return data;
|
428
|
443
|
}
|
429
|
444
|
|
430
|
|
- void setTime(byte t) {
|
|
445
|
+ void setTime(short t) {
|
431
|
446
|
duration = t;
|
432
|
447
|
}
|
433
|
448
|
|
434
|
|
- byte getTime() {
|
|
449
|
+ short getTime() {
|
435
|
450
|
return duration;
|
436
|
451
|
}
|
437
|
452
|
|
438
|
|
- byte[] getLayer(int i) {
|
|
453
|
+ short[] getLayer(int i) {
|
439
|
454
|
return Arrays.copyOfRange(data, (i * 8), (i * 8) + 8);
|
440
|
455
|
}
|
441
|
456
|
}
|