SSD1306 Support in TinyCLR

Is there any support for SSD1306 devices in TinyCLR?

That is the display used on the BrainPad. So yes it is there

So BrainPad code tutorials will have the info?

Ok, so I managed to cobble together some code from various sources, however I can’t get DrawString to work.

        ushort SSD1306_I2C_ADDRESS = (0x3C);
       
        I2cDevice I2C = I2cController.FromName(FEZCobraIII.I2cBus.I2c0).GetDevice(new I2cConnectionSettings(SSD1306_I2C_ADDRESS));
        SSD1306Controller oledDisplay = new SSD1306Controller(I2C);
        BufferDrawTargetVerticalByteStrip1Bpp _buffer = new BufferDrawTargetVerticalByteStrip1Bpp(oledDisplay.Width, oledDisplay.Height);
        SolidBrush _brush = new SolidBrush(Color.Black);
        Graphics _screen = Graphics.FromHdc(GraphicsManager.RegisterDrawTarget(_buffer));

        _screen.DrawString("Startup...", Properties.Resources.GetFont(Properties.Resources.FontResources.SegoeUI), _brush, 0, 0);

        oledDisplay.DrawBuffer(_buffer.GetData());

I’m getting a System.NotSupportedException when I try to do DrawString.

Does it all work if you draw a line or a circle?

Drawing a line seems to work. I don’t get an exception, and it seems to be drawing a line. (I’m not home right now, so I’m looking at the screen from a security camera).

This should work. The full font support doesn’t work yet on SPI/I2C displays.

var teal = new SolidBrush(Color.Teal);
var font = new Font("GHIMono8x5", 8);
screen.DrawString("Hello World!", font, teal, 40, 10);
screen.Flush();

It looks like its working. So no support for custom fonts just yet. Thanks much.

1 Like