Skip to content

Commit

Permalink
Fix knit carriage belt shift
Browse files Browse the repository at this point in the history
  • Loading branch information
clholgat committed Aug 25, 2024
1 parent 600d0e3 commit b013100
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ayab/encoders.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ constexpr uint8_t START_OFFSET[NUM_MACHINES][NUM_DIRECTIONS][NUM_CARRIAGES] = {
// KH910
{
// K, L, G
{40U, 32U, 32U}, // Left
{42U, 32U, 32U}, // Left
{16U, 32U, 50U} // Right
},
// KH930
Expand Down
17 changes: 13 additions & 4 deletions src/ayab/knitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,8 @@ bool Knitter::calculatePixelAndSolenoid() {
uint8_t startOffset = 0;
uint8_t laceOffset = 0;

bool beltShift = BeltShift_t::Shifted == m_beltShift;

switch (m_direction) {
// calculate the solenoid and pixel to be set
// implemented according to machine manual
Expand All @@ -400,9 +402,16 @@ bool Knitter::calculatePixelAndSolenoid() {

m_pixelToSet = m_position - startOffset;

if ((BeltShift::Regular == m_beltShift)) {
// The Knit carriage is special
// It's probably more apt to say that the other carriages are special but the
// Knit carriage is outnumbered
if (Carriage_t::Knit == m_carriage) {
beltShift = !beltShift;
}

if (!beltShift) {
m_solenoidToSet = m_pixelToSet % SOLENOIDS_NUM[static_cast<uint8_t>(m_machineType)];
} else if (BeltShift::Shifted == m_beltShift) {
} else {
m_solenoidToSet = (m_pixelToSet + HALF_SOLENOIDS_NUM[static_cast<uint8_t>(m_machineType)]) % SOLENOIDS_NUM[static_cast<uint8_t>(m_machineType)];
}
break;
Expand All @@ -411,9 +420,9 @@ bool Knitter::calculatePixelAndSolenoid() {
startOffset = getStartOffset(Direction_t::Right);
m_pixelToSet = m_position - startOffset;

if (BeltShift::Regular == m_beltShift) {
if (!beltShift) {
m_solenoidToSet = (m_pixelToSet + HALF_SOLENOIDS_NUM[static_cast<uint8_t>(m_machineType)]) % SOLENOIDS_NUM[static_cast<uint8_t>(m_machineType)];
} else if (BeltShift::Shifted == m_beltShift) {
} else {
m_solenoidToSet = m_pixelToSet % SOLENOIDS_NUM[static_cast<uint8_t>(m_machineType)];
}
break;
Expand Down

0 comments on commit b013100

Please sign in to comment.