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,6 +36,7 @@ B)	Increment NUMOFANIMATION by the number of animations you are going to add.
36 36
 C)	Put a function pointer to your new animation into the animations[] Array.
37 37
 D)	Implement your animation!
38 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 42
 // Prototypes for all animations
@@ -48,7 +49,7 @@ void zWave2(uint8_t i);
48 49
 
49 50
 // Array of animation functions
50 51
 #define NUMOFANIMATIONS 0
51
-void (*animations[NUMOFANIMATIONS])(void) = { };
52
+uint8_t (*animations[NUMOFANIMATIONS])(void) = { };
52 53
 
53 54
 #define WAVELENGTH 2
54 55
 
@@ -56,7 +57,7 @@ uint8_t numOfAnimations(void) {
56 57
 	return NUMOFANIMATIONS + 24;
57 58
 }
58 59
 
59
-void executeAnimation(uint8_t id) {
60
+uint8_t executeAnimation(uint8_t id) {
60 61
 	if (id < (6*4)) {
61 62
 		if (id < 4) {
62 63
 			upWave(id);
@@ -71,9 +72,11 @@ void executeAnimation(uint8_t id) {
71 72
 		} else {
72 73
 			zWave2(id - 20);
73 74
 		}
75
+		return 1;
74 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 82
 void upWave(uint8_t i) {

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

@@ -22,4 +22,4 @@
22 22
  */
23 23
 
24 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,9 +166,9 @@ int main(void) {
166 166
 					}
167 167
 				} else {
168 168
 					// Built-In Frames
169
-					if (isFinished()) {
169
+					if (isFinished() > duration) {
170 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,7 +24,7 @@
24 24
 
25 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 28
 const char stringSelfTestError[] PROGMEM = "Self-Test Error: 0b"; // 1
29 29
 const char stringInit[] PROGMEM = "Initialized: "; // 2
30 30
 const char stringAudioError[] PROGMEM = " => No answer from Audio!\n"; // 3

Loading…
Cancel
Save