Added ImageScrollDemo

This commit is contained in:
nopnop2002 2022-08-10 08:08:46 +09:00
parent 97f3b06477
commit cfd3ba8fd3
13 changed files with 434 additions and 0 deletions

View File

@ -0,0 +1,8 @@
# The following lines of boilerplate have to be in your project's CMakeLists
# in this exact order for cmake to work correctly
cmake_minimum_required(VERSION 3.5)
set(EXTRA_COMPONENT_DIRS ../components/ssd1306)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(ssd1306)

24
ImageScrollDemo/README.md Normal file
View File

@ -0,0 +1,24 @@
# ImageScrollDemo for SSD1306
![ImageScrollDemo](https://user-images.githubusercontent.com/6020549/183776833-692411ca-9464-4fe7-afea-cddcbd5901ae.JPG)
I borrowed the BIT MAP data from [here](https://www.iconspng.com/search.php?png=16+segment+display).
# How to make Alphabet image
- Download png file.
- Eliminate shadows using Windows paint.
- Convert image to monochrome using convert.
```
convert [in] -monochrome [out]
```
- Eliminate dot-line using Windows paint.
- Resize image to 48x62 using convert.
```
convert [in] -resize -x48 [out]
```
- Convert image file to BMP data using this [page](https://www.mischianti.org/2021/07/14/ssd1306-oled-display-draw-images-splash-and-animations-2/).
- Paste the BMP data into your code.

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -0,0 +1,4 @@
set(COMPONENT_SRCS "main.c")
set(COMPONENT_ADD_INCLUDEDIRS "")
register_component()

View File

@ -0,0 +1,8 @@
#
# Main component makefile.
#
# This Makefile can be left empty. By default, it will take the sources in the
# src/ directory, compile them and link them into lib(subdirectory_name).a
# in the build directory. This behaviour is entirely configurable,
# please read the ESP-IDF documents if you need to do this.
#

372
ImageScrollDemo/main/main.c Normal file
View File

@ -0,0 +1,372 @@
#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"
#define NUM_IMAGES 7
#define IMAGE_WIDTH 48
// (48/6)*62=372
#define BITMAPS 372
uint8_t segmentDisplay[NUM_IMAGES][BITMAPS] = {
{
// https://www.iconspng.com/image/94065/16-segment-display-h
// '16-segment-display-h', 48x62px
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, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x70,
0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00,
0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e,
0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0,
0x00, 0x1e, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x1e, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00,
0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c,
0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x07, 0x80,
0x00, 0x78, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00,
0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x27,
0xf8, 0x1f, 0xf6, 0x00, 0x00, 0x1f, 0xfe, 0x7f, 0xf8, 0x00, 0x00, 0x1f, 0xfc, 0x7f, 0xf0, 0x00,
0x00, 0x6f, 0xf0, 0x1f, 0xee, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x1e, 0x00, 0x01, 0xe0, 0x00, 0x00,
0x1e, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x1e, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x1e, 0x00, 0x01, 0xe0,
0x00, 0x00, 0x3e, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x3c, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x3c, 0x00,
0x03, 0xc0, 0x00, 0x00, 0x3c, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x3c, 0x00, 0x03, 0xc0, 0x00, 0x00,
0x3c, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x78, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x78, 0x00, 0x07, 0x80,
0x00, 0x00, 0x78, 0x00, 0x07, 0x80, 0x00, 0x00, 0x78, 0x00, 0x07, 0x80, 0x00, 0x00, 0x78, 0x00,
0x07, 0x80, 0x00, 0x00, 0x78, 0x00, 0x07, 0x80, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00,
0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00,
0x00, 0x00, 0xf0, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x60, 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
},
{
// https://www.iconspng.com/image/94062/16-segment-display-e
// '16-segment-display-e', 48x62px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0xff, 0x80, 0x00, 0x01, 0xff, 0xe1, 0xff, 0xc0, 0x00, 0x01,
0xff, 0xf3, 0xff, 0xc0, 0x00, 0x06, 0xff, 0xe3, 0xff, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00,
0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x27,
0xf8, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfe, 0x00, 0x00, 0x00, 0x00, 0x1f, 0xfc, 0x00, 0x00, 0x00,
0x00, 0x6f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0,
0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80,
0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00,
0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0xff, 0xc7, 0xff, 0x00, 0x00,
0x03, 0xff, 0xcf, 0xff, 0x80, 0x00, 0x07, 0xff, 0x87, 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
},
{
// '16-segment-display-l', 48x62px
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, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00,
0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e,
0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00,
0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00,
0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3c,
0x00, 0x00, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00,
0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00,
0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00,
0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x01, 0xe0,
0x00, 0x00, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x00, 0x00,
0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x00,
0x00, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80,
0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00,
0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0d, 0xff, 0xc7, 0xff, 0x00, 0x00,
0x03, 0xff, 0xcf, 0xff, 0x80, 0x00, 0x07, 0xff, 0x87, 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
},
{
// '16-segment-display-o', 48x62px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0xff, 0xc0, 0x00, 0x01, 0xff, 0xe1, 0xff, 0xc0, 0x00, 0x01,
0xff, 0xf3, 0xff, 0xc0, 0x00, 0x06, 0xff, 0xe3, 0xff, 0x30, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x70,
0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00,
0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e,
0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0,
0x00, 0x1e, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x1e, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00,
0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c,
0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x07, 0x80,
0x00, 0x78, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00,
0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x20,
0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x60, 0x00, 0x00, 0x0e, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x1e, 0x00, 0x01, 0xe0, 0x00, 0x00,
0x1e, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x1e, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x1e, 0x00, 0x01, 0xe0,
0x00, 0x00, 0x3e, 0x00, 0x01, 0xe0, 0x00, 0x00, 0x3c, 0x00, 0x03, 0xe0, 0x00, 0x00, 0x3c, 0x00,
0x03, 0xc0, 0x00, 0x00, 0x3c, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x3c, 0x00, 0x03, 0xc0, 0x00, 0x00,
0x3c, 0x00, 0x03, 0xc0, 0x00, 0x00, 0x78, 0x00, 0x07, 0xc0, 0x00, 0x00, 0x78, 0x00, 0x07, 0x80,
0x00, 0x00, 0x78, 0x00, 0x07, 0x80, 0x00, 0x00, 0x78, 0x00, 0x07, 0x80, 0x00, 0x00, 0x78, 0x00,
0x07, 0x80, 0x00, 0x00, 0x78, 0x00, 0x07, 0x80, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00,
0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00,
0x00, 0x00, 0xf0, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0d, 0xff, 0xc7, 0xff, 0x60, 0x00,
0x03, 0xff, 0xcf, 0xff, 0x80, 0x00, 0x07, 0xff, 0x87, 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
},
{
// '16-segment-display-w', 48x62px
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, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x70,
0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00,
0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e,
0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0,
0x00, 0x1e, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x1e, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00,
0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c,
0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x07, 0x80,
0x00, 0x78, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00,
0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x20,
0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00,
0x00, 0x60, 0x06, 0xc0, 0x0e, 0x00, 0x00, 0xf0, 0x1c, 0xe0, 0x1e, 0x00, 0x01, 0xe0, 0x1c, 0x60,
0x1e, 0x00, 0x01, 0xe0, 0x38, 0x70, 0x1e, 0x00, 0x01, 0xe0, 0x78, 0x70, 0x1e, 0x00, 0x01, 0xe0,
0xf0, 0x70, 0x3e, 0x00, 0x01, 0xe0, 0xf0, 0x78, 0x3c, 0x00, 0x03, 0xe1, 0xe0, 0x78, 0x3c, 0x00,
0x03, 0xc3, 0xe0, 0x78, 0x3c, 0x00, 0x03, 0xc3, 0xc0, 0x3c, 0x3c, 0x00, 0x03, 0xc7, 0xc0, 0x3c,
0x3c, 0x00, 0x03, 0xcf, 0x80, 0x3e, 0x78, 0x00, 0x07, 0xdf, 0x00, 0x1e, 0x78, 0x00, 0x07, 0x9e,
0x00, 0x1e, 0x78, 0x00, 0x07, 0xbe, 0x00, 0x1f, 0x78, 0x00, 0x07, 0xbc, 0x00, 0x0f, 0x78, 0x00,
0x07, 0xf8, 0x00, 0x0f, 0x78, 0x00, 0x07, 0xf8, 0x00, 0x07, 0xf0, 0x00, 0x0f, 0x70, 0x00, 0x07,
0xf0, 0x00, 0x0f, 0x40, 0x00, 0x02, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x03, 0xf0, 0x00, 0x0f, 0x00,
0x00, 0x00, 0xf0, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x60, 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
},
{
// '16-segment-display-r', 48x62px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0xff, 0xc0, 0x00, 0x01, 0xff, 0xe1, 0xff, 0xc0, 0x00, 0x01,
0xff, 0xf3, 0xff, 0xc0, 0x00, 0x06, 0xff, 0xe3, 0xff, 0x30, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x70,
0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00,
0x00, 0xf0, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e,
0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x1e, 0x00, 0x00, 0x01, 0xe0,
0x00, 0x1e, 0x00, 0x00, 0x01, 0xc0, 0x00, 0x1e, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00,
0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c,
0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x07, 0x80,
0x00, 0x78, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x07, 0x80, 0x00, 0x78, 0x00, 0x00,
0x07, 0x80, 0x00, 0x78, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x70, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x27,
0xf8, 0x1f, 0xf6, 0x00, 0x00, 0x1f, 0xfe, 0x7f, 0xf8, 0x00, 0x00, 0x1f, 0xfc, 0xff, 0xf0, 0x00,
0x00, 0x6f, 0xf0, 0xdf, 0xe0, 0x00, 0x00, 0xf0, 0x00, 0xe0, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x60,
0x00, 0x00, 0x01, 0xe0, 0x00, 0x70, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x70, 0x00, 0x00, 0x01, 0xe0,
0x00, 0x70, 0x00, 0x00, 0x01, 0xe0, 0x00, 0x78, 0x00, 0x00, 0x03, 0xe0, 0x00, 0x78, 0x00, 0x00,
0x03, 0xc0, 0x00, 0x78, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c, 0x00, 0x00, 0x03, 0xc0, 0x00, 0x3c,
0x00, 0x00, 0x03, 0xc0, 0x00, 0x3e, 0x00, 0x00, 0x07, 0xc0, 0x00, 0x1e, 0x00, 0x00, 0x07, 0x80,
0x00, 0x1e, 0x00, 0x00, 0x07, 0x80, 0x00, 0x1f, 0x00, 0x00, 0x07, 0x80, 0x00, 0x0f, 0x00, 0x00,
0x07, 0x80, 0x00, 0x0f, 0x00, 0x00, 0x07, 0x80, 0x00, 0x07, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x07,
0x00, 0x00, 0x0f, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x0f, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 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
},
{
// '16-segment-display-d', 48x62px
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0xff, 0xc0, 0xff, 0xc0, 0x00, 0x01, 0xff, 0xe1, 0xff, 0xc0, 0x00, 0x01,
0xff, 0xf3, 0xff, 0xc0, 0x00, 0x00, 0xff, 0xeb, 0xff, 0x30, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x70,
0x00, 0x00, 0x00, 0x3c, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x3c, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x3c,
0x00, 0xf0, 0x00, 0x00, 0x00, 0x7c, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x78, 0x01, 0xe0, 0x00, 0x00,
0x00, 0x78, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x78, 0x01, 0xe0, 0x00, 0x00, 0x00, 0x78, 0x01, 0xe0,
0x00, 0x00, 0x00, 0xf8, 0x01, 0xc0, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xc0, 0x00, 0x00, 0x00, 0xf0,
0x03, 0xc0, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xc0, 0x00, 0x00, 0x00, 0xf0, 0x03, 0xc0, 0x00, 0x00,
0x01, 0xf0, 0x03, 0xc0, 0x00, 0x00, 0x01, 0xf0, 0x07, 0x80, 0x00, 0x00, 0x01, 0xe0, 0x07, 0x80,
0x00, 0x00, 0x01, 0xe0, 0x07, 0x80, 0x00, 0x00, 0x00, 0xc0, 0x07, 0x80, 0x00, 0x00, 0x00, 0xc0,
0x07, 0x80, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00, 0x00, 0x80, 0x0f, 0x00, 0x00, 0x00,
0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00,
0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x03, 0x00, 0x1e, 0x00, 0x00, 0x00,
0x07, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x3c, 0x00,
0x00, 0x00, 0x0f, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x0f, 0x00,
0x3c, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x78, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x78, 0x00, 0x00, 0x00,
0x1e, 0x00, 0x78, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x78, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x78, 0x00,
0x00, 0x00, 0x1e, 0x00, 0x78, 0x00, 0x00, 0x00, 0x3e, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x3c, 0x00,
0xf0, 0x00, 0x00, 0x00, 0x3c, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x3c, 0x00, 0xf0, 0x00, 0x00, 0x00,
0x3c, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x38, 0x00, 0xf0, 0x00, 0x01, 0xff, 0xc7, 0xff, 0x60, 0x00,
0x03, 0xff, 0xcf, 0xff, 0x80, 0x00, 0x07, 0xff, 0x87, 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
}
};
// H E L L O SP W O R L D
int imageTable[] = {0, 1, 2, 2, 3, -1, 4, 3, 5, 2, 6};
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_LOGE(TAG, "Panel is 128x32. This demo cannot be run.");
while(1) { vTaskDelay(1); }
#endif // CONFIG_SSD1306_128x32
ssd1306_contrast(&dev, 0xff);
int numOfTable = sizeof(imageTable)/sizeof(int);
ESP_LOGI(TAG, "numOfTable=%d", numOfTable);
// Allocate memory
uint8_t *buffer = (uint8_t *)malloc(8*128); // 8 page 128 pixel
if (buffer == NULL) {
ESP_LOGE(TAG, "malloc failed");
while(1) { vTaskDelay(1); }
}
uint8_t *segmentImage = (uint8_t *)malloc(NUM_IMAGES*8*IMAGE_WIDTH); // 10 image 8 page 48 pixel
if (segmentImage == NULL) {
ESP_LOGE(TAG, "malloc failed");
while(1) { vTaskDelay(1); }
}
// Convert from segmentDisplay to segmentImage
for (int imageIndex=0;imageIndex<NUM_IMAGES;imageIndex++) {
ssd1306_clear_screen(&dev, false);
ssd1306_bitmaps(&dev, 0, 1, segmentDisplay[imageIndex], IMAGE_WIDTH, 62, false);
vTaskDelay(200 / portTICK_PERIOD_MS);
// Get from internal buffer to local buffer
// buffer is [8][128] 8 page 128 pixel
ssd1306_get_buffer(&dev, buffer);
// Save from buffer to segmentImage
// segmentImage is [10][8][IMAGE_WIDTH] 10 image 8 page 48 pixel
int segmentImageIndex = imageIndex * BITMAPS;
for (int page=0;page<8;page++) {
//ESP_LOGI(TAG, "segmentImageIndex+page*IMAGE_WIDTH=%d", segmentImageIndex+page*IMAGE_WIDTH);
memcpy(&segmentImage[segmentImageIndex+page*IMAGE_WIDTH], &buffer[page*128], IMAGE_WIDTH);
//ESP_LOGI(TAG, "page=%d", page);
//ESP_LOG_BUFFER_HEXDUMP(TAG, &buffer[page*128], IMAGE_WIDTH, ESP_LOG_INFO);
}
#if 0
ssd1306_clear_screen(&dev, false);
for (int page=0;page<8;page++) {
ssd1306_display_image(&dev, page, 0, &segmentImage[segmentImageIndex+page*IMAGE_WIDTH], IMAGE_WIDTH);
//ESP_LOGI(TAG, "page=%d", page);
//ESP_LOG_BUFFER_HEXDUMP(TAG, &segmentImage[segmentImageIndex+page*IMAGE_WIDTH], IMAGE_WIDTH, ESP_LOG_INFO);
}
vTaskDelay(1000 / portTICK_PERIOD_MS);
#endif
}
int imageIndex = 0;
int imageSegment = 0;
ssd1306_clear_screen(&dev, false);
while(1) {
// Shift segment data left by 2 bits
for (int page=0;page<8;page++) {
int bufferIndex = page*128;
memcpy(&buffer[bufferIndex], &buffer[bufferIndex+2], 126);
}
// Insert 2 bits at the end of segment data
if (imageTable[imageIndex] >= 0) {
int segmentImageIndex = imageTable[imageIndex] * BITMAPS;
for (int page=0;page<8;page++) {
int bufferIndex = page*128+126;
buffer[bufferIndex] = segmentImage[segmentImageIndex+page*IMAGE_WIDTH+imageSegment];
buffer[bufferIndex+1] = segmentImage[segmentImageIndex+page*IMAGE_WIDTH+imageSegment+1];
}
} else {
for (int page=0;page<8;page++) {
int bufferIndex = page*128+126;
buffer[bufferIndex] = 0;
buffer[bufferIndex+1] = 0;
}
}
imageSegment=imageSegment+2;
ssd1306_set_buffer(&dev, buffer);
ssd1306_show_buffer(&dev);
//vTaskDelay(5);
// End of display of one character
if (imageSegment == IMAGE_WIDTH) {
imageIndex++;
if (imageIndex == numOfTable) {
// All characters have been displayed.
// Scroll to last character.
for (int segs=0;segs<64;segs++) {
for (int page=0;page<8;page++) {
int bufferIndex = page*128;
memcpy(&buffer[bufferIndex], &buffer[bufferIndex+2], 126);
}
for (int page=0;page<8;page++) {
int bufferIndex = page*128+126;
buffer[bufferIndex]=0;
buffer[bufferIndex+1]=0;
}
ssd1306_set_buffer(&dev, buffer);
ssd1306_show_buffer(&dev);
}
imageIndex = 0;
}
imageSegment = 0;
}
} // end while
free(buffer);
}

View File

@ -0,0 +1,18 @@
#
# ESP32-specific
#
CONFIG_ESP32_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=240
#
# ESP32S2-specific
#
CONFIG_ESP32S2_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32S2_DEFAULT_CPU_FREQ_MHZ=240
#
# ESP32S3-specific
#
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_240=y
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_MHZ=240