Beispiel #1
0
unsigned int threada ( unsigned int event )
{
    unsigned int nowtick;
    unsigned int tickdiff;

    switch(event)
    {
        case INIT:
        {
            ta_send_char=1;
            ta_char_to_send=0x31;
            ta_tick_last=get_timer_tick();
            ta_led_state=0;
            change_led_state(0,ta_led_state);
            return(0);
        }
        case HEARTBEAT:
        {
            if(ta_send_char)
            {
                if(uart_tx_if_ready(ta_char_to_send)) ta_send_char=0;
            }
            nowtick=get_timer_tick();
            tickdiff=(nowtick-ta_tick_last)&TIMER_TICK_MASK;
            if(tickdiff>=10000000)
            {
                ta_tick_last=(ta_tick_last+10000000)&TIMER_TICK_MASK;
                ta_send_char=1;
                //ta_char_to_send=
                ta_led_state=(ta_led_state+1)&1;
                change_led_state(0,ta_led_state);
            }
            return(0);
        }
        default:
        {
            break;
        }
    }
    return(0);
}
Beispiel #2
0
unsigned int threadb ( unsigned int event )
{
    unsigned int nowtick;

    switch(event)
    {
        case INIT:
        {
            tb_send_char=1;
            tb_char_to_send=0x32;
            tb_tick_last=get_timer_tick();
            tb_led_state=0;
            change_led_state(1,tb_led_state);
            return(0);
        }
        case HEARTBEAT:
        {
            if(tb_send_char)
            {
                if(uart_tx_if_ready(tb_char_to_send)) tb_send_char=0;
            }
            nowtick=get_timer_tick();
            if((nowtick-tb_tick_last)>=5000000)
            {
                tb_tick_last+=5000000;
                tb_send_char=1;
                //tb_char_to_send=
                tb_led_state=(tb_led_state+1)&1;
                change_led_state(1,tb_led_state);
            }
            return(0);
        }
        default:
        {
            break;
        }
    }
    return(0);
}
Beispiel #3
0
void handle_play_mode(FILINFO* pfile_info) {
  // reset to the root after a possible record operation
  change_dir("/");
  // refresh the file list to avoid blank entries bug
  if ((g_num_files = get_num_files(pfile_info)) == 0) {
    lcd_title_P(S_NO_FILES_FOUND);
    lcd_busy_spinner();
    return;
  }

  g_cur_file_index = 0;
  if (!get_file_at_index(pfile_info, g_cur_file_index)) {
    // shouldn't happen...
    lcd_title_P(S_NO_FILES_FOUND);
    lcd_busy_spinner();
    return;
  }

  lcd_title_P(S_SELECT_FILE);
  display_filename(pfile_info);
  
  while (1) {
    switch(get_cur_command()) {
      case COMMAND_SELECT:
        if (pfile_info->fattrib & AM_DIR) {
          if (change_dir(pfile_info->fname) == FR_OK) {
            g_num_files = get_num_files(pfile_info);
            g_cur_file_index = 0;
            get_file_at_index(pfile_info, g_cur_file_index);
            display_filename(pfile_info);
          } else {
            lcd_status_P(S_CHDIR_FAILED);
          }
        } else {
          display_filename(pfile_info);
          play_file(pfile_info);
          lcd_title_P(S_SELECT_FILE);
          // buffer is used so get the file again
          get_file_at_index(pfile_info, g_cur_file_index);
          display_filename(pfile_info);
        }
      break;
      case COMMAND_ABORT:
        if (g_fs.cdir != 0) {
          if (change_dir("..") == FR_OK) {
            g_num_files = get_num_files(pfile_info);
            g_cur_file_index = 0;
            get_file_at_index(pfile_info, g_cur_file_index);
            display_filename(pfile_info);
          } else {
            lcd_status_P(S_CHDIR_FAILED);
          }        
        } else {
          // back to main menu
          return;
        }
      break;
      case COMMAND_NEXT:
        if (++g_cur_file_index >= g_num_files) {
          g_cur_file_index = 0;
        }
        get_file_at_index(pfile_info, g_cur_file_index);
        display_filename(pfile_info);
      break;
      case COMMAND_PREVIOUS:
        if (--g_cur_file_index < 0) {
          g_cur_file_index = g_num_files - 1;
        }
        get_file_at_index(pfile_info, g_cur_file_index);
        display_filename(pfile_info);
      break;
    }
    filename_ticker(pfile_info, get_timer_tick());
  }
}