Code Monkey home page Code Monkey logo

Comments (6)

ropg avatar ropg commented on May 26, 2024

Hi Alan,

First of all: You shouldn't put the variable types in there. They are there in the definition of the functions to show what the function expects, but in the actual call to the function you leave them out.

Furthermore the clock is already built into M5ez, so you cannot create a header widget called "clock" (or "title" or "wifi" for that matter). To see the clock, simply get online with your app: the clock should on by default.

from m5ez.

meteosat007 avatar meteosat007 commented on May 26, 2024

Hi,

Ok yes can see that now.

I have the latest libraries in Arduino and have setup a very basic sketch with a header with my text in it and that loads into the unit and I see the dark blue header with the text I supplied but no clock or Wifi which is up and connected. Please what am I doing wrong here?

#include <M5Stack.h>
#include <M5ez.h>
#include <ezTime.h>
#include <WiFi.h>

const char* ssid = "Y";
const char* password = "***********";

const char* ntpServer = "de.pool.ntp.org";
const long  gmtOffset_sec = 3600;
const int   daylightOffset_sec = 0;

WiFiClient wifiClient;

void wifiConnect() {
    
  WiFi.begin(ssid, password);

  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
   // Serial.print("*");
  }

  Serial.print("WiFi connected: ");
  Serial.println(WiFi.localIP());

}
void setup() {
  Serial.begin(115200);
  
  //M5.begin();
  ez.begin();
  ez.header.show("Sullivan Control");

  wifiConnect();

 //init and get the time
  configTime(gmtOffset_sec, daylightOffset_sec, ntpServer);
  delay(1500);
}

void loop() {
  delay(1000);
}

Thanks Alan

from m5ez.

meteosat007 avatar meteosat007 commented on May 26, 2024

Ok so I have wifi bars in header, but still no clock. Do I need to begin the eztime or something else as the code below does not show a clock in header. :-(

  ez.header.show();
  ez.header.draw("clock");
  ez.header.draw("wifi");

from m5ez.

meteosat007 avatar meteosat007 commented on May 26, 2024

All sorted as it need a Canvas statement to make the clock appear...

Now to press on with the content.

Keep up the good work as it does make life easier now that I have the basics.
Maybe a small example in the examples section that shows the clock and wifi in the header?

Cheers Alan

from m5ez.

ropg avatar ropg commented on May 26, 2024

Hi Alan,

Take a look at the M5ez demo program. You'll see it does absolutely nothing special to get clock and wifi in the header: they just work. So no need to provide ntp server, the SSID/password or really anything at all. Note that the delay function doesn't do enough: If you did it the way you do, you would want to run ez.yield(). But try this sketch instead:

#include <M5Stack.h>
#include <M5ez.h>

void setup() {
  ez.begin();
  ezMenu sc("Sullivan Control");
  sc.addItem("Settings", ez.settings.menu);
  sc.addItem("Something else", something_else);
  sc.run();
}

void loop() {
  // only here to keep arduino compiler happy:
  // program never leaves setup() because sc.run() never exits
}

void something_else() {
  ez.msgBox("Something else", "Indeed", "OK");
}

You will mostly want some menu item or something that points to ez.settings.menu. That way you have access to the settings to get online or change the clock settings or whatever.

from m5ez.

ropg avatar ropg commented on May 26, 2024

(If you surround your sketch or example code with three backticks ( ``` ) on a line by themselves it will look nicer like in the edited posts above...) Let me know if you get stuck and I'll try to help.

from m5ez.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.