[Logo] TCC discussion forum
  [Search] Search   [Recent Topics] Recent Topics   [Hottest Topics] Hottest Topics   [Top Downloads] Top Downloads   [Groups] Back to home page 
[Register] Register /  [Login] Login 


This forum is read only and new users cannot register, please ask all new questions either using GitHub discussions, or in Arduino forum tagging @davetcc.

ESP32 & Adafruit_GFX RSS feed
Forum Index » tcMenu Arduinio library
Author Message
Mistercoenkel


Joined: Jun 30, 2022
Messages: 7
Offline
Hi,

I have a problem with my OLED SSD1306 display.

Usually I use the u8g2 library but it doesn't work with my current ESP32-PICO-D4 , only the Adafruit library works.

So in TcMenu Designer I have correctly declared my screen:

- AdaFruit_GFX with manual declaration and configuration
- Display variable name: gfx
- Display variable type: Adafruit_SSD1306

Then in my sketch I declared :

#include "myMenu_menu.h"

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>

#define SCREEN_WIDTH 128 // OLED display width, in pixels
#define SCREEN_HEIGHT 64 // OLED display height, in pixels

#define OLED_RESET     -1 // Reset pin # (or -1 if sharing Arduino reset pin)
#define SCREEN_ADDRESS 0x3D ///< See datasheet for Address; 0x3D for 128x64, 0x3C for 128x32

Adafruit_SSD1306 gfx(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

void setup() {
  
  Serial.begin(9600);
  
  Wire.begin(15, 33);

  // SSD1306_SWITCHCAPVCC = generate display voltage from 3.3V internally
  if(!gfx.begin(SSD1306_SWITCHCAPVCC, SCREEN_ADDRESS)) {
    Serial.println(F("SSD1306 allocation failed"));
    for(;;); // Don't proceed, loop forever
  }

  // Show initial display buffer contents on the screen --
  // the library initializes this with an Adafruit splash screen.
  gfx.display();
  
  delay(2000); // Pause for 2 seconds

  // Clear the buffer
  gfx.clearDisplay();
    
  setupMenu();
  
}

void loop() {
  
  taskManager.runLoop();

}


My display works, I see the Adafruit logo but my menu does not appear and then my display is black.

I not find a tcMenu example with the Adafruit library.

My project is attached, if you can help me or if you have an example that would be nice.

Thanks
 Filename myMenu.rar [Disk] Download
 Description No description given
 Filesize 8 Kbytes
 Downloaded:  154 time(s)

davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
If you are using an OLED display, in AdafruitGFX library this is a memory buffered display, you need to ensure the "Library is memory buffered" option is ticked in the Code Generator display options. Without this, the display would never render anything.
Mistercoenkel


Joined: Jun 30, 2022
Messages: 7
Offline
davetcc wrote:If you are using an OLED display, in AdafruitGFX library this is a memory buffered display, you need to ensure the "Library is memory buffered" option is ticked in the Code Generator display options. Without this, the display would never render anything.


I forgot to specify that I had tried with and without the "Library is memory buffered" option.

Same result, only the adafruit logo is visible then it remains blocked on it as if the screen was not updating. I tried to use "gfx.clearDisplay();" before "setupMenu();" but nothing worked.

and the example gived on this link: "https://www.thecoderscorner.com/products/arduino-libraries/tc-menu/tcmenu-plugins/adafruit_gfx-renderer-plugin/" use the u8g2 library and not Adafruit.

Using the menu library with OLED SSD1306

The library for this display is both memory buffered and monochrome. Again there is a complete example menu packaged with tcMenu. This example was tested on both ESP32 and ESP8266, but the concepts are generally applicable to any processor. Link below takes you to the source on github.

[https://github.com/davetcc/tcMenuLib/tree/master/examples/esp8266WifiOled]
davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
To be honest, we nearly always use U8G2 with OLED displays. Is there a reason that you use the Adafruit library instead? I'll need to test it myself to see if there is an issue as I don't think many use this combination (Adafruit with OLED).

I have an ESP32 board with an OLED somewhere, I'll try your example on that but it may take me a day or two.
Mistercoenkel


Joined: Jun 30, 2022
Messages: 7
Offline
davetcc wrote:To be honest, we nearly always use U8G2 with OLED displays. Is there a reason that you use the Adafruit library instead? I'll need to test it myself to see if there is an issue as I don't think many use this combination (Adafruit with OLED).

I have an ESP32 board with an OLED somewhere, I'll try your example on that but it may take me a day or two.


Well the u8g2 library does not work with my ESP32-PICO-D4 (SMD) card and I don't know why, I have already talk with the developer of the u8g2 library and we have not been able to find the problem . (https://github.com/olikraus/u8g2/issues/1955)

Only the Adafruit library works.

Edit: The menu now appears when I use the code
display.display();

in the loop but it seems strange to me to have to refresh the screen all the time even when there is no activity. i'm right ?

If you do test, let me know. Thanks
davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
Edit: The menu now appears when I use the code
display.display();

in the loop but it seems strange to me to have to refresh the screen all the time even when there is no activity. i'm right ?


I think there is a bug in the Adafruit plugin, I'll put in a fix for the next version, if you open the adafruit plugin header file that gets put into your project I think it will work:

Find this line:

#define DISPLAY_HAS_MEMBUFFER false


In the file within your project: tcMenuAdaFruitGfx.h

and change false to true
Mistercoenkel


Joined: Jun 30, 2022
Messages: 7
Offline
davetcc wrote:
Edit: The menu now appears when I use the code
display.display();

in the loop but it seems strange to me to have to refresh the screen all the time even when there is no activity. i'm right ?


I think there is a bug in the Adafruit plugin, I'll put in a fix for the next version, if you open the adafruit plugin header file that gets put into your project I think it will work:

Find this line:

#define DISPLAY_HAS_MEMBUFFER false


In the file within your project: tcMenuAdaFruitGfx.h

and change false to true


It works perfectly now.

Thanks
davetcc


Joined: Jan 19, 2019
Messages: 686
Offline
I’ve confirmed this as a bug in the plug-in variable substitution code. It affects the Ethernet plugin as well.

It will be fixed in the next version and I’ll ensure that unit tests capture that case too.
Mistercoenkel


Joined: Jun 30, 2022
Messages: 7
Offline
davetcc wrote:I’ve confirmed this as a bug in the plug-in variable substitution code. It affects the Ethernet plugin as well.

It will be fixed in the next version and I’ll ensure that unit tests capture that case too.


Well I'm happy that my problem is helped to fix a bug. You may also add an example on github with the Adafruit library. smilie
 
Forum Index » tcMenu Arduinio library
Go to:   
Mobile view
Powered by JForum 2.7.0 © 2020 JForum Team • Maintained by Andowson Chang and Ulf Dittmer

This site uses cookies to analyse traffic, serve ads by Google AdSense (non-personalized in EEA/UK), and to record consent. We also embed Twitter, Youtube and Disqus content on some pages, these companies have their own privacy policies.

Our privacy policy applies to all pages on our site

Should you need further guidance on how to proceed: External link for information about cookie management.