full-screen background image #1820
Replies: 28 comments
-
Posted at 2020-01-14 by @gfwilliams Nice! if you're after a bit more performance you might find it's better to write separate binary files for each 'slice' of the image. You can then load them directly without having to do atob. Not sure if you spotted it but there is already a way to get slices of image as well: https://github.com/espruino/EspruinoWebTools/blob/master/examples/imageconverter.html#L80 |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-14 by Andreas_Rozek Ah, thanks for the hints! Let me see, what I can do with this info! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-14 by JumJum Wow, great job !! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-14 by Andreas_Rozek thanks for the offer, but my problem is not the translation itself (DeepL already does a pretty good 80% translation), but to isolate text from markup before translation and adding markup properly afterwards). I'm working on it, but I only have little time... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-14 by JumJum @Andreas_Rozek |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-14 by Andreas_Rozek Very interesting... although the translation itself is horrible, it may indeed be "better than nothing". It is impressive to see how far Google gets with keeping the formatting - although I have not looked into the details with all my annotations, embedded code etc. It won't help me anyway as my pages are created automatically using my own kind of CMS and I will have to translate all the building block individually. Nevertheless, until then people may help themselves using this translator. Thanks for this hint! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-19 by Abhigkar Honestly, I had this idea before to use a full image as clock face. Since lack of actual Bangle device and a quick learning about low RAM took me down to drop the idea. After some time this idea again activated in my mind with a bit difference. So this time I split the 240x240 image into 16 slices with dimensions of 60x60 each and converted image to binary using image converter tool. Now the idea is to save each binary image file to storage, and draw all image once when face is initialized. 16 images will help to identify the segment of display to be updated on each minute and update only those image which is effected by the clock hands to be re-print. Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-19 by Abhigkar 16 images are just a max slices required for an asymmetric watch face, but the actual numbers of images can be reduces by re-using the same image on different screen position. Like corner images are same but just filliped and rotated. So one saved image can be used to get 4 different ways. It will save some space still having 16 segments of display.. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-19 by Abhigkar Here is an ugly but working example. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-19 by Robin Sun 2020.01.19 Nicely done @abhinav and a code block for others to emulate too! I have a feeling your technique will get used a lot!! |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-19 by Abhigkar Thanks @robin, I am still learning the BangleJs ecosystem. :) |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-20 by @gfwilliams Wow, nice! Just looking at that and your suggestion of rotating by 90 degrees each time, I guess there's even the possibility of having a small radial slice and rotating by 30 degrees each time? In terms of the big image, I added some code last week which should allow one single big image to be written to flash and rendered from there - but I've still got to add some tools to let you actually upload that image (and right now it won't work in the emulator because there is no concept of flash storage). |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-20 by Abhigkar Thanks @gfwilliams!! Yes possibilities are endless, however
I struggled to render the image with rotation if rotation angle is less. It does not render and sometimes result is a distorted image. See attachment.
This is great!! Where I can find this in source code? Another thing that I really like to have fake storage in emulator. so that read and write can be done via chrome storage that emulate the device storage. Is it possible??Attachments: |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-21 by Robin Mon 2020.01.20
Until Gordon is able to reply with a specific link, unless that reference was specific for the emulator which is in#2 post; the running list of updates location of all source code files It is much easier to navigate the source using VSCode and I had been given a tremendous amount of assistance getting started. Took me a bit to get going as can be seen from this thread, which may be used as an overview, should that choice be desired. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-21 by @gfwilliams When you specify a rotation, the image starts getting centered in the middle - so all you need to do is use some of the code used in other watchfaces with Faking flash storage in the emulator is possible, but it's low priority for me right now since there's more work to do to actually make the emulator 'remember'. Right now I'm interested in actually getting the real watch working well ready for next month :)
It should 'just work'. If you write an image into flash memory as an 'image string' (I'm working on some tools to do this nicely in the IDE) then you can just do |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-05-25 by FransM Got redirected here by Abhigkar I've been pondering at this as well. The solution I was thinking of is to restore only the display used by the hand (or by the graphic representing a digit). The latter is easier as the position of the hand is moving. Of course it is a bit less trivial as I sketched since we have two hands and they can be overlapping, but I hope you get the idea. How does this sound? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-05-25 by @allObjects Had outlined @FransM 's approach a while ago in a different conversation... even before background image support was made available... worst case - with a long hand it is still redrawing a quarter of the full image with axis-parallel, rectangular support only. Going a step further would require rectangular support of rectangles of any orientation... (Or triangles... that then allow any polygon to be handled). Partial redrawing (of background image) from the storage is though not sufficient to satisfy all requirements... because there are multiple hands and may be other dials 'in the face, over one another', like day of the month, moon-phase, etc. At one point it's getting to the point that each of the 'moving' / changing areas have to be updated and the updates have to be buffered. Just with three hands this makes easy more than 60 percent... of the full image... Therefore, it all depends, and a real solution is very dedicated to all what is going on in a watch's face. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-05-26 by @gfwilliams In recent builds I have added a function called It should go a long way towards making this much easier. Right now, the 'Image Clock' app exists which does a fullscreen background: https://github.com/espruino/BangleApps/blob/master/apps/imgclock/app.js And that works with a digital clock by just copying the area of the image where the clock is to an image stored in flash (The new In terms of update speed, it's a mix of things -the default path for rendering has to deal with multiple BPP, screen rotation, etc so has a lot of overhead. New firmwares are a lot faster though as there's a 'fast path' for common operations. In terms of an analog clock - I'd suggest using
Potentially you could even use a bounding box to redraw only what had changed... For hour/minute drawImages will be fine, but for second hand you may notice some lag from the redraw if you don't attempt to do something to restrict how much gets drawn. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-05-27 by FransM @allObjects updating 60% is of course not desirable. @gfwilliams To phrase it differently. Or, if I simplify the drawing of the clock hand to: Only pixels that are overwritten by the hand need to be restored. Does this sound feasible? edit: a possible call could be something like |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-05-28 by @allObjects
@FransM, great idea... almost like some IO (SPI?) protocol works: send bytes for no reason just to get the clock going and getting something back. Instead of drawing the pixels you say to draw, you pick the pixls from an image / buffer and put it to display. Redrawing the same with background or previous color works quite well. I used in http://www.espruino.com/ui | Modular and extensible UI framework and ui elements. - have to update that - and also when I tried to get a pac man game going - watch .mp4 clip... |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-05-28 by @gfwilliams
Right now, I don't think that's possible to do - but the extra computation is likely to outweigh the savings of not writing to the screen. It's not that slow drawing to the screen - it's the work that has to be done around that (eg loading the image from flash) that's the issue. If you want to do that your best bet is to just work out the area that was changed previously and use |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-05-31 by FransM I fear the amount of available memory will become the limiting factor. Also with a minute hand I might need 60 different images (unless there is rotational symmetry in the background in which case multiple hand backgrounds could use the same image to restore. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-05-31 by @allObjects it all depends... how you go for it. But yes, memory is a factor as well as the processing. Unfortunately, you can go only once every minute after the plain image in the store and for performance it is best to know the bounding boxes of your hands. Let's have a walk thru the sencarios:
You can optimize 14, 15 and 16 to draw overlaps of all three bounding boxes only once.... give most relieve for 2:07 and :08, 4:22 and :23, 7:37 and:38 and 10:52 and :53. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-06-01 by @gfwilliams
I'm not sure I understand... The code I'd posted above draws two clock hands over a solid background image. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-06-02 by FransM Rotate is quite ok for drawing the hand. I still feel it might be doable to restore background images based on the clock hand, if you have reasonably fast flash access and know where the picture data is (it does help if the data is stored continuously, so not having it scattered over the flash in different sectors; haven't studied the file system to see how the FS works). How much time do you think is needed to read a byte from flash at a given position? I'll see if I can come up with some pseudocode or C code to illustrate what I want, but it may be Friday or Saturday before I get to that. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-06-03 by @gfwilliams I think you need to post up some code - I'm really not understanding what you're after.
Honestly, the answer to all those questions is 'it depends'. The best thing to do is to benchmark. Flash memory is laid out intentionally such that everything is contiguous, so yes, you can just randomly access pixels if needed. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-06-03 by FransM Let me try to clarify. Of course one can rewrite the old background in full: expensive. Or, rephrasing the problem: Did I now express my problem better? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-06-04 by @gfwilliams
The code I'd posted a few posts back would do that, and the ability to restrict the bounds you draw to just the area including the old and new hands would get the redrawn area down to something sensible. Obviously it's not as efficient as something purpose built, but I feel it's 'good enough' and it's also really flexible. But the best way to explain is with an example, so here's an analog clock with an image background, no flicker, and that's fast enough to include a second hand: If someone feels like a fun project it'd be nice to use the 'customiser' from the background image clock (https://github.com/espruino/BangleApps/tree/master/apps/imgclock) and add it here, so we could have a single clock with multiple different backgrounds. I'm definitely up for ways to boost the performance of drawImage and drawImages (without increasing memory usage too much) though. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2020-01-14 by Andreas_Rozek
Good morning!
This morning I had some spare time with my Bangle.js and I managed to upload and display a bitmap with 240x240 pixels and 16-bit colours.
Upload takes a while, but I wrote a web form, that does all the hard stuff for you. Displaying the whole bitmap takes approx. 2.2 secs on my Bangle.js.
Now I have to find out, how to write only parts of such an image in order to make it fast enough to be used as a clock background...
Stay tuned...
P.S.: yes, sorry, those web pages are still in German - trouble with files simply took far more time than I expected. Sorry - but I haven't forgotten all those enthusiasts without thorough knowledge of the German language...
Beta Was this translation helpful? Give feedback.
All reactions