Drivers SSD1306 for FeatherWing

I connected a FeatherWing on FEZ Feather to display text.
FeatherWing isn’t 128x64 but 128x32, so I set it in code. But only half of screen is usable, and text is not write very well if I don’t change vertical scale.
Am I doing something wrong or error is link with driver ?

using GHIElectronics.TinyCLR.Devices.I2c;
using GHIElectronics.TinyCLR.Drivers.BasicGraphics;
using GHIElectronics.TinyCLR.Drivers.SolomonSystech.SSD1306;
using GHIElectronics.TinyCLR.Pins;

namespace testFeatherOled
{
    class Program
    {
        static void Main()
        {
            uint white = 0x00ffffffU; // For OneBpp, is it correct ?

            // FeatherWing with address 0x3c connected on FEZ Feather
            I2cConnectionSettings ics = new I2cConnectionSettings(0x3c, I2cAddressFormat.SevenBit, 400_000U);
            I2cController i2CController = I2cController.FromName(SC20100.I2cBus.I2c1);
            I2cDevice device = i2CController.GetDevice(ics);
            SSD1306Controller ctl = new SSD1306Controller(device);

            // Setting for monochrome display (w:128 x h:32)
            var basicGfx = new BasicGraphics(128, 32, ColorFormat.OneBpp);
            basicGfx.Clear();

            basicGfx.DrawString("Test", white, 0, 0, 2, 8);

            ctl.DrawBufferNative(basicGfx.Buffer);
        }
    }
}

That because the SSD1306 driver supports 128x64 only.

You need to change 64 to 32 in SSD1306 driver.

try to change:

private readonly byte[] vram = new byte[128 * 32/ 8 + 1];

And this is why the drivers are open source :slight_smile:

2 Likes

And this is why I like GHI :+1:

vram buffer modification isn’t sufficient: I need to modify initialization too:

           this.SendCommand(0xAE); //turn off oled panel
            this.SendCommand(0xD5); //set display clock divide ratio/oscillator frequency
            this.SendCommand(0x80); //set divide ratio
            this.SendCommand(0xA8); //set multiplex ratio(1 to 64)
            this.SendCommand((Height == 32) ? (byte)0x1F : (byte)0x3F); //1/64 duty if height is 64, 1/32 if height is 32
            this.SendCommand(0xD3); //set display offset
            this.SendCommand(0x00); //not offset
            this.SendCommand(0x00); //set start line address **CHANGE**
            this.SendCommand(0x8D); //set Charge Pump enable/disable
            this.SendCommand(0x14); //set(0x10) disable proper vcc
            this.SendCommand(0xA1); //set segment re-map 95 to 0
            this.SendCommand(0xC8); //mirror the screen
            this.SendCommand(0xDA); //set com pins hardware configuration
            this.SendCommand((Height == 32) ? (byte)0x02 : (byte)0x12);

            this.SendCommand(0x81); //set contrast control register
            this.SendCommand((Height == 32) ? (byte)0x8F : (byte)0xCF);
            this.SendCommand(0xD9); //set pre-charge period
            this.SendCommand(0xF1);
            this.SendCommand(0xDB); //set vcomh
            this.SendCommand(0x40); //set startline 0x0

            this.SendCommand(0xA6); //set normal display
            this.SendCommand(0x2E); //change
            this.SendCommand(0xAF); //turn on oled panel

            // Mapping
            this.SendCommand(0x20);
            this.SendCommand(0x00);
            this.SendCommand(0x21);
            this.SendCommand(0);
            this.SendCommand(128 - 1);
            this.SendCommand(0x22);
            this.SendCommand(0);
            this.SendCommand(0xFF);
4 Likes