     MOTION_NORMAL = 1,
     MOTION_DECELETING = 2
 };
-struct PlannerPoint
+typedef struct
 {
     long err;
     double delta[NUM_AXIS];

    finishCommand();
}

void addMotion(long x, long y, uint8_t power, uint8_t speed, uint8_t acceleration)
{
    if (_sys.plannedLength >= POINTS_COUNT)
    {
        waitingPushPoint();
    }
    PlannerPoint prevPoint = _sys.prevPoint;
    PlannerPoint nextPoint;
    nextPoint.targetPosition[0] = x;
    nextPoint.targetPosition[1] = y;
    nextPoint.dir[0] = prevPoint.targetPosition[0] < nextPoint.targetPosition[0];
    nextPoint.dir[1] = prevPoint.targetPosition[1] < nextPoint.targetPosition[1];
    nextPoint.targetCount[0] = abs(nextPoint.targetPosition[0] - prevPoint.targetPosition[0]);
    nextPoint.targetCount[1] = abs(nextPoint.targetPosition[1] - prevPoint.targetPosition[1]);
    nextPoint.delta[0] = (nextPoint.targetCount[0]);
    nextPoint.delta[1] = (nextPoint.targetCount[1]);
    nextPoint.totalCount = nextPoint.delta[0] + nextPoint.delta[1];
    nextPoint.enterSpeed = _sys.plannedIndex > 0 ? prevPoint.exitSpeed : _sys.defaultSpeed;
    nextPoint.speed = fmax(1, speed);
    prevPoint.exitSpeed = fmax(1, sqrt(nextPoint.speed));
    nextPoint.acceleration = acceleration;
    long dist = sqrt(nextPoint.delta[0] * nextPoint.delta[0] + nextPoint.delta[1] * nextPoint.delta[1]) / 2;
    nextPoint.accelCount = nextPoint.totalCount - min(dist, _sys.defaultAccelCount);
    nextPoint.decelCount = min(dist, _sys.defaultDecelCount);
    nextPoint.power = power;
    nextPoint.err = (nextPoint.delta[0] > nextPoint.delta[1] ? nextPoint.delta[0] : -nextPoint.delta[1]) / 2;
    _sys.points[_sys.plannedIndex] = nextPoint;
    _sys.prevPoint = nextPoint;
    _sys.plannedIndex++;
    _sys.plannedLength++;
}
void finishCommand()
{
    if (commandsLength() < POINTS_COUNT)
    {
        Serial.print("ok:");
        Serial.println(commandsLength());
    }
}
int8_t commandsLength()
{
    return _sys.plannedLength;
}
void setPower(uint8_t power)
{
    _sys.power = fmaxf(0.0, fminf(100.0, power));
}
void setSpeed(uint8_t speed)
{
    _sys.speed = fmaxf(0.0, fminf(100.0, speed));
}
void setAccel(uint8_t accel)
{
    _sys.acceleration = fmaxf(0.0, fminf(100.0, accel));
}
void firePower(uint8_t power)
{
    pinMode(_sys.powerPin, OUTPUT);
    analogWrite(_sys.powerPin, fmaxf(0.0, fminf(255.0, power)));
}
void openPower()
{
    pinMode(_sys.powerPin, OUTPUT);
    analogWrite(_sys.powerPin, _sys.power * 2.55);
}
void closePower()
{
    analogWrite(_sys.powerPin, 0);
}
/**
 * motion control in Timer

    uint8_t isRunningState = MOTION_ACCELETING;
    uint8_t powerPin = 10;
    String buffer = "";
} SystemStatus;
static SystemStatus _sys;
volatile uint8_t plannedLength = 0;
volatile uint8_t plannedIndex = 0;
volatile bool busy = false;
MeStepper steppers[NUM_AXIS] = {MeStepper(SLOT_1), MeStepper(SLOT_2)};

void setup()
