OLED display and logger interaction on Patch Submodule

There is some interaction between the OLED display driver and the USB logger on the Patch Submodule that prevents logging when the OLED display is running and visa versa. I have been debugging this for a while on a larger application but have distilled it down to a simple app. If StartLog() is commented out the display works as expected, the display initialization is commented out the logger works as expected. There is also a time element involved because sometimes the display loop will execute several times before failing, other times it fails immediately.

#include "dev/oled_ssd130x.h"
#include "daisy_patch_sm.h"

using namespace daisy;
using namespace patch_sm;

DaisyPatchSM hw;
OledDisplay<SSD130x4WireSpi128x64Driver> display;

int main(void)
{
    hw.Init();
    hw.StartLog(true);

    OledDisplay<SSD130x4WireSpi128x64Driver>::Config cfg;

    cfg.driver_config.transport_config.spi_config.periph = SpiHandle::Config::Peripheral::SPI_2;   
    cfg.driver_config.transport_config.spi_config.pin_config.nss = hw.GetPin(DaisyPatchSM::PinBank::D, 1);
    cfg.driver_config.transport_config.spi_config.pin_config.miso = Pin();
    cfg.driver_config.transport_config.spi_config.pin_config.mosi = hw.GetPin(DaisyPatchSM::PinBank::D, 9);
    cfg.driver_config.transport_config.spi_config.pin_config.sclk = hw.GetPin(DaisyPatchSM::PinBank::D, 10);
    cfg.driver_config.transport_config.pin_config.dc = hw.GetPin(DaisyPatchSM::PinBank::D, 8);    
    cfg.driver_config.transport_config.pin_config.reset = hw.GetPin(DaisyPatchSM::PinBank::D, 6);

    display.Init(cfg);

    for (int i = 0; i < 10000; ++i) {
        System::Delay(100);
        hw.PrintLine("Hello world");
        display.Fill(false);
        display.SetCursor(0, i % 46);
        display.WriteString("Hello world", Font_11x18, true);
        display.Update();
    }
}

Hi Greg.

Thank you for this code, it helped hook up the oled.

Just to add to this issue, Im also experiencing it, but I found that the freezing behaviour only hapens if:

  1. you are not listening to serial. It seems to be blocked if the serial is not read, but if im actively reading it, the display refreshes.
  2. If I take out the serial printline it will update normally.

hw.StartLog(true) will block until a connection is made to the USB serial; hw.StartLog(false) or hwStartLog() doesn’t block.

https://electro-smith.github.io/libDaisy/classdaisy_1_1_logger.html