Created
November 29, 2014 15:04
-
-
Save Arachnid/eac23706517c89f3e35b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
typedef enum { | |
STATE_MAIN, | |
STATE_RECEIVE, | |
STATE_SEND, | |
STATE_PLAY | |
} state_t; | |
void state_machine() { | |
while(1) | |
{ | |
switch(state) | |
{ | |
case STATE_MAIN: | |
{ | |
check_buttons(); | |
break; | |
} | |
case STATE_RECEIVE: | |
{ | |
read_ir_data(); | |
break; | |
} | |
case STATE_SEND: | |
{ | |
//TODO: Turn on some LEDs to signify data being sent (no PWM) | |
send_data(currentTune); | |
state = STATE_MAIN; | |
_delay_ms(1000); | |
break; | |
} | |
case STATE_PLAY: | |
{ | |
play_tune(currentTune); | |
state = STATE_MAIN; | |
break; | |
} | |
default: | |
{ | |
state = STATE_MAIN; | |
break; | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment