I can confirm that : I use Arduino IDE and I also hear noise while communicating with WiFi. I also tried the dacwrite instruction without any success. I don't want to do a hardware mod but this is annoying...
CrazyHorse80
@CrazyHorse80
Posts made by CrazyHorse80
-
RE: So much noise!
-
RE: M5ez, a complete interface builder system for the M5Stack as an Arduino library. Extremely easy to use.
@rop I thought MyTZ object was already declared in your library, my fault.
Thank you for your explanation about objects. I misunderstood your previous directions and I thought I must use them to the widget to work. It seems it was a lot easier to do than that! The widgets I need to display are really simple, just a small text or icon reflecting the state of some variable's value, so I think a regular function will work. I'll try one more time. ;) -
RE: M5ez, a complete interface builder system for the M5Stack as an Arduino library. Extremely easy to use.
@rop 在 M5ez, a complete interface builder system for the M5Stack as an Arduino library. Extremely easy to use. 中说:
@crazyhorse80
Do you also have problems if you lookup the timezone from code (like withMyTZ.setlocation("Europe/Amsterdam")
?I tried to put this line
MyTZ.setlocation("Europe/Rome")
in mysetup()
function, but I get an error:error: 'MyTZ' was not declared in this scope
I also tried to setup TZ in the clock menu at runtime but I can't find the
/
character on onscreen keyboard...
I'm not sure I could do something that would be more informative than the clock code fromM5ez.cpp
. Let's walk through:[...]
Hope this helps, otherwise you'll have to tell me what is not working for you, or (better yet) show code that you are trying to make work.
I think I understood how the clock widget works, but I can't replicate it with my own widget code, here it is:
this is on a tab of its own namedWidgets
:////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // // B B A N D // ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// class ezBBand { public: static void begin(); static void restart(); static void menu(); static uint16_t loop(); static void clear(); static void draw(uint16_t x, uint16_t w); private: static void _writePrefs(); static bool _on; static bool _starting; }; bool ezBBand::_on; bool ezBBand::_starting = true; void ezBBand::begin() { Preferences prefs; prefs.begin("M5ez", true); // read-only _on = prefs.getBool("BBand_on", true); prefs.end(); ez.settings.menuObj.addItem("BBand settings", ezBBand.menu); ez.addEvent(ezBBand.loop); ezBBand.restart(); } void ezBBand::restart() { ez.header.remove("BBand"); uint8_t length; if (_on) { length = 2; ez.setFont(ez.theme->clock_font); uint8_t width = length * m5.lcd.textWidth("F") + ez.theme->header_hmargin * 2; ez.header.insert(ez.header.position("title") + 2, "BBand", width, ezBBand.draw); } } void ezBBand::menu() { bool on_orig = _on; while(true) { ezMenu bbandmenu("BBand settings"); bbandmenu.txtSmall(); bbandmenu.buttons("up#Back#select##down#"); bbandmenu.addItem("on|Display BBand\t" + (String)(_on ? "on" : "off")); if (_on) { } switch (bbandmenu.runOnce()) { case 1: _on = !_on; ezBBand.restart(); break; case 0: if (_on != on_orig) { _writePrefs(); } return; } } } uint16_t ezBBand::loop() { ezt::events(); if (_starting && timeStatus() != timeNotSet) { _starting = false; ez.header.draw("BBand"); } else { if (_on && ezt::minuteChanged()) ez.header.draw("BBand"); } return 250; } void ezBBand::draw(uint16_t x, uint16_t w) { if (_starting) return; m5.lcd.fillRect(x, 0, w, ez.theme->header_height, ez.theme->header_bgcolor); ez.setFont(ez.theme->clock_font); m5.lcd.setTextColor(ez.theme->header_fgcolor); m5.lcd.setTextDatum(TL_DATUM); m5.lcd.drawString("Fx", x + ez.theme->header_hmargin, ez.theme->header_tmargin + 2); } void ezBBand::_writePrefs() { Preferences prefs; prefs.begin("M5ez"); prefs.putBool("BBand_on", _on); prefs.end(); }
It should display the string
Fx
between WiFi and clock widgets (I'll modify that to display a string from a variable if I get it to work).
In my main tab (M5remDisplay) I put this:
ezBBand BBand;
as a global variable declaration andBBand.begin();
in mysetup()
function.This is a list of errors I got:
M5remDisplay:16:1: error: 'ezBBand' does not name a type ezBBand BBand; ^ C:\Users\Utente\AppData\Local\Temp\arduino_modified_sketch_422641\M5remDisplay.ino: In function 'void setup()': M5remDisplay:58:3: error: 'BBand' was not declared in this scope BBand.begin(); ^ Z:\_PVControl\M5remDisplay\Widgets.ino: In static member function 'static void ezBBand::begin()': Widgets:30:58: error: expected primary-expression before '.' token ez.settings.menuObj.addItem("BBand settings", ezBBand.menu); ^ Widgets:31:24: error: expected primary-expression before '.' token ez.addEvent(ezBBand.loop); ^ Widgets:32:12: error: expected unqualified-id before '.' token ezBBand.restart(); ^ Z:\_PVControl\M5remDisplay\Widgets.ino: In static member function 'static void ezBBand::restart()': Widgets:42:80: error: expected primary-expression before '.' token ez.header.insert(ez.header.position("title") + 2, "BBand", width, ezBBand.draw); ^ Z:\_PVControl\M5remDisplay\Widgets.ino: In static member function 'static void ezBBand::menu()': Widgets:58:18: error: expected unqualified-id before '.' token ezBBand.restart(); ^
Thank you for helping me and having so much patience...
-
RE: M5ez, a complete interface builder system for the M5Stack as an Arduino library. Extremely easy to use.
@Rop Hi! Could you consider some changes requests to M5ez?
-
I have some problem with Geo-IP timezone auto-select, it always timeouts and it's only executed once: could you, please, modify this function to retry if timeout occurs?
-
Could you make the actual header to be a "system" header (with title, WiFi and clock widgets) and add a "user" header so the user could put more widgets in it? I ask for this one 'cause I'm planning an app that will require to display few widgets and I have no pixels to show them all. (In case you're not planning to do that, I'll simply add my code to be displayed in the canvas space with a function of my own).
-
And now a more personal request: could you please make a dummy widget complete with all the code to associate a settings menu (with enable / disable widget setting) and the draw code. It'll be perfect if it will simply display a variable value and update every time the minute changes. I've tried to modify the clock widget but I didn't have success with that.
Thank you in advance!
-
-
RE: I need help with a webserver project...
Thanks for your help, I'll try to follow your directions in the following days.
-
RE: I need help with a webserver project...
@rop Here's what my full code looks like at the moment:
#include <M5Stack.h> #include <ezTime.h> #include <M5ez.h> #include <WiFi.h> #include <WiFiClient.h> #include <WebServer.h> #include <ESPmDNS.h> #include "images.h" #define MAIN_DECLARED WebServer rDserver(1980); byte remYear = 0; // Current PVControl server Year byte remMonth = 0; // Current PVControl server Month byte remDay = 0; // Current PVControl server Day byte remHour = 0; // Current PVControl server Hour byte remMinute = 0; // Current PVControl server Minute float GenE = 0; // Last Generated Energy float UseE = 0; // Last Consumed Energy float TtGE = 0; // Last to the Grid Energy float FtGE = 0; // Last from the Grid Energy int GenP = 0; // Last Generated Power int UseP = 0; // Last Consumed Power int NetP = 0; // Last Net Power void setup() { #include <themes/default.h> #include <themes/dark.h> ezt::setDebug(NONE); ez.begin(); if (ez.wifi.indexForSSID("xxx") == -1) { ez.wifi.add("xxx", "xxx"); ez.wifi.writeFlash(); } MDNS.begin("remdisplay1"); rDserver.on("/", handleRoot); rDserver.onNotFound(handleNotFound); rDserver.begin(); dacWrite(25,0); // Speaker mute ez.addEvent(serveClients, 3000); ezMenu mainmenu("remDisplay"); // mainmenu.txtSmall(); mainmenu.addItem("PVControl", remDisplay); mainmenu.addItem("Settings", mainmenu_image); // mainmenu.addItem("Updates via https", mainmenu_ota); mainmenu.upOnFirst("last|up"); mainmenu.downOnLast("first|down"); mainmenu.run(); } void loop() { } uint16_t serveClients() { rDserver.handleClient(); return 50; } void handleRoot() { for (uint8_t i = 0; i < rDserver.headers(); i++) { //debug only Serial.print(" "); Serial.print(rDserver.headerName(i)); Serial.print(": "); Serial.println(rDserver.header(i)); } for (uint8_t i = 0; i < rDserver.args(); i++) { //debug only Serial.print(" "); Serial.print(rDserver.argName(i)); Serial.print(": "); Serial.println(rDserver.arg(i)); } if(rDserver.args() == 7) { if((rDserver.argName(0) != "r") || (rDserver.argName(1) != "da") || (rDserver.argName(2) != "ti") || (rDserver.argName(3) != "v1") || (rDserver.argName(4) != "v2") || (rDserver.argName(5) != "v3") || (rDserver.argName(6) != "v4")) { rDserver.send(400, "text/plain", " Bad Request"); return; } else { rDserver.send(200, "text/plain", " OK"); remYear = atoi(rDserver.arg(1).substring(0,3).c_str()); remMonth = atoi(rDserver.arg(1).substring(4,5).c_str()); remDay = atoi(rDserver.arg(1).substring(6,7).c_str()); remHour = atoi(rDserver.arg(2).substring(0,1).c_str()); remMinute = atoi(rDserver.arg(2).substring(2,3).c_str()); GenE = atoi(rDserver.arg(3).c_str()); GenP = atoi(rDserver.arg(4).c_str()); UseE = atoi(rDserver.arg(5).c_str()); UseP = atoi(rDserver.arg(6).c_str()); NetP = GenP - UseP; // Last Net Power remDisplay(); } } else { rDserver.send(400, "text/plain", " Bad Request"); return; } } void handleNotFound() { String message = "File Not Found\n\n"; message += "URI: "; message += rDserver.uri(); message += "\nMethod: "; message += (rDserver.method() == HTTP_GET) ? "GET" : "POST"; message += "\nArguments: "; message += rDserver.args(); message += "\n"; for (uint8_t i = 0; i < rDserver.args(); i++) { message += " " + rDserver.argName(i) + ": " + rDserver.arg(i) + "\n"; } rDserver.send(404, "text/plain", message); } void mainmenu_image() { ezMenu images; images.imgBackground(TFT_BLACK); images.imgFromTop(40); images.imgCaptionColor(TFT_WHITE); images.addItem(sysinfo_jpg, "System Information", sysInfo); images.addItem(wifi_jpg, "Built-in wifi & other settings", ez.settings.menu); images.addItem(wifi_jpg, "WiFi Settings", ez.wifi.menu); images.addItem(about_jpg, "About remDisplay", about); images.addItem(sleep_jpg, "Power Off", powerOff); images.addItem(return_jpg, "Back"); images.run(); } void powerOff() { m5.powerOFF(); } void about() { ez.msgBox("About remDisplay", ""); } String exit_buttonrD = "Exit"; void remDisplay() { remDisplayPage1(); while (true) { String btn = ez.buttons.poll(); if (btn == "up") remDisplayPage1(); if (btn == "down") remDisplayPage2(); if (btn == "Exit") break; } } void remDisplayPage1() { const byte tab = 120; ez.screen.clear(); ez.header.show("PVControl (1/2)"); ez.buttons.show("#" + exit_buttonrD + "#down"); ez.canvas.font(&FreeSans9pt7b); ez.canvas.lmargin(10); ez.canvas.println(""); ez.canvas.print("Produzione:"); ez.canvas.x(tab);ez.canvas.print(GenP); ez.canvas.println(" W"); ez.canvas.x(tab); ez.canvas.print(GenE / 1000); ez.canvas.println(" kWh"); ez.canvas.print("Consumo:"); ez.canvas.x(tab); ez.canvas.print(UseP); ez.canvas.println(" W"); ez.canvas.x(tab); ez.canvas.print(UseE / 1000); ez.canvas.println(" kWh"); ez.canvas.print("Immissione:"); ez.canvas.x(tab); if(NetP > 0) ez.canvas.print(NetP); else ez.canvas.print("0"); ez.canvas.println(" W"); ez.canvas.x(tab); ez.canvas.println(" kWh"); ez.canvas.print("Prelievo:"); ez.canvas.x(tab); if(NetP < 0) ez.canvas.print(abs(NetP)); else ez.canvas.print("0"); ez.canvas.println(" W"); ez.canvas.x(tab); ez.canvas.println(" kWh"); } void remDisplayPage2() { const byte tab = 140; ez.screen.clear(); ez.header.show("PVControl (2/2)"); ez.buttons.show("up#" + exit_buttonrD + "#"); ez.canvas.font(&FreeSans9pt7b); ez.canvas.lmargin(10); ez.canvas.println(""); ez.canvas.print("Free RAM:"); ez.canvas.x(tab); ez.canvas.println(String((long)ESP.getFreeHeap()) + " bytes"); ez.canvas.print("Min. free seen:"); ez.canvas.x(tab); ez.canvas.println(String((long)esp_get_minimum_free_heap_size()) + " bytes"); }
It's only a part of what I want to achieve and here I'll try to explain what my project should do when it'll be complete:
every minute my M5Stack will receive from another Arduino board an HTTP GET request with data and it stores them in global variables and eventually does some operation with them;
it should have a multi-page view to show data received and stored in variables (one displays data in numeric form, another will display them in graphs, another one will only change screen background color and make some noise based on data received, and maybe some more);
it also should have access to the menus to change wi-fi and screen preferences and some more options related to my program (sound volume, default page to display on startup and so on).
I'd also like to have some more widgets:
one will have to show me if data received is older than one minute (it means I've lost connection with the Arduino board);
another one will have to show the current energy billing band based on what time and day of week it is.
The problem with M5ez, and ESP32 in general, is that I've no clue of where to put my code: do I have to do all in loop() function? Or should I register various functions with ez.addEvent()? Or should I do it some other way? I'm a bit confused... Can you show me a proof of concept application using M5ez (even if not related to my needs, so I could understand how it works)? -
RE: I need help with a webserver project...
I need the clock... :( I have that same error every 5 / 7 minutes, it restarts and works for a few minutes again and so on...
Maybe I can do some test without the clock to see if it is the cause of the problem... -
RE: Backticks... (Request to admins)
It should be good to explain how to use other tags, too (if any).
Thank you in advance! -
RE: I need help with a webserver project...
Could you please help me with this backtrace I got few moments ago?
PC: 0x400853e3: esp_log_write at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/log/log.c line 214 EXCVADDR: 0x00000000 Decoding stack results 0x400853e3: esp_log_write at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/log/log.c line 214 0x400f54d2: __assert_func at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/bootloader_support/src/bootloader_init.c line 537 0x4008de99: vTaskEnterCritical at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/freertos/portmux_impl.inc.h line 106 0x4008fd4b: multi_heap_internal_lock at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/heap/multi_heap.c line 372 0x400903d3: multi_heap_malloc at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/heap/multi_heap_poisoning.c line 190 0x400856b5: heap_caps_malloc at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/heap/heap_caps.c line 110 0x400857b9: heap_caps_realloc at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/heap/heap_caps.c line 275 0x4008586e: heap_caps_realloc_default at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/heap/heap_caps.c line 162 0x40087799: _realloc_r at /Users/ficeto/Desktop/ESP32/ESP32/esp-idf-public/components/newlib/syscalls.c line 47 0x400ead7a: String::changeBuffer(unsigned int) at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\cores\esp32\WString.cpp line 170 0x400eadc8: String::reserve(unsigned int) at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\cores\esp32\WString.cpp line 158 0x400eade9: String::copy(char const*, unsigned int) at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\cores\esp32\WString.cpp line 195 0x400eae23: String::String(char const*) at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\cores\esp32\WString.cpp line 39 0x400d8dfa: Timezone::dateTime(long, ezLocalOrUTC_t, String) at C:\Arduino-1.8.7\portable\sketchbook\libraries\ezTime\src\ezTime.cpp line 1164 0x400d9622: Timezone::dateTime(long, String) at C:\Arduino-1.8.7\portable\sketchbook\libraries\ezTime\src\ezTime.cpp line 1154 0x400d9801: Timezone::dateTime(String) at C:\Arduino-1.8.7\portable\sketchbook\libraries\ezTime\src\ezTime.cpp line 1150 0x400e1eb3: ezClock::draw(unsigned short, unsigned short) at C:\Arduino-1.8.7\portable\sketchbook\libraries\M5ez\src\M5ez.cpp line 973 0x400de59d: ezHeader::show(String) at C:\Arduino-1.8.7\portable\sketchbook\libraries\M5ez\src\M5ez.cpp line 184 0x400d2307: remDisplayPage1() at Z:\_PVControl\M5remDisplay/M5remDisplay.ino line 164 0x400d26ba: remDisplay() at Z:\_PVControl\M5remDisplay/M5remDisplay.ino line 152 0x400d2c13: handleRoot() at Z:\_PVControl\M5remDisplay/M5remDisplay.ino line 103 0x4017b6c1: std::_Function_handler ::_M_invoke(std::_Any_data const&) at c:\arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0/functional line 1871 0x400d5ee2: std::function ::operator()() const at c:\arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0/functional line 2271 0x400e9bdd: FunctionRequestHandler::handle(WebServer&, HTTPMethod, String) at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\libraries\WebServer\src\detail/RequestHandlersImpl.h line 42 0x400e9c2a: WebServer::_handleRequest() at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\libraries\WebServer\src\WebServer.cpp line 617 0x400e9d86: WebServer::handleClient() at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\libraries\WebServer\src\WebServer.cpp line 320 0x400d3a44: serveClients() at Z:\_PVControl\M5remDisplay/M5remDisplay.ino line 64 0x400dbb68: M5ez::yield() at C:\Arduino-1.8.7\portable\sketchbook\libraries\M5ez\src\M5ez.cpp line 1736 0x400dbbb4: ezButtons::poll() at C:\Arduino-1.8.7\portable\sketchbook\libraries\M5ez\src\M5ez.cpp line 612 0x400d26c2: remDisplay() at Z:\_PVControl\M5remDisplay/M5remDisplay.ino line 154 0x400d2c13: handleRoot() at Z:\_PVControl\M5remDisplay/M5remDisplay.ino line 103 0x4017b6c1: std::_Function_handler ::_M_invoke(std::_Any_data const&) at c:\arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0/functional line 1871 0x400d5ee2: std::function ::operator()() const at c:\arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0/functional line 2271 0x400e9bdd: FunctionRequestHandler::handle(WebServer&, HTTPMethod, String) at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\libraries\WebServer\src\detail/RequestHandlersImpl.h line 42 0x400e9c2a: WebServer::_handleRequest() at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\libraries\WebServer\src\WebServer.cpp line 617 0x400e9d86: WebServer::handleClient() at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\libraries\WebServer\src\WebServer.cpp line 320 0x400d3a44: serveClients() at Z:\_PVControl\M5remDisplay/M5remDisplay.ino line 64 0x400dbb68: M5ez::yield() at C:\Arduino-1.8.7\portable\sketchbook\libraries\M5ez\src\M5ez.cpp line 1736 0x400dbbb4: ezButtons::poll() at C:\Arduino-1.8.7\portable\sketchbook\libraries\M5ez\src\M5ez.cpp line 612 0x400d26c2: remDisplay() at Z:\_PVControl\M5remDisplay/M5remDisplay.ino line 154 0x400d2c13: handleRoot() at Z:\_PVControl\M5remDisplay/M5remDisplay.ino line 103 0x4017b6c1: std::_Function_handler ::_M_invoke(std::_Any_data const&) at c:\arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0/functional line 1871 0x400d5ee2: std::function ::operator()() const at c:\arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\tools\xtensa-esp32-elf\xtensa-esp32-elf\include\c++\5.2.0/functional line 2271 0x400e9bdd: FunctionRequestHandler::handle(WebServer&, HTTPMethod, String) at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\libraries\WebServer\src\detail/RequestHandlersImpl.h line 42 0x400e9c2a: WebServer::_handleRequest() at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\libraries\WebServer\src\WebServer.cpp line 617 0x400e9d86: WebServer::handleClient() at C:\Arduino-1.8.7\portable\sketchbook\hardware\espressif\esp32\libraries\WebServer\src\WebServer.cpp line 320 0x400d3a44: serveClients() at Z:\_PVControl\M5remDisplay/M5remDisplay.ino line 64 0x400dbb68: M5ez::yield() at C:\Arduino-1.8.7\portable\sketchbook\libraries\M5ez\src\M5ez.cpp line 1736 0x400dbbb4: ezButtons::poll() at C:\Arduino-1.8.7\portable\sketchbook\libraries\M5ez\src\M5ez.cpp line 612 0x400d26c2: remDisplay() at Z:\_PVControl\M5remDisplay/M5remDisplay.ino line 154