-
Notifications
You must be signed in to change notification settings - Fork 474
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
Set pixels as image, add show_bitmap_1d(), show_text() #121
Conversation
Ugh, I seem to have mixed tabs and spaces, sorry. If you have some cleanup I should run, happy to do this (I did not see a developer guide) - am used to running |
🤔 Having just displayed
I think I have this upside down, so my font map is upside down 🙄 Guess I should have done that first -> will revise. |
Avoid buffer overflow
d46d506
to
d17cd85
Compare
Turns out this is probably largely redundant having looked at https://github.com/pimoroni/scroll-phat-hd which would probably be a better API if ported (though still does not allow for a scrolling view across a larger buffer). Does contain a useful 5x7 font though (found in HackSpace issue 41) |
PR's - especially ones this thorough and well considered - are always welcome. Thank you! I'll have to give this a try, but I like what you're doing here. Your premise is solid - with "scroll" in the product name but not demonstrated in the software things feel a bit silly. It could be well worth baking the 5x7 font into the C++ library and adding functions for rendering text across an arbitrary length buffer. There are definitely differences of opinion when it comes to fonts, but I guess having one baked-in wouldn't prevent anyone from ignoring it and rolling their own. Given the relatively small memory overhead, maybe we could add a "scroll_text" function that just takes a text string, a speed and a loop count and just does the rest for you. It may be possible to render the text even on the fly and avoid a full-sized buffer altogether. |
@Gadgetoid thanks for the positive feedback - am working on adding in a C implementation of the font rendering I used in the Python code, so should see a commit added to the PR soon. Adding a Along these lines, I guess something for showing text (e.g. 14°C or whatever) in a non-scrolling manner would also be useful. May as well get all this done in one go. |
Derived from https://github.com/graeme-winter/rpi-pico/blob/main/font5x7/generate.py which in turn derives the character set from http://sdf.org/~kt8216/font5x7/unknown-small-5x7.txt which I will properly document in a follow-up README
@Gadgetoid I have added
It's not set to loop, as I figured you could do that externally if you wanted. It will scroll the text for an offset of However, this is probably in a good place for review now. |
Also fixed space assignment in font render
e2e78e8
to
4cafb30
Compare
For info, |
0-5 dice 1-6 2 x rectangle 2 x square smile / neutral / sad / confused top, bottom lines
I wanted to make this part of the GitHub workflow so we could enforce some consistency on the whole codebase... I know line endings have gone all awry at least. An initial tidy would probably be part of the commits adding that change and probably worth doing separately. Thanks for all the effort! I'll have a play with this now. |
D'oh I cannot for the life of me find a Pico Scroll Pack so I've put one on order and will get to this ASAP! |
🤣 |
Okay having got this up and running, it works great but it should be implemented in the C++ libraries so both C++ Pico SDK and MicroPython users can use it. I've done that for I've stubbed out This, in theory, should have no appreciable difference to Python users but makes this good stuff available to everyone else too. |
Okay that commit is stale now, I've force pushed to Gadgetoid@b3798cd which isn't quite so broken! |
Aaand again. I might have got carried away here - Gadgetoid@cc3e997 Crux of this is making everything use the same underlying utility function - Brings show_text (now set_text), show_bitmap_1d (now set_bitmap_1d) and set_pixels into the fold, too. |
I'll checkout your version a bit later... happy to see merged with C library |
Move scroll_text into the C++ library and make it support std::string. Move show_bitmap_1d to set_bitmap_1d in the C++ library. Use it as the basis for show_text and scroll_text. Change show_text to set_text since it does not implicitly show the result. Add a new pico-scroll demo to show off the scrolling text functionality.
Picked, built & run - seems to do the same things 🙂 Having in C++ API makes more sense but was not something I was in a position to test. How do you want to proceed with this now? Am happy to push the commit to this PR? |
Sure, you can push it to this PR- any way works for me. I had the scrolling text running on my desk for a day or so, rock solid. I'll have to see if it's pin compatible with 👀 pico wireless pack 👀. I merged the Matrix11x7 driver today and couldn't help but think all this code should probably be ported over. Will have to add that to The List. 😆 |
It's pushed - happy to see this be recycled as much as anyone likes! I only have the scroll top though |
Woohoo! Merged. Will get this out in a Python release ASAP! |
\o/ |
Preamble
I don't know how you folks feel about PR's - if this is not your game, I will not be offended if I see a close with no comments.
Proposed API extensions
Show images
Show images using a
set_pixels
method:seems convenient for cases where you want to redraw the image from one "frame" to the next, means all of the pixel value copying is done in C not Python/
Scroll bitmaps
Scroll bitmaps (one dimensional, e.g. text) using a
show_bitmap_1d
method:Detailed illustration in this gist
Motivation for second one: pico scroll did not offer a simple method to actually scroll text across the display, and I feel that this is pretty fundamental so decided to offer one. I wondered about adding the code to render the text to a bitmap to the API but decided on balance to keep things simple, as fonts are something people hold strong opinions about.
End product:
https://youtu.be/XIvKc523NwM
Will welcome any feedback here, I tried to stick to the "house style"