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

Recorder: add clockinfo #2900

Merged
merged 9 commits into from
Aug 3, 2023
Merged

Conversation

bobrippling
Copy link
Collaborator

@bobrippling bobrippling commented Jul 23, 2023

This introduces a clockinfo for the recorder, to allow quick toggling of recording state.

Currently the pause icon is white (for a dark background) - I use drawImage({ ..., palette }) to alter this based on the g.theme, but I'd like the icon to highlight when the clock info is selected, like the step icon.

I can't see how the step icon does it though - it's a fixed image, which apps then draw just by passing to g.drawImage() - does it work by something like the icon is 1-bit and so drawImage uses the background or foreground colour as its palette?

@gfwilliams
Copy link
Member

Great idea, thanks!

Does Recorder really need its own category though given it only has one icon? Maybe it's better just as a member of Bangle.

Also, maybe if there is no widget (eg the clock face isn't loading widgets) we should just not create a clockinfo at all? I think return { name: "Bangle", items: [] } should do it. Currently if there is no widget it'll return Paused but I think if it's tapped on, it'll cause an exception. The whole recorder widget isn't great, a library would be better - but it's a bit of a hangover from how things used to be done.

I'd like the icon to highlight when the clock info is selected, like the step icon.

You need to make sure you create a 1bpp icon, ideally transparent, with white as the color of the icon itself. I think most clocks expect 24x24px too - that's what we do for other clockinfos and it should work fine... If there's any trouble post the image up and I can do it here

@bobrippling
Copy link
Collaborator Author

Does Recorder really need its own category though given it only has one icon? Maybe it's better just as a member of Bangle.

Also, maybe if there is no widget (eg the clock face isn't loading widgets) we should just not create a clockinfo at all? I think return { name: "Bangle", items: [] } should do it. Currently if there is no widget it'll return Paused but I think if it's tapped on, it'll cause an exception. The whole recorder widget isn't great, a library would be better - but it's a bit of a hangover from how things used to be done.

Ah yes, it's much nicer like that, and likewise with handling a missing widget - thanks!

a 1bpp icon, ideally transparent, with white as the color of the icon itself. I think most clocks expect 24x24px too - that's what we do for other clockinfos and it should work fine... If there's any trouble post the image up and I can do it here

Thanks - I believe I have it sorted but can't test on my watch - unable to write and I'm holding off resetting it in case you'd like to debug into the FW addr fail error

@gfwilliams
Copy link
Member

Thanks - let's wait until you can test nicely then - thanks for the help debugging storage

@bobrippling
Copy link
Collaborator Author

The 1-bit image did the trick, thanks again! I've made a small tweak to clock_info too, which helped debug a load issue (WIDGETS not being defined), happy to move to another PR if desired.


There's one problem: if a clock loads clock_info before it does Bangle.loadWidgets(), the user will never see the recorder clock info because WIDGETS doesn't exist at that point.

Out of the clocks that use both clock_info and widgets, only lcdclock loads widgets first, so all the other clocks won't see the recorder widget.

Clocks using `clock_info` & widgets
grep -l clock_info apps/*/*.js | xargs grep -El 'clock_info|Bangle\.loadWidgets'

To fix this I think would be difficult, we'd have to make it so clocks load clock_info after any widget loads, or somehow make the clock_info menu dynamic. What do you think?

We can't tell whether Bangle.loadWidgets() might be called later,
so assume it does, and handle the case where it hasn't been.
@bobrippling
Copy link
Collaborator Author

Sorted it - we always show the recorder clkinfo and if the widget's not present, the clock hasn't run Bangle.loadWidgets() but we just let the user scroll to another clkinfo.

@bobrippling bobrippling marked this pull request as ready for review July 31, 2023 20:54
@gfwilliams
Copy link
Member

Looks great, thanks! Is it worth putting in a PR for LCD clock to change it?

@gfwilliams gfwilliams merged commit 85ee76c into espruino:master Aug 3, 2023
1 check passed
@bobrippling bobrippling deleted the recorder-clockinfo branch August 3, 2023 11:31
bobrippling added a commit to bobrippling/BangleApps that referenced this pull request Aug 8, 2023
This matches the behaviour of other clocks, meaning any dependencies
between widgets and clock info is consistent

See also espruino#2900
bobrippling added a commit to bobrippling/BangleApps that referenced this pull request Aug 8, 2023
This matches the behaviour of other clocks, meaning any dependencies
between widgets and clock info is consistent

See also espruino#2900
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.

2 participants