Download 14002672/user/main.c from Beifengdo/Arduino-Development: direct link, hf CLI and curl.
- Browser
- Download file 5.04 kB
-
https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/main/14002672/user/main.c
- Command line
-
hf download hf://datasets/Beifengdo/Arduino-Development/14002672/user/main.c
-
curl -L -o main.c https://huggingface.co/datasets/Beifengdo/Arduino-Development/resolve/main/14002672/user/main.c
5.04 kB
| unsigned char seg_string[10]; | |
| unsigned char seg_buf[8]; | |
| unsigned char pos; | |
| unsigned char Key_Value; | |
| unsigned char Key_Old,Key_Down,Key_UP; | |
| unsigned char ucled; | |
| unsigned int Seg_Slow_down; | |
| unsigned int Key_Slow_down; | |
| unsigned char n=0;//�������� | |
| unsigned char res;//�������� | |
| unsigned char res_old; | |
| unsigned char ds_time[3]={55,55,23};//ds1302ʱ�� | |
| unsigned int temptuer;//�¶� | |
| unsigned int count;//ne555Ƶ�� | |
| unsigned int ne555_count; | |
| unsigned int ne555_time;//ne555ʱ����� | |
| unsigned char ne555_shidu; | |
| unsigned int temptuer_old; | |
| unsigned int ne555_shidu_old; | |
| unsigned int t_pcf;//�������ʱ�� | |
| unsigned char cai_h; | |
| unsigned char cai_m; | |
| unsigned int t_2s; | |
| unsigned int temptuer_num; | |
| unsigned int ne555_shidu_num; | |
| unsigned char wendu=30;//�¶��趨���� | |
| unsigned char shidu=68;//ʪ���趨���� | |
| unsigned char jiemian_flag;//������� | |
| unsigned char huixian_flag;//���Խ������ | |
| unsigned char cai_flag; //�ɼ���־λ | |
| bit t_flag=0; | |
| //bit ne555_flag;//ne555��־λ | |
| bit bit_flag; | |
| bit flag2; | |
| void Seg_Proc(); | |
| void Key_Proc(); | |
| void Led_Proc(); | |
| void main() | |
| { | |
| Initsystem(); | |
| Timer1Init(); | |
| Timer0Init(); | |
| EA=1; | |
| write_ds13(ds_time); | |
| temptuer=read_temptuer()/16; | |
| res_old=Read_Pcf8591(0x01); | |
| res=Read_Pcf8591(0x01); | |
| while(1) | |
| { | |
| Key_Proc(); | |
| Seg_Proc(); | |
| Led_Proc(); | |
| temptuer_old=temptuer; | |
| ne555_shidu_old=ne555_shidu; | |
| } | |
| } | |
| void ServiceT1() interrupt 3 | |
| { | |
| if(++Seg_Slow_down==200)Seg_Slow_down=0; | |
| if(++Key_Slow_down==10)Key_Slow_down=0; | |
| Seg_Disp(pos,seg_buf); | |
| if(++pos==8)pos=0; | |
| Led_Disp(ucled); | |
| ne555_time++; | |
| if(ne555_time==1000) | |
| { | |
| ne555_time=0; | |
| ne555_count=count; | |
| count=0; | |
| } | |
| if(cai_flag==1) | |
| { | |
| t_pcf++; | |
| if(t_pcf==3000) | |
| { | |
| t_pcf=0; | |
| cai_flag=0; | |
| } | |
| } | |
| if(t_flag==1) | |
| { | |
| t_2s++; | |
| } | |
| } | |
| void ServiceT0() interrupt 1 | |
| { | |
| count++; | |
| } | |
| void Seg_Proc() | |
| { | |
| if(Seg_Slow_down)return; | |
| Seg_Slow_down=1; | |
| // temptuer=read_temptuer()/16; | |
| if(t_pcf==0) | |
| { | |
| res=Read_Pcf8591(0x01); | |
| if(res<50) | |
| { | |
| temptuer=read_temptuer()/16; | |
| ne555_shidu=10+(ne555_count-200)*0.044; | |
| n++; | |
| cai_flag=1; | |
| temptuer_num+=temptuer; | |
| ne555_shidu_num+=ne555_shidu; | |
| t_pcf++; | |
| read_ds13(ds_time); | |
| cai_h=ds_time[2]; | |
| cai_m=ds_time[1]; | |
| // flag1=1; | |
| } | |
| res_old=res; | |
| } | |
| if(cai_flag==1) | |
| { | |
| if((ne555_count<200)||(ne555_count>2000)) | |
| { | |
| sprintf(seg_string,"E %2d-AA",(int)temptuer); | |
| flag2=1; | |
| } | |
| else | |
| { | |
| sprintf(seg_string,"E %2d-%2d",(int)temptuer,(int)ne555_shidu); | |
| flag2=0; | |
| } | |
| Seg_Tran(seg_string,seg_buf); | |
| } | |
| else | |
| { | |
| if(jiemian_flag==0)//����1 | |
| { | |
| read_ds13(ds_time); | |
| sprintf(seg_string,"%02d-%02d-%02d",(int)ds_time[2],(int)ds_time[1],(int)ds_time[0]); | |
| } | |
| else if | |
| (jiemian_flag==1)//����2 | |
| { | |
| if(huixian_flag==0) | |
| { | |
| if(n==0) | |
| { | |
| sprintf(seg_string,"C "); | |
| } | |
| else | |
| { | |
| sprintf(seg_string,"C %2d-%3.1f",(int)wendu,(float)temptuer_num/n); | |
| } | |
| } | |
| else if(huixian_flag==1) | |
| { | |
| if(n==0) | |
| { | |
| sprintf(seg_string,"H "); | |
| } | |
| else{ | |
| if(ne555_shidu_num/n) | |
| { | |
| sprintf(seg_string,"H %d-%3.1f",(int)shidu,(float)ne555_shidu_num/n); | |
| } | |
| } | |
| } | |
| else | |
| { | |
| if(n==0) | |
| { | |
| sprintf(seg_string,"F%02d ",(int)n); | |
| } | |
| else | |
| sprintf(seg_string,"F%02d%02d-%02d",(int)n,(int)cai_h,(int)cai_m); | |
| } | |
| } | |
| else //����3 | |
| { | |
| sprintf(seg_string,"P %2D",(int)wendu); | |
| } | |
| Seg_Tran(seg_string,seg_buf); | |
| } | |
| } | |
| void Key_Proc() | |
| { | |
| if(Key_Slow_down)return; | |
| Key_Slow_down=1; | |
| Key_Value=Key_Read(); | |
| Key_Down=Key_Value&(Key_Old^Key_Value); | |
| Key_UP=~Key_Value&(Key_Old^Key_Value); | |
| Key_Old=Key_Value; | |
| if(cai_flag==0) | |
| { | |
| switch(Key_Down) | |
| { | |
| case 4: | |
| jiemian_flag++; | |
| if(jiemian_flag==3)jiemian_flag=0; | |
| break; | |
| case 5: | |
| if(jiemian_flag==1) | |
| { | |
| huixian_flag++; | |
| if(huixian_flag==3)huixian_flag=0; | |
| } | |
| break; | |
| case 8: | |
| if(jiemian_flag==2) | |
| { | |
| wendu++; | |
| } | |
| break; | |
| case 9: | |
| if(jiemian_flag==2) | |
| { | |
| wendu--; | |
| } | |
| if((jiemian_flag==1)&&(huixian_flag==2)) | |
| { | |
| t_flag=1; | |
| } | |
| break; | |
| } | |
| switch(Key_UP) | |
| { | |
| case 9: | |
| t_flag=0; | |
| if(t_2s>2000) | |
| { | |
| n=0; | |
| ne555_shidu_num=0; | |
| temptuer_num=0; | |
| } | |
| t_2s=0; | |
| break; | |
| } | |
| } | |
| } | |
| void Led_Proc() | |
| { | |
| if(cai_flag==1) | |
| { | |
| ucled=ucled&0xf8|0x04; | |
| } | |
| else if(jiemian_flag==1) | |
| { | |
| ucled=ucled&0xf8|0x02; | |
| } | |
| else if(jiemian_flag==0) | |
| { | |
| ucled=ucled&0xf8|0x01; | |
| } | |
| else | |
| { | |
| ucled=ucled&0xf8; | |
| } | |
| if(flag2) | |
| { | |
| ucled|=0x10; | |
| } | |
| else | |
| { | |
| ucled&=0xef; | |
| } | |
| // if(flag1==1) | |
| // { | |
| // if(temptuer_old==0) | |
| // | |
| // } | |
| // | |
| } | |