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