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

📄 playedit.c

📁 mega128+VS1003做的mp3的程序 可以用WINAVR编译
💻 C
📖 第 1 页 / 共 2 页
字号:
 temp += '0';
 temp -= 32;
 temp *= 16;
 show_lcd(page, ii, 8, 2, &nAsciiDot[temp],type);
 ii = 112;				
}

/*
*添加一条新的记录
*/
extern uchar Filename[40];	  	   //保持选择的文件名称
void Edit_add(uchar data)
{
 struct time playtime;
 struct fileinfor FILE;
 uchar path[10];
 uint point;
 uchar day;
 //检查空间
 point = 0;
 point += 8*data*sizeof(FILE);
 day = 0;
 while(1){ 
 while(1){
 		  get_sys_path(&path[0]);
		  Print_str("选择工作目录=");
		  Print_str(&path[0]);
 		  Print_str("\r\n");
		  if(path[0] == 0x00) {return;}
		  if(keybuf == K_ESC) return;
		  if(keybuf == K_ENTER) break;
 }
 while(1)
 {
    for(;day<8; day++)
    {
	 point += sizeof(FILE); //下一个
	 EEPROMReadBytes(point,&FILE,sizeof(FILE));
     if(FILE.active != 0x55) {day++; break;}
    } 
 if(day == 8){
 		      show_lcd(2, 0, 192, 4, &full[0],0);
			  delay_1s();
			  delay_1s();
			  break;//无空间了
			 } 	
 playtime.hour = 0x01;
 playtime.min  = 0x01;
 playtime.sec  = 0x01;
 while(1){
 		  Play_xuanzhe(&path[0],1);	  	 		   //文件选择菜单
 		  if(keybuf == K_ESC) goto out;
		  if(keybuf == K_ENTER) break;
		 } 
 show_clear();	 	  	 		   //清除显示区
 show_lcd(0, 0, 192, 2, &please_time[0],0);    
 show_play(&Filename[0],3,0);	   //显示选择的文件名
 set_out_time(&playtime,6);		   //得到定时时间
 if(keybuf == K_ESC) break;
 FILE.hour = playtime.hour;
 FILE.min  = playtime.min;
 FILE.sec  = playtime.sec;
 FILE.active  = 0x55;
 strcpy(&FILE.filename[0],&Filename[0]);
 EEPROMWriteBytes(point,&FILE,sizeof(FILE));
 } 
 out:;
 }
 }
 
 /////////////////////////////////////////////////////////////////////////////////////////////
 extern uchar const DotTbl16[];
 extern unsigned char const add_tab[];
 extern unsigned char const del_tab[];
 extern unsigned char const show_tab[];
 extern unsigned char const nAsciiDot[];
 void Play_edit_data(void)
 {
   uchar ii;
   uchar data;
   data = 0;
   show_clear();
   while(1){
   			ii = 0;
   			show_lcd(0, ii, 16, 2, &DotTbl16[9*32],0);//星期
   			ii += 16;
   			show_lcd(0, ii, 16, 2, &DotTbl16[10*32],0);//星期
			ii += 16;
   			show_lcd(0, ii, 8, 2, &nAsciiDot[26*16],0);//:
			
			ii = 32;
			show_lcd(3, ii, 16, 2, &DotTbl16[11*32],0);
			ii += 32;
			show_lcd(3, ii, 16, 2, &DotTbl16[12*32],0);
			ii += 32;
			show_lcd(3, ii, 16, 2, &DotTbl16[13*32],0);
			ii = 129;
			show_lcd(3, ii, 16, 2, &DotTbl16[14*32],0);
			
			ii += 32;
			show_lcd(3, ii, 16, 2, &DotTbl16[15*32],0);
			ii = 0;
			show_lcd(6, ii, 16, 2, &DotTbl16[16*32],0);
			ii += 32;
			show_lcd(6, ii, 16, 2, &DotTbl16[2*32],0);
			ii += 32;
			switch(data){
						 case 0://星期1
						 	    show_lcd(3, 32, 16, 2, &DotTbl16[11*32],1);
						 	    break;
						 case 1://星期2
						 	    show_lcd(3, 64, 16, 2, &DotTbl16[12*32],1);
						 	    break;
					     case 2://星期3
						 	    show_lcd(3, 96, 16, 2, &DotTbl16[13*32],1);
						 	    break;
						 case 3://星期4
						 	    show_lcd(3, 129, 16, 2, &DotTbl16[14*32],1);
						 	    break;
						 case 4://星期5
						        show_lcd(3, 161, 16, 2, &DotTbl16[15*32],1);
						 	    break;
						 case 5://星期6
						 	    show_lcd(6, 0, 16, 2, &DotTbl16[16*32],1);
						 	    break;
						 case 6://星期日
						 	    show_lcd(6, 32, 16, 2, &DotTbl16[2*32],1);
						 	    break;													
			            }
			KEYBUF_NULL;
			while(keybuf == NULL);
			if((keybuf == K_RIFT)|(keybuf == K_DOWN)){(++data == 7) ? (data = 0) : 0;}
			if((keybuf == K_LIFT)|(keybuf == K_UP)){(--data == 255) ? (data = 6) : 0;}
			if(keybuf == K_ESC) break;
			if(keybuf != K_ENTER) continue;
			ii = 0;
			while(1){
					 show_clear();
 					 show_lcd(0, 56, 80, 2, &show_tab[0],0);  
 					 show_lcd(3, 56, 80, 2, &add_tab[0],0);  
 					 show_lcd(6, 56, 80, 2, &del_tab[0], 0); 
 					 switch(ii)
  						{
   						case 0: show_lcd(0, 56, 80, 2, &show_tab[0],1);
   		   				break;
   						case 1: show_lcd(3, 56, 80, 2, &add_tab[0],1);
   		   				break;
   						case 2: show_lcd(6, 56, 80, 2, &del_tab[0],1);
   		   				}
					 KEYBUF_NULL;
					 while(keybuf == NULL);
					 if(keybuf == K_DOWN){(++ii == 3) ? (ii = 0) : 0;}
					 if(keybuf == K_UP){(--ii == 255) ? (ii = 2) : 0;}
					 if(keybuf == K_ESC) break;
					 if(keybuf != K_ENTER) continue;
					 switch(ii)
  						{
   						case 0: adjust_cheng(1);  //手动操作打开MP3通道  
							    Play_Edit(data);
								adjust_cheng(0);  //  
   		   					    break;
   						case 1: Edit_add(data);
   		   					 	break;
   						case 2: Del_Edit(data);
							    break;
   		   				} 	
					  KEYBUF_NULL; 	
					 }//while(1)
		   show_clear(); 			
		   }//while(1)	
 }
 /*****************************************************************************
 *根据当前时间查看需要自动播放的文件,并播放
/*****************************************************************************/
#define  MAXINDEX 8																		   
void autoplay(struct time_now *time)
{
 static uchar index=0;          //记录索引号
 struct fileinfor FILE;
 unsigned long int timenow;
 unsigned long int timeplay;
 uchar temp;
 uint point;
 uchar data;
 Print_str("Run outplay test\r\n");
 data = time->week;
 data -= 1;
 point = 8*data*sizeof(FILE);   //得到当前日期的地址
 point += sizeof(FILE); 		//指向记录的第一条
 point += index*sizeof(FILE); 	//指向当前记录条
 EEPROMReadBytes(point,&FILE,sizeof(FILE)); //读取记录
 if(++index >= MAXINDEX) index = 0;
 if(FILE.active != 0x55)      return;  //已经被删除的记录则返回
 if(FILE.filename[0] != 0x5c) return;  //没有正确的文件名返回
  Print_str("Run outplay test time\r\n");
  //计算当前时间得到秒
  temp = time->hour;
  temp >>= 4;
  temp = (temp&0x0f)*10;
  temp += (0x0f&time->hour);
  timenow = temp*3600;
  
  temp = time->min;
  temp >>= 4;
  temp = (temp&0x0f)*10;
  temp += (0x0f&time->min);
  timenow += temp*60;
  
  temp = time->sec;
  temp >>= 4;
  temp = (temp&0x0f)*10;
  temp += (0x0f&time->sec);
  timenow += temp;
  //计算设置时间得到秒
  temp = FILE.hour;
  temp >>= 4;
  temp = (temp&0x0f)*10;
  temp += (0x0f&FILE.hour);
  timeplay = temp*3600;
  
  temp = FILE.min;
  temp >>= 4;
  temp = (temp&0x0f)*10;
  temp += (0x0f&FILE.min);
  timeplay += temp*60;
  
  temp = FILE.sec;
  temp >>= 4;
  temp = (temp&0x0f)*10;
  temp += (0x0f&FILE.sec);
  timeplay += temp;
  
  Print_str("Run outplay test ok\r\n");
 if(timenow < timeplay)        return;  //测试播放条件是否成立
 if(timenow > (timeplay+5))    return;  //5秒误差均可以播放
 if(EEPROMread(2047) != 0)     return;  //MP3输出是否有效
 adjust_cheng(1);  //开功放
 mp3_play(&FILE.filename[0],0); 		//播放设定的文件
 adjust_cheng(0);  //关功放
 show_clear();
 show_status();	   //播放起空闲的状态
}
//请选择工作目录
#include "Path.h"
void get_sys_path(uchar *path)
{
 uchar ii=0;
 uchar *ps;
 show_clear();
 show_lcd(0, 0, 192, 2, &path_menu[0],0);
 while(1)
 {
 show_lcd(2, 56, 80, 2, &path_3[0],0);  
 show_lcd(4, 56, 80, 2, &path_2[0],0);  
 show_lcd(6, 56, 80, 2, &path_1[0],0); 
 ps = path;
 switch(ii)
  {
   case 0: show_lcd(2, 56, 80, 2, &path_3[0],1);
   		   strcpy(ps,"\\*");
   		   break;
   case 1: show_lcd(4, 56, 80, 2, &path_2[0],1);
   		   strcpy(ps,"\\MUSIC\\*");
   		   break;
   case 2: show_lcd(6, 56, 80, 2, &path_1[0],1);
   		   strcpy(ps,"\\RECORD\\*");
   		   break;
  }
  KEYBUF_NULL;
  while(keybuf == NULL);
  if(keybuf == K_UP){
 			 		  (--ii == 255) ? (ii = 2) : 0;
                    }
  if(keybuf == K_DOWN){
   			 		  (++ii == 3) ? (ii = 0) : 0;
                    }							 
  if(keybuf == K_ESC) {*ps = 0x00;break;}
  if(keybuf != K_ENTER) continue;  
  break;
 } 
}

⌨️ 快捷键说明

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