Ejemplo n.º 1
0
void CreateFileCount()
{
BYTE i=0;
//fCreateNew=1;
FileCreated=0;	//penanda  file create baru, file sebelumnya diabaikan
	while(i<10)
		{
			
			MyFileName[5]=i+0x30;

		if(!FileSearch(MyFileName))	//jika nama file tidak ditemukan,
			{
			UartSendString("try new file : ");
			UartSendString(MyFileName);
			UartSendString("\n");
			break;
			}
			i++;
		}
	if(i>9)return;
	
	if(FileInit(MyFileName)==FIL_OK)
		{
			FileCreated=1;
		}
//fCreateNew=0;
}
Ejemplo n.º 2
0
void Read_PM25(void)
{
  unsigned char i ,PM25uchar[21] = "Dust Density:   ug/m3",
                UnderThreshold[31] = "Dust Density is under threshold";
  unsigned int Sum = 0;
  float X = 0;
  
  for(i = 0; i <10; i++)
    Sum = Temp_PM25[i] + Sum;
  Sum = Sum /10;
  if(Sum < 435)
    UartSendString(UnderThreshold, 31);
  else
  {
  X = (float)Sum*33/2048;                 //x10
  X = (X-7)/56*1000;                      //change the unit(mg/m3) to um/m3
  
  PM25uchar[13] = (int)X/100 +0x30;
  PM25uchar[14] = (int)X/10%10 +0x30;
  PM25uchar[15] = (int)X%10 +0x30;
  
  SendData(7,PM25uchar[13]);
  SendData(8,PM25uchar[14]);
  SendData(9,PM25uchar[15]);
  /*
  UartSendString(PM25uchar, 21);*/
  }
}
Ejemplo n.º 3
0
void AdcWriteFile()
{
	if(!FileCreated)return;
	//if(!fCreateNew)return;
	if(FillFileBuffer(0, 512))
		{
			UartSendString("ADC store 512 \n");
			FileWriteString(FileWriteBuff,512);
		}
}
Ejemplo n.º 4
0
uint16 SendUART(uint8 taskid, uint16 events)
{ 
  if ( events & SEND_UART )
  {
    tempA=0;
    tempB=0;
    
    //UartSendString(periodicData,14);
    if(periodicData[0]==0x41)
          {      UartSendString(ROOM1,16);
                  tempA = periodicData[26]-0x30 + (periodicData[25]-0x30)*10 + (periodicData[24]-0x30)*100 ;
              while( tempA != cntnumberA+1 )
                   {
                   missmessageA = tempA- cntnumberA -1;
                   MMchar[23] = periodicData[0];                           // A
                   MMchar[24] = missmessageA /100 + 0x30;          // 100
                   MMchar[25] = missmessageA /10 %10 + 0x30;    // 10
                   MMchar[26] = missmessageA %10 +0x30;           // 1
                   UartSendString(MMchar,33);
                   break;
                   }cntnumberA = tempA;
          }
    else
          {        UartSendString(ROOM2,16);
                    tempB = periodicData[26]-0x30 + (periodicData[25]-0x30)*10 + (periodicData[24]-0x30)*100 ;
              while( tempB != cntnumberB+1)
                     {
                     missmessageB = tempB- cntnumberB -1;
                     MMchar[23] = periodicData[0];                           // B
                     MMchar[24] = missmessageB /100 + 0x30;          // 100
                     MMchar[25] = missmessageB /10 %10 + 0x30;    // 10
                     MMchar[26] = missmessageB %10 +0x30;           // 1
                     UartSendString(MMchar,33);
                     break;
                     }cntnumberB = tempB;
          }
     
    UartSendString(periodicData,28);
    
     unsigned char CNT_Output[4] = {0x30,0x30,0x30,0x30};
      CNT_Output[0]=periodicData[0];
      CNT_Output[1]=periodicData[24];
      CNT_Output[2]=periodicData[25];
      CNT_Output[3]=periodicData[26];
    UartSendString(CNT_Output,4);
    
 
    
    unsigned char Temperature_Output[19]="Temperature: __._ C";
      Temperature_Output[13]=periodicData[1];
      Temperature_Output[14]=periodicData[2];
      Temperature_Output[16]=periodicData[3];
     
     unsigned char Humidity_Output[16]="Humidity: __._ %";
      Humidity_Output[10]=periodicData[4];
      Humidity_Output[11]=periodicData[5];
      Humidity_Output[13]=periodicData[6];
     
     unsigned char Dust_Output[19]="Dust: ___ ug/m3   ";
      Dust_Output[6]=periodicData[7];
      Dust_Output[7]=periodicData[8];
      Dust_Output[8]=periodicData[9];
     if(periodicData[7]==0x30 && periodicData[8]==0x30 && periodicData[9]==0x30 )
     {
        Dust_Output[6]='u'; Dust_Output[7]='n'; Dust_Output[8]='d'; Dust_Output[9]='e'; Dust_Output[10]='r'; 
        Dust_Output[11]=' ';  Dust_Output[12]='1'; Dust_Output[13]='u'; Dust_Output[14]='g'; Dust_Output[15]='/'; 
        Dust_Output[16]='m'; Dust_Output[17]='3'; 
     }
     
    
    unsigned char CO2_Output[13]="CO2 : ____ppm";
      CO2_Output[6]=periodicData[10];
      CO2_Output[7]=periodicData[11];
      CO2_Output[8]=periodicData[12];
      CO2_Output[9]=periodicData[13];
      
    unsigned char CO_Output[12]="CO : ____ppm";
       CO_Output[5]=periodicData[14];
       CO_Output[6]=periodicData[15];
       CO_Output[7]=periodicData[16];
       CO_Output[8]=periodicData[17];
        
    unsigned char CH2O_Output[11]="CH2O: __ppm";
      CH2O_Output[6]=periodicData[18];
      CH2O_Output[7]=periodicData[19];
    
    unsigned char CH4_Output[12]="CH4: ____ppm";
       CH4_Output[5]=periodicData[20];
       CH4_Output[6]=periodicData[21];
       CH4_Output[7]=periodicData[22];
       CH4_Output[8]=periodicData[23];
        
    UartSendString(Temperature_Output,19);
    UartSendString(Humidity_Output,16);
    UartSendString(Dust_Output,19);
    UartSendString(CO2_Output,13);
    UartSendString(CO_Output,12);
    UartSendString(CH2O_Output,11);
    UartSendString(CH4_Output,12);
    UartSendString(periodicData,28);
    
      
      
    return (events ^ SEND_UART);
  }return 0;
}