/** \brief Initialization of edOLED Library. Setup IO pins for SPI port then send initialization commands to the SSD1306 controller inside the OLED. */ void edOLED::begin() { // default 5x7 font setFontType(0); setColor(WHITE); setDrawMode(NORM); setCursor(0,0); spiSetup(); RST_PIN.pinWrite(HIGH); //(digitalWrite(rstPin, HIGH); usleep(5000); // VDD (3.3V) goes high at start, lets just chill for 5 ms RST_PIN.pinWrite(LOW); // bring reset low usleep(10000); // wait 10ms RST_PIN.pinWrite(HIGH); //digitalWrite(rstPin, HIGH); // Init sequence for 64x48 OLED module command(DISPLAYOFF); // 0xAE command(SETDISPLAYCLOCKDIV); // 0xD5 command(0x80); // the suggested ratio 0x80 command(SETMULTIPLEX); // 0xA8 command(0x2F); command(SETDISPLAYOFFSET); // 0xD3 command(0x0); // no offset command(SETSTARTLINE | 0x0); // line #0 command(CHARGEPUMP); // enable charge pump command(0x14); command(NORMALDISPLAY); // 0xA6 command(DISPLAYALLONRESUME); // 0xA4 command(SEGREMAP | 0x1); command(COMSCANDEC); command(SETCOMPINS); // 0xDA command(0x12); command(SETCONTRAST); // 0x81 command(0x8F); command(SETPRECHARGE); // 0xd9 command(0xF1); command(SETVCOMDESELECT); // 0xDB command(0x40); command(DISPLAYON); //--turn on oled panel clear(ALL); // Erase hardware memory inside the OLED }
/** \brief SPI data. Setup DC and SS pins, then send data via SPI to SSD1306 controller. */ void edOLED::data(unsigned char c) { DC_PIN.pinWrite(HIGH); // DC HIGH spiTransfer(c); }
/** \brief SPI command. Setup DC and SS pins, then send command via SPI to SSD1306 controller. */ void edOLED::command(unsigned char c) { DC_PIN.pinWrite(LOW); // DC pin LOW spiTransfer(c); }