Hello everybody,
I could need some help to convert a bitmap picture to a working HEX code for the u8g2 library. I know how to do it, but it´s just not working.
I used a LCD Immage Converter to generate the code. If I up load the "immage code" to my Arduino, it´s just not displaying right. All I get to see is a square of random pixles. I just can´t find anything in the internet that works for me.
If I copy a HEX code of a bitmap from another example scatch, this is working, but if I try to make my own by using a converter, they don´t and I don´t know why !
I just did the same like some youtuber, nothing ! Didn´t work.
Is there anybody who can help me ? What do I do wrong ?
Here is my code.
The "batt" bmp doesn´t work, the "cross_bits" bmp works.
the "batt" is the one that I created by using a converter, I tryed different converters but same result !??
#include <Arduino.h>
#include <U8g2lib.h>
#ifdef U8X8_HAVE_HW_SPI
#include <SPI.h>
#endif
#ifdef U8X8_HAVE_HW_I2C
#include <Wire.h>
#endif
U8G2_SH1106_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
#define cross_width 50
#define cross_height 20
const unsigned char batt[] {
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f,
0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f,
0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f,
0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f,
0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f,
0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f,
0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f,
0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f,
0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f,
0x00, 0xff, 0xff, 0xff, 0xff, 0xf8, 0x3f,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f,
};
#define cross_width 24
#define cross_height 24
static const unsigned char cross_bits[] U8X8_PROGMEM = {
0x00, 0x18, 0x00, 0x00, 0x24, 0x00, 0x00, 0x24, 0x00, 0x00, 0x42, 0x00,
0x00, 0x42, 0x00, 0x00, 0x42, 0x00, 0x00, 0x81, 0x00, 0x00, 0x81, 0x00,
0xC0, 0x00, 0x03, 0x38, 0x3C, 0x1C, 0x06, 0x42, 0x60, 0x01, 0x42, 0x80,
0x01, 0x42, 0x80, 0x06, 0x42, 0x60, 0x38, 0x3C, 0x1C, 0xC0, 0x00, 0x03,
0x00, 0x81, 0x00, 0x00, 0x81, 0x00, 0x00, 0x42, 0x00, 0x00, 0x42, 0x00,
0x00, 0x42, 0x00, 0x00, 0x24, 0x00, 0x00, 0x24, 0x00, 0x00, 0x18, 0x00, };
void setup(void) {
u8g2.begin();
}
void loop(void) {
u8g2.clearBuffer(); // clear the internal memory
u8g2.setFont(u8g2_font_ncenB08_tr); // choose a suitable font
// u8g2.drawStr(20,30,"Hello World!"); // write something to the internal memory
u8g2.drawXBMP(30, 20, 50, 20, batt); // Draw Bitmap (lins/rechts, hoch/runter, width, hight, picture)
u8g2.sendBuffer(); // transfer internal memory to the display
}