Ayahuasec / RaspberryPiOLEDMonitor

A simple RaspberryPi monitor using an I2C OLED Screen (SSD1306) and wiringPi lib.
GNU General Public License v3.0
1 stars 1 forks source link

Question: How can I use the larger font in oledfont.h #1

Open IraSch opened 4 years ago

IraSch commented 4 years ago

Hi,

I just downloaded your Oled Monitor example and it worked well on Rpi Zero (one tweak for the Net usage function).

I would like to use your structure to work with the Oled display, and I see that oledfont.h has a larger font. What do I need to do to make use of that font?

Thank you.

Ayahuasec commented 3 years ago

I nearly forget this project :sweat_smile: If you want to use the F8X16 font, some modification in the function 'UpdateBuffer()' will be needed. When using this font, this OLED screen can only display 4 lines with 16 chars in each line. And when updating each string line it need write 2 screen buffer lines. You can try to use this code to replace original 'UpdateBuffer()'.

void UpdateBuffer()
{
    int i,j,k;
    for(i=0;i<8;i++)
    {
        wiringPiI2CWriteReg8(fd,0x00,0xb0+i);
        if(i%2==0) 
        {
            //Upper font part
            for(j=0;j<16;j++)
                for(k=0;k<8;k++)
                    wiringPiI2CWriteReg8(fd,0x40,F8x16[(DisplayBuffer[i/2][j]-0x20)*16+k]);
        }
        else
        {
            //Lower font part
            for(j=0;j<16;j++)
                for(k=0;k<8;k++)
                    wiringPiI2CWriteReg8(fd,0x40,F8x16[(DisplayBuffer[i/2][j]-0x20)*16+k+8]);
        }
    }
}

But I didn't test this code, because my RPi3 is still being used in another project. You may also need to adjust some other code to fit it in, since it can't display as much characters when using F8X16 font compared to F6X8 font.