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

📄 timer.c

📁 Vx1828点3.5"TFT屏的的源程序
💻 C
📖 第 1 页 / 共 2 页
字号:
				//printf("w%bxh%bx%m%bx",temp[0],temp[1],temp[2]);
				read_timer(0x02,&on_time);
				if(on_time.hour==0){
					on_time.hour=24;
					}
				on_time.hour--;
				on_time_menu(on_time.hour, on_time.minute);
				shi_sub_write(EEPROM, 0x20, 0, &on_time.hour);DelayXms(0x30);
				write_timer(0x02, &on_time);
				break;
			case 4:
				read_timer(0x02,&on_time);
				if(on_time.minute==0){
					on_time.minute=60;
					}
				on_time.minute--;
				on_time_menu(on_time.hour, on_time.minute);
				shi_sub_write(EEPROM, 0x21, 0, &on_time.minute);DelayXms(0x30);
				write_timer(0x02,&on_time);
				break;
			case 5:
				timer_able_flag=~timer_able_flag;
				able_time_menu(timer_able_flag);
				shi_sub_write(EEPROM, 0x24, 0, &timer_able_flag);DelayXms(0x30);
				break;
			case 6:
				read_timer(0x03,&off_time);
				if(off_time.hour==0){
					off_time.hour=24;
				}
				off_time.hour--;
				off_time_menu(off_time.hour, off_time.minute);
				shi_sub_write(EEPROM, 0x22, 0, &off_time.hour);DelayXms(0x30);
				write_timer(0x03, &off_time);
				break;
			case 7:
				read_timer(0x03,&off_time);
				if(off_time.minute==0){
					off_time.minute=60;
				}
				off_time.minute--;
				off_time_menu(off_time.hour, off_time.minute);
				shi_sub_write(EEPROM, 0x23, 0, &off_time.minute);DelayXms(0x30);
				write_timer(0x03, &off_time);
				break;
			case 8:
				timer_able_flag=~timer_able_flag;
				able_time_menu(timer_able_flag);
				shi_sub_write(EEPROM, 0x24, 0, &timer_able_flag);DelayXms(0x30);
				write_timer(0x03, &off_time);
				break;
			case 9:
				 
				break;
			default:
				break;
		}
	}

	if(timemenu_flag&&irright_flag){
		irright_flag=0;
		switch (time_sel){
			case 1:
				read_timer(0x01,&curr_time);
				curr_time.hour++;
				if(curr_time.hour==24){
					curr_time.hour=0;
				}				
				current_time_menu(curr_time.hour, curr_time.minute,curr_time.second);
				//write to timer chip
				
				//temp[0]=curr_time.hour;
				//read_timer(&curr_time);
				//curr_time.hour=temp[0];
				write_timer(1,&curr_time);	
				
				break;
			case 2:
				read_timer(0x01,&curr_time);
				curr_time.minute++;
				if(curr_time.minute==60){
					curr_time.minute=0;
				}
				current_time_menu(curr_time.hour, curr_time.minute,curr_time.second);
				//write to timer chip
				//temp[1]=curr_time.minute;
				//read_timer(&curr_time);
				//curr_time.minute=temp[0];
				write_timer(0x01,&curr_time);
				
				break;
			case 3:
				read_timer(0x02,&on_time);
				on_time.hour++;
				if(on_time.hour==24){
					on_time.hour=0;
					}
				on_time_menu(on_time.hour, on_time.minute);
				shi_sub_write(EEPROM, 0x20, 0, &on_time.hour);DelayXms(0x30);
				write_timer(0x02, &on_time);
				break;
			case 4:
				read_timer(0x02,&on_time);
				on_time.minute++;
				if(on_time.minute==60){
					on_time.minute=0;
					}
				on_time_menu(on_time.hour, on_time.minute);
				shi_sub_write(EEPROM, 0x21, 0, &on_time.minute);DelayXms(0x30);
				write_timer(0x02, &on_time);
				break;
			case 5:
				timer_able_flag=~timer_able_flag;
				able_time_menu(timer_able_flag);
				shi_sub_write(EEPROM, 0x24, 0, &timer_able_flag);DelayXms(0x30);
				break;
			case 6:
				read_timer(0x03,&off_time);
				off_time.hour++;
				if(off_time.hour==24){
					off_time.hour=0;
					}
				off_time_menu(off_time.hour, off_time.minute);
				shi_sub_write(EEPROM, 0x22, 0, &off_time.hour);DelayXms(0x30);
				write_timer(0x03, &off_time);
				break;
			case 7:
				read_timer(0x03,&off_time);
				off_time.minute++;
				if(off_time.minute==60){
					off_time.minute=0;
					}
				off_time_menu(off_time.hour, off_time.minute);
				shi_sub_write(EEPROM, 0x23, 0, &off_time.minute);DelayXms(0x30);
				write_timer(0x03, &off_time);
				break;
			case 8:
				timer_able_flag=~timer_able_flag;
				able_time_menu(timer_able_flag);
				shi_sub_write(EEPROM, 0x24, 0, &timer_able_flag);DelayXms(0x30);
				break;
			case 9:
 				break;
			default:
				break;
		}
	}		
	//====== when timer open ,we must do so.
	
	
	
}
#endif
void timer_on_off(void)//zl.d 1.5

{
	shi_sub_read(EEPROM, 0x24, 0, &timer_able_flag);
	//printf("EEPROM, 0x24, 0, &timer_able_flag%bx\n",timer_able_flag);
	
	if (timer_able_flag)
	{
		if(!ptime_int1&ptime_int2)//pown on
			{
			
			DelayXms(250);
//////////////////////////////////////////////////////////////////
			if(!ptime_int1&ptime_int2)//0n
				{
				unsigned char temp;
				if(!power_flag)
					{
						printf("ptime_int1=0ptime_int2=1\n");
				
						osd_timer=0;TR0=1;
						printf("the key is power.\n");
                         			irpower_flag = 1;	// IR Power Button Active
						XIE_Power=0;
						osd_timer=0;TR0=1;
						shi_sub_read1(0x62, 00, &temp);
						temp=temp&0xfb;
						//temp=temp+0x60;//set int2 is high
						shi_sub_write1(0x62, 00, &temp);
					}
				else 
					{
						shi_sub_read1(0x62, 00, &temp);
						temp=temp&0xfb;
						//temp=temp+0x60;//set int2 is high
						shi_sub_write1(0x62, 00, &temp);
					
					}
				
				
				}


			
			}
//////////////////////////////////////////////////////////////////
		if(!ptime_int2&ptime_int1)//0ff
			{
			DelayXms(250);
			if(!ptime_int2&ptime_int1)
				{
					unsigned char  temp;
				if(power_flag)
					{
						printf("ptime_int1=1ptime_int2=0\n");
				
						osd_timer=0;TR0=1;
						printf("the key is power.\n");
                         			irpower_flag = 1;	// IR Power Button Active
						XIE_Power=0;
						osd_timer=0;TR0=1;
						shi_sub_read1(0x62, 00, &temp);
						temp=temp&0xbf;
						//temp=temp+0x60;//set int2 is high
						shi_sub_write1(0x62, 00, &temp);

					
					}
				else
					{
						shi_sub_read1(0x62, 00, &temp);
						temp=temp&0xbf;
						//temp=temp+0x60;//set int2 is high
						shi_sub_write1(0x62, 00, &temp);

					
					}
				
				
				}
			
			}
/////////////////////////////////////////////////////////////////
	}

}
/////////////////////////////////////////////////////////////////
void read_timer(char temp1,struct TIME *time)//read timer  zl.d
{
	unsigned char data temp[3]=0;
	unsigned char data temp2=0;
	unsigned char data i;
	struct TIME *currrret_time;
	currrret_time=time;
	temp2=temp1;
	switch(temp2)
		{
		case  1:
			shi_sub_read1(0x66, 0x02, &temp);//read current time 2
			i=((temp[0]&0x30)>>4)*10+(temp[0]&0x0f);//zl.d 2006.1.3
			(*currrret_time).hour=i;
			i=((temp[1]&0x70)>>4)*10+(temp[1]&0x0f);
			(*currrret_time).minute=i;
			i=((temp[2]&0x70)>>4)*10+(temp[2]&0x0f);
			(*currrret_time).second=i;
			break;
		case  2:
			shi_sub_read1(0x68, 0x02, &temp);//read  int1 
			i=((temp[1]&0x30)>>4)*10+(temp[1]&0x0f);//zl.d 2006.1.3
			(*currrret_time).hour=i;
			i=((temp[2]&0x70)>>4)*10+(temp[2]&0x0f);
			(*currrret_time).minute=i;
			break;
		case  3:
			shi_sub_read1(0x6a, 0x02, &temp);//read int2 
			i=((temp[1]&0x30)>>4)*10+(temp[1]&0x0f);//zl.d 2006.1.3
			(*currrret_time).hour=i;
			i=((temp[2]&0x70)>>4)*10+(temp[2]&0x0f);
			(*currrret_time).minute=i;
			break;
		default:
				break;
					
		}
	//delay_nop();
	DelayXms(0x3A); 
	
	//time=&curr_time;
}
/////////////////////////////////////////////////////////////////

void write_timer(char temp1,struct TIME *time)
{
	unsigned char data temp[3]=0;
	unsigned char data i;
	unsigned char data temp2=0;
	unsigned char data temp3=0;
	struct TIME *currrret_time;
	temp2=temp1;
	currrret_time=time;
	temp3=0;
	switch(temp2)
		{
		case 1:
			temp[0] = (*currrret_time).hour/10;
			i=(*currrret_time).hour%10;
			temp[0]=(temp[0]<<4)+i;
			//printf("temp%bx",temp[0]);
			//printf("currrret_time).minute%bx\n",(*currrret_time).minute);
			temp[1]=(*currrret_time).minute/10;
			i= (*currrret_time).minute%10;
			temp[1]=(temp[1]<<4)+i;
			//printf("write4==%bx%bx%bx\n",temp[0],temp[1],temp[2]);
			temp[2]=(*currrret_time).second/10;
			i= (*currrret_time).second%10;
			temp[2]=(temp[2]<<4)+i;
			shi_sub_write1(0x66, 0x02, &temp);
			break;
		case 2:
			if((*currrret_time).hour>12){temp3=12;}
			else temp3=8;
					
			temp[1] = (*currrret_time).hour/10;
			temp[1]+=temp3;
			i=(*currrret_time).hour%10;
			temp[1]=(temp[1]<<4)+i;
			
			temp[2]=(*currrret_time).minute/10;
			temp[2]+=8;
			i= (*currrret_time).minute%10;
			temp[2]=(temp[2]<<4)+i;
			
			temp[0]=0;
			
			shi_sub_write1(0x68, 0x02, &temp);
			break;
		case 3:

			if((*currrret_time).hour>12){temp3=12;}
			else temp3=8;
			
			temp[1] = (*currrret_time).hour/10;
			temp[1]+=temp3;
			i=(*currrret_time).hour%10;
			temp[1]=(temp[1]<<4)+i;
			
			temp[2]=(*currrret_time).minute/10;
			temp[2]+=8;
			i= (*currrret_time).minute%10;
			temp[2]=(temp[2]<<4)+i;
			
			temp[0]=0;
			shi_sub_write1(0x6a, 0x02, &temp);
			break;
		default:
				break;
		
		}
				
				/*
				curr_time.hour=temp1[0];
				temp1[0] = curr_time.hour/10;
				i= curr_time.hour%10;
				temp1[0]=(temp[0]<<4)+i;
				printf("temp1[0]%bx",temp1[0]);
				curr_time.minute=temp1[1];
				temp1[1] = curr_time.minute/10;
				i= curr_time.minute%10;
				temp1[1]=(temp1[1])<<4+i;
				printf("temp1[1]%bx\n",temp1[1]);
				*/
}
////////////////////////////////////////////////////////////////////
void init_s35390()//init s3539 zl.d 2005.12.26
	{
		char  device ;
		char tmp2,tmp,tmp3[7]={0};
			
			
		device=S3539+0x00;//powner reset s35390A zl.d 2005.26 
		tmp=4;
		shi_sub_read1( device, 0x00, &tmp);DelayXms(0x3A); 
		printf("ini_tstate0==%bx\n",tmp);
		if (tmp&0x80 | tmp&0x40)
			{
				tmp2=0x01;
				device=S3539+0x00;
			   	shi_sub_write1(device, 0x00, &tmp2);
				DelayXms(0x3A); DelayXms(0x3A); 
				
				tmp2=0x02;
		
		
				shi_sub_read1( device, 0x00, &tmp);DelayXms(0x3A); 
				printf("dzl4==%bx\n",tmp);
			}
		tmp2=0x02;
		device=S3539+0x00;
		shi_sub_write1(0x60, 0x00, &tmp2);
		//tmp2=0x44;
		//shi_sub_write1(0x62, 0x00, &tmp2);
		tmp2=0x44;
		shi_sub_write1(0x62, 0x00, &tmp2);
		
		/*
		shi_sub_read1( 0x60, 0x00, &tmp);
		printf("state1==%bx\n",tmp);
		shi_sub_read1( 0x62, 0x00, &tmp);
		printf("state2==%bx\n",tmp);
		shi_sub_read1( 0x64, 0x00, &tmp);
		printf("state3==%bx\n",tmp);
		
		shi_sub_read1( 0x66, 0x02, &tmp3);
		printf("state4==%bx%bx%bx\n",tmp3[0],tmp3[1],tmp3[2]);
		tmp3[0]=0;tmp3[1]=0;tmp3[2]=0;
		shi_sub_read1( 0x66, 0x02, &tmp3);
		printf("state4==%bx%bx%bx\n",tmp3[0],tmp3[1],tmp3[2]);
		tmp3[0]=0;tmp3[1]=0;tmp3[2]=0;
		shi_sub_read1( 0x66, 0x02, &tmp3);
		printf("state4==%bx%bx%bx\n",tmp3[0],tmp3[1],tmp3[2]);
		tmp3[0]=0;tmp3[1]=0;tmp3[2]=0;

		
		tmp3[0]=1;tmp3[1]=2;tmp3[2]=3;
		shi_sub_write1(0x66, 0x02, &tmp3);
		shi_sub_read1( 0x66, 0x02, &tmp3);
		printf("state4==%bx%bx%bx\n",tmp3[0],tmp3[1],tmp3[2]);
		tmp3[0]=4;tmp3[1]=5;tmp3[2]=6;
		shi_sub_write1(0x66, 0x02, &tmp3);
		shi_sub_read1( 0x66, 0x02, &tmp3);
		printf("state4==%bx%bx%bx\n",tmp3[0],tmp3[1],tmp3[2]);
		tmp3[0]=7;tmp3[1]=7;tmp3[2]=9;
		shi_sub_write1(0x66, 0x02, &tmp3);
		shi_sub_read1( 0x66, 0x02, &tmp3);
		printf("state4==%bx%bx%bx\n",tmp3[0],tmp3[1],tmp3[2]);

		
		
		shi_sub_read1( 0x68, 0x00, &tmp);
		printf("state5==%bx\n",tmp);
		shi_sub_read1( 0x6a, 0x00, &tmp);
		printf("state6==%bx\n",tmp);
		shi_sub_read1( 0x6c, 0x00, &tmp);
		printf("state7==%bx\n",tmp);
		shi_sub_read1( 0x6e, 0x00, &tmp);
		printf("state8==%bx\n",tmp);
		*/
		
             /* tmp2=0x0a;
		device=S3539+0x00;
		shi_sub_write1(device, 0x00, &tmp2);
		shi_sub_read1( device, 0x00, &tmp);DelayXms(0x3A); 
		printf("write%bx",tmp);*/
		
		/*	device=S3539+0x04;
				shi_sub_read1( device, 0x06, &tmp3);DelayXms(0x3A); 
				printf("dzl5==%bx\n",tmp3[0]);
printf("dzl5==%bx\n",tmp3[1]);
printf("dzl5==%bx\n",tmp3[2]);
printf("dzl5==%bx\n",tmp3[3]);
printf("dzl5==%bx\n",tmp3[4]);
printf("dzl5==%bx\n",tmp3[5]);printf("dzl5==%bx\n",tmp3[6]);*/

		
	}
//////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

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