void totalizer() // For Cummulative Run Hr Only
{
if( OnStatus == 0 )
{ OnStatus =1;
//WriteEeprom OnStatus
//Serial.println("Device Begin 1st Time with following data ");
/* DAY1st=DAY ;
MONTH1st=MONTH ;
YEAR1st=YEAR ;
HOUR1st=HOUR ;
MINUTE1st=MINUTE ;
SECOND1st=SECOND ;*/
//WriteEeprom 1st Date & Time
}
if( dg==0 && ebr==0 && eby==0 && ebb ==0 ) // BT Run Hr
{
if(BTrunRawSec > 59)
{ //BTrunRawSec = BTrunRawSec - 60 ;
BTrunRawSec = 0;
BTrunRawMin++ ;
prevMillisBT=millis()/1000 ;
Serial.println("BT Increasing");
if(BTrunRawMin > 59){BTrunRawMin =0; BTrunRawHr++; }
str = String (BTrunRawHr);
if(str >="0" && str <= "99" ){ str = str.substring(0,2); runRawhr1 = str.toInt() ; }
else if(str >="100" && str <= "999" ){str1 = str.substring(1); runRawhr1 = str1.toInt() ;
str2 = str.substring(0,1); runRawhr2 = str2.toInt() ; }
else if(str >="1000" && str <= "9999" ){str1 = str.substring(2); runRawhr1 = str1.toInt() ;
str2 = str.substring(0,2); runRawhr2 = str2.toInt() ;}
else if(str >="10000" && str <= "99999" ){str1 = str.substring(3); runRawhr1 = str1.toInt() ;
str2 = str.substring(1,2); runRawhr2 = str2.toInt() ;
str3 = str.substring(0,1); runRawhr3 = str3.toInt() ;}
else if(str >= "100000" && str <= "999999"){ str1 = str.substring(4); runRawhr1 = str1.toInt() ;
str2 = str.substring(2,2); runRawhr2 = str2.toInt() ;
str3 = str.substring(0,2); runRawhr3 = str3.toInt() ;}
str="";
str1="";
str2="";
str3="";
//Write to EEPROM every minute
EEPROM.update(ad_BTmin, BTrunRawMin);
delay(10);
EEPROM.update(ad_BThr1, runRawhr1);
delay(10);
EEPROM.update(ad_BThr2, runRawhr2);
delay(10);
EEPROM.update(ad_BThr3, runRawhr3);
delay(10);
if(BTrunRawHr >999999){BTrunRawHr=0; BTrunRawMin=0; prevMillisBT=0 ; currMillisBT=0 ; }
}
}
if( ebr==1 || eby==1 || ebb ==1 ) // EB Run Hr
{
if(EBrunRawSec > 59)
{ EBrunRawSec = 0 ;
EBrunRawMin++;
prevMillisEB= millis()/1000 ;
if(EBrunRawMin > 59){EBrunRawMin =0; EBrunRawHr++; }
str = String (EBrunRawHr);
if(str >="0" && str <= "99" ){ str = str.substring(0,2); runRawhr1 = str.toInt() ; }
else if(str >="100" && str <= "999" ){str1 = str.substring(1); runRawhr1 = str1.toInt() ;
str2 = str.substring(0,1); runRawhr2 = str2.toInt() ; }
else if(str >="1000" && str <= "9999" ){str1 = str.substring(2); runRawhr1 = str1.toInt() ;
str2 = str.substring(0,2); runRawhr2 = str2.toInt() ;}
else if(str >="10000" && str <= "99999" ){str1 = str.substring(3); runRawhr1 = str1.toInt() ;
str2 = str.substring(1,2); runRawhr2 = str2.toInt() ;
str3 = str.substring(0,1); runRawhr3 = str3.toInt() ;}
else if(str >= "100000" && str <= "999999"){ str1 = str.substring(4); runRawhr1 = str1.toInt() ;
str2 = str.substring(2,2); runRawhr2 = str2.toInt() ;
str3 = str.substring(0,2); runRawhr3 = str3.toInt() ;}
str="";
str1="";
str2="";
str3="";
//Write to EEPROM every minute
EEPROM.update(ad_EBmin, EBrunRawMin);
delay(10);
EEPROM.update(ad_EBhr1, runRawhr1);
delay(10);
EEPROM.update(ad_EBhr2, runRawhr2);
delay(10);
EEPROM.update(ad_EBhr3, runRawhr3);
delay(10);
if(EBrunRawHr >999999){EBrunRawHr=0; EBrunRawMin=0; prevMillisEB=0 ;currMillisEB=0 ; }
}
}
if( vib==1 && dg==1 && ebr==0 && eby==0 && ebr==0 ) // DG Run Hr
{
if(DGrunRawSec > 59)
{ DGrunRawSec = 0 ;
DGrunRawMin++;
prevMillisDG= millis()/1000 ;
if(DGrunRawMin > 59){DGrunRawMin =0; DGrunRawHr++; }
str = String (DGrunRawHr);
if(str >="0" && str <= "99" ){ str = str.substring(0,2); runRawhr1 = str.toInt() ; }
else if(str >="100" && str <= "999" ){str1 = str.substring(1); runRawhr1 = str1.toInt() ;
str2 = str.substring(0,1); runRawhr2 = str2.toInt() ; }
else if(str >="1000" && str <= "9999" ){str1 = str.substring(2); runRawhr1 = str1.toInt() ;
str2 = str.substring(0,2); runRawhr2 = str2.toInt() ;}
else if(str >="10000" && str <= "99999" ){str1 = str.substring(3); runRawhr1 = str1.toInt() ;
str2 = str.substring(1,2); runRawhr2 = str2.toInt() ;
str3 = str.substring(0,1); runRawhr3 = str3.toInt() ;}
else if(str >= "100000" && str <= "999999"){ str1 = str.substring(4); runRawhr1 = str1.toInt() ;
str2 = str.substring(2,2); runRawhr2 = str2.toInt() ;
str3 = str.substring(0,2); runRawhr3 = str3.toInt() ;}
str="";
str1="";
str2="";
str3="";
//Write to EEPROM every minute
EEPROM.update(ad_DGmin, DGrunRawMin);
delay(10);
EEPROM.update(ad_DGhr1, runRawhr1);
delay(10);
EEPROM.update(ad_DGhr2, runRawhr2);
delay(10);
EEPROM.update(ad_DGhr3, runRawhr3);
delay(10);
if(DGrunRawHr >999999){DGrunRawHr=0; DGrunRawMin=0; prevMillisDG=0 ;currMillisDG=0 ; }
}
}
if( dg==1 && (ebr==1 || eby==1 || ebb ==1) ) // OL Run Hr
{
if(OLrunRawSec > 59)
{ //OLrunRawSec = OLrunRawSec -60 ;
OLrunRawSec = 0;
OLrunRawMin++;
prevMillisOL= millis()/1000 ;
if(OLrunRawMin > 59){ OLrunRawMin =0; OLrunRawHr++; }
str = String (OLrunRawHr);
if(str >="0" && str <= "99" ){ str = str.substring(0,2); runRawhr1 = str.toInt() ; }
else if(str >="100" && str <= "999" ){str1 = str.substring(1); runRawhr1 = str1.toInt() ;
str2 = str.substring(0,1); runRawhr2 = str2.toInt() ; }
else if(str >="1000" && str <= "9999" ){str1 = str.substring(2); runRawhr1 = str1.toInt() ;
str2 = str.substring(0,2); runRawhr2 = str2.toInt() ;}
else if(str >="10000" && str <= "99999" ){str1 = str.substring(3); runRawhr1 = str1.toInt() ;
str2 = str.substring(1,2); runRawhr2 = str2.toInt() ;
str3 = str.substring(0,1); runRawhr3 = str3.toInt() ;}
else if(str >= "100000" && str <= "999999"){ str1 = str.substring(4); runRawhr1 = str1.toInt() ;
str2 = str.substring(2,2); runRawhr2 = str2.toInt() ;
str3 = str.substring(0,2); runRawhr3 = str3.toInt() ;}
str="";
str1="";
str2="";
str3="";
//Write to EEPROM every minute
EEPROM.update(ad_OLmin, OLrunRawMin);
delay(10);
EEPROM.update(ad_OLhr1, runRawhr1);
delay(10);
EEPROM.update(ad_OLhr2, runRawhr2);
delay(10);
EEPROM.update(ad_OLhr3, runRawhr3);
delay(10);
if(OLrunRawHr >999999){OLrunRawHr=0; OLrunRawMin=0; prevMillisOL=0 ;currMillisOL=0 ; }
}
}
} //////////////// Total Ends ////////////