ESP32S2 Qt py - ESP-IDF & OLED

For Adafruit customers who seek help with microcontrollers

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tomhavel
 
Posts: 6
Joined: Sat Feb 26, 2022 3:11 am

ESP32S2 Qt py - ESP-IDF & OLED

Post by tomhavel »

Hello everyone,

I recently started playing with the ESP32S2 QT Py board and 128x128 SSD1327 OLED display. As I wanted to move on from the Arduino and try something "more advanced", I chose the ESP-IDF framework for my project.

However, as I do not have a massive experience in microcontroller programming, I soon got to a dead end. As the dedicated Adafruit library for SSD1327 is yet just for the Arduino framework, I opted for a u8g2 library, that with a couple of tweaks and a lot of browsing on Github got to a "working" stage.

For this entire process, I found quite a nice guide: https://www.lucadentella.it/en/2017/10/ ... -con-u8g2/, which I followed. As I finally progressed and got the display to turn on, the framerate was hilarious. I am aware that I2C speeds are not great, but this was truly lame. I am talking about a refresh rate of around 0.1Hz (yes, it literally took almost 10 seconds to print one display's screen)

For what it's worth I am including the code:

Code: Select all

#include <driver/gpio.h>
#include <driver/spi_master.h>
#include <esp_log.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <stdio.h>
#include <string.h>

#include "u8g2_esp32_hal.h"
#include "icons.h"

#define PIN_SDA 41
#define PIN_SCL 40



void app_main() {

	// initialize the u8g2 hal
u8g2_esp32_hal_t u8g2_esp32_hal = U8G2_ESP32_HAL_DEFAULT;
u8g2_esp32_hal.sda = PIN_SDA;
u8g2_esp32_hal.scl = PIN_SCL;
u8g2_esp32_hal_init(u8g2_esp32_hal);

	// initialize the u8g2 library
	u8g2_t u8g2;
	u8g2_Setup_ssd1327_i2c_midas_128x128_f(
		&u8g2,
		U8G2_R0,
		u8g2_esp32_i2c_byte_cb,
		u8g2_esp32_gpio_and_delay_cb);
	
	// set the display address
	u8x8_SetI2CAddress(&u8g2.u8x8, 0x3D);
	
	// initialize the display
	u8g2_InitDisplay(&u8g2);
	
	// wake up the display
	u8g2_SetPowerSave(&u8g2, 0);
	
	// loop
	while(1) {
		
		// draw the hourglass animation, full-half-empty
		//u8g2_ClearBuffer(&u8g2);
		u8g2_DrawXBM(&u8g2, 34, 2, 60, 60, hourglass_full);
		u8g2_SendBuffer(&u8g2);
		vTaskDelay(1000 / portTICK_RATE_MS);
		
		//u8g2_ClearBuffer(&u8g2);
		u8g2_DrawXBM(&u8g2, 34, 2, 60, 60, hourglass_half);
		u8g2_SendBuffer(&u8g2);
		vTaskDelay(1000 / portTICK_RATE_MS);

		//u8g2_ClearBuffer(&u8g2);
		u8g2_DrawXBM(&u8g2, 34, 2, 60, 60, hourglass_empty);
		u8g2_SendBuffer(&u8g2);
		vTaskDelay(1000 / portTICK_RATE_MS);	
		
		// set font and write hello world
		//u8g2_ClearBuffer(&u8g2);
		u8g2_SetFont(&u8g2, u8g2_font_timR14_tf);
		u8g2_DrawStr(&u8g2, 2,17,"Hello World!");
		u8g2_SendBuffer(&u8g2);
		vTaskDelay(5000 / portTICK_RATE_MS);
	}	
}
Is there any chance someone has experienced a similar issue? Or would be able to pinpoint the problem? Possibly a workaround, a different library, or anything actually.
Thanks a lot!

User avatar
adafruit_support_mike
 
Posts: 67485
Joined: Thu Feb 11, 2010 2:51 pm

Re: ESP32S2 Qt py - ESP-IDF & OLED

Post by adafruit_support_mike »

Try using straight CircuitPython instead. Trying to port libraries from one environment to another is a 55 gallon drum of worms that you don't need as a beginner.

The only people who can move from one IDE to another comfortably are the ones who know both underlying systems well enough to rewrite code from one in terms that work for the other, and almost no one learns that much voluntarily. The population consists of experienced programmers with high frustration tolerances who were unable or unwilling to let a wall be tougher than their foreheads.

Locked
Please be positive and constructive with your questions and comments.

Return to “Microcontrollers”