Exemple #1
0
/**
 * @brief main code for Mode 1
 * Prompts the user to press a certain random dot, gives feedback based on
 * whether they pressed the correct dot
 * @return Void
 */
void md1_main(void)
{
  switch(current_state)
  {
    case STATE_INITIAL:
      log_msg("[MD1] Entering MD1\n\r");
      used_num_cnt = 0;
      // Play the introductory message for Mode 1
      play_mp3(MODE_FILESET,MP3_INTRODUCTION);
      current_state = STATE_REQUEST_INPUT1;
      break;
    case STATE_REQUEST_INPUT1:
      play_mp3(MODE_FILESET,MP3_FIND_DOT);
      expected_dot = random_number_as_char();
      current_state = STATE_REQUEST_INPUT2;
      break;
    case STATE_REQUEST_INPUT2:
      // Generate a random char from '1' to '6'
      play_dot(expected_dot);
      current_state = STATE_WAIT_INPUT;
      break;
    case STATE_WAIT_INPUT:
      if(last_dot != 0)
        current_state = STATE_PROC_INPUT;
      break;
    case STATE_PROC_INPUT:
      if(last_dot != expected_dot)
      {
        play_mp3(LANG_FILESET,MP3_INCORRECT);
        play_mp3(MODE_FILESET, MP3_FIND_DOT);
        play_dot(expected_dot);
        last_dot = 0;
        current_state = STATE_WAIT_INPUT;
      }
      else
      {
        play_mp3(LANG_FILESET,MP3_CORRECT);
        play_mp3(SYS_FILESET, MP3_TADA);
        last_dot = 0;
        current_state = STATE_REQUEST_INPUT1;
      }
      break;
    default:
      break;
  }
}
Exemple #2
0
/**
* @brief Gets current dot and then sets it to NO_DOTS
* @param void
* @return char - Current dot
*/
char get_dot(void) {
	play_dot(io_dot);
	char ret_val = io_dot;
	io_dot = NO_DOTS;
	return ret_val;
}
/**
 * @brief  Set the dot the from input
 * @param this_dot the dot input
 * @return Void
 */
void mode_5_input_dot(char this_dot) {
    last_dot = this_dot;
    log_msg("In input dot: %x", this_dot);
    play_dot(this_dot);
}