Browse Source

Continued animation, added buffClearAllPixels

Max Nuding 12 years ago
parent
commit
7b2507a49d
3 changed files with 77 additions and 10 deletions
  1. 64
    8
      CubeFirmware/animations.c
  2. 11
    1
      CubeFirmware/buffhelp.c
  3. 2
    1
      CubeFirmware/header/buffhelp.h

+ 64
- 8
CubeFirmware/animations.c View File

@@ -51,6 +51,7 @@ void simpleAnimation(void) {
51 51
 	
52 52
 	buff = buffNew();
53 53
 
54
+	//Up-wave
54 55
 	for(y = 0; y < 8; y++) {
55 56
 		for(x = 0; x < 8; x++) {
56 57
 			for(z = 0; z < 8; z++) {
@@ -63,11 +64,7 @@ void simpleAnimation(void) {
63 64
 			wdt_reset();
64 65
 		}
65 66
 	
66
-		for(x = 0; x < 8; x++) {
67
-			for(z = 0; z < 8; z++) {
68
-				buffClearPixel(buff, x, y, z);
69
-			}
70
-		}
67
+		buffClearAllPixels(buff);	
71 68
 	}
72 69
 	
73 70
 	// Down-wave (Frames 9-15 of showoff.cube)
@@ -83,12 +80,71 @@ void simpleAnimation(void) {
83 80
 			wdt_reset();
84 81
 		}
85 82
 	
86
-		for(x = 0; x < 8; x++) {
83
+		buffClearAllPixels(buff);	
84
+	}
85
+
86
+	//x-axis wave
87
+	for(x = 0; x < 8; x++) {
88
+		for(y = 0; y < 8; y++) {
87 89
 			for(z = 0; z < 8; z++) {
88
-				buffClearPixel(buff, x, y, z);
90
+				buffSetPixel(buff, x, y, z);
89 91
 			}
90 92
 		}
91
-	}		
93
+
94
+		setImage(buff);
95
+		while(!isFinished()) {
96
+			wdt_reset();
97
+		}
98
+		
99
+		buffClearAllPixels(buff);
100
+	}
101
+	
102
+		for(x = 7; x >= 0; x--) {
103
+			for(y = 0; y < 8; y++) {
104
+				for(z = 0; z < 8; z++) {
105
+					buffSetPixel(buff, x, y, z);
106
+			}
107
+		}
108
+
109
+		setImage(buff);
110
+		while(!isFinished()) {
111
+			wdt_reset();
112
+		}
113
+	
114
+		ClearAllPixels(buff)	
115
+	}
116
+
117
+	//z-axis-wave
118
+	for(z = 0; z < 8; z++) {
119
+		for(y = 0; y < 8; y++) {
120
+			for(x = 0; x < 8; x++) {
121
+				buffSetPixel(buff, x, y, z);
122
+			}
123
+		}
124
+
125
+		setImage(buff);
126
+		while(!isFinished()) {
127
+			wdt_reset();
128
+		}
129
+		
130
+		buffClearAllPixels(buff);
131
+	}
132
+	
133
+		for(z = 7; z >= 0; z--) {
134
+			for(x = 0; x < 8; x++) {
135
+				for(y = 0; y < 8; y++) {
136
+					buffSetPixel(buff, x, y, z);
137
+				}
138
+			}
139
+
140
+			setImage(buff);
141
+			while(!isFinished()) {
142
+				wdt_reset();
143
+			}
144
+	
145
+			ClearAllPixels(buff)	
146
+	}
147
+
92 148
 }
93 149
 
94 150
 void anotherAnimation(void) {

+ 11
- 1
CubeFirmware/buffhelp.c View File

@@ -49,7 +49,17 @@ void buffSetPixel(uint8_t *buffer, uint8_t x, uint8_t y, uint8_t z) {
49 49
 void buffClearPixel(uint8_t *buffer, uint8_t x, uint8_t y, uint8_t z) {
50 50
 	buffer[(8 * (7 - z)) + (7 - y)] &= ~(1 << x);
51 51
 }
52
+void buffClearAllPixels(uint8_t *buffer) {
53
+uint8_t x,y,z;
54
+for(y = 7; y >= 0; y--) {	
55
+		for(x = 0; x < 8; x++) {
56
+			for(z = 0; z < 8; z++) {
57
+				buffClearPixel(buffer, x, y, z);
58
+			}
59
+		}
60
+	}
61
+}
52 62
 
53 63
 void buffFree(uint8_t *buffer) {
54 64
 	free(buffer);
55
-}
65
+}

+ 2
- 1
CubeFirmware/header/buffhelp.h View File

@@ -23,4 +23,5 @@
23 23
 uint8_t *buffNew(void);
24 24
 void buffSetPixel(uint8_t *buffer, uint8_t x, uint8_t y, uint8_t z);
25 25
 void buffClearPixel(uint8_t *buffer, uint8_t x, uint8_t y, uint8_t z);
26
-void buffFree(uint8_t *buffer);
26
+void buffClearAllPixels(uint8_t *buffer);
27
+void buffFree(uint8_t *buffer);

Loading…
Cancel
Save