public static void Main(string[] args)
        {
            const byte ssdI2cAddress = 0x3C;

            var sdaPin  = ConnectorPin.P1Pin03;
            var sclPin  = ConnectorPin.P1Pin05;
            var driver  = new I2cDriver(sdaPin.ToProcessor(), sclPin.ToProcessor());
            var ssd1306 = new Ssd1306Connection(driver.Connect(ssdI2cAddress));

            // Clear the screen and turn the display on
            ssd1306.ClearScreen();
            ssd1306.On();

            // Flash screen
            ssd1306.InvertDisplay();
            Thread.Sleep(1000);
            ssd1306.NormalDisplay();
            Thread.Sleep(1000);
            ssd1306.InvertDisplay();
            Thread.Sleep(1000);
            ssd1306.NormalDisplay();

            // Write "Hello world!" with different fonts
            var fontFixed = new Fixed1L();
            var font2L    = new Proportional2L();
            var font3L    = new Proportional3L();

            ssd1306.GotoXY(0, 0);
            ssd1306.DrawText(fontFixed, "Hello World!");
            ssd1306.GotoXY(0, 2);
            ssd1306.DrawText(font2L, "Raspberry Pi");
            ssd1306.GotoXY(0, 5);
            ssd1306.DrawText(font3L, "Ssd 1306");

            Thread.Sleep(5000);

            // Draw test image logo
            var logo = new byte[] {
                0x40,
                0xC0, 0xF0, 0xF8, 0x1C, 0x0C, 0x06, 0xF6, 0xFE, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0xC0, 0xFE,
                0xFF, 0xFF, 0x7F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
                0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00,
                0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x7E, 0x1E, 0x0E, 0x07, 0x03, 0x03, 0x03, 0x23, 0x7E, 0x3E,
                0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80,
                0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x9E,
                0xBE, 0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
                0x01, 0x03, 0x03, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x06, 0x06, 0x86, 0xFE, 0xFF, 0xFF,
                0xFF, 0x0F, 0x00, 0xE0, 0xF8, 0xFC, 0xFE, 0x7F, 0x07, 0x03, 0x01, 0x99, 0xFF, 0xFF, 0x10, 0x10,
                0xD8, 0xFE, 0xFF, 0xFF, 0x7F, 0x0F, 0x03, 0x83, 0xFF, 0xFF, 0xFF, 0xFF, 0x0E, 0x06, 0x03, 0xFF,
                0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0xE0, 0xF8, 0xFC, 0xFF, 0xDF, 0xC7, 0x41, 0x71, 0x3F, 0x1F,
                0x00, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFC, 0xFC, 0x3C,
                0x00, 0xC0, 0xF0, 0xFC, 0xFE, 0xFF, 0xCF, 0xC3, 0x61, 0x71, 0x3F, 0x0F, 0x00, 0xE0, 0xFF, 0xFF,
                0xFF, 0x3F, 0x07, 0x03, 0x83, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF,
                0x1F, 0x00, 0x00, 0xC0, 0xF8, 0xFC, 0xFE, 0xFF, 0xCF, 0xC3, 0x61, 0x39, 0x1F, 0x0F, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x3C, 0x3F, 0x3F, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x30, 0x3F, 0x3F, 0x3F, 0x1F,
                0x00, 0x00, 0x00, 0x0F, 0x1F, 0x3F, 0x3F, 0x38, 0x38, 0x38, 0x1C, 0x0F, 0x07, 0x01, 0x00, 0x38,
                0x3F, 0x3F, 0x3F, 0x0F, 0x00, 0x00, 0x30, 0x3F, 0x3F, 0x3F, 0x1F, 0x00, 0x00, 0x00, 0x0E, 0x3F,
                0x3F, 0x3F, 0x39, 0x38, 0x18, 0x0E, 0x1F, 0x3F, 0x3F, 0x3F, 0x38, 0x38, 0x38, 0x18, 0x04, 0x00,
                0x00, 0x00, 0x01, 0xE1, 0xF3, 0x73, 0x77, 0x77, 0x67, 0x03, 0xF3, 0xFF, 0xFF, 0x7F, 0x07, 0x00,
                0x00, 0x0F, 0x1F, 0x3F, 0x3F, 0x3C, 0x38, 0x30, 0x38, 0x18, 0x08, 0x04, 0x3E, 0x3F, 0x3F, 0x3F,
                0x07, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x3F, 0x3F, 0x38, 0x38, 0x1C, 0x0F, 0x3F, 0x3F, 0x3F, 0x3F,
                0x38, 0x18, 0x0C, 0x0F, 0x1F, 0x3F, 0x3F, 0x3C, 0x38, 0x38, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x07, 0x07, 0x0C, 0x0C, 0x0C, 0x0C, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            };

            ssd1306.ClearScreen();
            ssd1306.GotoXY(0, 3);
            ssd1306.DrawImage(logo);

            ((IDisposable)driver).Dispose();
        }
Example #2
0
        public static void Main(string[] args)
        {
            const byte ssdI2cAddress = 0x3C;

            var sdaPin = ConnectorPin.P1Pin03;
            var sclPin = ConnectorPin.P1Pin05;
            var driver = new I2cDriver(sdaPin.ToProcessor(), sclPin.ToProcessor());
            var ssd1306 = new Ssd1306Connection(driver.Connect(ssdI2cAddress));

            // Clear the screen and turn the display on
            ssd1306.ClearScreen();
            ssd1306.On();

            // Flash screen
            ssd1306.InvertDisplay();
            Thread.Sleep(1000);
            ssd1306.NormalDisplay();
            Thread.Sleep(1000);
            ssd1306.InvertDisplay();
            Thread.Sleep(1000);
            ssd1306.NormalDisplay();

            // Write "Hello world!" with different fonts
            var fontFixed = new Fixed1L();
            var font2L = new Proportional2L();
            var font3L = new Proportional3L();
            ssd1306.GotoXY(0, 0);
            ssd1306.DrawText(fontFixed, "Hello World!");
            ssd1306.GotoXY(0, 2);
            ssd1306.DrawText(font2L, "Raspberry Pi");
            ssd1306.GotoXY(0, 5);
            ssd1306.DrawText(font3L, "Ssd 1306");

            Thread.Sleep(5000);

            // Draw test image logo
            var logo = new byte[]{
                0x40,
                0xC0, 0xF0, 0xF8, 0x1C, 0x0C, 0x06, 0xF6, 0xFE, 0xFF, 0xFF, 0x0F, 0x00, 0x00, 0x00, 0xC0, 0xFE,
                0xFF, 0xFF, 0x7F, 0x03, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80,
                0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00,
                0x00, 0x00, 0xC0, 0xF0, 0xF8, 0xFC, 0x7E, 0x1E, 0x0E, 0x07, 0x03, 0x03, 0x03, 0x23, 0x7E, 0x3E,
                0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80,
                0x80, 0x80, 0x80, 0x00, 0x00, 0x80, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x9C, 0x9E,
                0xBE, 0x1C, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, 0x00,
                0x01, 0x03, 0x03, 0x00, 0xE0, 0xFF, 0xFF, 0xFF, 0x3F, 0x07, 0x06, 0x06, 0x86, 0xFE, 0xFF, 0xFF,
                0xFF, 0x0F, 0x00, 0xE0, 0xF8, 0xFC, 0xFE, 0x7F, 0x07, 0x03, 0x01, 0x99, 0xFF, 0xFF, 0x10, 0x10,
                0xD8, 0xFE, 0xFF, 0xFF, 0x7F, 0x0F, 0x03, 0x83, 0xFF, 0xFF, 0xFF, 0xFF, 0x0E, 0x06, 0x03, 0xFF,
                0xFF, 0xFF, 0xFF, 0x04, 0x00, 0x00, 0xE0, 0xF8, 0xFC, 0xFF, 0xDF, 0xC7, 0x41, 0x71, 0x3F, 0x1F,
                0x00, 0x3E, 0xFF, 0xFF, 0xFF, 0xFF, 0x80, 0x00, 0x00, 0x00, 0x00, 0x80, 0xF8, 0xFC, 0xFC, 0x3C,
                0x00, 0xC0, 0xF0, 0xFC, 0xFE, 0xFF, 0xCF, 0xC3, 0x61, 0x71, 0x3F, 0x0F, 0x00, 0xE0, 0xFF, 0xFF,
                0xFF, 0x3F, 0x07, 0x03, 0x83, 0xFF, 0xFF, 0xFF, 0x7F, 0x00, 0x00, 0x00, 0xF0, 0xFF, 0xFF, 0xFF,
                0x1F, 0x00, 0x00, 0xC0, 0xF8, 0xFC, 0xFE, 0xFF, 0xCF, 0xC3, 0x61, 0x39, 0x1F, 0x0F, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x3C, 0x3F, 0x3F, 0x3F, 0x07, 0x00, 0x00, 0x00, 0x30, 0x3F, 0x3F, 0x3F, 0x1F,
                0x00, 0x00, 0x00, 0x0F, 0x1F, 0x3F, 0x3F, 0x38, 0x38, 0x38, 0x1C, 0x0F, 0x07, 0x01, 0x00, 0x38,
                0x3F, 0x3F, 0x3F, 0x0F, 0x00, 0x00, 0x30, 0x3F, 0x3F, 0x3F, 0x1F, 0x00, 0x00, 0x00, 0x0E, 0x3F,
                0x3F, 0x3F, 0x39, 0x38, 0x18, 0x0E, 0x1F, 0x3F, 0x3F, 0x3F, 0x38, 0x38, 0x38, 0x18, 0x04, 0x00,
                0x00, 0x00, 0x01, 0xE1, 0xF3, 0x73, 0x77, 0x77, 0x67, 0x03, 0xF3, 0xFF, 0xFF, 0x7F, 0x07, 0x00,
                0x00, 0x0F, 0x1F, 0x3F, 0x3F, 0x3C, 0x38, 0x30, 0x38, 0x18, 0x08, 0x04, 0x3E, 0x3F, 0x3F, 0x3F,
                0x07, 0x00, 0x00, 0x00, 0x1F, 0x3F, 0x3F, 0x3F, 0x38, 0x38, 0x1C, 0x0F, 0x3F, 0x3F, 0x3F, 0x3F,
                0x38, 0x18, 0x0C, 0x0F, 0x1F, 0x3F, 0x3F, 0x3C, 0x38, 0x38, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x07, 0x07, 0x0C, 0x0C, 0x0C, 0x0C, 0x0F, 0x07, 0x03, 0x01, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
                0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
            };
            ssd1306.ClearScreen();
            ssd1306.GotoXY(0, 3);
            ssd1306.DrawImage(logo);

            ((IDisposable)driver).Dispose();
        }