New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lolin ESP32 OLED #200
Comments
Not using 5,4 pins in this github so it should not be the root cause |
Dear Luc With the sample code it works, When I try to integrate with your code the display stay off. |
I read sample works
works alone ? |
Dear Luc I have found the problem, I had to add this function "display.display();" display.init(); display.flipScreenVertically(); This works. |
Can you tell me where is the functions that print IP to the serial exist? so I can add this to print also on the display? |
Lines 408 to 409 in 13ee5e1
for first one in command.cpp for [ESP111] command. |
Dear Luc I have added the: in the ESP3D.ino file. In the void setup I added the: display.flipScreenVertically(); If I set something to print(OLED) on the loop or setup it works. it says that "display" is not defined in this scope. |
Each cpp is compiled individualy and so need to have all global variable information before linker do its job. This is basic programming thing - you can find lot of information on google : https://www.google.fr/search?q=share+variable+in+several+file+arduino |
Dear Luc
After that I get the IP address correctly on the OLED display. Where can I find the place that it show the wifi signal? |
Dear Luc I have encounter with resets on ESP32 I have found a solution in here: #include "soc/soc.h" it seems to solve the problem. |
@shaddow501 I have studied the oled API and prepared some test sketch for rendering, screen refresh, etc.. if you want to have a look : The functions I use and wrote do not use delay / yield as oled must be compatible with async webserver, I plan to add an update screen function which will be in main loop and update screen every 1 sec as minimum trigger to not overload esp It should cover all needs for the ESP - may be need to define a boot splash screen - and may be add a clock when SPIFFS will support time About reset : I never had such issue, which confirm it is an HW issue as mentioned in thread you shared, it could be added using flag, but it should not be enabled by default IMHO |
Dear Luc At the moment the module is stable and running good. The screen show my printer name , SSID and IP. I don’t think that there is anymore room to add anything else in the screen. By the way I don’t think that it is important to update the screen every second, I think that the display should be updated with new info only if IP or SSID changes. |
I did modify those sections: //this is AP mode } else {
} |
I added OLed and 5 way tactile button support for ESP32 and use the second core to run the display task. This way the animations are fluently and you can leave the brownout (watchdog) active. in esp3d.ino in setup I add
I moved the complete loop to a task: `
#ifdef CAPTIVE_PORTAL_FEATURE and left the loop with only:
in Oled.cpp I have the implementation: ` // Include the correct display library // Include the UI lib // Include custom images //Hardware pin assignment #define PIN_UP 12 #define TARGET_FPS 30 //--- 4way(U,D,L,R) Switch Read --- #define MODE_MENU 1 // Initialize the OLED display using Wire library OLEDDisplayUi ui ( &display ); int oldButtonState = HIGH; int key_code = 0; void oledTask(void *pvParameters) { while (1) { void msOverlay(OLEDDisplay display, OLEDDisplayUiState state) { void drawFrame1(OLEDDisplay display, OLEDDisplayUiState state, int16_t x, int16_t y) { display->drawXbm(x + 34, y + 14, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits); void drawFrame2(OLEDDisplay display, OLEDDisplayUiState state, int16_t x, int16_t y) { display->setFont(ArialMT_Plain_10); // This array keeps function pointers to all frames // Overlays are statically drawn on top of a frame eg. a clock void initOled(void) { //init the keypad // The ESP is capable of rendering 60fps in 80Mhz mode // You can change this to // Defines where the first frame is located in the bar. // You can change the transition that is used // Add frames // Add overlays // Initialising the UI will init the display too. display.flipScreenVertically(); display.setTextAlignment(TEXT_ALIGN_LEFT); display.display(); //-------------------------------------------
} int oLedUpdate(void) { KeyPolling(); if (key_code == KEY_ID_LEFT) { return ui.update(); |
Hi, Where can I download the complete code to test? |
I think issue can be closed now |
the code is on github |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Dear Luc
I am trying to add OLED support to the ESP3D and it just doesnt work.
I use an example file:
#include "images.h"
// Initialize the OLED display using SPI
// D5 -> CLK
// D7 -> MOSI (DOUT)
// D0 -> RES
// D2 -> DC
// D8 -> CS
// SSD1306Spi display(D0, D2, D8);
// or
// SH1106Spi display(D0, D2);
// Initialize the OLED display using brzo_i2c
// D3 -> SDA
// D5 -> SCL
// SSD1306Brzo display(0x3c, D3, D5);
// or
// SH1106Brzo display(0x3c, D3, D5);
// Initialize the OLED display using Wire library
SSD1306 display(0x3c, 5, 4);
// SH1106 display(0x3c, D3, D5);
#define DEMO_DURATION 3000
typedef void (*Demo)(void);
int demoMode = 0;
int counter = 1;
void setup() {
Serial.begin(115200);
Serial.println();
Serial.println();
// Initialising the UI will init the display too.
display.init();
display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);
}
void drawFontFaceDemo() {
// Font Demo1
// create more fonts at http://oleddisplay.squix.ch/
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.setFont(ArialMT_Plain_10);
display.drawString(0, 0, "Hello world");
display.setFont(ArialMT_Plain_16);
display.drawString(0, 10, "Hello world");
display.setFont(ArialMT_Plain_24);
display.drawString(0, 26, "Hello world");
}
void drawTextFlowDemo() {
display.setFont(ArialMT_Plain_10);
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawStringMaxWidth(0, 0, 128,
"Lorem ipsum\n dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore." );
}
void drawTextAlignmentDemo() {
// Text alignment demo
display.setFont(ArialMT_Plain_10);
// The coordinates define the left starting point of the text
display.setTextAlignment(TEXT_ALIGN_LEFT);
display.drawString(0, 10, "Left aligned (0,10)");
// The coordinates define the center of the text
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 22, "Center aligned (64,22)");
// The coordinates define the right end of the text
display.setTextAlignment(TEXT_ALIGN_RIGHT);
display.drawString(128, 33, "Right aligned (128,33)");
}
void drawRectDemo() {
// Draw a pixel at given position
for (int i = 0; i < 10; i++) {
display.setPixel(i, i);
display.setPixel(10 - i, i);
}
display.drawRect(12, 12, 20, 20);
}
void drawCircleDemo() {
for (int i=1; i < 8; i++) {
display.setColor(WHITE);
display.drawCircle(32, 32, i3);
if (i % 2 == 0) {
display.setColor(BLACK);
}
display.fillCircle(96, 32, 32 - i 3);
}
}
void drawProgressBarDemo() {
int progress = (counter / 5) % 100;
// draw the progress bar
display.drawProgressBar(0, 32, 120, 10, progress);
// draw the percentage as String
display.setTextAlignment(TEXT_ALIGN_CENTER);
display.drawString(64, 15, String(progress) + "%");
}
void drawImageDemo() {
// see http://blog.squix.org/2015/05/esp8266-nodemcu-how-to-create-xbm.html
// on how to create xbm files
display.drawXbm(34, 14, WiFi_Logo_width, WiFi_Logo_height, WiFi_Logo_bits);
}
Demo demos[] = {drawFontFaceDemo, drawTextFlowDemo, drawTextAlignmentDemo, drawRectDemo, drawCircleDemo, drawProgressBarDemo, drawImageDemo};
int demoLength = (sizeof(demos) / sizeof(Demo));
long timeSinceLastModeSwitch = 0;
void loop() {
// clear the display
display.clear();
// draw the current demo method
demosdemoMode;
display.setTextAlignment(TEXT_ALIGN_RIGHT);
display.drawString(10, 128, String(millis()));
// write the buffer to the display
display.display();
if (millis() - timeSinceLastModeSwitch > DEMO_DURATION) {
demoMode = (demoMode + 1) % demoLength;
timeSinceLastModeSwitch = millis();
}
counter++;
delay(10);
}
And with the example file the OLED on the lolin works.
I add those lines in the ESP3D.ino file:
#include "SSD1306.h"
#include "Wire.h"
SSD1306 display(0x3c, 5, 4);
And in void setup: (just to test if it works I add those lines)
display.init();
display.clear();
display.flipScreenVertically();
display.setFont(ArialMT_Plain_10);
display.drawString(0, 0, "Hello world");
the code compile successfully but there is nothing shown in the display.
Is there anywhere in your code that you are using pins 4 & 5? is there anything in your code that can affect the OLED function?
by the way I have added those lines also in the void loop:
but still the OLED display doesnt show anything.
I am lost...
The text was updated successfully, but these errors were encountered: