⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 song_task.c

📁 atmel at89c51snd1c mp3芯片方案源码
💻 C
📖 第 1 页 / 共 2 页
字号:
            break;

        //  case KEY_SOUND:
        //   song_snd_select();              /* select next sound control */
        //   print_sound();                  /* display selected sound icon */
        //    print_sound_level();            /* display new level */
        //    break;

          case KEY_REPEAT:
            song_loop = ~song_loop;         /* display repeat or not */
            print_repeat(song_loop);
            break;

          case KEY_STOP:
            song_stop();                    /* stop playing song */
            Fclose();
            song_state = SONG_STOP;
            break;

  
//          case KEY_FILE_SELECT:
//            song_stop();                    /* stop playing song */
//            Fclose();
//			File_entry_root(FILE_MP3 | FILE_DIR); /* goto root directory */
           // print_file_name(); 
//            song_state = SONG_FILE_SELECT;
//            break;

          default:
            break;
        }
        gl_key_press = FALSE;               /* ack key usage */
      }
      break;
    }

    case SONG_PAUSE:                        /* one file openned */
    { 
	  LED_GREEN = 1;
	  LED_RED = 0;
      if (gl_key_press)                     /* a key is pressed? */
      {
        switch (gl_key)
        {
          case KEY_PLAY:
            disp_clock_start();             /* restart clock timer */
            Aud_song_play();                /* restart sample request */
            print_state_play();             /* display play icon */
            song_state = SONG_PLAY;
            break;

          case KEY_NEXT:
            song_pause();                   /* pause playing song */
            Fclose();
            loop = TRUE;                    /* keypad action so loop */
            song_state = SONG_NEXT;
            break;

          case KEY_PREV:
            song_pause();                   /* pause playing song */
            Fclose();
            loop = TRUE;                    /* keypad action so loop */
            song_state = SONG_PREV;
            break;

          case KEY_INC:
            song_snd_inc();                 /* increment selected control */
            print_sound_level();            /* display new level */
            break;

          case KEY_DEC:
            song_snd_dec();                 /* decrement selected control */
            print_sound_level();            /* display new level */
            break;

        //  case KEY_SOUND:
        //    song_snd_select();              /* select next sound control */
        //    print_sound();                  /* display selected sound icon */
        //    print_sound_level();            /* display new level */
        //    break;

          case KEY_REPEAT:
            song_loop = ~song_loop;         /* display repeat or not */
            print_repeat(song_loop);
            break;

          case KEY_STOP:
            song_stop();                    /* stop playing song */
            Fclose();
            song_state = SONG_STOP;
            break;

          default:
            break;
        }
        gl_key_press = FALSE;               /* ack key usage */
      }
      break;
    }


    case SONG_NEW:
    {
    #if PLAYER_PLAY_MODE == PLAY_DISK
      if (File_type() == FILE_DIR)
      {
        if (file_entry_dir(FILE_MP3 | FILE_DIR) == OK)
        { /* mp3 or dir in sub-dir */
          song_state = SONG_NEW;            /* stay in same state */
        }
        else
        { /* no mp3 or dir in sub-dir */
          song_state = SONG_NEXT;           /* select next */
        }
      }
      else
      { /* file is MP3 */
        song_state = SONG_INIT;             /* new song */
        // print_repeat(song_loop);
        //Mp3_set_right_vol(0);
        //Mp3_set_left_vol(0);
        print_file_name();                  /* display file name */
      }
      break;
    #else /* PLAYER_MODE == PLAY_DIR */
      song_state = SONG_INIT;               /* new song */
      print_repeat(song_loop);
      //Mp3_set_right_vol(0);
      //Mp3_set_left_vol(0);
      print_file_name();                    /* display file name */
      break;
    #endif
    }

    case SONG_NEXT:
    {   
    //disp_name_stop();                     /* stop scrolling */
    #if PLAYER_PLAY_MODE == PLAY_DISK
      if (file_seek_next(FILE_MP3 | FILE_DIR, FALSE))/* next song or dir */
      { /* mp3 or dir selected */
        song_state = SONG_NEW;
      }
      else
      { /* at end of dir */
        if (File_goto_parent(FILE_MP3 | FILE_DIR) == OK)
        { /* parent exists, point on dir */
          song_state = SONG_NEXT;           /* next will select next file */
        }
        else
        { /* no parent: end of root dir */
          if (loop)
          {
            song_state = SONG_NEW;
          }
          else
          {
            song_stop();
            song_state = SONG_STOP;
          }
        }
      }
      break;
    #else /* PLAYER_MODE == PLAY_DIR */
      if (file_seek_next(FILE_MP3, loop))   /* select next song */
      { /* still some file to play */
        song_state = SONG_NEW;
      }
      else
      { /* end of dir: stop */
        song_stop();
        song_state = SONG_STOP;
      }
      break;
    #endif
    }

    case SONG_PREV:
    {
	    //disp_name_stop();                     /* stop scrolling */
    #if PLAYER_PLAY_MODE == PLAY_DISK
		while( song_state == SONG_PREV )
		{	/* prev song or dir */
	      if( !file_seek_prev(FILE_MP3 | FILE_DIR, FALSE))
	      { /* No mp3 or dir selected, at beginning of dir */
	        if (File_goto_parent(FILE_MP3 | FILE_DIR) != OK)
	        { /* no parent: beginning of root dir */
	           if (loop)
	           {
				 if(File_goto_last() != OK)    /* goto to the end of dir */
				 {	/* error system */
		            song_stop();
		            song_state = SONG_STOP;
				 }
	           }
	           else
	           { /* end of dir: stop */
	             song_stop();
	             song_state = SONG_STOP;
	           }
	         }
			 else
			 {
			   continue;    										/* goto to previous file in dir parent */
			 }
	      }

	      while (File_type() == FILE_DIR)
	      { /* file found is directory -> enter directory and goto last file */
	  	     if (file_entry_dir(FILE_MP3 | FILE_DIR) == OK)
	         { /* mp3 or dir in sub-dir */
			   if(File_goto_last() != OK)               /* goto to the end of dir */
			   { /* error system */
	             song_stop();
	             song_state = SONG_STOP;
			   }
			 }
			 else
			 {
			   break;					/* directory empty goto search previous file */
			 }
		   }

		   if (File_type() == FILE_MP3)
     	  { /* mp3 file -> stop research previous file */
			 song_state = SONG_NEW;
		  }
				/* HERE song_state == SONG_PREV, if select file is empty directory or not mp3 file */
	   }
       break;
    #else /* PLAYER_MODE == PLAY_DIR */
      if (file_seek_prev(FILE_MP3, loop))   /* select prev song */
      { /* still some file to play */
        song_state = SONG_NEW;
      }
      else
      { /* beginning of dir: stop */
        song_stop();
        song_state = SONG_STOP;
      }
      break;
    #endif
    }


    case SONG_STOP:
    {
      lcd_print_string(0x40,"stop");
      disp_end_of_play();                   /* end of music... */
      disp_clock_reset();                   /* reset clock timer */
      print_file_name();                    /* display file name */
      song_state = SONG_IDLE;
      break;
    }


    case SONG_ERROR:
    {
      song_stop();                          /* stop playing song */
      Fclose();                             /* close opened file */
      disp_clock_reset();                   /* reset clock timer */
      print_state_error();                  /* display error icon */
      disp_name_stop();
      song_state = SONG_IDLE;
      break;
    }
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -