Author |
Message |
08/06/2021 14:44:58
|
#16
|
ScubaSteve
Joined: May 14, 2021
Messages: 30
Offline
|
Hi Dave. Yeah, as soon as I made that post .... I realized there were two sets of generated files. Cleaned it up and unchecked the "src" box.
I'm presently compiling with Wire.begin() and the pins specified in the UMF file. I'll try it your way.
|
|
|
08/06/2021 14:48:38
|
#17
|
davetcc
Joined: Jan 19, 2019
Messages: 686
Offline
|
Maybe we need a new option in 2.2 to move all (or at least some of the variables in the menu.cpp/h definition file into a namespace. With a warning that this is an advanced feature requiring an understanding of namespaces.
Then even if you had a variable/function called display elsewhere you could access the generated one through a namespace:
myapp::display
|
|
|
08/06/2021 14:52:02
|
#18
|
davetcc
Joined: Jan 19, 2019
Messages: 686
Offline
|
I have to say that after looking at the U8G2 code and conditional blocks for ESP32, I would have expected everything to work by passing in SDA and SCL to the U8G2 constructor.
However, that did not seem as reliable as calling Wire.begin(....) upfront, and if I'm honest, I'm not really sure why.
|
|
|
08/06/2021 15:18:24
|
#19
|
ScubaSteve
Joined: May 14, 2021
Messages: 30
Offline
|
So frustrating!
The toaster example compiles and works perfectly with the display. It's got 5/4 listed for the pins in Designer, and Software I2C. Calls Wire.begin() with no options.
Interestingly, my display appears to be on 26/29 (SDA to D22, SDA to D21). Replacing that in Designer and/or Wire.begin() ... still no display with your test code.
What could I possibly be doing wrong?
|
|
|
08/06/2021 15:47:26
|
#20
|
davetcc
Joined: Jan 19, 2019
Messages: 686
Offline
|
Agreed, there's nothing worse than trying to get something like this working.
Let me try and mirror your situation later, connecting the display on the standard SDA and SCL pins. I'll feedback once I've done that.
Another option:
What you can also do, is you can also use the custom U8G2 plugin, where you define the U8G2 variable yourself as a global variable, and initialise the display before setupMenu() is called, and then just provide the name of the variable during code generation. It works well for cases when the quick start doesn't work.
|
|
|
08/06/2021 16:09:27
|
#21
|
davetcc
Joined: Jan 19, 2019
Messages: 686
Offline
|
I've just wired to the standard SDA and SCL pins (21/22). I've got a fairly standard I2C SH1106 64 line hardware display from AZ delivery.
My setup was a follows:
void setup() {
Serial.begin(115200);
Wire.begin();
setupMenu();
}
My properties are as the attached image. Don't forget that when using software I2C the latency reduction option should not be ticked (we added a warning that it's for hardware I2C only).
Something to bear in mind, once you call Wire.begin() it is no longer possible to adjust the pins in future, for that reason I recommend calling Wire.begin as soon as possible in setup(). See https://github.com/espressif/arduino-esp32/blob/a618fc1361b08aa968407dd81b7b065cca207f46/libraries/Wire/src/Wire.cpp#L72
EDIT: also note that in the original example I had picked 21 as my switch pin, I have moved that now to 37 in the latest example to avoid a clash.
|
Filename |
rename-display-variable2.jpg |
Download
|
Description |
shows the settings that work for me with default I2C pins |
Filesize |
72 Kbytes
|
Downloaded: |
50753 time(s) |
|
|
|
08/06/2021 16:31:50
|
#22
|
ScubaSteve
Joined: May 14, 2021
Messages: 30
Offline
|
I'm using the Advanced version. I'm pretty sure I've been at this point, ran into a problem and then tried the Simple...
I've got the global:
U8G2_SH1106_128X64_NONAME_F_HW_I2C gfx(U8G2_R0, U8X8_PIN_NONE, U8X8_PIN_NONE, U8X8_PIN_NONE);
And in setup():
Wire.begin();
gfx.begin();
setupMenu();
renderer.setResetCallback(onMenuBeingReset);
renderer.setResetIntervalTimeSeconds(MENU_TIMEOUT);
renderer.takeOverDisplay(welcome);
The welcome() function worked on all other display types. For some reason, I'm getting nothing on the LCD screen until I press the OK button on the encoder, then I'm presented with a menu. After the timeout, the display goes blank again.
I've confirmed the takeover function is getting invoked via serial logging.
The welcome() function is pretty simple -- stuff like this.
gfx.clearDisplay();
display_struct.updateTop = false;
display_struct.updateBottom = false;
gfx.setCursor(0, 0);
gfx.print("Welcome");
gfx.display();
delay(5000);
gfx.clearDisplay();
I don't think this is a bug. I'm just on the struggle bus with this particular display..
|
|
|
08/06/2021 17:01:09
|
#23
|
davetcc
Joined: Jan 19, 2019
Messages: 686
Offline
|
Can you try
gfx.sendBuffer();
Instead of
gfx.display()
As you are using full-frame I think this is needed. Worth a try at any rate as it's a quick change.
|
|
|
08/06/2021 17:18:04
|
#24
|
ScubaSteve
Joined: May 14, 2021
Messages: 30
Offline
|
Ah ha! That was it. Thank you, Dave!!!
I still think there's something awry with the Simple stuff, I just don't know what or where.
=)
|
|
|
08/06/2021 17:48:08
|
#25
|
davetcc
Joined: Jan 19, 2019
Messages: 686
Offline
|
No problem.
On the U8G2 quick start option, I've tried every option that I can on ESP32, NanoBLE, and also on ESP8266.
* ESP32: I've tried HW_I2C on both regular and non-standard pins. I've tried with the yield flag enabled and disabled.
* ESP8266: I've tried both HW (yield in both states) and SW modes (yield off)
* Nano: I've tried HW mode (yield in both states)
|
|
|
|