Browse Source

Idle Animations can set a desired duration now.

Also incremented version number.
Thomas Buck 12 years ago
parent
commit
d7f90d3801
5 changed files with 1193 additions and 1191 deletions
  1. 6
    3
      CubeFirmware/animations.c
  2. 1
    1
      CubeFirmware/header/animations.h
  3. 2
    2
      CubeFirmware/main.c
  4. 1183
    1184
      CubeFirmware/main.hex
  5. 1
    1
      CubeFirmware/strings.c

+ 6
- 3
CubeFirmware/animations.c View File

36
 C)	Put a function pointer to your new animation into the animations[] Array.
36
 C)	Put a function pointer to your new animation into the animations[] Array.
37
 D)	Implement your animation!
37
 D)	Implement your animation!
38
 	--> Get a buffer with buffNew(); Display it with setImage(); Free Buffer after usage!
38
 	--> Get a buffer with buffNew(); Display it with setImage(); Free Buffer after usage!
39
+	--> Return desired duration until the next animation is called, in frames (24fps)
39
 */
40
 */
40
 
41
 
41
 // Prototypes for all animations
42
 // Prototypes for all animations
48
 
49
 
49
 // Array of animation functions
50
 // Array of animation functions
50
 #define NUMOFANIMATIONS 0
51
 #define NUMOFANIMATIONS 0
51
-void (*animations[NUMOFANIMATIONS])(void) = { };
52
+uint8_t (*animations[NUMOFANIMATIONS])(void) = { };
52
 
53
 
53
 #define WAVELENGTH 2
54
 #define WAVELENGTH 2
54
 
55
 
56
 	return NUMOFANIMATIONS + 24;
57
 	return NUMOFANIMATIONS + 24;
57
 }
58
 }
58
 
59
 
59
-void executeAnimation(uint8_t id) {
60
+uint8_t executeAnimation(uint8_t id) {
60
 	if (id < (6*4)) {
61
 	if (id < (6*4)) {
61
 		if (id < 4) {
62
 		if (id < 4) {
62
 			upWave(id);
63
 			upWave(id);
71
 		} else {
72
 		} else {
72
 			zWave2(id - 20);
73
 			zWave2(id - 20);
73
 		}
74
 		}
75
+		return 1;
74
 	} else if ((id - (6*4)) < NUMOFANIMATIONS) {
76
 	} else if ((id - (6*4)) < NUMOFANIMATIONS) {
75
-		animations[id - (6*4)](); // Call animation
77
+		return animations[id - (6*4)](); // Call animation
76
 	}
78
 	}
79
+	return 1;
77
 }
80
 }
78
 
81
 
79
 void upWave(uint8_t i) {
82
 void upWave(uint8_t i) {

+ 1
- 1
CubeFirmware/header/animations.h View File

22
  */
22
  */
23
 
23
 
24
 uint8_t numOfAnimations(void);
24
 uint8_t numOfAnimations(void);
25
-void executeAnimation(uint8_t id);
25
+uint8_t executeAnimation(uint8_t id); // Returns desired duration

+ 2
- 2
CubeFirmware/main.c View File

166
 					}
166
 					}
167
 				} else {
167
 				} else {
168
 					// Built-In Frames
168
 					// Built-In Frames
169
-					if (isFinished()) {
169
+					if (isFinished() > duration) {
170
 						idleIndex = (idleIndex < (idleCount - 1)) ? (idleIndex + 1) : 0;
170
 						idleIndex = (idleIndex < (idleCount - 1)) ? (idleIndex + 1) : 0;
171
-						executeAnimation(idleIndex);
171
+						duration = executeAnimation(idleIndex);
172
 					}
172
 					}
173
 				}
173
 				}
174
 			}
174
 			}

+ 1183
- 1184
CubeFirmware/main.hex
File diff suppressed because it is too large
View File


+ 1
- 1
CubeFirmware/strings.c View File

24
 
24
 
25
 char buffer[60];
25
 char buffer[60];
26
 
26
 
27
-const char stringVersion[] PROGMEM = "v2.4\n"; // 0
27
+const char stringVersion[] PROGMEM = "v2.5\n"; // 0
28
 const char stringSelfTestError[] PROGMEM = "Self-Test Error: 0b"; // 1
28
 const char stringSelfTestError[] PROGMEM = "Self-Test Error: 0b"; // 1
29
 const char stringInit[] PROGMEM = "Initialized: "; // 2
29
 const char stringInit[] PROGMEM = "Initialized: "; // 2
30
 const char stringAudioError[] PROGMEM = " => No answer from Audio!\n"; // 3
30
 const char stringAudioError[] PROGMEM = " => No answer from Audio!\n"; // 3

Loading…
Cancel
Save