Loading...
Logo
Processing Forum
Hi,

I have a state machine structure that the states are spread across draw() and serialEvent()... It is working fine.
My question is if there is any drawbacks against doing this:
Here is an example of what it looks like:

SerialEvent(Serial p) {
myData = p.readString();
Switch (myState) {
      case 1:
            // does something with myData
      case 3:
            // does something with myData
}
}
Darw() {
Switch (myState) {
      case 0:

      case 2:

      case 4:

      case 5:

      case 6:
}
}

Thanks

Replies(1)

I see no problems in doing it this way.