Added i2c port number selection

This commit is contained in:
nopnop2002 2023-07-25 06:18:04 +09:00
parent 7f88e535de
commit 80df658070
4 changed files with 39 additions and 12 deletions

View File

@ -51,14 +51,12 @@ You have to set this config value with menuconfig.
# Generic SSD1306 128x32 i2c
![128x32](https://user-images.githubusercontent.com/6020549/56449097-6d12e880-6350-11e9-8edd-7a8fc5eaeedc.JPG)
![config-128x32_i2c](https://user-images.githubusercontent.com/6020549/115942099-79a01d80-a4e3-11eb-9274-8746920fca78.jpg)
![config-128x32_i2c](https://github.com/nopnop2002/esp-idf-ssd1306/assets/6020549/9a7e019f-09d3-4c23-8f9c-544847e5f365)
# Generic SSD1306 128x64 i2c
![128x64](https://user-images.githubusercontent.com/6020549/56449101-7dc35e80-6350-11e9-8579-32fff38369c0.JPG)
![config-128x64_i2c](https://user-images.githubusercontent.com/6020549/127076697-385ecafa-ccb7-4511-a862-70a6143930dd.jpg)
![config-128x64_i2c](https://github.com/nopnop2002/esp-idf-ssd1306/assets/6020549/794645f9-9f95-4760-8a55-9befceb9349e)
# Generic SH1106 128x64 i2c
__Hardware scroll Not support__
@ -66,8 +64,7 @@ Left:1.3 inch SH1106
Right:0.96 inch SSD1306
![SH1106_i2c](https://user-images.githubusercontent.com/6020549/106342871-09b83780-62e6-11eb-999c-912f0e0c9f0f.JPG)
![config-sh1106_i2c](https://user-images.githubusercontent.com/6020549/127077379-ad688621-999e-475e-b1fe-c093d7599783.jpg)
![config-sh1106_i2c](https://github.com/nopnop2002/esp-idf-ssd1306/assets/6020549/4f4e7638-5519-4a1d-9932-780a4d87a8e6)
# 128x64 TTGO
Unlike other ESP32 development boards, the RTC_CLOCK crystal on this board uses a 26MHz one.
@ -76,13 +73,12 @@ You need to change the RTC CLOCK frequency to 26MHz using menuconfig.
![ESP32-TTGO-1](https://user-images.githubusercontent.com/6020549/56449111-9764a600-6350-11e9-9902-e2ad1c4aefb0.JPG)
![ESP32-TTGO-2](https://user-images.githubusercontent.com/6020549/56449116-9a5f9680-6350-11e9-86ec-e06648118add.JPG)
![128x64_Reset](https://user-images.githubusercontent.com/6020549/56449118-9e8bb400-6350-11e9-9b90-1eb1f9fa8e99.JPG)
![config-128x64_TTGO](https://user-images.githubusercontent.com/6020549/202875582-493856ce-5f24-4965-a17f-4419120b113d.jpg)
![config-128x64_TTGO](https://github.com/nopnop2002/esp-idf-ssd1306/assets/6020549/f234b8e0-ef4e-49db-ad78-bbc705649a18)
# 128x64 ESP-WROOM-32
![ESP32-OLED-2](https://user-images.githubusercontent.com/6020549/57063327-d229ef00-6cfd-11e9-98ab-8448e14d81e2.JPG)
![config-ESP-WROOM-32](https://user-images.githubusercontent.com/6020549/173222738-35269c7f-a184-4623-8faf-27f98bd958cb.jpg)
![config-ESP-WROOM-32](https://github.com/nopnop2002/esp-idf-ssd1306/assets/6020549/72434f83-8496-43bb-9333-8c35db155c74)
---
@ -110,6 +106,15 @@ Right:0.96 inch SSD1306
---
# I2C Port selection
![config-i2c-port](https://github.com/nopnop2002/esp-idf-ssd1306/assets/6020549/2acc08b1-cd79-4cc1-9153-4f0e5b56acfd)
The ESP32 series has two I2C Ports.
You can use these two ports freely.
If you use this module at the same time as another I2C device using I2C port 0, you must change it to I2C port 1.
---
# SPI BUS selection
![config-spi-bus](https://user-images.githubusercontent.com/6020549/202815807-6c2df14f-f38e-4032-94fb-da1723607279.jpg)

View File

@ -66,8 +66,8 @@ void app_main(void)
ssd1306_clear_screen(&dev, false);
ssd1306_contrast(&dev, 0xff);
ssd1306_display_text_x3(&dev, 0, "Hello", 5, false);
vTaskDelay(3000 / portTICK_PERIOD_MS);
ssd1306_display_text_x3(&dev, 0, "Hello", 5, false);
vTaskDelay(3000 / portTICK_PERIOD_MS);
#if CONFIG_SSD1306_128x64
top = 2;

View File

@ -145,6 +145,23 @@ menu "SSD1306 Configuration"
Some GPIOs are used for other purposes (flash connections, etc.) and cannot be used to RESET.
GPIOs 35-39 are input-only so cannot be used as outputs.
choice I2C_PORT
depends on I2C_INTERFACE
prompt "I2C port that controls this bus"
default I2C_PORT_0
help
Select I2C port that controls this bus.
config I2C_PORT_0
bool "I2C_PORT_0"
help
Use I2C_PORT_0.
config I2C_PORT_1
depends on IDF_TARGET_ESP32 || IDF_TARGET_ESP32S2 || IDF_TARGET_ESP32S3
bool "I2C_PORT_1"
help
Use I2C_PORT_1.
endchoice
choice SPI_HOST
depends on SPI_INTERFACE
prompt "SPI peripheral that controls this bus"

View File

@ -10,8 +10,13 @@
#define tag "SSD1306"
#if CONFIG_I2C_PORT_0
#define I2C_NUM I2C_NUM_0
//#define I2C_NUM I2C_NUM_1
#elif CONFIG_I2C_PORT_1
#define I2C_NUM I2C_NUM_1
#else
#define I2C_NUM I2C_NUM_0 // if spi is selected
#endif
#define I2C_MASTER_FREQ_HZ 400000 /*!< I2C clock of SSD1306 can run at 400 kHz max. */