How to display grayscale bitmaps on SSD1327_128x128

Hi all,
Im unable to display grayscale bitmaps on the SSD1327_128x128 using SPI. Im currently using the U8G2 library (MCU is a ESP32)


Above is an image of what it currently displays.
Here is the current code:

code

#include <Arduino.h>
#include <U8g2lib.h>

#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif

#define cat_width 128
#define cat_height 128
static const unsigned char cat_bits[] PROGMEM = {
0xff, 0xff, 0x27, 0xd3, 0xff, 0xff, 0x7f, 0xd2, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x57, 0xd4, 0xff, 0xff, 0x7f, 0xd5,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xbf, 0x00, 0x80,
0xfe, 0xff, 0x0b, 0x80, 0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,....};
(not entire bitmap array)

U8G2_SSD1327_EA_W128128_F_4W_SW_SPI u8g2(U8G2_R0, /* clock=/ 18, / data=/ 23, / cs=/ 2, / dc=/ 4, / reset=*/ 5);

void setup(void) {
u8g2.begin();
}

void loop(void) {
u8g2.clearBuffer();
u8g2.drawXBMP(0, 0, cat_width, cat_height, cat_bits);
u8g2.sendBuffer();
delay(3000);
}

The code above is using an XBM exported grayscale cat image, but it displays as monochrome.
Is it even possible to display grayscale bitmap using the U8G2 library? If so how could it be done?
The adafruit gfx library seems to support 8-bit grayscale bitmaps even though our display is 4-bit. This is something I've tried with no avail. Monochrome bitmaps work fine and grayscale works on the adafruit GFX library but only with the geometry, not the bitmaps. Any guidance would be greatly appreciated :slight_smile: .

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.