Skip to content

Commit

Permalink
[270] Fix alignment issues
Browse files Browse the repository at this point in the history
  • Loading branch information
clholgat authored and dl1com committed Oct 27, 2024
1 parent 85d0842 commit fbc015c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ayab/encoders.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,8 @@ constexpr uint8_t START_OFFSET[NUM_MACHINES][NUM_DIRECTIONS][NUM_CARRIAGES] = {
// KH270
{
// K
{28U, 0U, 0U}, // Left: x % 12 == 4
{16U, 0U, 0U} // Right: (x + 6) % 12 == 10
{28U, 0U, 0U}, // Left
{16U, 0U, 0U} // Right
}};

// Should be calibrated to each device
Expand Down
22 changes: 21 additions & 1 deletion src/ayab/knitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,14 @@ bool Knitter::calculatePixelAndSolenoid() {

bool beltShift = BeltShift_t::Shifted == m_beltShift;

// 270 Doesn't care about belt shift
if (Machine_t::Kh270 == m_machineType) {
beltShift = false;
}

// 270 needs additional start offsets because of it's wierdness
uint8_t bulkyOffset = 0;

switch (m_direction) {
// calculate the solenoid and pixel to be set
// implemented according to machine manual
Expand All @@ -403,10 +411,22 @@ bool Knitter::calculatePixelAndSolenoid() {
beltShift = !beltShift;
}

// Page 6 of the 270 service manual: https://mostlyknittingmachines.weebly.com/uploads/8/4/6/7/846749/brother_kh270_service_manual.pdf
// Pixel 0 needs to be written into solenoid 4 (indexed from 0) L -> R
if (Machine_t::Kh270 == m_machineType) {
bulkyOffset = 4;
}

break;
case Direction_t::Left:
startOffset = getStartOffset(Direction_t::Right);

// Page 6 of the 270 service manual: https://mostlyknittingmachines.weebly.com/uploads/8/4/6/7/846749/brother_kh270_service_manual.pdf
// Pixel 0 needs to be written into solenoid 10 (indexed from 0) R -> L
if (Machine_t::Kh270 == m_machineType) {
bulkyOffset = 10;
}

break;
default:
return false;
Expand All @@ -415,7 +435,7 @@ bool Knitter::calculatePixelAndSolenoid() {
m_pixelToSet = m_position - startOffset;

if (!beltShift) {
m_solenoidToSet = m_pixelToSet % SOLENOIDS_NUM[static_cast<uint8_t>(m_machineType)];
m_solenoidToSet = (m_pixelToSet + bulkyOffset) % SOLENOIDS_NUM[static_cast<uint8_t>(m_machineType)];
} else {
m_solenoidToSet = (m_pixelToSet + HALF_SOLENOIDS_NUM[static_cast<uint8_t>(m_machineType)]) % SOLENOIDS_NUM[static_cast<uint8_t>(m_machineType)];
}
Expand Down

0 comments on commit fbc015c

Please sign in to comment.