-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[WIP] circlesclock: load circles from clkinfo #2251
Conversation
Just thinking out loud: Could clock_info be good for this? It's used in BWClock and LinuxClock. And for example SmplTmr provides clock_info, so maybe scheduler could/should be made to do that as well. Also there's this discussion #2226. Sorry, don't have a solution to your problem with the icon. |
Well, maybe. The thing is that I wrote this piece of code a while ago when clkinfo wasn't there yet. |
Yeah, it's the same for me as well ;) Good idea about adding timer! :) |
Anyway, I am still struggling with the icon: here's an example (you can try in the IDE) with the timer image I created (16x16, 1bbp, image string, inverted) and with another icon from circlesclock. Without colour they both look fine, but if I change colour the timer looks bad and doesn't even take the right colour (the code reproduces how images are rendered in the clock). const timerIcon = atob("EBAB/////+AH8A/zz/GP+B/8P/5//D/4H/AP8A/gB/////8=");
const pressureIcon = atob("EBCBAAAAAYADwAJAAkADwAPAA8ADwAfgB+AH4AfgA8ABgAAA");
function drawPics(icon, x) {
g.drawImage(icon, 0+x,0);
const colorTimerIcon = {
width: 16,
height: 16,
bpp: 1,
transparent: 0,
buffer: E.toArrayBuffer(icon),
palette: new Uint16Array(['#fff', g.toColor('#f0f')])
};
g.drawImage(colorTimerIcon, 16+x,0);
}
drawPics(timerIcon, 0);
drawPics(pressureIcon, 32); |
Hi - I think there are two issues here...
So this would work great if the images were converted 'uninverted'. But if you post up the source images I could do it for you. BUTI'm really not a fan of shoving loads of code into clock faces for extras. That's why we created For example, you should probably use the ... and then someone else will copy it into a new clock face and so on, and before we know it we have this not-quite-working code all over the place and it's a nightmare to fix. Also, as far as I can tell if you install https://banglejs.com/apps/?id=smpltmr then this functionality is already part of clock_info (and it deals correctly with the different states of alarms)... If you're dead set on not using clock_info, you should probably still copy the https://github.com/espruino/BangleApps/blob/master/apps/smpltmr/clkinfo.js code to get active timers So I guess is there a way we can modify clock_info to make it do what you need? For example as you're drawing these circles maybe we need to return the value as a number, and min/max values for each circle? |
This works how I'd expect now?
Yes, I think it probably should be. I can't remember 100% but I think it's probably because it's @peerdavid who really started using clock-info, and since the simpletimer app is his I think he just added the code in there to avoid messing with a 'default' app - but maybe we could look at moving it...
The existing docs are at the top of https://github.com/espruino/BangleApps/blob/master/modules/clock_info.js Right now we return an icon and text, but we could easily extend it without breaking anything to include a min/max and numerical value too... In fact I just pushed a change to add this. |
Hi,
exactly I added this to the simpletimer app as I was not sure if we want this in the default sched library. But I totally agree with you that it would fit better in the sched library in case we want this :) |
Well, I can have a check then, at least to implement it for the timer in this watchface. Thanks for fixing the icon, however if the clkinfo returns an icon too, that could even be easier (although this clock requires a 16x16, the 24x24 may be just too big). |
Yea I think moving the file from simpletimer to sched is enough :) |
It's a little trickier as the simple timer has just one single timer (and gets it through its id), I'm playing around to see what can I do with it. |
clock_info can return more than one item, so I guess it could sort them by the time until they'll fire, and then list them all, nearest first. So then you get one shown, but if you swipe you can cycle through others |
2c6745e
to
ae1bf1c
Compare
@glemco feel free to make your changes to circlesclock if you want to. So far your changes look fine for me. |
How's this looking now? Is it still a work in progress? |
Thanks @myxor , hope not to screw it up 😅 |
I am still struggling with the icons, right now I'm getting them from the clkinfo and it works fine for the bangle stuff, however the ones from the weather clkinfo don't really work.. they always get the background color and I cannot manage to change it const icon1 = atob("GBiBAf/D//+B//8Y//88//88//88//88//88//8k//8k//8k//8k//8k//8k//4kf/5mf/zDP/yBP/yBP/zDP/5mf/48f/8A///D/w==");
const icon2 = atob("GBiBAf/7///z///x///g///g///Af//Af/3Af/nA//jg//B/v/B/H+A/H8A+D8AeB8AcB4AYA8AYA8AYA+A4A/B4A//4A//8B///Dw==");
const icon3 = atob("GBiBAf4f//wP//nn//Pn//Pzg//nAf/meIAOfAAefP///P//+fAAAfAAB////////wAAP4AAH///z///z//nz//nz//zj//wH//8Pw==");
function drawPics(icon, y) {
g.reset().drawImage(icon, 0,y*24);
g.setColor('#f0f').drawImage(icon, 24,y*24);
}
g.setColor("#888").fillRect(0,0,512,512);
drawPics(icon1, 0);
drawPics(icon2, 1);
drawPics(icon3, 2); |
Is that true whatever theme you set/whatever the background color is? |
Well, they are invisible both on my bangle (dark theme) and on the emulator. I didn't try anything else but the clock is supposed to change their colour according to settings (e.g. each circle has its own colour) and I cannot manage that |
Just a note that you can use But it looks like the issue is that:
So I don't see how this could ever have worked properly :( I've just pushed a fix for that though! If it helps anyone else, you can fix it with this code.
|
BW Clock inverts the theme at some point. Maybe that's an explanation? |
Ahh, that might do it! Although I'd have thought that with clock_info either weather would work and all the others are broken, or the others would be work and weather would be broken. But maybe the icons were copied out of BW clock and not tested? |
Thank you both very much! Finally I'm starting to understand a little more about the image format. |
Yes - if you update weather using the development app loader that should be fixed though |
I put in this pull request only the modifications on circlesclock, in the meanwhile I changed something in some
|
This looks great, thanks! Sounds like a good plan about detecting items changing - but if it's a worry then we could add a
I think if this becomes a problem, maybe - however the idea of clock_info is to display the stuff in quite a small area (I'm using 50px wide in my tests at the moment) so hopefully all the infos will be designed not to be that wide. |
That would make sense too! Later on I should be checking those indicators more carefully.
Well, inside circles the text is really small (ideally just a number + measure unit), take the simple timer for instance: the timer value is given in the format Thanks for the feedback 👍 |
I'd be very happy if you wanted to do a PR to add an optional |
Great! I'll add it to the pipeline. |
Just a note that something came up in the forum about this, and it seems that these changes broke the HRM and probably anything that would auto-update: https://forum.espruino.com/conversations/382172/#comment16789739 I've made some big changes to try and strip out all the old code now and to just use the addInteractive function. It's not ideal, but I think at least it's a better staring point for it now. |
Well, it clearly did (and probably the same with other sensor-based data), but wouldn't it be cleaner if the clkinfo itself was managing the activation of the sensors? |
Well, it does if you use The issue is that some sensors (like HRM) don't have the data ready instantly - they have to go away and come back some time later. If you want to interface with the clock infos at a lower level than addInteractive, you have to tell them when they're visible, and when they're not, and respond to their requests to redraw. There's been a lot of work put in to ensure they handle everything else based on that. The real issue I see with what's done now is the colors are still per-circle, but now you can cycle through what gets shown. So I guess really the settings for color need to be per type of circle (eg, HRM, etc). |
Mmh I see, looks promising. I'd not mess up with it until the interface is stable then. |
One way around the specific problem with Quick Launch could be to add actions on double swipes in Quick Launch. That way you can reserve single swipe actions to the clock, although the clock would act on the first of the two swipes in that case. I have though about adding this to Quick Launch but haven't got around to it as I currently use Slope Clock which doesn't do anything on swipes. |
Yeah that could be an option too, but honestly I'd still prefer using swipes for Quick Launch. |
That delay has always existed, but maybe it's more noticeable now the clock draws first - the 'ring draw' algorithm just draws a gazillion circles, and takes 0.25 sec PER ring. If there are 3x full circles that ends up being 6x0.25 sec just to draw the rings! So really someone ought to change that - when this came up I'd actually posted a ring draw algorithm to the forum but if I change it and the rings a bit different someone will likely complain.
Normally, swiping has no effect on clock_info, it's only when you tap and focus one of the circles. Perhaps clock_info could set Or I believe when @peerdavid gets time he's planning to fix some outstanding issues with the clock_info in BW clock and then maybe add that code to clock_info itself, so when that happens maybe the code could be used here instead. I think clock_info is getting big enough that maybe it could be an item in the app loader in its own right, with a settings page. In that case, what appears in each element (and the mode of interaction) could be configured. |
Damn, never noticed! Or wouldn't it be better off implemented in the Graphics library itself, something like a
That looks neat. Can it be done with the current events interface or does it need an extension under?
Agree, also there's no way to update the clkinfo module (or any module) without updating the app itself using it, right? |
Simple view of the closest running timer in the clock.
I cannot figure out how to properly generate the icon though, I created a 16x16 image and converted in b/w but it only works if I don't set a colour, otherwise the picture is weirdly mirrored (I bet it has something to do with the size, any hint is appreciated).
TODO: