AllYarnsAreBeautiful / ayab-firmware

Contains the Arduino Firmware for the AYAB Shield
GNU General Public License v3.0
23 stars 19 forks source link

formalize states of `Knit` operation #166

Open t0mpr1c3 opened 1 year ago

t0mpr1c3 commented 1 year ago

At the moment, the Knit operation is governed by multiple state variables that control program flow in procedures such as knit(). These variables include the following members of class OpKnit:

  bool m_lineRequested;
  bool m_lastLineFlag;
  bool m_firstRun;
  bool m_workedOnLine;

plus (m_sOldPosition == position) and so on.

The imperative code works fine but if we want to pursue a more OO programming style it is possible to abstract some or all of these into a sequence of operations governed by the finite state machine.

My suggestion is to leave things as they are for now, but think about making changes if we want to do #105 which will add further complexity to the program flow.

t0mpr1c3 commented 1 year ago

We can actually get rid of one of these state variables right away by moving the first run from OpKnit::knit() to OpKnit::begin().