mirror of
https://github.com/nopnop2002/esp-idf-ssd1306.git
synced 2024-10-03 18:18:47 -04:00
added TextBoxDemo
This commit is contained in:
parent
acab283d94
commit
97d775a6cf
8
TextBoxDemo/CMakeLists.txt
Normal file
8
TextBoxDemo/CMakeLists.txt
Normal 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)
|
7
TextBoxDemo/README.md
Normal file
7
TextBoxDemo/README.md
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
# TextBoxDemo for SSD1306
|
||||||
|
|
||||||
|
This project uses an 8-dot font.
|
||||||
|
The maximum number of characters that can be displayed is 16 characters.
|
||||||
|
By using the ssd1306_display_text_box function, it is possible to display more than 16 characters.
|
||||||
|
|
||||||
|
|
4
TextBoxDemo/main/CMakeLists.txt
Normal file
4
TextBoxDemo/main/CMakeLists.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
set(COMPONENT_SRCS "main.c")
|
||||||
|
set(COMPONENT_ADD_INCLUDEDIRS "")
|
||||||
|
|
||||||
|
register_component()
|
8
TextBoxDemo/main/component.mk
Normal file
8
TextBoxDemo/main/component.mk
Normal 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.
|
||||||
|
#
|
90
TextBoxDemo/main/main.c
Normal file
90
TextBoxDemo/main/main.c
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
#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"
|
||||||
|
|
||||||
|
void app_main(void)
|
||||||
|
{
|
||||||
|
SSD1306_t dev;
|
||||||
|
#if 0
|
||||||
|
int center, top, bottom;
|
||||||
|
char lineChar[20];
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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
|
||||||
|
|
||||||
|
while(1) {
|
||||||
|
ssd1306_clear_screen(&dev, false);
|
||||||
|
ssd1306_contrast(&dev, 0xff);
|
||||||
|
ssd1306_display_text_box1(&dev, 0, 48, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 4, 4, false, 100);
|
||||||
|
ssd1306_display_text_box1(&dev, 0, 48, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 4, 26, false, 2);
|
||||||
|
ssd1306_display_text_box1(&dev, 1, 32, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 8, 8, false, 100);
|
||||||
|
ssd1306_display_text_box1(&dev, 1, 32, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 8, 26, false, 3);
|
||||||
|
ssd1306_display_text_box1(&dev, 2, 16, "ABCDEFGHIJKLMNOPQRSTUVWXYZ",12, 12, false, 100);
|
||||||
|
ssd1306_display_text_box1(&dev, 2, 16, "ABCDEFGHIJKLMNOPQRSTUVWXYZ",12, 26, false, 4);
|
||||||
|
ssd1306_display_text_box1(&dev, 3, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ",16, 16, false, 100);
|
||||||
|
ssd1306_display_text_box1(&dev, 3, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ",16, 26, false, 5);
|
||||||
|
vTaskDelay(100);
|
||||||
|
|
||||||
|
#if CONFIG_SSD1306_128x64
|
||||||
|
ssd1306_display_text_box2(&dev, 4, 48, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 4, 26, false, 2);
|
||||||
|
ssd1306_display_text_box2(&dev, 5, 32, "ABCDEFGHIJKLMNOPQRSTUVWXYZ", 8, 26, false, 2);
|
||||||
|
ssd1306_display_text_box2(&dev, 6, 16, "ABCDEFGHIJKLMNOPQRSTUVWXYZ",12, 26, false, 2);
|
||||||
|
ssd1306_display_text_box2(&dev, 7, 0, "ABCDEFGHIJKLMNOPQRSTUVWXYZ",16, 26, false, 2);
|
||||||
|
vTaskDelay(100);
|
||||||
|
#endif
|
||||||
|
} // end while
|
||||||
|
}
|
18
TextBoxDemo/sdkconfig.defaults
Normal file
18
TextBoxDemo/sdkconfig.defaults
Normal 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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user