📄 acus.lst
字号:
714 *说明:采用依次前移,如果队列大应采用有效算法
715 *参数:无
716 *返回:无
717 **************************************************/
718 uchar PopNews(void) {
719 1 uchar ch,i;
720 1 ch=NewsStr[1];
721 1 for(i=1;i<2;i++) {
722 2 NewsStr[i]=NewsStr[i+1];
723 2 }
724 1 NewsStr[3]=0;
725 1 NewsStr[0]--;
726 1 return ch;
727 1 }
728
729 /**************************************************
730 *原型:void DealNews(void)
731 *功能:对按键的处理模块
732 *说明:无
733 *参数:无
734 *返回:无
735 **************************************************/
736
737 uchar DealNews(void) {
C51 COMPILER V7.01 ACUS 11/24/2004 13:33:22 PAGE 13
738 1 uchar NewsBuff;
739 1 if(NewsStr[0])
740 1 {
741 2 NewsBuff=PopNews();
742 2
743 2 }
744 1 else{
745 2 NewsBuff=0x00;
746 2
747 2 }
748 1 return NewsBuff;
749 1 }
750 /**************************************************
751 *原型:uchar kb_hit(void)
752 *功能:确定有键按下
753 *说明:无
754 *参数:无
755 *返回:有键按下返回1,否则返回0
756 **************************************************/
757 uchar kb_hit(void)
758 {
759 1 //P1&=0xf3;
760 1 if((P1|0xfb)==0xfb) return(0);
761 1 return(1);
762 1 }
763
764 /**************************************************
765 *原型:void ScanKey(void)
766 *功能:扫描键盘模块
767 *说明:采用任务模式进行扫描,不循环等待,有效按键压入键盘队列,
768 *参数:无
769 *返回:无
770 **************************************************/
771 void ScanKey(void)
772 {
773 1 watchdog();
774 1
775 1 if(kb_hit())
776 1 { os_wait(K_TMO,2,0);
777 2 if(kb_hit())
778 2 {KeyOk=1;
779 3 PushNews(); //有键按下
780 3 }
781 2
782 2 }
783 1
784 1 if(!kb_hit()&&KeyOk) //是否松开
785 1 { os_wait(K_TMO,2,0);
786 2
787 2 if(!kb_hit())
788 2 {
789 3 NewsStr[0]++; //消息加1
790 3 KeyOk=0;}
791 2
792 2 }
793 1 }
794 /*********************************************************
795 *名称:signalon(void)
796 *功能:检查系统时钟是否在启动和结束之间
797 *入口参数:无
798 *出口参数:位变量,为0则时间到,为1时间未到
799 *********************************************************/
C51 COMPILER V7.01 ACUS 11/24/2004 13:33:22 PAGE 14
800 /*bit signalon(){
801 if(memcmp(&start,&end,sizeof(struct time))<0)
802 {if((memcmp(&start,&ctime,sizeof(struct time))<=0)&&
803 (memcmp(&ctime,&end,sizeof(struct time))<0))
804 return (1);
805 }
806 else{
807 if(memcmp(&end,&ctime,sizeof(struct time))>0 &&
808 memcmp(&ctime,&start,sizeof(struct time))>=0 )
809 return (1);
810 }
811 return(0);
812
813 }
814 /*********************************************************
815 *名称:init(void)
816 *功能:初始化
817 *入口参数:无
818 *出口参数:无
819 *********************************************************/
820 void init(void) _task_ INIT
821 {
822 1 CPU_init();
823 1 os_create_task(CLOCK);
824 1 os_create_task(LIGHTS);
825 1 os_create_task(KEYREAD);
826 1 os_create_task(TIMESET);///////////////////////
827 1 os_delete_task(INIT) ;
828 1
829 1 }
830 /*********************************************************
831 *名称:Clock()
832 *功能:定时任务
833 *入口参数:no
834 *出口参数:无
835 *********************************************************/
836 void clock (void) _task_ CLOCK {
837 1 uchar Time,ALAMETIME;
838 1
839 1 while (1) { /* clock is an endless loop */
840 2 if (++ctime.msec == 4)
841 2 {
842 3 ctime.msec = 0;
843 3 if(ALAMECON)
844 3 {if(ALAMETIME/2)ALAME=~ALAME;
845 4 if(ALAMETIME++>10)
846 4 {ALAME=0;ALAMETIME=0;ALAMECON=0;}
847 4 }
848 3 else ALAMETIME=0;
849 3 watchdog();
850 3 if (++ctime.sec == 60)
851 3 { /* calculate the second */
852 4 ctime.sec = 0;
853 4 Time=TimeLimit;
854 4 if(TimeLimit<=1)
855 4 Time=0;
856 4 EEPROMwrite(TIMEADDR, Time-1);/*每分钟记录一次当前剩余时间 */
857 4 if (++ctime.min == 60)
858 4 { /* calculate the minute */
859 5 ctime.min = 0;
860 5 if (++ctime.hour == 24)
861 5 { /* calculate the hour */
C51 COMPILER V7.01 ACUS 11/24/2004 13:33:22 PAGE 15
862 6 ctime.hour = 0;
863 6 }
864 5 }
865 4 }
866 3 }
867 2 watchdog();
868 2 os_wait (K_IVL,100, 0); /* wait interval: 1 second */
869 2 }
870 1 }
871
872 /*********************************************************
873 *名称:TempControl()
874 *功能:显示任务
875 *入口参数:no
876 *出口参数:无
877 *********************************************************/
878 void Lights(void) _task_ LIGHTS
879 { while (1) { /* endless loop */
880 2 Disp(dispbuff); /* increment counter 1 */
881 2 watchdog();
882 2 P03=~P03;
883 2 os_wait (K_TMO, 3, 0); /* wait for timeout: 10 ticks */
884 2 }
885 1 }
886
887 /*********************************************************
888 *名称:KeyRead()
889 *功能:键盘控制任务
890 *入口参数:no
891 *出口参数:无
892 *********************************************************/
893 void KeyRead(void) _task_ KEYREAD
894 {uchar keytemp ;
895 1
896 1 while (1)
897 1 {
898 2 if(P13)
899 2 { os_create_task(TEMPSET); //创建温度设置任务
900 3 os_delete_task (TEMPCON);
901 3 templed=CLOSE; } //停止升温
902 2 else
903 2 {
904 3 if(TaskStart==1)
905 3 os_create_task (TEMPCON);//如果已经开始治疗就创建温度控制任务
906 3 os_delete_task (TEMPSET);//删除温度设置任务
907 3
908 3 }
909 2
910 2
911 2 ScanKey();
912 2 keytemp=DealNews( ) ;
913 2 switch( keytemp)
914 2 {
915 3 case 0xff: /*时间控制*/
916 3 {
917 4 os_send_signal (TIMESET);
918 4 TimeCounter=0;
919 4 keytemp=0;
920 4 break;}
921 3 case 0xfd: /*时间控制*/
922 3 {
923 4 os_send_signal (TIMESET);
C51 COMPILER V7.01 ACUS 11/24/2004 13:33:22 PAGE 16
924 4 TimeCounter=0;
925 4 keytemp=0;
926 4 break;}
927 3 case 0xfe: /*温度控制*/
928 3 { TimeCounter=0;
929 4 keytemp=0;
930 4
931 4 break;}
932 3
933 3 default:
934 3 { break;}
935 3 }
936 2
937 2 os_wait (K_TMO, 10, 0);
938 2
939 2 }
940 1
941 1 }
942
943
944 /*********************************************************
945 *名称:TempControl()
946 *功能:温度控制任务
947 *入口参数:no
948 *出口参数:无
949 *********************************************************/
950 TempControl() _task_ TEMPCON
951 { uchar deca ,first;
952 1 while (1) {
953 2 TemperatuerResult();//读18b20温度值
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -