M5ez, a complete interface builder system for the M5Stack as an Arduino library. Extremely easy to use.
-
@bobolink There is now an
include_file
script (here) in the/tools
directory of the M5ez repository. If you get it, make it executable withchmod a+x include_file
and run it with a file as an argument, like:your_prompt$ ./include_file settings.jpg Converting input file: settings.jpg Creating include file: settings_jpg.h
That include file then contains:
#pragma once // // Include this file to use settings.jpg (1087 bytes) in your sketch. // // File created on Thu Aug 16 11:39:50 CEST 2018 // Made by the include_file script that is part of // "M5ez: the easiest way to program on M5Stack." // https://github.com/ropg/M5ez // const char settings_jpg[] PROGMEM = { 0xff, 0xd8, 0xff, 0xe0, 0x00, 0x10, 0x4a, 0x46, 0x49, 0x46, 0x00, 0x01, 0x01, 0x00, 0x00, 0x60, 0x00, 0x60, 0x00, 0x00, 0xff, 0xe1, 0x00, 0x8c, 0x45, 0x78, 0x69, 0x66, [...] snip [...] 0x35, 0xf4, 0x0a, 0x6e, 0x75, 0x6b, 0x92, 0xab, 0xf6, 0x8b, 0x8d, 0x91, 0x79, 0x3e, 0x50, 0x8e, 0x30, 0xbb, 0x49, 0x90, 0x03, 0xff, 0xd9 };
Once this file is included, you can then provide the
settings_jpg
as the first argument toez.addItem
if you are adding an item to an image menu. -
@rop Thank you. I’ll check it out.
I think this is HexWorkshop mentioned above. .EXE for Windows. -
Avesom work @Rop .
Still waiting for NTC/RTC time issue... ;-) -
@janseta I am loosely thinking about adding:
- NTP time and also an inactivity power-off
- A settings menu with
- link to the wifi menu
- NTP on/off, which server(s) and sync interval
- clock display in header on/off
- display backlight brightness
- FACES keyboard support on/off
- Setting up the M5Stack peripherals (which GPIOs etc)
But everything I add adds code size. So there probably there will be a few more code blocks like the present
#ifndef M5EZ_WITHOUT_WIFI
to allow people to not compile what they do not need.But before I get to this I need to figure out why the
.setTimeout
method does not seem to affect the https transfers for the firmware because they timeout way too often.Everyone: please feel free to suggest new features or tell me what you think about the proposed ones above.
-
@rop Finally got around to trying the image converter script--works great. Thanks again.
I have a windows 7 machine for HexWorkshop but ...I need to center the image I'm using but I should be able to figure that out.
Also, new a version of your library showed up in the Arduino-IDE library check! Automagically.
-
@bobolink As to centering the images: I can put it anywhere, but have no easy way (that is without linking in a ton of code) to figure out how high or how wide a jpg is. I could provide an image offset in x and y, but that would probably make most sense if it was settable per image. You could always just center them in Photoshop / Gimp / etc...
-
Hi @Rop
I wonder if you could help me.
I am really looking forward to using M5ez but unfortunately I'm having problems compiling the examples and I'm getting persistent errors relating to any instance of println
This is a snippet of the error messages
Arduino: 1.8.5 (Mac OS X), Board: "M5Stack-Core-ESP32, QIO, 80MHz, Minimal SPIFFS (Large APPS with OTA), 921600, Debug"
In file included from /Users//Documents/Arduino/libraries/M5ez/examples/M5ez-demo/M5ez-demo.ino:2:0:
/Users//Documents/Arduino/libraries/M5ez/src/M5ez.h:42:27: error: 'TFT_TRANSPARENT' was not declared in this scope
#define PRINT_DEFAULT_COL TFT_TRANSPARENT
^
/Users//Documents/Arduino/libraries/M5ez/src/M5ez.h:117:104: note: in expansion of macro 'PRINT_DEFAULT_COL'
void print(String text, int16_t x = -1, int16_t y = -1, const GFXfont* font = NULL, uint16_t color = PRINT_DEFAULT_COL);
^
/Users//Documents/Arduino/libraries/M5ez/src/M5ez.h:42:27: error: 'TFT_TRANSPARENT' was not declared in this scope
#define PRINT_DEFAULT_COL TFT_TRANSPARENT
^
/Users//Documents/Arduino/libraries/M5ez/src/M5ez.h:118:106: note: in expansion of macro 'PRINT_DEFAULT_COL'
void println(String text, int16_t x = -1, int16_t y = -1, const GFXfont* font = NULL, uint16_t color = PRINT_DEFAULT_COL);
^
/Users//Documents/Arduino/libraries/M5ez/examples/M5ez-demo/M5ez-demo.ino: In function 'void submenu_more()':
M5ez-demo:51: error: call to 'void M5ez::println(String, int16_t, int16_t, const GFXfont*, uint16_t)' uses the default argument for parameter 5, which is not yet defined
ez.println("");
^
M5ez-demo:52: error: call to 'void M5ez::println(String, int16_t, int16_t, const GFXfont*, uint16_t)' uses the default argument for parameter 5, which is not yet defined
ez.println("ezMenu menu("Main menu");");
^
M5ez-demo:53: error: call to 'void M5ez::println(String, int16_t, int16_t, const GFXfont*, uint16_t)' uses the default argument for parameter 5, which is not yet defined
ez.println("menu.addItem("Option 1");");
^
M5ez-demo:54: error: call to 'void M5ez::println(String, int16_t, int16_t, const GFXfont*, uint16_t)' uses the default argument for parameter 5, which is not yet defined
ez.println("menu.addItem("Option 2");");
^
M5ez-demo:55: error: call to 'void M5ez::println(String, int16_t, int16_t, const GFXfont*, uint16_t)' uses the default argument for parameter 5, which is not yet defined
ez.println("menu.addItem("Option 3");");
^
M5ez-demo:56: error: call to 'void M5ez::println(String, int16_t, int16_t, const GFXfont*, uint16_t)' uses the default argument for parameter 5, which is not yet defined
ez.println("while ( menu.run() ) {");
^
M5ez-demo:57: error: call to 'void M5ez::println(String, int16_t, int16_t, const GFXfont*, uint16_t)' uses the default argument for parameter 5, which is not yet defined
ez.println(" if (menu.pick == 1) {");
^<<<<AND SO ON WITH THE OTHER PRINTLN CALLS >>>>>>
Looks like I'm missing something from my environment but any ideas?
Many thanks
-
@btmp 在 M5ez, a complete interface builder system for the M5Stack as an Arduino library. Extremely easy to use. 中说:
'TFT_TRANSPARENT' was not declared in this scope
That is the problem here. Strange...
With me that #define comes with the M5Stack library, as part of the display driver, in the file .../Arduino/libraries/m5stack/src/utility/In_eSPI.h on line 373. I have version 0.2.2 of that library.
-
So....that file wasn't actually there on my system.
A lesson in keeping up to date for me there.
All compiles now.
Really nice piece of work, especially like the OTA update functionality.
Thanks for the help. -
@rop
Hi Rop,
I see you worked hard with the clock in ezTime library...
I wonder what will be the next step...Will you merge M5ez with ezTime?
Will they be independent works?
Will M5ez call the functions of ezTime?¯_('-')_/¯
-
@janseta If you have ezTime and turn on the clock (it'll be a
#define
), M5ez will use ezTime to show an on-screen clock. And naturally if you include it in your own sketch you can use the features of it in your own code as well. Soon... -
Hi everyone,
I just released version 1.3.1 of M5ez: it can now use images from program flash, SD-card and SPIFFS in image menus.The documentation says how, and there's an example that shows it in action.
-
Hi Rop,
I finaly found some time and as non programmer i did manage to use your code and make it talk mqtt just copy and pasted some code from you and the pubsub lib and it does work.
Below the code i used to control my domoticz setup thru mqtt :
I had to make some adjustment to PubSubClient.h and made some values higher like socket timeout, max packet size and degraded version.
So i guess it isnt that hard after all. To make sure you understand that i am a compete noob and dont even know what language i have been copy and pasting.Next try will be to use the ezProgressBar and let that drive the dimmer based on pb.value. But that will be a real challenge for me as copy and paste coder.
adjustment to PubSubClient.h:
#define MQTT_SOCKET_TIMEOUT 60
#define MQTT_MAX_PACKET_SIZE 1024
#define MQTT_VERSION_3_1 3Now the code below runs fine sofar ( 15 mins or so )
#include <M5Stack.h> #include <M5ez.h> #include <WiFi.h> #include <PubSubClient.h> const char* ssid = "xxxxxx"; const char* password = "xxxxxxxxxxx"; const char* mqttServer = "xxxxxxxxxxxxxx"; const int mqttPort = 1883; const char* mqttUser = "xxxxxxxxxxxxxxxxt"; const char* mqttPassword = "xxxxxxxxxxxxxx"; WiFiClient esp32Client; PubSubClient client(esp32Client); long lastMsg = 0; char msg[50]; int value = 0; void setup() { Serial.begin(115200); WiFi.begin(ssid, password); while (WiFi.status() != WL_CONNECTED) { delay(500); Serial.println("Connecting to WiFi.."); } Serial.println("Connected to the WiFi network"); client.setServer(mqttServer, mqttPort); while (!client.connected()) { Serial.println("Connecting to MQTT..."); if (client.connect("esp32Client", mqttUser, mqttPassword )) { Serial.println("connected"); } else { Serial.print("failed with state "); Serial.print(client.state()); delay(2000); } } m5.begin(); } void loop() { ezMenu myMenu("Main menu"); myMenu.addItem("lamp bank aan", mainmenu_one); myMenu.addItem("lampbank uit", mainmenu_two); myMenu.addItem("dimmer keukenlamp", mainmenu_three); myMenu.run(); } void mainmenu_one() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 136, \"switchcmd\": \"On\", \"level\": 100}"); Serial.println("mqtt send"); } void mainmenu_two() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 136, \"switchcmd\": \"Off\", \"level\": 0}"); Serial.println("mqtt off send"); } void mainmenu_three() { ezMenu subMenu("Submenu"); subMenu.addItem("Keuken off", submenu_off); subMenu.addItem("Dim 10%", submenu_one); subMenu.addItem("Dim 20% ", submenu_two); subMenu.addItem("Dim 30%", submenu_three); subMenu.addItem("Dim 40%", submenu_four); subMenu.addItem("Dim 50%", submenu_five); subMenu.addItem("Dim 60%", submenu_six); subMenu.addItem("Dim 70%", submenu_seven); subMenu.addItem("Dim 80%", submenu_eight); subMenu.addItem("Dim 90%", submenu_nine); subMenu.addItem("Dim 100%", submenu_ten); subMenu.addItem("Back | Back to main menu"); subMenu.upOnFirst("last|up"); subMenu.downOnLast("first|down"); subMenu.run(); client.loop(); } void submenu_one() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 143, \"switchcmd\": \"Set Level\", \"level\": 10}"); Serial.println("mqtt send"); } void submenu_two() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 143, \"switchcmd\": \"Set Level\", \"level\": 20}"); Serial.println("mqtt send"); } void submenu_three() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 143, \"switchcmd\": \"Set Level\", \"level\": 30}"); Serial.println("mqtt send"); } void submenu_four() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 143, \"switchcmd\": \"Set Level\", \"level\": 40}"); Serial.println("mqtt send"); } void submenu_five() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 143, \"switchcmd\": \"Set Level\", \"level\": 50}"); Serial.println("mqtt send"); } void submenu_six() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 143, \"switchcmd\": \"Set Level\", \"level\": 60}"); Serial.println("mqtt send"); } void submenu_seven() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 143, \"switchcmd\": \"Set Level\", \"level\": 70}"); Serial.println("mqtt send"); } void submenu_eight() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 143, \"switchcmd\": \"Set Level\", \"level\": 80}"); Serial.println("mqtt send"); } void submenu_nine() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 143, \"switchcmd\": \"Set Level\", \"level\": 90}"); Serial.println("mqtt send"); } void submenu_ten() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 143, \"switchcmd\": \"Set Level\", \"level\": 100}"); Serial.println("mqtt send"); } void submenu_off() { client.publish("domoticz/in", "{\"command\": \"switchlight\", \"idx\": 143, \"switchcmd\": \"Off\", \"level\": 0}"); Serial.println("mqtt send"); }```
-
@rop
I’m completing my first project using M5ez/M5stack. A remote control.
I would like to indicate two things on a menu, the current state of the remote equipment and the next state (that will become the current state when the “select” button is pressed and a ESP-Now message is sent/acknowledged).
The next state is your select item black cursor line with reverse text but people might think that is the current state of the remote equipment—if they forget to press “select”. I could automatically send the message after dwelling on a selection after a few seconds like a tv remote. But I’d like to make them explicitly press “select” with this remote equipment.
I now indicate current state by putting it as the first item on the menu and using bold text but a green check mark ✅ or dot ⚫️ would be more assertive. Unless I’m overlooking a better method.
Thanks again for M5ez.
@bobolink -
I am failing hard on the progressbar, is there any other pointer or example people could share.
I have been reading for a few days, but i just dont get it.
I am not sure about pb.value(float val)
i want to add or distract 10 on a button push, but i am failing hard.
if (btnpressed == "up") break; else (btnpressed == "left"); { pb = pb + 10; ; } if (btnpressed == "right"); { pb = pb + 10; }
Would be nice to abuse the progressbar for things like volume or dimmer status and if any one has a pointer. thanks in advance.
-
@Rop
Ouch!
I forgot M5EZ blocks!
Doesn’t lend itself to a controller at all.
Starting over. -
Okay i can get some value in to pb now and raise it once with + 10 by pushing a button and then i stall.
void add(){ ezProgressBar pb ("Dimmer", "Dims te kitchen light", "LEFT#UP#RIGHT"); pb.value(val); while (val <= 101 && val >= 1 ) { String btnpressed = ez.getButtons(); if (btnpressed == "UP") loop(); if (btnpressed == "LEFT") { pb.value(val - 10);} if (btnpressed == "RIGHT") { pb.value(val + 10); } } }
but i am not giving in until i got this running.
Any one that can give this noob some pointers ? It doesn't have to be a fixed solution but after some days of learning i am kind of blinded
-
@r_255 Whoops... I just noticed yesterday that progressBar is broken in that it can only go up, not down. Expect a fix with the all new M5ez 2.0, out as soon as I am done. (It's 85% there, a few days more...)
2.0 will also have backlight setting, a clock in the header bar as well as definable header widgets and the ability to register functions to be part of M5ez's idle loop.
-
Thats good to know, so it could be that it isnt me... Learned a lot the past days! Thanks
Still have some issues on loosing connection over time, but not sure if that is me or the m5stack. Am i the only one ?
PS: backlight dimming would be nice on a ProgressBar, if it isnt to much work.
-
@bobolink
I solved the blocking issue by putting the UI on one core and the communications (esp-now) on the other.