|
@@ -52,7 +52,6 @@
|
52
|
52
|
#define IDLELENGTH 48
|
53
|
53
|
|
54
|
54
|
void init(void);
|
55
|
|
-uint8_t audioModeSelected(void);
|
56
|
55
|
uint8_t selfTest(void);
|
57
|
56
|
void serialHandler(char c);
|
58
|
57
|
|
|
@@ -136,9 +135,6 @@ int main(void) {
|
136
|
135
|
uint8_t i;
|
137
|
136
|
uint8_t imageIndex = 0, imageCount = 0;
|
138
|
137
|
uint8_t idleIndex = 0, idleCount = 0;
|
139
|
|
- uint8_t lastButtonCheck;
|
140
|
|
- // uint8_t fpsWasSent = 0;
|
141
|
|
- // uint32_t temp;
|
142
|
138
|
uint8_t *imageData = NULL, *audioData = NULL;
|
143
|
139
|
uint8_t duration = 0;
|
144
|
140
|
|
|
@@ -155,14 +151,13 @@ int main(void) {
|
155
|
151
|
disableMemory = 1;
|
156
|
152
|
serialWriteString(getString(0)); // Print Version
|
157
|
153
|
|
158
|
|
- audioModeSelected(); // Initial button state check
|
159
|
|
- lastButtonCheck = getSystemTime(); // Time we checked
|
160
|
|
-
|
161
|
154
|
if (disableMemory == 0)
|
162
|
155
|
imageCount = getAnimationCount(); // Retrieve image count from memory
|
163
|
156
|
idleCount = numOfAnimations();
|
164
|
157
|
if (disableAudioData == 0)
|
165
|
158
|
maxButtonState = numberOfVisualizations() + 1; // Number of toggle steps for button
|
|
159
|
+ lastButtonState = 1;
|
|
160
|
+
|
166
|
161
|
|
167
|
162
|
while(1) { // Our Mainloop
|
168
|
163
|
if (!shouldRestart) { // A flag to trigger a watchdog reset
|
|
@@ -179,10 +174,13 @@ int main(void) {
|
179
|
174
|
serialHandler((char)(serialGet()));
|
180
|
175
|
}
|
181
|
176
|
|
182
|
|
- //if ((getSystemTime() - lastButtonCheck) >= 150) { // Check button state every 150ms
|
183
|
|
- audioModeSelected();
|
184
|
|
- // lastButtonCheck = getSystemTime();
|
185
|
|
- //}
|
|
177
|
+ if (debounce(PINB, PB0)) {
|
|
178
|
+ if (lastButtonState > 0) {
|
|
179
|
+ lastButtonState--;
|
|
180
|
+ } else {
|
|
181
|
+ lastButtonState = maxButtonState - 1;
|
|
182
|
+ }
|
|
183
|
+ }
|
186
|
184
|
|
187
|
185
|
if (lastButtonState == 0) {
|
188
|
186
|
// Display animations, stored or built-in
|
|
@@ -259,20 +257,6 @@ void init(void) {
|
259
|
257
|
setImage(defaultImageCube); // Display something
|
260
|
258
|
}
|
261
|
259
|
|
262
|
|
-uint8_t audioModeSelected(void) {
|
263
|
|
- // Pushbutton: PB0, Low active
|
264
|
|
- if (debounce(PINB, PB0)) {
|
265
|
|
- // Button pushed
|
266
|
|
- if (lastButtonState < (maxButtonState - 1)) {
|
267
|
|
- lastButtonState++;
|
268
|
|
- } else {
|
269
|
|
- lastButtonState = 0;
|
270
|
|
- }
|
271
|
|
-
|
272
|
|
- }
|
273
|
|
- return lastButtonState;
|
274
|
|
-}
|
275
|
|
-
|
276
|
260
|
uint8_t selfTest(void) {
|
277
|
261
|
uint8_t result = NOERROR;
|
278
|
262
|
|
|
@@ -393,10 +377,10 @@ void serialHandler(char c) {
|
393
|
377
|
break;
|
394
|
378
|
|
395
|
379
|
case 'm': case 'M':
|
396
|
|
- if (lastButtonState < (maxButtonState - 1)) {
|
397
|
|
- lastButtonState++;
|
|
380
|
+ if (lastButtonState > 0) {
|
|
381
|
+ lastButtonState--;
|
398
|
382
|
} else {
|
399
|
|
- lastButtonState = 0;
|
|
383
|
+ lastButtonState = maxButtonState - 1;
|
400
|
384
|
}
|
401
|
385
|
if (lastButtonState) {
|
402
|
386
|
serialWriteString(getString(41));
|