OLED 96x96 with ARDUINO DUE

Hello everybody,

I have bought the OLED 96x96 and I want to use it on a DUE board without the groove shield, but after modifying library to make it compile nothing happend on the screen.

Is there a way to make it work ?

Tank you for you time

Hi,jeanb0aptiste3

I should remind you that the Arduino Due is a microcontroller board based on the Atmel SAM3X8E ARM Cortex-M3 CPU (datasheet) which is different than other Arduino boards based on the AVR microcontrollers. When Uploading sketches to the Arduino Due, the flash memory needs to be erased before being re-programmed and the Arduino Due board runs at 3.3V. Do you pay attention to it?

I want to know if it is ok when control other modules on the DUE board and how do you change the library files?

Hi zhangkun,

I paid attention to the flash memory reset, but the most important problem is the 3.3v of the board. I have found recently that the I2C port of the DUE doesn’t delivery 5v and the OLED 96x96 doesn’t have a TTL system so, I think the 3.3v of the DUE I2C is not recognize as a logical level by the screen.

So I found two or three things on the web :
http://playground.arduino.cc/Main/I2CBi-directionalLevelShifter about level shifter

For the library it seems that the <avr/pgmspace.h> library is not available for the DUE because the board store automaticly the const in flash memory (I’m not sure of that I found it on a Forum).

And by removing #include <avr/pgmspace.h> you need to make some little change in the code :

const unsigned char BasicFont[][8] PROGMEM= { to const unsigned char BasicFont[][8] = {

and [code]void SeeedGrayOLED::putChar(unsigned char C)
{
if(C < 32 || C > 127) //Ignore non-printable ASCII characters. This can be modified for multilingual font.
{
C=’ '; //Space
}

for(char i=0;i<8;i=i+2)
{
    for(char j=0;j<8;j++)
    {
        // Character is constructed two pixel at a time using vertical mode from the default 8x8 font
        char c=0x00;
        char bit1=(pgm_read_byte(&BasicFont[C-32][i]) >> j)  & 0x01;  
        char bit2=(pgm_read_byte(&BasicFont[C-32][i+1]) >> j) & 0x01;
       // Each bit is changed to a nibble
        c|=(bit1)?grayH:0x00;
        c|=(bit2)?grayL:0x00;
        sendData(c);
    }
}

}[/code]
to

[code]void SeeedGrayOLED::putChar(unsigned char C)
{
if(C < 32 || C > 127) //Ignore non-printable ASCII characters. This can be modified for multilingual font.
{
C=’ '; //Space
}

for(char i=0;i<8;i=i+2)
{
    for(char j=0;j<8;j++)
    {
        // Character is constructed two pixel at a time using vertical mode from the default 8x8 font
        char c=0x00;
        char bit1=(BasicFont[C-32][i] >> j)  & 0x01;  
        char bit2=(BasicFont[C-32][i+1] >> j) & 0x01;
       // Each bit is changed to a nibble
        c|=(bit1)?grayH:0x00;
        c|=(bit2)?grayL:0x00;
        sendData(c);
    }
}

}[/code]

and finally [code]void SeeedGrayOLED::drawBitmap(unsigned char *bitmaparray,int bytes)
{
char localAddressMode = addressingMode;
if(addressingMode != HORIZONTAL_MODE)
{
//Bitmap is drawn in horizontal mode
setHorizontalMode();
}

for(int i=0;i<bytes;i++)
{

for(int j=0;j<8;j=j+2) 
{
    char c=0x00;
    char bit1=pgm_read_byte(&bitmaparray[i]) << j  & 0x80;  
    char bit2=pgm_read_byte(&bitmaparray[i]) << (j+1) & 0x80;

    // Each bit is changed to a nibble
    c|=(bit1)?grayH:0x00;
    // Each bit is changed to a nibble
    c|=(bit2)?grayL:0x00;
    sendData(c);
 }
}
if(localAddressMode == VERTICAL_MODE)
{
    //If Vertical Mode was used earlier, restore it.
    setVerticalMode();
}

}[/code]
to [code]void SeeedGrayOLED::drawBitmap(unsigned char *bitmaparray,int bytes)
{
char localAddressMode = addressingMode;
if(addressingMode != HORIZONTAL_MODE)
{
//Bitmap is drawn in horizontal mode
setHorizontalMode();
}

for(int i=0;i<bytes;i++)
{

for(int j=0;j<8;j=j+2) 
{
    char c=0x00;
    char bit1=bitmaparray[i] << j  & 0x80;  
    char bit2=bitmaparray[i] << (j+1) & 0x80;

    // Each bit is changed to a nibble
    c|=(bit1)?grayH:0x00;
    // Each bit is changed to a nibble
    c|=(bit2)?grayL:0x00;
    sendData(c);
 }
}
if(localAddressMode == VERTICAL_MODE)
{
    //If Vertical Mode was used earlier, restore it.
    setVerticalMode();
}

}[/code]

Because of the logical level problem I can’t test the change until I order all the component needed to create a level shifter but the library compile find on a Due board.

I wish to compliment Jimbo We and Frankie Chu for the well designed Serial LCD board, and all the ones involved in the creation of the libraries and the examples without that wealth of information it would have been impossible to get it working*