Main Site Documentation

SSD1306 Support in TinyCLR


#1

Is there any support for SSD1306 devices in TinyCLR?


#2

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


#3

#4

So BrainPad code tutorials will have the info?


#5

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.


#6

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


#7

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).


#8

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();

#9

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