4

I am trying to use OLED display in a dspic33f microchip. I've successfully initialized and sent data using I2C to OLED. I managed to display a small font(8pt) on the OLED. However, when I tried a bigger font, part of the font is being obstructed(can't show the whole part of that font).

The code is as the following.

static unsigned char buffer[1024 ] = {      
    // @18 '2' (5 pixels wide)         //generated by using The Dot Factory
    0xC0, 0x80, // ##      #
    0xA0, 0x80, // # #     #
    0x90, 0x80, // #  #    #
    0x8D, 0x80, // #   ## ##
    0x87, 0x00, // #    ###  

    // @9 '2' (4 pixels wide)
    0x00,
    0xC1, // ##     #
    0xA1, // # #    #
    0x91, // #  #   #
    0x8E, // #   ### 
    0x00
};

void Oled_init(void){   
    command(0xAE);  //display off
    command(0xD5);  //display clk div
    command(0x80);  //ratio -- continuation of clk_div
    command(0xA8);  //mux ratio
    command(0x3F);
    command(0xD3);  //display offset
    command(0x0);   //no offset- continuation of display_offset
    command(0x40 | 0x00);   //display starting line
    command(0x8D);  //charge pump
    command(0x14);  //internal vcc          
    command(0x20);  //memory mode
    command(0x00);      
    command(0xA1);  //remap columns
    command(0xC8);  //remap rows
    command(0xDA);  //com pins
    command(0x12);  
    command(0x81);  //set contrast
    command(0xCF);              
    command(0xDB);  //set Vcomh
    command(0x40);              
    command(0xD9);  //pre charge
    command(0xF1);          
    command(0xA4);  //entire display on
    command(0xA6);  //normal display 
    command(0x2E);
    command(0xAF);  //display on    
}

void display (void){
    command(0x21);  //column start address
    command(0);
    command(0x7F);

    command(0x22);  //set page address
    command(0x00);  //min
    command(0x07);  //max   //128x64resolution

    unsigned int i = 0;
    unsigned char x = 0;

    for(i = 0; i < 1023; i++){
      OpenI2C2(I2CConfig2, I2C2_BRG);
      IdleI2C2 ();
      StartI2C2 ();
      while(I2C2CONbits.SEN);
      MasterWriteI2C2(0x78);  
      MasterWriteI2C2(0x40);      //Co = 0, D/C = 1, last 6 bit = 0

      for (x = 0; x < 16; x++){   
         MasterWriteI2C2(buffer[i]);
         i++;
       }           
         i--;

      StopI2C2 ();
      while(I2C2CONbits.PEN);
      CloseI2C2();        
   } 
}

Number "2" with 5 pixels wide

Number "2" with 4 pixels wide

This problem has been troubling me since the last few weeks and I still couldn't find any solution to it. Thanks for any solution in advance.

Niteesh Shanbog
  • 711
  • 7
  • 21
Allure
  • 41
  • 1
  • 1
    Is it working with pixel coordinates or character coordinates? Looks like pixel. Just shift them down. – Eugene Sh. Jul 28 '16 at 14:33
  • 1
    Wait.. I think I've misunderstood how it is supposed to work.. – Eugene Sh. Jul 28 '16 at 14:43
  • what does it mean by shift them down? do you mean adding 0x00 in front of the buffer? Eg, static unsigned buffer = { 0x00,0x00,0x00,0x00,...., 0xC0,0x80,0xA0, 0x80,0x90, 0x80, 0x8D, 0x80,0x87, 0x00} – Allure Jul 28 '16 at 14:44
  • Can you show the code for the small font? I think the issue is with this `16` in the inner loop. – Eugene Sh. Jul 28 '16 at 15:02
  • oh... the code for small font is already in the snippet of code. In the static unsigned buffer, there is a 4 pixels wide data which is {0x00, 0xC1, 0xA1, 0x91,0x8E, 0x00} and how i did was to call the display function right after oled init in the main program. – Allure Jul 28 '16 at 15:06
  • But you have two images. Which one is produced by the presented code? Anyway show the other one as well – Eugene Sh. Jul 28 '16 at 15:08
  • oh.. sorry for the confusion.. actually both are produced by the same code. just that i commented the second part of the buffer when capturing the first image and vice versa. I should've presented both all together – Allure Jul 28 '16 at 15:13
  • I *think* this `16` in the inner loop should be replaced by `64/`... – Eugene Sh. Jul 28 '16 at 15:19

0 Answers0