     alarm_set();
     o_r = r;
   }
+
 }
 
 void changelcdicon()


void doTvOffTimer()
{
  irSendTv(0, 0);
  tvOffTimer();
  lcd.setCursor(15, 0);
  lcd.write(6);
}

void doTvOnTimer()
{
  irSendTv(1, 0);
  tvOnTimer();
  lcd.setCursor(15, 0);
  lcd.print(" ");
}



void doTvControlbyPir(int onoff)
{
  switch (onoff) {
    case 1:
      lcd.setCursor(15, 0);
      lcd.print(" ");
      irSendTv(1, 1);
      break;
    case 0:
      lcd.setCursor(15, 0);
      lcd.write(6);
      irSendTv(0, 1);
      break;
  }
  r = !r;
}

void irSendTv(int onoff, int bywhat)
{
  if ( o_wrkMode == 1 && o_startMode == 1 )
  {
    if ( o_offMode == 1 )
    {
      switch (onoff) {
        case 1:
          if ( tvPowerStatus == 0 || bywhat == 1 )
          {
            irsend.sendNEC(tv_onoff, 32);

            if ( bywhat == 0 ) {
              tvPowerStatus = 1;
              temp_Mills = millis();
            }

            delay(300);
            irrecv.enableIRIn();
          }
          break;
        case 0:
          if ( tvPowerStatus == 1 )
          {
            irsend.sendNEC(tv_onoff, 32);

            if ( bywhat == 0 ) {
              tvPowerStatus = 0;
              temp_Mills = millis();
            }

            delay(300);
            irrecv.enableIRIn();
          }
          break;
        default:
          return;
          break;

      }
    } else {
      switch (onoff) {
        case 1:
          if ( tvPowerStatus == 0 || bywhat == 1 )
          {
            irsend.sendNEC(tv_input, 32);
            delay(3000);

            for ( int i = 0 ; i < o_channelGap ; i++ ) {
              irsend.sendNEC(tv_left, 32);
              delay(300);
            }

            irsend.sendNEC(tv_enter, 32);

            if ( bywhat == 0 ) {
              tvPowerStatus = 1;
            }

            delay(300);
            irrecv.enableIRIn();
          }
          break;
        case 0:
          if ( tvPowerStatus == 1 )
          {
            irsend.sendNEC(tv_input, 32);
            delay(3000);

            for ( int i = 0 ; i < o_channelGap ; i++ ) {
              irsend.sendNEC(tv_right, 32);
              delay(300);
            }

            irsend.sendNEC(tv_enter, 32);

            if ( bywhat == 0 ) {
              tvPowerStatus = 0;
            }

            delay(300);
            irrecv.enableIRIn();
          }
          break;
        default:
          return;
          break;

      }
    }
  } else {

    return;

  }

}

// TimeTime
void displaytimeleft() {


  // event Timer
  int TempCEvent      = t.every(2000, doUpdateTempC);
  int TempCArrayEvent = t.every(300000, doUpdateTempCArray);

}

