M5ez, a complete interface builder system for the M5Stack as an Arduino library. Extremely easy to use.



  • I can load other M5Stack examples but not those in the M5ez directory. Any idea? Thanks in advance!
    PS: Please forgive my bad English but I'm from Italy...



  • I think ( but i am a noob) that the location of your libraries are not right.

    Got multiple versions of the arduino ide installed ?

    C:\arduino-1.8.7\libraries\WiFi
    C:\arduino-1.8.7\hardware\espressif\esp32\libraries\WiFi
    C:\arduino-1.8.7\portable\sketchbook\libraries\M5ez\

    My best guess is to clean up other versions..... or update all versions on your system to m5ez 2.01



  • @crazyhorse80 Please don't apologise for being Italian, it happens in the best families :)

    The interesting thing is that some of these compiler warnings/errors are real. Sometimes a non-void function indeed returned nothing, some of the other errors are rather nitpicky. Thing is that my IDE never cared about these things: I had "Arduino / Preferences / Compiler Warnings" set to "Default". You must have it set higher. Naturally all of these errors need to be fixed in my code, and I will do so over the next few days and release 1.0.2. Until then, simply set "Compiler Warnings" to "None" and all will be good...

    (I have no idea what your undoubtably Italian version of the IDE calls "Arduino / Preferences / Compiler Warnings", but you'll figure it out...)

    Sorry for the inconvenience, my bad...



  • Thank you all for your replies. I have multiple versions of the Arduino IDE installed but they're all portable installations and they all run fine.
    I will change compiler configuration as suggested and I 'll let you know how it' ll do.
    PS: nice joke ;)



  • Setting compiler warnings to none made it load and execute. Thank you! I hope you can fix it soon 'cause I think it'll be the base for all my M5Stack sketches! ;)

    EDIT: The only thing I can't get working is OTA update... It stops at around 212kB for timeout every time, even near to the router. Is it supposed to actually work?

    EDIT 2: Are you planning to support multi language interface in near future? I think it would be great to have a simple way to change language something like themes, wouldn't it be?



  • @crazyhorse80 Good that it works now...

    OTA: The underlying "Upgrade.h" library is not very robust: it gives up too easily. I am planning to use functions from it but replicate the main loop in my own code and give it longer timeouts. Strange that it's at the same number of bytes though: I have it giving up at random points sometimes, more often when further from access point. But then some days it works fine.

    Multi-language: Depending on how it's done can make the code quite a bit bigger, and ayt a minimum needs printf statements with the variables as arguments to make up for different grammar structures. So that's quite a bit of work to stick in, but I'll place it on my list of possible features. (No clue how to do Mandarin or Right-To-Left languages or anything like that though. That will at least also involve providing the fonts, if Adafruit's gfx library even does things like that.



  • @rop: awesome project ;-)

    Question : how can I preconfigure wifi settings (ssid, pass) for my application on m5 without playing with ez.wifi.menu ??



  • @macle Depends on what you need. Are you mass-programming a bunch of devices? The easiest way is probably to add a bit of code to your program that does this. Haven't tested, but something like this should work:

    void setup() {
      ez.begin();
      [...]
      if (ez.wifi.indexForSSID("your-ssid") == -1) {
        ez.wifi.add("your-ssid", "your-key");
        ez.wifi.writeFlash();
      }
      [...]
    }
    

    (It's all here in the manual.)



  • @rop
    That should be
    ez.wifi.indexForSSID("your-ssid")
    ;)

    Can I ask if someone has already integrated a simple web server with your software? Could you point me to some easy example? Thank you!
    Basically I have an Arduino board sending GET requests to my M5Stack address and I need to decode the GET string and display some variable value on screen every time I got a new connection.



  • @crazyhorse80M5ez, a complete interface builder system for the M5Stack as an Arduino library. Extremely easy to use. 中说:

    @rop
    That should be
    ez.wifi.indexForSSID("your-ssid")
    ;)

    Whoops, so right... Fixed.

     

    Can I ask if someone has already integrated a simple web server with your software? Could you point me to some easy example? Thank you!
    Basically I have an Arduino board sending GET requests to my M5Stack address and I need to decode the GET string and display some variable value on screen every time I got a new connection.

    I haven't done this, but the new ez.addEvent feature (manual) allows you to put any code you want in the idle loop of M5ez. For example, if you were to use the WebServer library from Espressif, you would create a function that runs as part of the M5ez main loop, and from it call that library's server.handleClient() (you can't do that directly because the M5ez event functions must return a uint16_t number to indicate after how many ms they would like to be ran again.)



  • Thak you! I'll have a look at that.



  • @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!



  • @crazyhorse80

    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?

    Do you also have problems if you lookup the timezone from code (like with MyTZ.setlocation("Europe/Amsterdam")? Retries (and periodic refreshes) of timezone data are planned.

     

    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).

    You could remove the header widgets and create new ones if you want to use the existing space on the display. Or you can write your own code to create your own header on the canvas either in place of or below the existing header. I do not plan to include a second header line.

     

    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.

    I'm not sure I could do something that would be more informative than the clock code from M5ez.cpp. Let's walk through:

    • If the clock is set to be displayed, ezClock::restart() calculates the width of the widget (clock uses a fixed-width font) and does:
    ez.header.insert(RIGHTMOST, "clock", width, ez.clock.draw);
    
    • The draw routine that this points to simply clears the area and draws the text. Note that this gets x-position and width from the header code :
    void ezClock::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(tz.dateTime(_datetime), x + ez.theme->header_hmargin, ez.theme->header_tmargin + 2);
    }
    
    • This redraw routine is automatically called by the header code every time the header is redrawn and additionally every minute — from ezClock::loop() — which simply says:
    if (_on && ezt::minuteChanged()) ez.header.draw("clock");
    
    • The clock header item can be removed with
    ez.header.remove("clock");`
    

     

    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.



  • @ropM5ez, 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 with MyTZ.setlocation("Europe/Amsterdam")?

    I tried to put this line MyTZ.setlocation("Europe/Rome") in my setup() 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 from M5ez.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 named Widgets:

    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
    //
    //   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 and BBand.begin(); in my setup() 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...



  • @crazyhorse80

    I tried to put this line MyTZ.setlocation("Europe/Rome") in my setup() function, but I get an error:
    error: 'MyTZ' was not declared in this scope

    MyTZ has to be declared first. If you put Timezone MyTZ outside of any functions (in the "global scope") it should work.

    More generally: using objects from my libraries works because they are declared in the ezTime.h and M5ez.h files and then implemented in the respective .cpp files. I would stay away from creating your own objects at this point. You don't need them: simple functions within your own sketch would work and are easier to understand. Simply put the header.add in your setup() (after ez.begin()), and point to a regular void function that takes two uint16_t parameters for drawing the widget.

    (If you do want to use a class, you'll have to make it static, because otherwise you cannot point to the draw function. But really, just use a regular function.)



  • @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. ;)


登录后回复
 

与 M5Stack Community 的连接断开,我们正在尝试重连,请耐心等待