AYAB Arduino Firmware 0.95
The goal of the AYAB project is to provide an alternative way to control the famous Brother KH-9xx range of knitting machines using a computer
Knitter Class Reference
Inheritance diagram for Knitter:
Inheritance graph
Collaboration diagram for Knitter:
Collaboration graph

Public Member Functions

void init () final
 Initialize Knitter object.
 
void setUpInterrupt () final
 Initialize interrupt service routine for Knitter object.
 
void isr () final
 Interrupt service routine.
 
Err_t startKnitting (uint8_t startNeedle, uint8_t stopNeedle, uint8_t *pattern_start, bool continuousReportingEnabled) final
 Enter OpState::knit machine state.
 
Err_t initMachine (Machine_t machine) final
 Initialize machine type.
 
void encodePosition () final
 Record current encoder position.
 
bool isReady () final
 Assess whether the Finite State Machine is ready to move from state OpState::init to OpState::ready.
 
void knit () final
 Function that is repeatedly called during state OpState::knit
 
void indState (Err_t error=ErrorCode::success) final
 Send indState message.
 
uint8_t getStartOffset (const Direction_t direction) final
 Get start offset.
 
Machine_t getMachineType () final
 Get knitting machine type.
 
bool setNextLine (uint8_t lineNumber) final
 Set line number of next row to be knitted.
 
void setLastLine () final
 Get value of last line flag.
 
void setMachineType (Machine_t) final
 Set machine type.
 

Private Member Functions

void reqLine (uint8_t lineNumber)
 Send reqLine message.
 
bool calculatePixelAndSolenoid ()
 Calculate the solenoid and pixel to be set.
 
void stopKnitting () const
 Finish knitting procedure.
 

Private Attributes

Machine_t m_machineType
 
uint8_t m_startNeedle
 
uint8_t m_stopNeedle
 
uint8_t * m_lineBuffer
 
bool m_continuousReportingEnabled
 
uint8_t m_position
 
Direction_t m_direction
 
Direction_t m_hallActive
 
BeltShift_t m_beltShift
 
Carriage_t m_carriage
 
bool m_lineRequested
 
uint8_t m_currentLineNumber
 
bool m_lastLineFlag
 
uint8_t m_sOldPosition
 
bool m_firstRun
 
bool m_workedOnLine
 
Direction_t m_lastHall
 
uint8_t m_solenoidToSet
 
uint8_t m_pixelToSet
 

Member Function Documentation

◆ calculatePixelAndSolenoid()

bool Knitter::calculatePixelAndSolenoid ( )
private

Calculate the solenoid and pixel to be set.

Returns
true if successful, false otherwise.

References getStartOffset().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ encodePosition()

void Knitter::encodePosition ( )
finalvirtual

Record current encoder position.

Used in hardware test procedure.

Implements KnitterInterface.

References calculatePixelAndSolenoid(), and indState().

Here is the call graph for this function:

◆ getMachineType()

Machine_t Knitter::getMachineType ( )
finalvirtual

Get knitting machine type.

Returns
Machine type.

Implements KnitterInterface.

◆ getStartOffset()

uint8_t Knitter::getStartOffset ( const Direction_t  direction)
finalvirtual

Get start offset.

Returns
Start offset, or 0 if unobtainable.

Implements KnitterInterface.

Here is the caller graph for this function:

◆ indState()

void Knitter::indState ( Err_t  error = ErrorCode::success)
finalvirtual

Send indState message.

Parameters
errorError state (0 = success, other values = error).

Implements KnitterInterface.

Here is the caller graph for this function:

◆ init()

void Knitter::init ( )
finalvirtual

Initialize Knitter object.

Initialize the solenoids as well as pins and interrupts.

Implements KnitterInterface.

◆ initMachine()

Err_t Knitter::initMachine ( Machine_t  machineType)
finalvirtual

Initialize machine type.

Parameters
machineTypeMachine type.
Returns
Error code (0 = success, other values = error).

Implements KnitterInterface.

References setUpInterrupt().

Here is the call graph for this function:

◆ isr()

void Knitter::isr ( )
finalvirtual

Interrupt service routine.

Update machine state data. Must execute as fast as possible. Machine type assumed valid.

Implements KnitterInterface.

◆ isReady()

bool Knitter::isReady ( )
finalvirtual

Assess whether the Finite State Machine is ready to move from state OpState::init to OpState::ready.

Returns
true if ready to move from state OpState::init to OpState::ready, false otherwise.

Implements KnitterInterface.

References indState().

Here is the call graph for this function:

◆ knit()

void Knitter::knit ( )
finalvirtual

Function that is repeatedly called during state OpState::knit

Implements KnitterInterface.

References calculatePixelAndSolenoid(), indState(), reqLine(), and stopKnitting().

Here is the call graph for this function:

◆ reqLine()

void Knitter::reqLine ( uint8_t  lineNumber)
private

Send reqLine message.

Parameters
lineNumberLine number requested.
Here is the caller graph for this function:

◆ setLastLine()

void Knitter::setLastLine ( )
finalvirtual

Get value of last line flag.

Parameters
`true`if current line is the last line in the pattern, false otherwise.

Implements KnitterInterface.

◆ setMachineType()

void Knitter::setMachineType ( Machine_t  machineType)
finalvirtual

Set machine type.

Parameters
Machinetype.

Implements KnitterInterface.

◆ setNextLine()

bool Knitter::setNextLine ( uint8_t  lineNumber)
finalvirtual

Set line number of next row to be knitted.

Parameters
lineNumberLine number (0-indexed and modulo 256).
Returns
true if successful, false otherwise.

Implements KnitterInterface.

References reqLine().

Here is the call graph for this function:

◆ setUpInterrupt()

void Knitter::setUpInterrupt ( )
finalvirtual

Initialize interrupt service routine for Knitter object.

Implements KnitterInterface.

Here is the caller graph for this function:

◆ startKnitting()

Err_t Knitter::startKnitting ( uint8_t  startNeedle,
uint8_t  stopNeedle,
uint8_t *  pattern_start,
bool  continuousReportingEnabled 
)
finalvirtual

Enter OpState::knit machine state.

Parameters
startNeedlePosition of first needle in the pattern.
stopNeedlePosition of last needle in the pattern.
patternStartPointer to buffer containing pattern data.
continuousReportingEnabledFlag variable indicating whether the device continuously reports its status to the host.
Returns
Error code (0 = success, other values = error).

Implements KnitterInterface.


The documentation for this class was generated from the following files: