diff --git a/src/ayab/encoders.h b/src/ayab/encoders.h index 228e4d56..99c97a92 100644 --- a/src/ayab/encoders.h +++ b/src/ayab/encoders.h @@ -89,8 +89,8 @@ constexpr uint8_t START_OFFSET[NUM_MACHINES][NUM_DIRECTIONS][NUM_CARRIAGES] = { // KH930 { // K, L, G - {40U, 40U, 8U}, // Left - {16U, 16U, 32U} // Right + {40U, 40U, 32U}, // Left + {16U, 16U, 56U} // Right }, // KH270 { diff --git a/src/ayab/knitter.cpp b/src/ayab/knitter.cpp index 81714ffe..7153ceaa 100644 --- a/src/ayab/knitter.cpp +++ b/src/ayab/knitter.cpp @@ -388,6 +388,7 @@ void Knitter::reqLine(uint8_t lineNumber) { */ bool Knitter::calculatePixelAndSolenoid() { uint8_t startOffset = 0; + uint8_t laceOffset = 0; switch (m_direction) { // calculate the solenoid and pixel to be set @@ -395,7 +396,15 @@ bool Knitter::calculatePixelAndSolenoid() { // magic numbers from machine manual case Direction_t::Right: startOffset = getStartOffset(Direction_t::Left); - if (m_position >= startOffset) { + + // We have to start setting pixels earlier when the lace carriage is selected because we shift + // the lace pixel selection up HALF_SOLENOIDS_NUM in this direction. Doesn't matter going back + // the other way. + if (Carriage_t::Lace == m_carriage) { + laceOffset = HALF_SOLENOIDS_NUM[static_cast(m_machineType)]; + } + + if (m_position >= startOffset - laceOffset) { m_pixelToSet = m_position - startOffset; if ((BeltShift::Regular == m_beltShift) || (m_machineType == Machine_t::Kh270)) { @@ -432,6 +441,7 @@ bool Knitter::calculatePixelAndSolenoid() { default: return false; } + // The 270 has 12 solenoids but they get shifted over 3 bits if (m_machineType == Machine_t::Kh270) { m_solenoidToSet = m_solenoidToSet + 3;