sparkfun / SparkFun_Qwiic_OLED_Arduino_Library

Arduino Library for SparkFun's OLED Qwiic (I²C) boards
https://docs.sparkfun.com/SparkFun_Qwiic_OLED_Arduino_Library/introduction/
Other
9 stars 7 forks source link

Bitmaps of certain heights don't draw correctly at non-zero y values #17

Closed mikelowe983 closed 6 months ago

mikelowe983 commented 6 months ago

When using bitmaps of certain sizes, the oled.bitmap function will not draw the bitmap correctly.

See the below example bitmap:

/*
    SQ_Symbol [8, 9]

             12345678
            .--------.
        0x01|********|
        0x02|*      *|
        0x04|*      *|
        0x08|*      *|
        0x10|*      *|
        0x20|*      *|
        0x40|*      *|
        0x80|*      *|
        0x01|********|   
            '--------'
*/

const int SQ_Symbol_Height = 9;
const int SQ_Symbol_Width = 8;
const uint8_t SQ_Symbol[] = {0xFF, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0xFF, 
0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01};

Calling oled.bitmap with a 0 for the y0 argument draws the bitmap as expected:

    oled.bitmap(0, 0, (uint8_t *)SQ_Symbol, SQ_Symbol_Width, SQ_Symbol_Height);

output:

********
*      *   
*      *
*      *
*      *
*      *
*      *
*      *
********

However, if I pass a non-zero value for y0, the bitmap does not draw correctly:

    oled.bitmap(0, 1, (uint8_t *)SQ_Symbol, SQ_Symbol_Width, SQ_Symbol_Height);

output:

********
*      *   
*      *
*      *
*      *
*      *
*      *
*      *

The bottom row is not drawn. This also occurs for bitmaps that have heights of 10, 11, 12, etc.

gigapod commented 6 months ago

Hi @mikelowe983 -

Quick question - which OLED screen where you using for your tests? I greb one of these when I take a look at this.

The bitmap code is very efficent, but a little complicated and I'll have to re-grok how I implemented it. I'll try to take a look at this in the next week.

-Kirk

mikelowe983 commented 6 months ago

Thanks @gigapod!

I am using this screen for my testing: https://www.digikey.com/en/products/detail/midas-displays/MCOT064048A1V-BM/18088018

It seems to be the same or very similar to the screen used in this breakout board: https://www.sparkfun.com/products/22495

I attempted to trace through the code within the QwGrSSD1306::drawBitmap function, but as you said, it was a bit tough to grok. I'll continue looking at it myself.

Let me know if there is anything I can do to help.

mikelowe983 commented 6 months ago

@gigapod I think I've isolated the issue. I've opened a PR which should resolve it here: #18

I read the contributing guidelines, which mentioned targeting the release_candidate branch, but I did not see one in this repo, so I targeted main instead.

Let me know if you have any feedback on the PR format, or code changes, let me know. Additionally, please test the changes yourself. I ran through some tests on my own, but it would be great to have your eyes on it as well.

Thanks!

gigapod commented 6 months ago

Thaks for finding this @mikelowe983 . I'll get a release updated so the Arduino library bot picks this up.