Beispiel #1
0
 /**
  * @brief  UsartReceive 串口接收中断服务函数,用来控制音量
  * @param  无
  * @retval 无
  */
void UsartReceive(void)
{
	//char  text[40];
	vu16 i=0;

	if(USART_GetFlagStatus(USART1,USART_IT_RXNE)==SET)
	{	 
		USART_ClearFlag(USART1, USART_FLAG_RXNE | USART_FLAG_ORE);
	    //读数据并清 RXNE、ORE位      
		i = USART_ReceiveData(USART1);
			printf("%c",i);
		if(i == '+')
		{
			Volume_Add();
			//printf("+");

		}else if(i == '-')
		{
			Volume_Dec();
			//printf("-");
		}	
		
	}
}
/**
  * @brief  even_process 根据事件标志进行处理
  * @param  none
  * @retval none
  */
static void even_process(void)
{
	switch(touch_even)
	{
		/* 音量加				 */
		case E_UP:														
			
			Volume_Add();		
			
			touch_even = E_NULL;
		
			break;
		
		/* 音量减 			*/
		case E_DOWN:													
			
			Volume_Dec();	
			
			touch_even = E_NULL;	
		
			break;
		
		/* 播放、暂停键	*/
		case E_PLAY_STOP:												
		
			if(player_state == S_PLAY)					//若当前状态为播放
			{
				player_state = S_STOP;						//切换为暂停状态
			}		
			else																//若当前状态为暂停
				player_state =S_PLAY;							//切换为播放暂停
				
			touch_even = E_NULL;
			break;	

		/* 上一首			*/	
		case E_PREV:														
			if(play_index <= 0)
			{
				play_index = 0;
			}
			else
			{
				play_index--;
				#if 0																//放在player_run 函数里统一处理了	
				/* 检测要切换的歌曲是否在播放列表的上一页 */
				if((play_index+8)/8 < current_page) //play_index从零开始计数所以+1,+7是使用进一法。 +1+7 =+8
				{
					current_page--;										//更新当前页码
					lcd_list(current_page);						//刷新LCD列表	
				}
				#endif

			}
			
			touch_even = E_NULL;						
			player_state = S_SWITCH;							//进入切歌状态
			
			break;
		
		/* 下一首	 	 */			
		case E_NEXT:														
			
			if(play_index < file_num-1)
			{
				play_index++;	
				#if 0															//放在player_run 函数里统一处理了
				/* 检测要切换的歌曲是否在播放列表的下一页 */
				if((play_index+8)/8 >current_page)  //play_index从零开始计数所以+1,+7是使用进一法。 +1+7 =+8
				{
					current_page++;										//更新当前页码
					lcd_list(current_page);						//刷新LCD列表
				}
				#endif
			}									
			else
			{
				play_index = file_num-1;						//play_index设置为最后一个歌曲文件
			}		
				touch_even = E_NULL;	
				player_state = S_SWITCH;						//进入切歌状态
		
			break;
		
		/* 向上			*/
		case E_SELT_UP:													
			if(select_index>0)
				select_index--;
			
			Lcd_GramScan(1);
			LCD_Clear(12,88,8,145,BACKGROUND);		//清除状态栏
			Lcd_show_bmp(320-(103+(select_index*18)),240-20,"/mp3player/ui_select.bmp");			//显示“打勾”标签
		
			touch_even = E_NULL;
			
			break;
		
		/* 向下 		*/ 
		case E_SELT_DOWN:												
			if(select_index<8-1 && (select_index+8*(current_page-1))<file_num-1)	//判断是否溢出,不大于8,不指向无文件名的位置
				select_index++;			
			
			Lcd_GramScan(1);
			LCD_Clear(12,88,8,145,BACKGROUND);	//清除状态栏
			Lcd_show_bmp(320-(103+(select_index*18)),240-20,"/mp3player/ui_select.bmp");			//显示“打勾”标签
		
			touch_even = E_NULL;	
					
			break;
		
		/* 直接点选歌曲	*/
		case E_SELECT:												
			
			play_index = select_index + ((current_page-1)*8);											//根据当前页和select_index确定play_index
			player_state = S_SWITCH;
		
			touch_even = E_NULL;	
		
			break;			
		
		/* 下一页				*/
		case E_SELT_NEXT:												
			
			if(current_page<all_page)
			{
				current_page++;										//更新当前页码
				lcd_list(current_page);						//刷新LCD列表
			}
			else
				current_page =all_page;
		
			touch_even = E_NULL;
			
			break;
		
		/* 上一页			*/
		case E_SELT_PREV:											
			if(current_page>1)					
			{
				current_page--;										//更新当前页码
				lcd_list(current_page);						//刷新LCD列表
			}
			else
				current_page =1;
			
			touch_even = E_NULL;
			break;
		
		/* OK					*/
		case E_SELT_OK:												
			play_index = select_index+8*(current_page-1);	//根据当前页和select_index确定play_index
			
			touch_even = E_NULL;	
			player_state = S_SWITCH;
			
			break;
		
		/* 扬声器 		*/
		case E_LOUD_SPEAK:										
			if(speaker_flag == 0)								//speaker关状态
			{
				Loud_Speaker_ON();								//开启speaker	
				speaker_flag =1;
				printf("\r\n loud on");
			}
			else																//speaker为开状态
			{
				Loud_Speaker_OFF();								//关闭speaker
				speaker_flag=0;
				printf("\r\n loud off");
			}
			
			touch_even = E_NULL;
			break;
		
		default:
			//touch_even = E_NULL;
			break;
	}

}