🤖Have you ever tried Chat.M5Stack.com before asking??😎
    M5Stack Community
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Register
    • Login

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

    PROJECTS
    22
    95
    606.8k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • C
      CrazyHorse80 @Rop
      last edited by

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

      RopR 1 Reply Last reply Reply Quote 0
      • RopR
        Rop @CrazyHorse80
        last edited by

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

        C 1 Reply Last reply Reply Quote 0
        • C
          CrazyHorse80 @Rop
          last edited by

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

          1 Reply Last reply Reply Quote 0
          • B
            BrianR
            last edited by

            @rop, M5ez is awesome - thank you for the enormous amount of time you put into it!

            I'm trying to use Blynk to receive events from another board. I have gotten events to show on the M5 in a simple standalone program, so I know it "works". Within M5ez, I believe I just need to call Blynk.run() with the ez.addEvent function, as Blynk.run needs to run often as possible - in most of my projects it's usually the only thing in the main loop, but I'm unsure of how/where to use the ez.addEvent function. There aren't any examples of ez.addEvent in the Demo or any of the other examples included with the library. Any help on syntax and where to put that statement?

            Thanks again for your time!!!

            RopR 1 Reply Last reply Reply Quote 0
            • RopR
              Rop @BrianR
              last edited by

              @brianr It depends on the rest of your program, but normally you would place it in setup(). Then make sure the event function returns 1 to run as often as possible. What that means is that you cannot provide Blynk.run() directly but must make your own function that runs Blynk.run() and returns a uint16_t of value 1

              This needs to be more convenient, I know. addEvent() needs another go-over, better documentation and examples, will put that on the list.

              B 1 Reply Last reply Reply Quote 0
              • B
                BrianR @Rop
                last edited by

                Ah yes, success! I added ez.addEvent(run_Blynk); to the setup(), and then created a function down below, after the loop, that looks like the following. It's worth noting that I'm using the M5 as a "receiver" from a bridge, thus the blynk_write(V1) statement.

                uint16_t run_Blynk() {
                  Blynk.run();
                  return 1;
                }
                
                BLYNK_WRITE(V1){
                    eventData = param.asString();
                }
                

                That did the trick, Blynk connects and stays connected. Now trying to figure out how to display the dynamic data from Blynk on the canvas. If I figure this all out, I'll write a short demo in a new topic for others, as I haven't seen many examples of actual use of M5ez, other than the demo program, but most projects are more than just menus, they have to display something... Again, @rop, excellent work, and thanks again so much!

                asalazaroA 1 Reply Last reply Reply Quote 0
                • B
                  bobolink
                  last edited by

                  I really like M5ez so I gave it its own core. Justified it by saying that’s real MVC architecture! Real Computer Science stuff.
                  /*


                  GLOBAL INFO
                  core 0 is the communications processor.
                  Uses the ESP-NOW protocol
                  on the 2.4 GHz radio
                  This process runs as a task created
                  on core 1
                  core 1 is the UI processor.
                  Maintains the M5Stack M5ez LCD menu
                  Runs Arduino setup() and loop()


                  */
                  Use RTOS semaphores when accessing the global vars to/from the local versions.

                  1 Reply Last reply Reply Quote 0
                  • M
                    macle
                    last edited by

                    Hello,

                    Is there a chance to change font (or size) of ez.header ?

                    Regards, M

                    1 Reply Last reply Reply Quote 0
                    • M
                      mawg
                      last edited by

                      Looks great! Does it play well with PlatformIO ?

                      1 Reply Last reply Reply Quote 0
                      • m5stackM
                        m5stack
                        last edited by

                        Great Job

                        1 Reply Last reply Reply Quote 0
                        • ajb2k3A
                          ajb2k3
                          last edited by

                          @Rop is M5EZ supporting the Stick C?
                          I have had a query from the Facebook group.

                          UIFlow, so easy an adult can learn it!
                          If I don't know it, be patient!
                          I've ether not learned it or am too drunk to remember it!
                          Author of the WIP UIFlow Handbook!
                          M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                          1 Reply Last reply Reply Quote 0
                          • RopR
                            Rop
                            last edited by

                            @ajb2k3

                            No it does not: it only works on the 3-Button M5Stack devices.

                            ajb2k3A 1 Reply Last reply Reply Quote 0
                            • ajb2k3A
                              ajb2k3 @Rop
                              last edited by

                              @rop Any intention of a stick version?

                              UIFlow, so easy an adult can learn it!
                              If I don't know it, be patient!
                              I've ether not learned it or am too drunk to remember it!
                              Author of the WIP UIFlow Handbook!
                              M5Black, Go, Stick, Core2, and so much more it cant be fit in here!

                              1 Reply Last reply Reply Quote 0
                              • asalazaroA
                                asalazaro @BrianR
                                last edited by

                                @brianr @rop Hey guys, thanks a lot for this very elegant solution, I´m using the ezMenu library in a program where I had installed Blynk working very well but everytime when I activated the ezMenu with mainmenu.run(); my Blynk app was very unstable, with the trick of ez.addEvent(run_Blynk) in the setup() function now is working very well, thanks for the help

                                1 Reply Last reply Reply Quote 0
                                • H
                                  hobo
                                  last edited by hobo

                                  Hi,
                                  great project.
                                  It is possible to use the face encoder for up, down and enter?
                                  if yes, you have an example?
                                  this will be great

                                  1 Reply Last reply Reply Quote 0
                                  • H
                                    hobo
                                    last edited by

                                    This post is deleted!
                                    1 Reply Last reply Reply Quote 0
                                    • G
                                      GSAL
                                      last edited by

                                      Hi,
                                      It is great using the M5EZ!
                                      But I want / need to give my Core a static IP address. Is there an easy way to alter the Wifi settings menu and add the option of adding static ip? Maybe In such a way it is stored in the preferences?

                                      kr, G

                                      1 Reply Last reply Reply Quote 0
                                      • K
                                        kilam
                                        last edited by

                                        Hi,
                                        I wanted to know if there is a way to use faces keyboard in the menus (i.e. I have the calculator keyboard and instead of using the three buttons to go up and down and select, I want to use the keys on the face, for example for selecting first line I will type on the key '1' and so on).
                                        and if it is possible, can you give me an example of code using it.
                                        Thanks

                                        1 Reply Last reply Reply Quote 0
                                        • A
                                          AndyT
                                          last edited by

                                          How do i get the characters for my region such as the pound sign £ ?

                                          1 Reply Last reply Reply Quote 0
                                          • First post
                                            Last post