Scrambled display

I’m developing an ESP32-based controller for my amplifier. I have breadboarded the essential components of the controller: Heltec WiFi kit 32 (V2.1 I think, maybe V2), IR receivers, push buttons, etc. I have also implemented a websockets app on the ESP32 so that I can control the amplifier via a web interface. It all works very well so far - all connected web clients update whenever a control is changed, regardless of whether that’s via a web client, or IR or buttons. So far so good.

I have now added some simple code to display the current status (Power/Mute/Volume/Input channel) on the built-in display, and I’ve run into a problem. The display updates perfectly when the status is changed by IR or by physical buttons, but when the same update functions are triggered by a websocket message the screen becomes progressively more scrambled the more commands I issue. Broken characters appear in places they shouldn’t, the lines move up and down etc.

The function that updates the display starts with Heltec.display -> clear();, has a bunch of drawString commands, and ends with Heltec.display -> display();. The same routine is called whenever a status change occurs, either by IR, buttons or websocket message.

It feels like a memory issue - does the websocket code somehow interfere with the display memory? I’m at a bit of a loss to debug this.

All suggestions gratefully received!

Thanks