Wait for button press at beginning

Bonus: added a FIXME to non-working code
master
LEdoianX 9 years ago
parent 05bfa953f4
commit 5603d53239

@ -33,10 +33,13 @@ void inline wait (int ticks) { // This works in libopenocm3 examples
int main (void) { int main (void) {
setup(); setup();
gpio_unset(GPIOC, GPIO8 | GPIO9);
while (gpio_get(GPIOA, GPIO0) == 0);
// Array of what leds should be on // Array of what leds should be on
uint16_t states[4] = {0, GPIO9, GPIO8, GPIO9 | GPIO8}; uint16_t states[4] = {0, GPIO9, GPIO8, GPIO9 | GPIO8};
enum {FORWARD, BACKWARD} direction = FORWARD; enum {FORWARD, BACKWARD} direction = FORWARD;
bool pressed = false; bool pressed = true;
char state; char state;
while (true) { while (true) {
@ -48,7 +51,7 @@ int main (void) {
} }
state = (direction == FORWARD ? (state + 1)%4 : (/*state+4-1*/ state+3)%4 ); state = (direction == FORWARD ? (state + 1)%4 : (/*state+4-1*/ state+3)%4 );
gpio_set(GPIOC, states[state]); gpio_set(GPIOC, states[state]); //FIXME: This doesn't work, as it does not write 0s to unmentioned pins!!
wait(DELAY); wait(DELAY);
} }
return 0; return 0;

Loading…
Cancel
Save