Go Down

Topic: Display Oled 20x04  (Read 343 times) previous topic - next topic

tix88

Hello everyone, I bought a 20x4 oled display, but I can not display more than two lines, I downloaded the library for 16x2 and with this I managed to see something, I then found a specific library for my type of display but it is not working because I believe there are problems with extensions, could someone help me? I attach the links of the libraries on git hub:

Lib 16x02 : https://github.com/gadjet/1602-OLED-Arduino-Library
Lib 20x04 : https://github.com/jafrado/2004_i2c_oled

Thanks so much

PaulS

Quote
but it is not working because I believe there are problems with extensions
Why do you believe this? What extensions?
The art of getting good answers lies in asking good questions.

tix88

I can not find .cpp files and .h files

tix88

With this sketch I can visualize the 4 lines
Code: [Select]
[code]
//***************************************//
// --- WIDE.HK---//
// --- Revised Date : 02/05/2014
// --- I2C Arduino - Arduino UNO Demo ---//
// --- SSD131x PMOLED Controller      ---//
// --- SCL, SDA, GND, VCC(3.3v -5v)   ---//
//***************************************//

#include <Wire.h>          // *** I2C Mode
#define OLED_Address 0x3c
#define OLED_Command_Mode 0x80
#define OLED_Data_Mode 0x40

void setup()
{
  Wire.begin();
}

void loop()
{
int i;
// *** I2C initial *** //
delay(100);
sendCommand(0x80);
sendCommand(0x2A);  // **** Set "RE"=1  00101010B
sendCommand(0x71);
sendCommand(0xC0);
sendCommand(0x00);
sendCommand(0x28);

sendCommand(0x08);  // **** Set Sleep Mode On
sendCommand(0x2A);  // **** Set "RE"=1  00101010B
sendCommand(0x79);  // **** Set "SD"=1  01111001B

sendCommand(0xD5);
sendCommand(0x70);
sendCommand(0x78);  // **** Set "SD"=0

//sendCommand(0x08);
sendCommand(0x09);  // **** Set 5-dot, 3 or 4 line(0x09), 1 or 2 line(0x08)


sendCommand(0x06);  // **** Set Com31-->Com0  Seg0-->Seg99
sendCommand(0x72);
  sendCommand(0xC0);
   sendCommand(0x01);
// **** Set OLED Characterization *** //
sendCommand(0x2A);    // **** Set "RE"=1
sendCommand(0x79);    // **** Set "SD"=1

// **** CGROM/CGRAM Management *** //
// sendCommand(0x72);   // **** Set ROM
// sendCommand(0x00);   // **** Set ROM A and 8 CGRAM

sendCommand(0xDC);    // **** Set ROM
sendCommand(0x00);    // **** Set ROM A and 8 CGRAM

sendCommand(0xDA);  // **** Set Seg Pins HW Config
sendCommand(0x10);   

sendCommand(0x81);    // **** Set Contrast
sendCommand(0xD9);    //
  sendCommand(0x8F);    // **** Set Contrast

sendCommand(0xF1);

sendCommand(0xDB);    // **** Set VCOM deselect level
sendCommand(0x30);    // **** VCC x 0.83

sendCommand(0xDC);    // **** Set gpio - turn EN for 15V generator on.
sendCommand(0x03);

sendCommand(0x78);    // **** Exiting Set OLED Characterization
sendCommand(0x28);
//sendCommand(0x2A);
//sendCommand(0x05);  // **** Set Entry Mode (invert)
sendCommand(0x06);  // **** Set Entry Mode

sendCommand(0x28);  // **** Set "IS"=0 , "RE" =0 //28
sendCommand(0x01);
sendCommand(0x80);  // **** Set DDRAM Address to 0x80 (line 1 start)

delay(100);
sendCommand(0x0C);    // **** Turn on Display



// ********************************************************************//
// **** Show Data Value *** //

send_string("\0"); send_string("1 English - Term 6<>");   //1 ??line
send_string("\0"); send_string("2 English - Term 7<>");   //2 ??line
send_string("\0"); send_string("3 English - Term 8<>");   //3 ??line
send_string("\0"); send_string("4 English - Term 9<>");   //4 ??line

/*
sendCommand(0x2C); //2 in 1 line

*/
   
while(1);

// **** Show Data Value *** //

}


void sendData(unsigned char data)
{
    Wire.beginTransmission(OLED_Address);   // **** Start I2C
    Wire.write(OLED_Data_Mode);         // **** Set OLED Data mode
    Wire.write(data);
    Wire.endTransmission();                     // **** End I2C
}

void sendCommand(unsigned char command)
{
    Wire.beginTransmission(OLED_Address);    // **** Start I2C
    Wire.write(OLED_Command_Mode);         // **** Set OLED Command mode
    Wire.write(command);
    Wire.endTransmission();                    // **** End I2C
      delay(10);
}

void send_string(const char *String)
{
    unsigned char i=0;
    while(String[i])
    {
        sendData(String[i]);      // *** Show String to OLED
        i++;
    }
}

[/code]

Go Up