|
| 1 | +# Waveshare ESP32-S3-LR1121-OLED-0.96 Display Support |
| 2 | + |
| 3 | +[](https://components.espressif.com/components/waveshare/esp_oled_ssd1315) |
| 4 | + |
| 5 | +Waveshare ESP32-S3-LR1121-OLED-0.96 Display used I2C |
| 6 | + |
| 7 | +| OLED controller | Communication interface | Component name | Link to datasheet | |
| 8 | +| :------------: |:-----------------------:| :------------: | :---------------------------------------------------------------------------: | |
| 9 | +| SSD1315 | I2C | esp_oled_ssd1315 | [PDF](https://files.waveshare.com/upload/f/f0/SSD1315_1.1.pdf) | |
| 10 | + |
| 11 | +## Add to project |
| 12 | + |
| 13 | +Packages from this repository are uploaded to [Espressif's component service](https://components.espressif.com/). |
| 14 | +You can add them to your project via `idf.py add-dependancy`, e.g. |
| 15 | +``` |
| 16 | + idf.py add-dependency "waveshare/esp_oled_ssd1315" |
| 17 | +``` |
| 18 | + |
| 19 | +Alternatively, you can create `idf_component.yml`. More is in [Espressif's documentation](https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html). |
| 20 | + |
| 21 | + |
| 22 | +## Initialization Code |
| 23 | + |
| 24 | + |
| 25 | +### I2C Interface |
| 26 | + |
| 27 | +```c |
| 28 | + ESP_LOGI(TAG, "Initialize I2C bus"); |
| 29 | + ESP_LOGI(TAG, "I2C Configuration: SDA=GPIO%d, SCL=GPIO%d, Freq=%dHz, Timeout=%dms", |
| 30 | + TEST_PIN_NUM_OLED_SDA, TEST_PIN_NUM_OLED_SCL, TEST_OLED_PIXEL_CLOCK_HZ, TEST_DELAY_TIME_MS); |
| 31 | + ESP_LOGI(TAG, "Display Configuration: Address=0x%02X", |
| 32 | + TEST_OLED_I2C_HW_ADDR); |
| 33 | + |
| 34 | + i2c_master_bus_handle_t i2c_bus_handle = NULL; |
| 35 | + i2c_master_bus_config_t bus_config = { |
| 36 | + .clk_source = I2C_CLK_SRC_DEFAULT, |
| 37 | + .glitch_ignore_cnt = 7, |
| 38 | + .i2c_port = TEST_OLED_HOST, |
| 39 | + .sda_io_num = TEST_PIN_NUM_OLED_SDA, |
| 40 | + .scl_io_num = TEST_PIN_NUM_OLED_SCL, |
| 41 | + .flags.enable_internal_pullup = true, |
| 42 | + }; |
| 43 | + |
| 44 | + /* Create I2C master bus */ |
| 45 | + ESP_ERROR_CHECK(i2c_new_master_bus(&bus_config, &i2c_bus_handle)); |
| 46 | + |
| 47 | + ESP_LOGI(TAG, "Install panel IO"); |
| 48 | + esp_lcd_panel_io_handle_t io_handle = NULL; |
| 49 | + esp_lcd_panel_io_i2c_config_t io_config = { |
| 50 | + .dev_addr = TEST_OLED_I2C_HW_ADDR, |
| 51 | + .scl_speed_hz = TEST_OLED_PIXEL_CLOCK_HZ, |
| 52 | + .control_phase_bytes = 1, // According to SSD1306 datasheet |
| 53 | + .lcd_cmd_bits = TEST_OLED_CMD_BITS, // According to SSD1306 datasheet |
| 54 | + .lcd_param_bits = TEST_OLED_CMD_BITS, // According to SSD1306 datasheet |
| 55 | + .dc_bit_offset = 6, // According to SSD1306 datasheet |
| 56 | + |
| 57 | + }; |
| 58 | + ESP_ERROR_CHECK(esp_lcd_new_panel_io_i2c(i2c_bus_handle, &io_config, &io_handle)); |
| 59 | + |
| 60 | + ESP_LOGI(TAG, "Install SSD1315 panel driver"); |
| 61 | + esp_lcd_panel_handle_t panel_handle = NULL; |
| 62 | + esp_lcd_panel_dev_config_t panel_config = { |
| 63 | + .bits_per_pixel = 1, |
| 64 | + .reset_gpio_num = TEST_PIN_NUM_OLED_RST, |
| 65 | + }; |
| 66 | + |
| 67 | + esp_lcd_panel_ssd1315_config_t ssd1315_config = { |
| 68 | + .height = TEST_OLED_V_RES, |
| 69 | + }; |
| 70 | + panel_config.vendor_config = &ssd1315_config; |
| 71 | + ESP_ERROR_CHECK(esp_lcd_new_panel_ssd1315(io_handle, &panel_config, &panel_handle)); |
| 72 | + |
| 73 | + ESP_ERROR_CHECK(esp_lcd_panel_init(panel_handle)); |
| 74 | + ESP_ERROR_CHECK(esp_lcd_panel_invert_color(panel_handle,true)); |
| 75 | + ESP_ERROR_CHECK(esp_lcd_panel_disp_on_off(panel_handle, true)); |
| 76 | +``` |
| 77 | +
|
| 78 | +## Notes |
| 79 | +
|
0 commit comments