mirror of
https://github.com/nopnop2002/esp-idf-ssd1306.git
synced 2024-10-03 18:18:47 -04:00
285 lines
16 KiB
C
285 lines
16 KiB
C
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "freertos/FreeRTOS.h"
|
|
#include "freertos/task.h"
|
|
#include "esp_log.h"
|
|
|
|
#include "ssd1306.h"
|
|
#include "font8x8_basic.h"
|
|
|
|
/*
|
|
You have to set this config value with menuconfig
|
|
CONFIG_INTERFACE
|
|
|
|
for i2c
|
|
CONFIG_MODEL
|
|
CONFIG_SDA_GPIO
|
|
CONFIG_SCL_GPIO
|
|
CONFIG_RESET_GPIO
|
|
|
|
for SPI
|
|
CONFIG_CS_GPIO
|
|
CONFIG_DC_GPIO
|
|
CONFIG_RESET_GPIO
|
|
*/
|
|
|
|
#define TAG "SSD1306"
|
|
|
|
// https://www.mischianti.org/2021/07/14/ssd1306-oled-display-draw-images-splash-and-animations-2/
|
|
uint8_t batman[] = {
|
|
0b11111111, 0b11111111, 0b11111111, 0b11111111,
|
|
0b11111111, 0b10011111, 0b11111001, 0b11111111,
|
|
0b11111110, 0b00111110, 0b01111100, 0b01111111,
|
|
0b11111000, 0b00111100, 0b00111100, 0b00011111,
|
|
0b11110000, 0b00011100, 0b00111000, 0b00001111,
|
|
0b11110000, 0b00000000, 0b00000000, 0b00001111,
|
|
0b11100000, 0b00000000, 0b00000000, 0b00000111,
|
|
0b11100000, 0b00000000, 0b00000000, 0b00000111,
|
|
0b11110000, 0b00000000, 0b00000000, 0b00001111,
|
|
0b11110000, 0b11000100, 0b00100011, 0b00001111,
|
|
0b11111001, 0b11111110, 0b01111111, 0b10011111,
|
|
0b11111100, 0b11111110, 0b01111111, 0b00111111,
|
|
0b11111111, 0b11111111, 0b11111111, 0b11111111
|
|
};
|
|
|
|
// https://www.mischianti.org/2021/07/14/ssd1306-oled-display-draw-images-splash-and-animations-2/
|
|
uint8_t logoMischianti [1024] = {
|
|
// 'logoBN128x64, 128x64px
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf3, 0xcf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xff, 0xff, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0xff, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x7f, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe7, 0xc0, 0x7f, 0xe7, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xe0, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x01, 0xf8, 0x0f, 0xff, 0xff, 0xf0, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x03, 0xff, 0xff, 0xc0, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0xff, 0xff, 0x00, 0x41, 0xe0, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0xe0, 0xf0, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x07, 0xe0, 0x00, 0xe0, 0x38, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x1c, 0x7f, 0xf0, 0x03, 0xe0, 0x00, 0xe0, 0x38, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x1c, 0x7f, 0xf0, 0x03, 0xc0, 0x1f, 0xff, 0x38, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x1c, 0x7f, 0xf0, 0x03, 0xe0, 0x1f, 0xff, 0x38, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x07, 0xe0, 0x00, 0x60, 0x38, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0xe0, 0x70, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x7c, 0x3e, 0x00, 0xe0, 0xf0, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0xf8, 0x1f, 0x00, 0x61, 0xe0, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x03, 0xe0, 0x07, 0xc0, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x01, 0xf8, 0x0f, 0xc0, 0x03, 0xf0, 0x1f, 0x80, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3f, 0xff, 0xff, 0xfc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xff, 0xff, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xff, 0xff, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x07, 0xff, 0xff, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0xf0, 0x0f, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfc, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x80, 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, 0x10, 0x00, 0x08, 0x10, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x46, 0x63, 0x31, 0x90, 0xff, 0x13, 0xc3, 0x8b, 0x91, 0xe5, 0xdc, 0x80, 0xf3, 0xbf, 0x00,
|
|
0x00, 0x66, 0x73, 0x39, 0x90, 0xcd, 0x92, 0x24, 0x4c, 0x92, 0x26, 0x48, 0x81, 0x13, 0x27, 0x00,
|
|
0x00, 0x2e, 0x57, 0x2b, 0x90, 0x88, 0x93, 0x04, 0x08, 0xd0, 0x24, 0x68, 0x81, 0x1a, 0x23, 0x00,
|
|
0x00, 0x2a, 0xd5, 0x6a, 0xb0, 0x88, 0x91, 0xcc, 0x08, 0xd3, 0xe4, 0x68, 0x83, 0x1a, 0x63, 0x00,
|
|
0x00, 0x2b, 0x95, 0xca, 0xe0, 0x88, 0x90, 0x64, 0x08, 0xd2, 0x24, 0x68, 0x81, 0x1a, 0x63, 0x00,
|
|
0x00, 0x39, 0x9c, 0xce, 0x60, 0x88, 0x96, 0x24, 0x48, 0xd6, 0x64, 0x68, 0x81, 0x12, 0x27, 0x00,
|
|
0x00, 0x11, 0x88, 0xc4, 0x6c, 0x88, 0x93, 0xc3, 0x88, 0xd3, 0xb4, 0x6e, 0x98, 0xf2, 0x3f, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x22, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00
|
|
};
|
|
|
|
// https://iitestudent.blogspot.com/2013/01/displaying-bitmap-on-graphic-lcd.html
|
|
uint8_t fleischer [1024] = {
|
|
// 'fleischer_420', 128x64px
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xff, 0x80, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xfc, 0x3f, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xf8, 0xff, 0xf8, 0x1f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xf9, 0xff, 0xfc, 0x00, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xf3, 0xff, 0xff, 0xff, 0x87, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xf3, 0xff, 0xff, 0xff, 0xe3, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xf3, 0xff, 0xff, 0xff, 0xf9, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xf3, 0xff, 0xff, 0xff, 0xfc, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xfb, 0x80, 0xff, 0xff, 0xfe, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xfc, 0x00, 0x07, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xf8, 0xff, 0xc0, 0xff, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xf3, 0xff, 0xf8, 0x3f, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xe7, 0xff, 0xff, 0x1f, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xef, 0xff, 0xff, 0x87, 0xff, 0xbf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xcf, 0xff, 0xff, 0xe3, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0x9f, 0xff, 0xff, 0xf3, 0xff, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0x9f, 0xff, 0xff, 0xfb, 0xfe, 0x7f, 0xfe, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0xbf, 0xff, 0xff, 0xff, 0x7c, 0xff, 0xf8, 0x01, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xff, 0x3f, 0xff, 0xf9, 0xff, 0xf9, 0xff, 0x03, 0xe0, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xfe, 0x77, 0xff, 0xfe, 0xfe, 0xc3, 0xfe, 0x7b, 0xf7, 0x3f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xfc, 0xff, 0xff, 0xfe, 0xfe, 0x6f, 0xc0, 0xff, 0xff, 0x9f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
|
|
0xf9, 0xdf, 0xff, 0xfc, 0xfe, 0x6f, 0x8e, 0x7f, 0xff, 0xcf, 0xff, 0x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 0x00, 0x01, 0xcf, 0xce, 0x7f, 0xff, 0xfe, 0x3f, 0xff, 0xff, 0xfe, 0xca, 0x6f, 0xff
|
|
};
|
|
|
|
void app_main(void)
|
|
{
|
|
SSD1306_t dev;
|
|
|
|
#if CONFIG_I2C_INTERFACE
|
|
ESP_LOGI(TAG, "INTERFACE is i2c");
|
|
ESP_LOGI(TAG, "CONFIG_SDA_GPIO=%d",CONFIG_SDA_GPIO);
|
|
ESP_LOGI(TAG, "CONFIG_SCL_GPIO=%d",CONFIG_SCL_GPIO);
|
|
ESP_LOGI(TAG, "CONFIG_RESET_GPIO=%d",CONFIG_RESET_GPIO);
|
|
i2c_master_init(&dev, CONFIG_SDA_GPIO, CONFIG_SCL_GPIO, CONFIG_RESET_GPIO);
|
|
#endif // CONFIG_I2C_INTERFACE
|
|
|
|
#if CONFIG_SPI_INTERFACE
|
|
ESP_LOGI(TAG, "INTERFACE is SPI");
|
|
ESP_LOGI(TAG, "CONFIG_MOSI_GPIO=%d",CONFIG_MOSI_GPIO);
|
|
ESP_LOGI(TAG, "CONFIG_SCLK_GPIO=%d",CONFIG_SCLK_GPIO);
|
|
ESP_LOGI(TAG, "CONFIG_CS_GPIO=%d",CONFIG_CS_GPIO);
|
|
ESP_LOGI(TAG, "CONFIG_DC_GPIO=%d",CONFIG_DC_GPIO);
|
|
ESP_LOGI(TAG, "CONFIG_RESET_GPIO=%d",CONFIG_RESET_GPIO);
|
|
spi_master_init(&dev, CONFIG_MOSI_GPIO, CONFIG_SCLK_GPIO, CONFIG_CS_GPIO, CONFIG_DC_GPIO, CONFIG_RESET_GPIO);
|
|
#endif // CONFIG_SPI_INTERFACE
|
|
|
|
#if CONFIG_FLIP
|
|
dev._flip = true;
|
|
ESP_LOGW(TAG, "Flip upside down");
|
|
#endif
|
|
|
|
#if CONFIG_SSD1306_128x64
|
|
ESP_LOGI(TAG, "Panel is 128x64");
|
|
ssd1306_init(&dev, 128, 64);
|
|
#endif // CONFIG_SSD1306_128x64
|
|
#if CONFIG_SSD1306_128x32
|
|
ESP_LOGI(TAG, "Panel is 128x32");
|
|
ssd1306_init(&dev, 128, 32);
|
|
#endif // CONFIG_SSD1306_128x32
|
|
|
|
ssd1306_contrast(&dev, 0xff);
|
|
|
|
#if 0
|
|
// for test code
|
|
int srcBits = 7;
|
|
int dstBits = 0;
|
|
for (int i=0;i<8;i++) {
|
|
uint8_t dst = 0;
|
|
dst = ssd1306_copy_bit(0xf0, srcBits, dst, dstBits);
|
|
ESP_LOGI(TAG, "dst=%02x", dst);
|
|
srcBits--;
|
|
dstBits++;
|
|
}
|
|
srcBits = 7;
|
|
dstBits = 0;
|
|
for (int i=0;i<8;i++) {
|
|
uint8_t dst = 0;
|
|
dst = ssd1306_copy_bit(0x0f, srcBits, dst, dstBits);
|
|
ESP_LOGI(TAG, "dst=%02x", dst);
|
|
srcBits--;
|
|
dstBits++;
|
|
}
|
|
#endif
|
|
|
|
while(1) {
|
|
ssd1306_clear_screen(&dev, false);
|
|
#if CONFIG_SSD1306_128x64
|
|
ssd1306_display_text(&dev, 0, "SSD1306 128x64", 14, false);
|
|
#endif // CONFIG_SSD1306_128x64
|
|
|
|
#if CONFIG_SSD1306_128x32
|
|
ssd1306_display_text(&dev, 0, "SSD1306 128x32", 14, false);
|
|
#endif // CONFIG_SSD1306_128x32
|
|
ssd1306_display_text(&dev, 1, "BATMAN", 6, false);
|
|
|
|
int bitmapWidth = 4*8;
|
|
int width = ssd1306_get_width(&dev);
|
|
int xpos = width / 2; // center of width
|
|
xpos = xpos - bitmapWidth/2;
|
|
int ypos = 16;
|
|
ESP_LOGD(TAG, "width=%d xpos=%d", width, xpos);
|
|
ssd1306_bitmaps(&dev, xpos, ypos, batman, 32, 13, false);
|
|
vTaskDelay(3000 / portTICK_PERIOD_MS);
|
|
|
|
for(int i=0;i<128;i++) {
|
|
ssd1306_wrap_arround(&dev, SCROLL_RIGHT, 2, 3, 0);
|
|
}
|
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
|
|
|
#if CONFIG_SSD1306_128x64
|
|
ssd1306_clear_screen(&dev, false);
|
|
ssd1306_bitmaps(&dev, 0, 0, logoMischianti, 128, 64, false);
|
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
|
|
|
for(int i=0;i<64;i++) {
|
|
ssd1306_wrap_arround(&dev, SCROLL_UP, 0, 127, 0);
|
|
}
|
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
|
|
|
ssd1306_clear_screen(&dev, false);
|
|
ssd1306_bitmaps(&dev, 0, 0, fleischer, 128, 64, false);
|
|
vTaskDelay(2000 / portTICK_PERIOD_MS);
|
|
#endif
|
|
}
|
|
}
|