Core2 and M5Unified display no longer works
-
Wow,
I have uploaded the standard M5Unified Button code to my M5Core2.
I know the program is running because my serial.print shows button counts.
But the display shows nothing.
I have tried this on multiple Core2 of which I know the display is not defect. All boards and libs are updated (as fwr as i know).
What am i doing wrong here?
Thanks#include <M5Unified.h> void setup(void) { M5.begin(); Serial.begin(115200); /// For models with EPD : refresh control M5.Display.setEpdMode(epd_mode_t::epd_fastest); // fastest but very-low quality. if (M5.Display.width() < M5.Display.height()) { /// Landscape mode. M5.Display.setRotation(M5.Display.getRotation() ^ 1); } } void loop(void) { M5.delay(1); M5.update(); //------------------- Button test /* /// List of available buttons: M5Stack BASIC/GRAY/GO/FIRE: BtnA,BtnB,BtnC M5Stack Core2: BtnA,BtnB,BtnC,BtnPWR M5Stick C/CPlus: BtnA,BtnB, BtnPWR M5Stick CoreInk: BtnA,BtnB,BtnC,BtnPWR,BtnEXT M5Paper: BtnA,BtnB,BtnC M5Station: BtnA,BtnB,BtnC,BtnPWR M5Tough: BtnPWR M5Atom M5AtomU: BtnA M5Stamp Pico/C3/C3U: BtnA */ static constexpr const int colors[] = { TFT_WHITE, TFT_CYAN, TFT_RED, TFT_YELLOW, TFT_BLUE, TFT_GREEN }; static constexpr const char* const names[] = { "none", "wasHold", "wasClicked", "wasPressed", "wasReleased", "wasDeciedCount" }; int w = M5.Display.width() / 5; int h = M5.Display.height(); M5.Display.startWrite(); /// BtnPWR: "wasClicked"/"wasHold" can be use. /// BtnPWR of CoreInk: "isPressed"/"wasPressed"/"isReleased"/"wasReleased"/"wasClicked"/"wasHold"/"isHolding" can be use. int state = M5.BtnPWR.wasHold() ? 1 : M5.BtnPWR.wasClicked() ? 2 : M5.BtnPWR.wasPressed() ? 3 : M5.BtnPWR.wasReleased() ? 4 : M5.BtnPWR.wasDecideClickCount() ? 5 : 0; if (state) { M5_LOGI("BtnPWR:%s count:%d", names[state], M5.BtnPWR.getClickCount()); M5.Display.fillRect(w*0, 0, w-1, h, colors[state]); } /// BtnA,BtnB,BtnC,BtnEXT: "isPressed"/"wasPressed"/"isReleased"/"wasReleased"/"wasClicked"/"wasHold"/"isHolding" can be use. state = M5.BtnA.wasHold() ? 1 : M5.BtnA.wasClicked() ? 2 : M5.BtnA.wasPressed() ? 3 : M5.BtnA.wasReleased() ? 4 : M5.BtnA.wasDecideClickCount() ? 5 : 0; if (state) { M5_LOGI("BtnA:%s count:%d", names[state], M5.BtnA.getClickCount()); M5.Display.fillRect(w*1, 0, w-1, h, colors[state]); Serial.println(M5.BtnA.getClickCount()); } state = M5.BtnB.wasHold() ? 1 : M5.BtnB.wasClicked() ? 2 : M5.BtnB.wasPressed() ? 3 : M5.BtnB.wasReleased() ? 4 : M5.BtnB.wasDecideClickCount() ? 5 : 0; if (state) { M5_LOGI("BtnB:%s count:%d", names[state], M5.BtnB.getClickCount()); M5.Display.fillRect(w*2, 0, w-1, h, colors[state]); } state = M5.BtnC.wasHold() ? 1 : M5.BtnC.wasClicked() ? 2 : M5.BtnC.wasPressed() ? 3 : M5.BtnC.wasReleased() ? 4 : M5.BtnC.wasDecideClickCount() ? 5 : 0; if (state) { M5_LOGI("BtnC:%s count:%d", names[state], M5.BtnC.getClickCount()); M5.Display.fillRect(w*3, 0, w-1, h, colors[state]); } state = M5.BtnEXT.wasHold() ? 1 : M5.BtnEXT.wasClicked() ? 2 : M5.BtnEXT.wasPressed() ? 3 : M5.BtnEXT.wasReleased() ? 4 : M5.BtnEXT.wasDecideClickCount() ? 5 : 0; if (state) { M5_LOGI("BtnEXT:%s count:%d", names[state], M5.BtnEXT.getClickCount()); M5.Display.fillRect(w*4, 0, w-1, h, colors[state]); } M5.Display.endWrite(); } #if !defined ( ARDUINO ) && defined ( ESP_PLATFORM ) extern "C" { void loopTask(void*) { setup(); for (;;) { loop(); } vTaskDelete(NULL); } void app_main() { xTaskCreatePinnedToCore(loopTask, "loopTask", 8192, NULL, 1, NULL, 1); } } #endif
-
The problem is caused by a line in your code that sets the display to "EPD mode," which is only for e-paper (e-ink) displays. The M5Core2 uses an LCD screen, not an e-paper screen.
This line:
M5.Display.setEpdMode(epd_mode_t::epd_fastest);
is not compatible with the M5Core2 screen.
To fix the issue:
Remove or comment out that line from your code.
After doing this, the display should start working normal
-
Hello @HappyUser
hmm, the button sample code works fine as it is for me. Tested with M5Core2 and M5Core2 v1.1.
For reference: I was using Arduino library v3.2.1, M5Unfied v0.2.8 and M5GFX v0.2.13.
@henryCharm : you are correct, the line
M5.Display.setEpdMode(epd_mode_t::epd_fastest);
is only used / required for ePaper however it is simply ignored on non ePaper displays. So yes, it would be cleaner to remove the line, but I don't think it does any harm. I think the reason it is there is so that the example works on different M5Cores.Thanks
Felix -
@felmue said in Core2 and M5Unified display no longer works:
Arduino library v3.2.1,
Dear all.
Thanks
@Felix : what do you exactly mean with Arduino library v3.2.1,?
My settings:
Arduino IDE 2.3.6
M5GFX : 0.2.13
M5Unified 0.2.8
Arduino ESP32 Boards 2.0.18M5Core2 display stays black. I have tried the same software on an M5Stick. Display also stays Black,
Software is running. Serial.print also shows the correct display dimensions.
Tried the software on a M5CoreS3 and the display is responding!!
Tried the software in M5Core2 AWS link text. and the display is responding!So apparantly for the M5Core2 and M5Stick I am missing something. M5CoreS3 works like expected?
Anyone a clue?
I am really grateful.(*As i noticed that the height and widt of the screen are correcty read and the buttons appear to be working, could it be that the backlight is just off?. Mind you, i have ttried on several devices so it is not a failure of one device *)
-
@HappyUser
Further research
Tried the default M5GFX Bargraph example (attached)
No display on M5Stick and M5COre2
Works perfect on M5StickCPlus and M5CoreS3This is realy weird.
I hope someone can help#include <arduino.h> #include <M5GFX.h> M5GFX display; //#include <M5UnitOLED.h> //M5UnitOLED display; // default setting //M5UnitOLED display ( 21, 22, 400000 ); // SDA, SCL, FREQ //#include <M5UnitLCD.h> //M5UnitLCD display; // default setting //M5UnitLCD display ( 21, 22, 400000 ); // SDA, SCL, FREQ //#include <M5UnitGLASS2.h> //M5UnitGLASS2 display; // default setting //M5UnitGLASS2 display ( 21, 22, 400000 ); // SDA, SCL, FREQ // #include <M5AtomDisplay.h> // M5AtomDisplay display; static constexpr size_t BAR_COUNT = 64; static int max_y[BAR_COUNT]; static int prev_y[BAR_COUNT]; static uint32_t colors[BAR_COUNT]; void setup(void) { display.init(); display.startWrite(); display.fillScreen(TFT_BLACK); if (display.isEPD()) { display.setEpdMode(epd_mode_t::epd_fastest); } if (display.width() < display.height()) { display.setRotation(display.getRotation() ^ 1); } for (int x = 0; x < BAR_COUNT; ++x) { prev_y[x] = display.height(); max_y[x] = display.height(); int r=0,g=0,b=0; switch (x >> 4) { case 0: b = 255; g = x*0x11; break; case 1: b = 255 - (x&15)*0x11; g = 255; break; case 2: g = 255; r = (x&15)*0x11; break; case 3: r = 255; g = 255 - (x&15)*0x11; break; } colors[x] = display.color888(r,g,b); } } void loop(void) { int h = display.height(); static int i; ++i; display.waitDisplay(); for (int x = 0; x < BAR_COUNT; ++x) { int y = (h>>1) - (sinf((float)((x-24)*i) / 3210.0f) + sinf((float)((x-40)*i) / 1234.0f)) * (h>>2); int xpos = x * display.width() / BAR_COUNT; int w = ((x+1) * display.width() / BAR_COUNT) - xpos - 1; if (max_y[x]+1 >= y) { max_y[x] = y-1; } else { if ((i & 3) ==0 ) { display.fillRect(xpos, max_y[x]-3, w, 1, TFT_BLACK); max_y[x]++; } } display.fillRect(xpos, max_y[x]-3, w, 3, TFT_WHITE); if (prev_y[x] < y) { display.fillRect(xpos, prev_y[x], w, y - prev_y[x], TFT_BLACK); } else { display.fillRect(xpos, y, w, prev_y[x] - y, colors[x]); } prev_y[x] = y; } display.display(); }
-
Hello @HappyUser
I mean this arduino library.
Maybe this article helps.
Note: I am using Visual Code (and not Arduino IDE).
Thanks
Felix