Example #1
0
        private static void WriteData(byte data)
        {
            //set D/C pin 7 high for data
            GPIOCmd.digitalWrite(4, 1);

            WriteByte(data);
        }
Example #2
0
        private static void WriteCommand(byte command)
        {
            //set D/C pin 7 low for command
            GPIOCmd.digitalWrite(4, 0);

            WriteByte(command);
            ShortDelay();
        }
Example #3
0
        private static bool InitDisplay()
        {
            bool result = false;

            //Reset first!!
            GPIOCmd.digitalWrite(17, 0);
            ShortDelay();
            GPIOCmd.digitalWrite(17, 1);   //release reset
            ShortDelay();

            // Init sequence for 128x64 OLED module
            WriteCommand(SSD1306_DISPLAYOFF);                    // 0xAE
            WriteCommand(SSD1306_SETDISPLAYCLOCKDIV);            // 0xD5
            WriteCommand(0x80);                                  // the suggested ratio 0x80
            WriteCommand(SSD1306_SETMULTIPLEX);                  // 0xA8
            WriteCommand(0x3F);
            WriteCommand(SSD1306_SETDISPLAYOFFSET);              // 0xD3
            WriteCommand(0x0);                                   // no offset
            WriteCommand(SSD1306_SETSTARTLINE | 0x0);            // line #0
            WriteCommand(SSD1306_CHARGEPUMP);                    // 0x8D
            WriteCommand(0x14);                                  //I always use the onboard switcher
            WriteCommand(SSD1306_MEMORYMODE);                    // 0x20
            WriteCommand(0x00);                                  // 0x0 act like ks0108
            WriteCommand(SSD1306_SEGREMAP | 0x1);
            WriteCommand(SSD1306_COMSCANDEC);
            WriteCommand(SSD1306_SETCOMPINS);                // 0xDA
            WriteCommand(0x12);
            WriteCommand(SSD1306_SETCONTRAST);               // 0x81
            WriteCommand(0xCF);                              //I always use the onboard switcher
            WriteCommand(SSD1306_SETPRECHARGE);              // 0xd9
            WriteCommand(0xF1);                              //I always use the onboard switcher
            WriteCommand(SSD1306_SETVCOMDETECT);             // 0xDB
            WriteCommand(0x40);
            WriteCommand(SSD1306_DISPLAYALLON_RESUME);       // 0xA4
            WriteCommand(SSD1306_NORMALDISPLAY);             // 0xA6

            //Finally turn on the display
            WriteCommand(SSD1306_DISPLAYON);

            //WriteCommand(SSD1306_DISPLAYALLON);                   //Screen should be white here!!
            return(result);
        }