 }
 
 void optimize(AccelStepper *chanel, int16_t step, int16_t hysteresis) {
-  boolean isFirstStep = true;
+  uint8_t stepCount = 0;
   yeld();
   uint16_t prevSetepPwr = rflPwrPercent;
   while (step != 0) {

    yeld();
    if (prevSetepPwr < (rflPwrPercent + hysteresis)) {
      step = -step;
      if (!isFirstStep) {
        step = step >> 1;
      }
    }
    prevSetepPwr = rflPwrPercent;
    if (((fwdPwrVal >> 4) == 0) || ((rflPwrVal >> 4) == 0)) {
      break;
    }
    isFirstStep = false;
  }
}

void autoTune() {

  stepperC1.moveTo(10);
  stepperC2.moveTo(10);
  optimize(&stepperL, 2000, 0);
  dprintf("autoTune() - stepperL finished in %8d uSec\n", micros() - startedTime);
  optimize(&stepperC1, 20, 0);
  dprintf("autoTune() - stepperC1 finished in %8d uSec\n", micros() - startedTime);
  optimize(&stepperC2, 20, 0);
  dprintf("autoTune() - stepperC2 finished in %8d uSec\n", micros() - startedTime);
  isAutoTune = 0;
}

