1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
/*
* CoreBaseKinematics.cpp
*
* Created on: 7 May 2017
* Author: David
*/
#include "CoreBaseKinematics.h"
#include "GCodes/GCodes.h"
CoreBaseKinematics::CoreBaseKinematics(KinematicsType t) : Kinematics(t)
{
for (size_t axis = 0; axis < XYZ_AXES; ++axis)
{
axisFactors[axis] = 1.0;
}
}
// Convert Cartesian coordinates to motor coordinates
bool CoreBaseKinematics::CartesianToMotorSteps(const float machinePos[], const float stepsPerMm[], size_t numVisibleAxes, size_t numTotalAxes, int32_t motorPos[]) const
{
for (size_t axis = 0; axis < numVisibleAxes; ++axis)
{
motorPos[axis] = (int32_t)roundf(MotorFactor(axis, machinePos) * stepsPerMm[axis]);
}
return true;
}
// Set the parameters from a M665, M666 or M669 command
// Return true if we changed any parameters. Set 'error' true if there was an error, otherwise leave it alone.
// This function is used for CoreXY and CoreXZ kinematics, but it overridden for CoreXYU kinematics
bool CoreBaseKinematics::Configure(unsigned int mCode, GCodeBuffer& gb, StringRef& reply, bool& error) /*override*/
{
if (mCode == 667)
{
bool seen = false;
for (size_t axis = 0; axis < XYZ_AXES; ++axis)
{
if (gb.Seen(GCodes::axisLetters[axis]))
{
axisFactors[axis] = gb.GetFValue();
seen = true;
}
}
if (!seen && !gb.Seen('S'))
{
reply.printf("Printer mode is %s with axis factors", GetName());
for (size_t axis = 0; axis < XYZ_AXES; ++axis)
{
reply.catf(" %c:%f", GCodes::axisLetters[axis], axisFactors[axis]);
}
}
return seen;
}
else
{
return Kinematics::Configure(mCode, gb, reply, error);
}
}
// End
|