olikraus:
This is true for AVR architectures only:
u8g2.drawXBM() --> The bitmap must be in SRAM area, the declaration does not require the U8X8_PROGMEM attribute.
u8g2.drawXBMP() --> The bitmap must be in Flash ROM area, the declaration requires the U8X8_PROGMEM attribute.
Oliver
Ahh, okay, the reference manual said
Note: The XBMP version requires, that the bitmap array is defined in this way:
static const unsigned char u8g_logo_bits[] U8X8_PROGMEM = { ...
And then, comparably, the tutorial just said to change
static unsigned char bitmap_bits[]
to
static const unsigned char bitmap_bits[] PROGMEM
But Id just forgotten to ask for more information on that as well, so thank you for clarifying! Now I see what you mean. Ive also made a few additional changes i saw later on in the tutorial, which answered my question about setup and loop as well. My updated code looks like this (but I have not yet replaced the delay with mills, or put the bitmap in a separate tab as im still not sure which parts to use to do so (or is it just the things before setup?) Anyway, my updated code is here:
#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_SSD1306_128X64_NONAME_F_HW_I2C u8g2(U8G2_R0, /* reset=*/ U8X8_PIN_NONE);
const long screenInterval = 1000; // interval at which to buffer (milliseconds)
unsigned long sensorInterval;
unsigned long previousMillis;
// Copy the contents of your .xbm file below
#define eyesstraight_width 65
#define eyesstraight_height 64
static unsigned char eyesstraight_bits[] PROGMEM = {
0x6f, 0xff, 0x00, 0x00, 0x00, 0x00, 0xb6, 0x7f, 0x01, 0x5f, 0xff, 0x00,
0x00, 0x00, 0x00, 0xae, 0x7f, 0x01, 0xb7, 0x7f, 0x00, 0x00, 0x00, 0x00,
0xb6, 0xff, 0x00, 0xaf, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x6e, 0xbf, 0x01,
0xb7, 0x7f, 0x00, 0x00, 0x00, 0x00, 0xaa, 0x7f, 0x01, 0xfe, 0xed, 0x00,
0x00, 0x00, 0x00, 0xfe, 0xed, 0x01, 0xfd, 0xdb, 0x00, 0x00, 0x00, 0x00,
0xfe, 0xdb, 0x01, 0xfb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xea, 0x01,
0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xd6, 0x01, 0xfd, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xfa, 0x01, 0xfa, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xea, 0x01, 0xf7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x01,
0xaf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x01, 0xaf, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7e, 0x01, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x7e, 0x01, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xae, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x6f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xde, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0xbf, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6e, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xd7, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xfc, 0xdb, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xea, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0xdb, 0x01, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xfe, 0xed, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xfc, 0xdb, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb, 0xd5, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x57, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0xdf, 0x7f, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x57, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xde, 0x7f, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0xff, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x4b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x01, 0xdf, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x7e, 0x01, 0xb7, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xfe, 0x00, 0xaf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xbe, 0x01,
0xb7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7e, 0x01, 0xfe, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xea, 0x01, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xd6, 0x01, 0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfa, 0x01,
0xfd, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0xd6, 0x01, 0xfd, 0xff, 0x00,
0x00, 0x00, 0x00, 0xfe, 0xf5, 0x01, 0xfb, 0xeb, 0x00, 0x00, 0x00, 0x00,
0xfe, 0xeb, 0x01, 0x6f, 0xff, 0x00, 0x00, 0x00, 0x00, 0x76, 0x7f, 0x01,
0xdf, 0x7e, 0x00, 0x00, 0x00, 0x00, 0xae, 0xbf, 0x01, 0xaf, 0xff, 0x00,
0x00, 0x00, 0x00, 0xaa, 0x7f, 0x01, 0xb7, 0x7e, 0x00, 0x00, 0x00, 0x00,
0xde, 0x7f, 0x01, 0xaf, 0xff, 0x00, 0x00, 0x00, 0x00, 0x56, 0x7f, 0x01 };
void draw(void) {
// graphic commands to redraw the complete screen should be placed here
u8g2.drawXBM( 0, 0, eyesstraight_width, eyesstraight_height, eyesstraight_bits);
}
void setup(void) {
u8g2.begin();
}
void loop(void) {
// picture loop
u8g2.firstPage();
do {
draw();
} while( u8g2.nextPage() );
// rebuild the picture after some delay
delay(1000);
}