Replies: 11 comments 4 replies
|
@taartspi @stefanhaustein I think this is a right fit for the pi4j-drivers project, correct? |
|
Yes. I read this over yesterday and was contemplating example versus driver. I think this goes into the driver repo (not sure if it is a new directory structure) and a usage example in example-devices/example |
|
I think these could also just be convenience methods added to the existing SenseHat class?
|
|
My response is lost in the github process of moving text to email. It
amounted to agreeing drivers and then demonstrate usage in examples
…On Mon, May 11, 2026 at 8:39 AM Stefan Haustein ***@***.***> wrote:
I think these could also just be convenience methods added to the existing
SenseHat class?
—
Reply to this email directly, view it on GitHub
<#633 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AK5A324LUS3U5OCSRDPYHNT42HJYXAVCNFSM6AAAAACYYAOTTCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTMOBXHE3DQMQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
|
Yes, keeping everything in the same class makes sense. I added a lot of stuffs: is only one class. but the PR will be a litle big The Gain ones it will requere a change in Class Tcs3400Driver
I can leave this for a second PR. And I need think about tests. |
|
Thanks! I am all for convenience, but let's not re-implement stuff that's already in drivers. For instance, why re-implement glyphs instead of using the BitmapFont? Ideally, looking at the convenience functions would teach users how to use the underlying APIs -- and ideally be as consistent with them as possible (rather than exactly matching python)? Also, I'd really prefer if we could do this incrementally, e.g. start with convenience calls for temperature, humidity etc. and take it from there by topic group? PS: Examples for using nearly everything in drivers can be found here: https://github.com/Pi4J/pi4j-example-devices/tree/master/src/main/java/com/pi4j/examples -- I'd really strongly recommend running the sense hat demo if you haven't yet. |
|
Thank you very much for the validation. Yes, I already refactored it using everything from BitmapFont instead of reinventing the wheel. I’ll also review the other parts to see if there is any additional duplicated logic. I’ll test everything properly, and yes, I can split the PR into smaller parts: Display thanks |
|
Maybe we should also take a step back and try to align on what we want here, so we have a better foundation for reviews:
Of course we could also do both |
|
Yes, we don't need reproduce Python, we want just some similar methods. My suggestion: Implementation priority:
I can split each number in one separated PR. |
|
PS: I am adding framebuffer read access in Pi4J/pi4j-drivers#122 |
|
Perhaps... Instead of implementing all scrolling logic directly inside SenseHat, I think it would be beneficial to introduce a reusable The SenseHat API would remain simple, while the scrolling implementation becomes reusable by other drivers and applications. MotivationCurrently, The scrolling logic includes:
None of this is really specific to the Sense HAT itself. Any Proposed APIMessageScroller.on(display)
.foreground(Argb32.RED)
.background(Argb32.BLACK)
.delay(Duration.ofMillis(75))
.direction(ScrollDirection.RIGHT_TO_LEFT)
.scroll("Hello");The senseHat.showMessage("Hello");which internally delegates to: MessageScroller.on(getDisplay())
.scroll("Hello");Or alternatively expose the scroller directly: MessageScroller scroller = senseHat.messageScroller();
scroller
.foreground(Argb32.GREEN)
.loop(true)
.start("Pi4J");Suggested Package
Containing:
FeaturesThe class could support:
Example: MessageScroller.on(display)
.foreground(Argb32.YELLOW)
.background(Argb32.BLACK)
.direction(ScrollDirection.LEFT_TO_RIGHT)
.delay(Duration.ofMillis(50))
.loop(true)
.start("Hello");Later: scroller.stop();Synchronous vs Asynchronous APII would suggest supporting both: Blocking: scroller.scroll("Hello");And non-blocking: scroller.start("Hello");
// ...
scroller.stop();This keeps the API flexible while remaining easy to use. Benefits
Possible Future ExtensionsOnce the scrolling logic is separated, it becomes straightforward to add features such as:
without adding more responsibilities to the |
Uh oh!
There was an error while loading. Please reload this page.
Hi everyone,
I’ve been working with the Raspberry Pi Sense HAT using Pi4J, and I noticed that while the current driver implementation is solid and modular, it differs quite a bit from the official Python Sense HAT API in terms of usability and developer experience.
In Python, the API is very high-level and convenient:
With Pi4J, this requires interacting with multiple lower-level components (display, sensors, joystick, etc.). That’s powerful, but less approachable—especially for users coming from Python.
Proposal
Introduce an optional high-level compatibility layer that mirrors the Python API, while keeping the current low-level drivers unchanged.
Example usage in Java:
Proposed Class Structure
The idea is to implement this as a thin wrapper over the existing SenseHat driver:
Main entry point
Display wrapper
Environment wrapper
Goals
Scope (initial PR)
Start small and incremental:
Then expand to:
Questions
Would this fit within the goals of Pi4J?
Should this live inside pi4j-drivers or as a separate module?
Any preference on naming (e.g. SenseHatCompat vs SenseHatApi)?
Would you prefer starting with a smaller PR (LED only)?
I already have a working draft implementation and can open a PR if this direction makes sense 👍
Thanks!
All reactions