sqfmi / Watchy

Watchy - An Open Source E-Ink Smartwatch
http://www.sqfmi.com
MIT License
1.98k stars 332 forks source link

`watchySettings` struct is undocumented #136

Open tetsuo-cpp opened 2 years ago

tetsuo-cpp commented 2 years ago

Hey there, I was following the instructions here and noticed that Watchy no longer has a default constructor and instead takes a watchySettings. I ended up copying across a settings.h from one of the preset watch faces.

I'd be happy to make a PR for https://github.com/sqfmi/watchy-docs, but I figured I'd check with you in case you've already got something in-progress.

sqfmi commented 2 years ago

Thanks @tetsuo-cpp! A PR would be great, we're a little behind on documenting some of the recent changes.

JollyWizard commented 1 year ago

I believe this is going to create a problem with the current gallery examples.

Tried using the Kitty watch from the gallery (the only one my daughter desperately wanted), and it depends on the default constructor, but does not include any versioning info, so I couldn't figure out what to peg it to to work. Having other slow and compilation problems with both Arduino and platformio, so it's hard to narrow it all down. The removal of default constructor definitely put a break in the code base, though.

Please reinstate a default constructor or do a review of all gallery examples and post migration guidance.

Thanks.

meisterluk commented 1 week ago

I just want to add an explicit fix for people not that familiar with programming. If you want to get the example Rand_Pics running, follow the following instructions:

watchySettings has the following structure (acc. to Watchy.h):

typedef struct watchySettings {
  // Weather Settings
  String cityID;
  String lat;
  String lon;
  String weatherAPIKey;
  String weatherURL;
  String weatherUnit;
  String weatherLang;
  int8_t weatherUpdateInterval;
  // NTP Settings
  String ntpServer;
  int gmtOffset;
  //
  bool vibrateOClock;
} watchySettings;

So you need to instantiate it:

watchySettings mySettings{
    .cityID = "2778067",
    .lat = "47.066669",
    .lon = "15.45",
    .weatherAPIKey = "HERE-I-INSERTED-MY-API-KEY",
    .weatherURL = "http://api.openweathermap.org/data/2.5/weather?lat={lat}&lon={lon}&lang={lang}&units={units}&appid={apiKey}",
    .weatherUnit = "metric",
    .weatherLang = "en",
    .weatherUpdateInterval = 30, //must be greater than 5, measured in minutes
    .ntpServer = "pool.ntp.org",
    .gmtOffset = 0, //New York is UTC -5 EST, -4 EDT, will be overwritten by weather data
    .vibrateOClock = true,
};

The API key can easily be requested if you are registered at openweathermap.org. I did not try it out with an invalid API key. I inserted these lines in Rand_Pics.cpp just before the line //Ratfink Artsheet.

Furthermore I replaced this line …

RandPics::RandPics(){} //constructor

… with the following line:

RandPics::RandPics(): Watchy(mySettings) {} //constructor

Finally, I had to rename all four files with filename Rand_pics.h to Rand_Pics.h.

Afterwards I was able to click the “Compile” button in Arduino IDE and did not get an error anymore.