执行模块

/**********************************************************
*                                                         *
*                   处理程序                                  *
*                                                          *
**********************************************************/
#include
#include
#include
#include "led.h"
#include "main.h"
//#include "act.h"
//#include "chuankou.h"
//#include "wenshi.h"

unsigned char idata TH_data,TL_data,RH_data,RL_data,CK_data;//全局变量 用来存储温湿度的值
unsigned char idata shi[],wen[],guang[],co2[];          //用于在显示屏上显示温湿度,传感器传来的
unsigned char idata shi_s[],wen_s[],guang_s[],co2_s[];  //用于在显示屏上显示温湿度,要设置达到的
unsigned char action[4];
unsigned char idata state[4];          //用于计算的温湿度,传感器传来的
unsigned char idata state_s[4];       //用于计算的温湿度,要设置达到的


void act(void)
{  
  int j;
   //测量的参数
   state[0]=RH_data;
   state[1]=TH_data;
   state[2]=(guang[0]-0x30)*100+(guang[1]-0x30)*10+(guang[2]-0x30);
   state[3]=(co2[0]-0x30)*100+(co2[1]-0x30)*10+(co2[2]-0x30);

    //想要的参数
   state_s[0]=(shi_s[0]-0x30)*10+(shi_s[1]-0x30);
   state_s[1]=(wen_s[0]-0x30)*10+(wen_s[1]-0x30);
   state_s[2]=(guang_s[0]-0x30)*100+(guang_s[1]-0x30)*10+(guang_s[2]-0x30);
   state_s[3]=(co2_s[0]-0x30)*100+(co2_s[1]-0x30)*10+(co2_s[2]-0x30);

   //action[4]   2 增加 1不变 0 减小
 for(j=0;j<4;j++)
   {
        if(state[j]*10>state_s[j]*11)//&& action[j]!=0)    //偏大 且 未开小
        {
               action[j]=0;
               set_led(action[j],j);
        }                                       //开小
       else if(state[j]*10         {
               action[j]=2;
               set_led(action[j],j);   
        }                                     //开大
       else //正好 且 未保持
        {
               action[j]=1;                                        //  使不变
            //   set_led(action[j],j);
        }
    
   }
   /*
   set_led(0,0);
   set_led(2,1);
   set_led(2,2);
   set_led(0,3);
    */
}

你可能感兴趣的:(嵌入式)