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

📄 playedit.c

📁 mega128+VS1003做的mp3的程序 可以用WINAVR编译
💻 C
📖 第 1 页 / 共 2 页
字号:
#include <iom64v.h>
#include <macros.h>
#include <string.h>
#include <stdio.h>
#include "../Vs1003/vs1003.h"
#include "../Ch375b/375interface.h"
#include "../Keyboard/key.h"
#include "../Ds1302/ds1302.h"
#include <eeprom.h>
extern uchar keybuf;
extern uchar const nAsciiDot[];
extern uchar const please_time[];
extern unsigned char const full[];
extern unsigned char const show_main[];

typedef struct fileinfor{ 		//当前时间的数据结构
		uchar filename[28]; //文件名
		uchar active;		//有效标志
		uchar hour;		/*时*/
		uchar min;   	/*分*/
        uchar sec;   	/*秒*/
};
/*
删除文件
*/					
void Del_Edit(uchar data)
{
 uchar day;
 uchar temp;
 uchar active[8];
 uchar move;
 struct fileinfor FILE[8];
 uint point;
 //检查空间
 RELOAD:
 point = 0;
 point += 8*data*sizeof(FILE[0]);
 
 for(day=0; day<8; day++)
    {
 	 point += sizeof(FILE[day]);
	 EEPROMReadBytes(point,&FILE[day],sizeof(FILE[day]));
    } 
 day = 0;
 for(temp=0; temp<8; temp++)
 {
  if(FILE[temp].active == 0x55) {active[day] = temp;day++;} 
 } 
 active[day] = 0xff;
 Print_val(day);
 day = 0;
 temp = 0;
 while(1){ //显示出来
 		    show_clear();
			show_lcd(0, 0, 192, 2, &show_main[0],0);
			move = 0;
				     if(active[day]   == 0xff) goto NEXT; 
			         if(active[day]   != 0xff){move += 1; 
					 					      show_name(&FILE[active[day]],2,0);
											 }
				     if(active[day+1]   == 0xff) goto NEXT;							 									 
					 if(active[day+1] != 0xff) {move += 1;
					                          show_name(&FILE[active[day+1]],4,0);
											 } 
					 if(active[day+2]   == 0xff) goto NEXT;
				     if(active[day+2] != 0xff) {move += 1;
					                          show_name(&FILE[active[day+2]],6,0);
											 }
	        NEXT:										 
            if(move != 0){											   
						switch(temp){
									 case 0:show_name(&FILE[active[day]],2,1);break;
									 case 1:show_name(&FILE[active[day+1]],4,1);break;
									 case 2:show_name(&FILE[active[day+2]],6,1);break;
						  			}
						} 
			KEYBUF_NULL;
			while(keybuf == NULL);
			if(keybuf == K_UP){
					  	       if(--temp == 255){
							   			 		 temp = 0;
												 if(day != 0) {day -= 3;temp=2;} 
							                    } 
			                  }
		    if(keybuf == K_DOWN){
					  	 	   if(move !=0){
							   			 	if(++temp == move){
										    		  	 	  temp = 0;
												              if(move == 3) day += 3;  
							               } 				  }
			                    }
			if(keybuf == K_ESC) break;
			if(keybuf != K_ENTER) continue;
			
			point = 0;
			point += 8*data*sizeof(FILE[0]);
			point += sizeof(FILE[0]);
			switch(temp){
						 case 0:FILE[active[day]].active = 0xff;
						 	    point += active[day]*sizeof(FILE[0]);	
								EEPROMWriteBytes(point,&FILE[active[day]],sizeof(FILE[0]));						 
						 	    break;
						 case 1:FILE[active[day+1]].active = 0xff;
						 	    point += active[day+1]*sizeof(FILE[0]);	
								EEPROMWriteBytes(point,&FILE[active[day+1]],sizeof(FILE[0]));
						 	    break;
						 case 2:FILE[active[day+2]].active = 0xff;
						 	    point += active[day+2]*sizeof(FILE[0]);	
								EEPROMWriteBytes(point,&FILE[active[day+2]],sizeof(FILE[0]));
								break;
						 case 3:FILE[active[day+3]].active = 0xff;
						        point += active[day+3]*sizeof(FILE[0]);	
								EEPROMWriteBytes(point,&FILE[active[day+3]],sizeof(FILE[0]));
						 	    break;
			            }
			goto  RELOAD;
						
 }

}
/*
编辑
*/					
void Play_Edit(uchar data)
{
 uchar day;
 uchar temp;
 uchar active[8];
 uchar move;
 struct fileinfor FILE[8];
 uint point;
 //检查空间

 point = 0;
 point += 8*data*sizeof(FILE[0]);
 
 for(day=0; day<8; day++)
    {
 	 point += sizeof(FILE[day]);
	 EEPROMReadBytes(point,&FILE[day],sizeof(FILE[day]));
    } 
 day = 0;
 for(temp=0; temp<8; temp++)
 {
  if(FILE[temp].active == 0x55) {active[day] = temp;day++;} 
 } 
 active[day] = 0xff;
 Print_val(day);
 day = 0;
 temp = 0;
 while(1){ //显示出来
 		    show_clear();
			show_lcd(0, 0, 192, 2, &show_main[0],0);
			move = 0;
				     if(active[day]   == 0xff) goto NEXT; 
			         if(active[day]   != 0xff){move += 1; 
					 					      show_name(&FILE[active[day]],2,0);
											 }
				     if(active[day+1]   == 0xff) goto NEXT;							 									 
					 if(active[day+1] != 0xff) {move += 1;
					                          show_name(&FILE[active[day+1]],4,0);
											 } 
					 if(active[day+2]   == 0xff) goto NEXT;
				     if(active[day+2] != 0xff) {move += 1;
					                          show_name(&FILE[active[day+2]],6,0);
											 }
	        NEXT:										 
            if(move != 0){											   
						switch(temp){
									 case 0:show_name(&FILE[active[day]],2,1);break;
									 case 1:show_name(&FILE[active[day+1]],4,1);break;
									 case 2:show_name(&FILE[active[day+2]],6,1);break;
						  			}
						} 
			KEYBUF_NULL;
			while(keybuf == NULL);
			if(keybuf == K_UP){
					  	       if(--temp == 255){
							   			 		 temp = 0;
												 if(day != 0) {day -= 3;temp=2;} 
							                    } 
			                  }
		    if(keybuf == K_DOWN){
					  	 	   if(move !=0){
							   			 	if(++temp == move){
										    		  	 	  temp = 0;
												              if(move == 3) day += 3;  
							               } 				  }
			                    }
			if(keybuf == K_ESC) break;
			if(keybuf != K_ENTER) continue;
			
			switch(temp){
						 case 0:if(FILE[active[day]].filename[0] == 0x5c)
						 	    mp3_play(&FILE[active[day]].filename[0],0);
								break;
						 case 1:if(FILE[active[day+1]].filename[0] == 0x5c)
						 	    mp3_play(&FILE[active[day+1]].filename[0],0);
								break;
						 case 2:if(FILE[active[day+2]].filename[0] == 0x5c)
						 	    mp3_play(&FILE[active[day+2]].filename[0],0);
								break;
						 case 3:if(FILE[active[day+3]].filename[0] == 0x5c)
						        mp3_play(&FILE[active[day+3]].filename[0],0);
								break;
			            }
			
						
 }

}
void show_name(struct fileinfor *pt,uchar page,uchar type)
{
 uchar *ps;
 uchar ii;
 uint  temp;
 ii=0;
 ps = &pt->filename[0];
 while(*ps != 0){
 		   	  	 temp = *ps++;
				 temp -= 32;
				 temp *= 16;
				 show_lcd(page, ii, 8, 2, &nAsciiDot[temp],type);   
				 ii += 8;		 
 		        }
 ii = 129;				
 temp = pt->hour;
 temp >>= 4;
 temp &= 0x000f;
 temp += '0';
 temp -= 32;
 temp *= 16;
 show_lcd(page, ii, 8, 2, &nAsciiDot[temp],type);
 ii += 8;		 
 
 temp = pt->hour;
 temp &= 0x000f;
 temp += '0';
 temp -= 32;
 temp *= 16;
 show_lcd(page, ii, 8, 2, &nAsciiDot[temp],type);
 ii += 8;
 
 temp = ':';
 temp -= 32;
 temp *= 16;
 show_lcd(page, ii, 8, 2, &nAsciiDot[temp],type);
 ii += 8;
 
 temp = pt->min;
 temp >>= 4;
 temp &= 0x000f;
 temp += '0';
 temp -= 32;
 temp *= 16;
 show_lcd(page, ii, 8, 2, &nAsciiDot[temp],type);
 ii += 8;		 
 
 temp = pt->min;
 temp &= 0x000f;
 temp += '0';
 temp -= 32;
 temp *= 16;
 show_lcd(page, ii, 8, 2, &nAsciiDot[temp],type);
 ii += 8;
 
 temp = ':';
 temp -= 32;
 temp *= 16;
 show_lcd(page, ii, 8, 2, &nAsciiDot[temp],type);
 ii += 8;
 
 temp = pt->sec;
 temp >>= 4;
 temp &= 0x000f;
 temp += '0';
 temp -= 32;
 temp *= 16;
 show_lcd(page, ii, 8, 2, &nAsciiDot[temp],type);
 ii += 8;		 
 
 temp = pt->sec;
 temp &= 0x000f;

⌨️ 快捷键说明

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