ESP8266 / Hiletgo 1.3" 128x64 OLED / U8g2 display library : Bitmap

Using drawXBMP (or drawXBM)

Using PlatformIO CLI

src/main.cpp

/*
Bitmap test using u8g2 library

Nodemcuv2

*/

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

U8G2_SH1106_128X64_NONAME_F_SW_I2C display(U8G2_R0,/*clk*/ 4, /*data*/ 5);

static const unsigned char r2d2_35x64[] U8X8_PROGMEM =
//static unsigned char r2d2_35x64[] =
{
   0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff,
   0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff,
   0x07, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0x7f, 0xe0, 0xff, 0x07, 0xff,
   0x1f, 0x88, 0xff, 0x07, 0xff, 0xcf, 0x07, 0xff, 0x07, 0xff, 0x87, 0x03,
   0xfe, 0x07, 0xff, 0x03, 0x03, 0xfa, 0x07, 0xff, 0x01, 0x00, 0xfe, 0x07,
   0xff, 0x01, 0x00, 0xf4, 0x07, 0xff, 0x00, 0x00, 0xf1, 0x07, 0xff, 0x00,
   0x00, 0xe0, 0x07, 0xff, 0x00, 0x00, 0xf0, 0x07, 0xff, 0x00, 0x00, 0xe3,
   0x07, 0x7f, 0x00, 0x00, 0xe0, 0x07, 0xff, 0x08, 0x80, 0xf7, 0x07, 0x7f,
   0x47, 0x00, 0xe0, 0x07, 0xbf, 0x06, 0x05, 0xf0, 0x07, 0xbf, 0x2e, 0x84,
   0xf0, 0x07, 0x1f, 0x8e, 0x0a, 0xe1, 0x07, 0x1f, 0x1e, 0xd0, 0xff, 0x07,
   0x0f, 0x9c, 0x06, 0xf0, 0x07, 0x0f, 0x1c, 0x08, 0xe0, 0x07, 0x0f, 0x9c,
   0xd6, 0xff, 0x07, 0x0f, 0x1c, 0xa8, 0xf8, 0x07, 0x0f, 0x9c, 0xea, 0xf2,
   0x07, 0x0f, 0x1a, 0xd4, 0xf2, 0x07, 0x1f, 0x8c, 0xd4, 0xea, 0x07, 0x1f,
   0x84, 0x84, 0xf8, 0x07, 0x3f, 0x00, 0xe4, 0xf8, 0x07, 0x3f, 0x00, 0x81,
   0xf8, 0x07, 0x3f, 0x44, 0xe4, 0xf8, 0x07, 0x3f, 0x00, 0xc1, 0xf8, 0x07,
   0x3f, 0x80, 0xc4, 0xfe, 0x07, 0x1f, 0x04, 0xa8, 0xff, 0x07, 0x3f, 0x00,
   0xa8, 0xf8, 0x07, 0x3f, 0x00, 0x84, 0xf8, 0x07, 0x3f, 0x00, 0x90, 0xe8,
   0x07, 0x1f, 0x00, 0x90, 0xe8, 0x07, 0x3f, 0x04, 0x84, 0xe2, 0x07, 0xbf,
   0x00, 0x20, 0xfc, 0x07, 0x3f, 0x00, 0x00, 0xe0, 0x07, 0x1f, 0x80, 0x0e,
   0xe8, 0x07, 0x1f, 0x80, 0x0f, 0xf0, 0x07, 0x3f, 0x00, 0x0e, 0x10, 0x07,
   0x1f, 0x00, 0x01, 0x60, 0x07, 0x1f, 0x00, 0x00, 0x00, 0x06, 0x17, 0x30,
   0x00, 0x00, 0x07, 0x17, 0x35, 0x00, 0x00, 0x06, 0x27, 0x2e, 0x00, 0x00,
   0x07, 0x8f, 0x08, 0xf8, 0xeb, 0x07, 0x17, 0x2e, 0xf8, 0xff, 0x07, 0x6f,
   0x0c, 0xfc, 0xff, 0x07, 0x9f, 0xdc, 0xff, 0xff, 0x07, 0x7f, 0xbc, 0xfe,
   0xff, 0x07, 0xff, 0xba, 0xff, 0xff, 0x07, 0xff, 0xed, 0xff, 0xff, 0x07,
   0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0x07, 0xff, 0xff,
   0xff, 0xff, 0x07, 0xff, 0xff, 0xff, 0xff, 0x07 };

void setup() {

  Serial.begin(74880);
  display.begin();

//can do it here or in the loop function
  display.clearBuffer();
//  display.setDrawColor(0);
  display.drawXBMP(0,0,35,64,r2d2_35x64);
  display.sendBuffer();

}

// the loop function runs over and over again forever
void loop() {
  Serial.println("Running...bitmap");
  delay(1000);
}
main.cpp

Setup

Using Linux (Ubuntu 18.04) + PlatformIO CLI (see my setup)

platformio.ini

[env:latest_stable]
framework = arduino
platform = espressif8266
board = nodemcuv2

lib_deps = olikraus/U8g2@^2.32.7

monitor_port = /dev/ttyUSB1
monitor_speed = 74880 ;Xtal on ESP8266 board (ESP-12E) is 26Mhz so 2880 * 26 = 74880

upload_speed = 921600 ; increased upload time from ~17 to ~3 secs.
build_type = debug
platformio.ini

Running on ESP8266

R2D2 on a 1.3" OLED screen

Oh, hello there R2!

For those interested or just starting out:

$ pio run --target upload
Processing latest_stable (framework: arduino; platform: espressif8266; board: nodemcuv2) ------------------------------------------------------------------------------------------ Verbose mode can be enabled via `-v, --verbose` option CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/nodemcuv2.html PLATFORM: Espressif 8266 (3.2.0) > NodeMCU 1.0 (ESP-12E Module) HARDWARE: ESP8266 80MHz, 80KB RAM, 4MB Flash PACKAGES: - framework-arduinoespressif8266 3.30002.0 (3.0.2) - tool-esptool 1.413.0 (4.13) - tool-esptoolpy 1.30000.201119 (3.0.0) - tool-mklittlefs 1.203.210628 (2.3) - tool-mkspiffs 1.200.0 (2.0) - toolchain-xtensa 2.100300.210717 (10.3.0) LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf LDF Modes: Finder ~ chain, Compatibility ~ soft Found 36 compatible libraries Scanning dependencies... Dependency Graph |-- 2.32.7 | |-- 1.0 | |-- 1.0 Building in debug mode Compiling .pio/build/latest_stable/src/main.cpp.o Linking .pio/build/latest_stable/firmware.elf Retrieving maximum program size .pio/build/latest_stable/firmware.elf Checking size .pio/build/latest_stable/firmware.elf Advanced Memory Usage is available via "PlatformIO Home > Project Inspect" RAM: [==== ] 36.9% (used 30208 bytes from 81920 bytes) Flash: [=== ] 26.5% (used 276601 bytes from 1044464 bytes) Building .pio/build/latest_stable/firmware.bin Creating BIN file ".pio/build/latest_stable/firmware.bin" using "/home/scotty/.platformio/packages/framework-arduinoespressif8266/bootloaders/eboot/eboot.elf" and ".pio/build/latest_stable/firmware.elf" Configuring upload protocol... AVAILABLE: espota, esptool CURRENT: upload_protocol = esptool Looking for upload port... Auto-detected: /dev/ttyUSB1 Uploading .pio/build/latest_stable/firmware.bin esptool.py v3.0 Serial port /dev/ttyUSB1 Connecting.... Chip is ESP8266EX Features: WiFi Crystal is 26MHz MAC: 84:0d:8e:8d:45:0e Uploading stub... Running stub... Stub running... Changing baud rate to 921600 Changed. Configuring flash size... Compressed 280752 bytes to 204038... Writing at 0x00000000... (7 %) Writing at 0x00004000... (15 %) Writing at 0x00008000... (23 %) Writing at 0x0000c000... (30 %) Writing at 0x00010000... (38 %) Writing at 0x00014000... (46 %) Writing at 0x00018000... (53 %) Writing at 0x0001c000... (61 %) Writing at 0x00020000... (69 %) Writing at 0x00024000... (76 %) Writing at 0x00028000... (84 %) Writing at 0x0002c000... (92 %) Writing at 0x00030000... (100 %) Wrote 280752 bytes (204038 compressed) at 0x00000000 in 2.7 seconds (effective 834.9 kbit/s)... Hash of data verified. Leaving... Hard resetting via RTS pin... ============================== [SUCCESS] Took 17.56 seconds ==============================