Help with emulating an LCD

Thanks for the reply.

Sidenote: I started implementing the LCD in JS, so it has roughly the same API here. Still needs some work, but it can do the bulk of things I will use it for, and looks pretty realistic (pixelated, only B&W, draw, text, etc.)

If I am understanding right, I need to make a queue in onValue, then draw the queue in onDraw, and I can send commands the LCD by OSC value calls. This makes sense! In your example, I see you are mixing ctx and command-processing similar to how I was originally thinking, which if I am understanding your text, is not viable. Did you mean more like this?:

function onValue(value) {
  if (Array.isArray(value)) {
    this.queue ||= []
    this.queue.push(value)
  }
}

function onDraw() {
  if (this.queue) {
    for (const cmd of this.queue) {
      // TODO run command on ctx here
    } 
    // all items have been drawn, so clear the queue
    this.queue = []
  }
}

Do both callbacks have access to the queue, via this, or do i need to do something with a shared var some other way?

If so, I really like this structure, and it should be really easy to make a self-contained & reusable LCD. So cool!