Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClockFace: add settings support #1893

Merged
merged 1 commit into from Jun 6, 2022

Conversation

rigrig
Copy link
Contributor

@rigrig rigrig commented May 27, 2022

The idea is you can specify a settingsFile in options, and it will be loaded directly into the clock object. (i.e. not inside a separate settings property, as I figured that only makes accessing settings more verbose.)

loadWidgets is special: it defaults to true, when false it prevents the call to Bangle.loadWidgets() (and we check if WIDGETS is loaded before calling drawWidgets()

showDate doesn't do anything special, but it does default to true

Also adds ClockFace_menu, although at the moment it only has two boolean menu options... Still cuts down on the boilerplate though.

@gfwilliams
Copy link
Member

Thanks! Merging, but...

I notice when using the settings, you do:

  const menu = {
    "": {"title": /*LANG*/"Bar Clock"},
    /*LANG*/"Show date": require("ClockFace_menu").showDate(s.showDate, saver('showDate')),
    /*LANG*/"Load widgets": require("ClockFace_menu").loadWidgets(s.loadWidgets, saver('loadWidgets')),
   // ...
  };

  E.showMenu(menu);

Do you think it would make sense to just have:

const menu = {
    "": {"title": /*LANG*/"Bar Clock"},
   // ...
  };
  require("ClockFace_menu").addMenu(menu, saver, { date:true, loadWidgets:true });
  E.showMenu(menu);

Then we keep all the names for menu items the same?

@gfwilliams gfwilliams merged commit 1a2d7a6 into espruino:master Jun 6, 2022
@rigrig
Copy link
Contributor Author

rigrig commented Jun 6, 2022

Do you think it would make sense to just have require("ClockFace_menu").addMenu(

Thanks, that's much cleaner. I will rewrite it to do that. (Good thing I didn't get round to converting a ton of clocks yet ;-)

@rigrig rigrig deleted the clockface-settings branch July 29, 2022 18:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants