КОРЗИНА
магазина
8 (499) 500-14-56 | ПН. - ПТ. 12:00-18:00
ЛЕСНОРЯДСКИЙ ПЕРЕУЛОК, 18С2, БЦ "ДМ-ПРЕСС"

Выводим изображение на Wemos ESP32 OLED

Общие сведения:

В этой статье рассматривается способ вывода на OLED дисплей встроенный в плату Wemos ESP32 OLED

Для того, чтобы добавить поддержку плат ESP32 в Arduino IDE, достаточно выполнить несколько простых шагов, описанных в инструкции.

Подключение

OLED дисплей подключен к шине I2C:

Вывдо дисплея Вывод ESP32
вывод SDA 5
вывод SCL 4

Подключите Wemos ESP32 OLED к ПК

Установите поддержку ESP32, если Вы не знаете как это сделать, воспользуйтесь нашей статьёй - Wiki - Установка ESP32 в Arduino IDE (руководство для ОС Windows)

В меню Arduino IDE Инструменны->Плата: выберете Wemos LOLIN32

Сектч

Для работы данного скетча необходимо установить библиотеки Adafruit GFX и Adafruit 1306. Об установке библиотек можно узнать из нашей Wiki - Установка библиотек в Arduino IDE.

Массив графики можно конвертировать из .bmp файла на сайте http://dot2pic.com/

// Подключаем библиотеки
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

// Определяем размеры матрицы
#define WIDTH 128
#define HEIGHT 64

// Определяем выводы к которым подключена OLED матрица
const uint8_t disp_SDA = 5;
const uint8_t disp_SCL = 4;

// Создаём объект дисплея
Adafruit_SSD1306 display(WIDTH, HEIGHT, &Wire, -1);

// Создаём массив для вывода графики
static const uint8_t image_data_Saraarray[1024] = {
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xe0,0x00,0x00,0x00,0x00,0xf9,0xe3,0xc1,0xe0,0xe3,0x11,0x1c,0xe1,0xfc,0x1e,0x63,
    0xc0,0x00,0x00,0x00,0x00,0x78,0xc1,0xc0,0x40,0x63,0x11,0x0c,0xc0,0xfc,0x04,0x63,
    0xc0,0x00,0x3f,0x80,0x00,0x78,0xc1,0xc0,0x40,0x23,0x11,0x0c,0x80,0x7c,0x04,0x63,
    0xc0,0x00,0x3f,0x80,0x00,0x78,0xc1,0xc4,0x46,0x23,0x11,0x0c,0x8c,0x7c,0x44,0x63,
    0xc0,0x00,0x20,0x80,0x00,0x78,0xc1,0xc4,0x46,0x23,0x11,0x04,0x8c,0x7c,0x64,0x63,
    0xc0,0x00,0x20,0x80,0x00,0x78,0xc0,0xc4,0x46,0x23,0x11,0x04,0x8c,0x7c,0x64,0x63,
    0xc1,0xff,0xe0,0xff,0xf0,0x78,0xc8,0xc4,0x46,0x23,0x11,0x00,0x8c,0x7c,0x44,0x63,
    0xc1,0xff,0xff,0xff,0xf0,0x78,0x88,0xc0,0x46,0x23,0x11,0x00,0x8c,0x7c,0x04,0x63,
    0xc1,0xff,0xff,0xff,0xf0,0x78,0x88,0xc0,0xc6,0x23,0x11,0x00,0x8c,0x7c,0x04,0x63,
    0xc1,0xff,0xff,0xff,0xf0,0x78,0x88,0xc0,0x46,0x23,0x11,0x00,0x8c,0x7c,0x04,0x63,
    0xc1,0xff,0xff,0xff,0xf0,0x78,0x88,0xc4,0x46,0x23,0x11,0x10,0x8c,0x7c,0x44,0x63,
    0xc1,0xff,0xff,0xff,0xf0,0x78,0x80,0xc4,0x46,0x23,0x11,0x10,0x8c,0x7c,0x60,0x63,
    0xff,0xff,0xff,0xff,0xff,0xf8,0x80,0x44,0x46,0x23,0x11,0x10,0x8c,0x7c,0x60,0x63,
    0xff,0xff,0xff,0xff,0xff,0xf8,0x1c,0x44,0x40,0x20,0x11,0x18,0x80,0x4c,0x62,0x03,
    0xe3,0xff,0xff,0xff,0xf0,0xf8,0x1c,0x44,0x40,0x30,0x31,0x18,0xc0,0xc4,0x62,0x07,
    0xc1,0xff,0xff,0xff,0xf0,0x79,0x1c,0x4e,0x60,0xf8,0x71,0x38,0xe1,0xcc,0xe7,0x0f,
    0xc1,0xff,0xff,0xff,0xf0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xc1,0xff,0xff,0xff,0xf0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xc1,0xff,0xff,0xff,0xf0,0x7f,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xc1,0xff,0xff,0xff,0xf0,0x7f,0xf9,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xe7,
    0xc1,0xc1,0xff,0xf0,0x70,0x78,0x81,0xc4,0x46,0x26,0x28,0x20,0x81,0x40,0x20,0x13,
    0xc0,0x41,0x84,0x30,0x40,0x7a,0x27,0xc4,0x56,0xa6,0xa8,0xa8,0x27,0x4a,0x60,0xd3,
    0xc0,0x61,0x84,0x30,0xc0,0x78,0x33,0xc5,0x46,0xa2,0xa0,0xa8,0x21,0x0a,0x20,0x43,
    0xc0,0x7f,0x84,0x3f,0xc0,0x78,0x33,0x85,0x46,0x22,0xa0,0xa8,0x20,0x0a,0x28,0x43,
    0xc0,0x00,0x04,0x00,0x00,0x7a,0x27,0x85,0x56,0xc2,0xa0,0xa8,0x24,0x0a,0x68,0xcb,
    0xc0,0x00,0x06,0x00,0x00,0x78,0x01,0x81,0x16,0xc8,0x00,0x08,0x80,0x4a,0x08,0x0b,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xb7,0xff,0xfc,0x9f,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,
    0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff
};

void setup() {
    // Инициируем последовательный порт
    Serial.begin(115200);

    // Инициируем I2C к которому подключена матрица
    Wire.begin(disp_SDA, disp_SCL);

    // Инициируем дисплей
    if(!display.begin(SSD1306_SWITCHCAPVCC, 0x3C, false, false)) {
        Serial.println(F("Не удалось инициировать дисплей"));
        for(;;);
    }
    delay(2000);

    // Очищаем дисплей
    display.clearDisplay();

    // выводим массив на дисплей
    display.drawBitmap(0, 0, image_data_Saraarray, 128, 64, 1);
    display.display();
}

void loop() {

}

Ссылки




Обсуждение

Гарантии и возврат Используя сайт Вы соглашаетесь с условями