nopnop2002 / esp-idf-ssd1306

SSD1306/SH1106 Driver for esp-idf
MIT License
264 stars 74 forks source link

Request: provide API to draw XBM bitmap from monochrome buffer with given height/width #18

Closed ghost closed 2 years ago

ghost commented 2 years ago

The API should be a functional equivalent to:

https://github.com/olikraus/u8g2/wiki/u8g2reference#drawxbm=

Description: Draw a XBM Bitmap. Position (x,y) is the upper left corner of the bitmap. XBM contains monochrome, 1-bit bitmaps. The current color index is used for drawing (see setColorIndex) pixel values 1. Version 2.15.x of U8g2 introduces a solid and a transparent mode for bitmaps. By default, drawXBM will draw solid bitmaps. This differs from the previous versions: Use setBitmapMode(1) to switch to the previous behavior. The XBMP version of this procedure expects the bitmap to be in PROGMEM area (AVR only). Many tools (including GIMP) can save a bitmap as XBM. A nice step by step instruction is here (external link). The result will look like this:

#define u8g_logo_width 38
#define u8g_logo_height 24
static unsigned char u8g_logo_bits[] = {
   0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xe0, 0xe0,
...
   0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0x3f };
ghost commented 2 years ago

The abstraction example can be found here: https://github.com/olikraus/u8g2/blob/adb13305ffa963ca04d68f4444201ab0ba56f905/sys/utf8/xbm_picture_loop/main.c

nopnop2002 commented 2 years ago

The API should be a functional equivalent to:

I don't think so.

ghost commented 2 years ago

If you can't or don't want to put the time into writing it, that is fine and entirely up to you, I don't have the time to write it myself right now.

nopnop2002 commented 2 years ago

There are two ways to control the ssd1306.

  1. Output in page units. It does not require internal memory and operates at high speed.

  2. Redraw the entire TFT 8 pages * 128 segment internal memory is required. And you need a flash function like utf8_show (). Nothing is displayed unless utf8_show () is done. Even when changing one character on the TFT, the entire drawing is performed.

A second method is needed to draw at Position (x, y).

Because SSD1306 can only operate pages.

SSD1306 has the concept of X position(=segment position), but not the concept of Y position.

Use the page number instead of the Y position.

ghost commented 2 years ago

Trying to find the source of the API, but this example is more accurate than the one I posted before: https://github.com/olikraus/u8g2/blob/master/sys/arduino/u8g2_page_buffer/XBM/XBM.ino

A function that is dependent on one single width seems a bit limited to me.

nopnop2002 commented 2 years ago

I found that XBM bitmap format is very usefull.

This page is very useful. https://www.mischianti.org/2021/07/14/ssd1306-oled-display-draw-images-splash-and-animations-2/

ghost commented 2 years ago

Excellent! Your repositories are a blessing, is there a way I can send you coffee/beer/bento money?

nopnop2002 commented 2 years ago

is there a way I can send you coffee/beer/bento money?

No, thanks.

I was able to gain knowledge of XBM bitmaps.