Replies: 6 comments 9 replies
-
My only word on this topic is caution to include any device implementations that are directly associated with the project. In the past Pi4J V1 codebase, many contributors were happy to contribute/add new device and/or chipset extensions to the project but this became problematic over time as issues would come in asking for support/assistance/instruction and the original author was no longer around to assist. Additionally there was no real method/strategy for the Pi4J project to properly test all the unique devices and expansion chipsets. I realize that we are not including these devices/extensions as part of the Pi4J V2 core repository, but if they are listed under the Pi4J organization, then I fear the same trouble will come along if these become unmanageable. I also do think its a good idea for the project to have a few (well supported) examples of commonly used devices and extensions/expanders to serve as examples for other developer. So I'm not against having some limited device support -- I just think we have to be careful and judicious here. My suggestion is to have each device/extension as a separate repository so that it can stand on it own and have its own place for instructions, issue tracking and support. I think having these as smaller independent repositories may also help to encourage users to contribute changes back when not having to deal with a large source tree/project. This may also encourage users to create and manage their own extensions outside of the Pi4J project. Lastly we could have a single repository whose sole intent is a location to aggregate and list Pi4J extensions. But it would be information only and provide links to the repository for each plugin project. I think generically speaking, all of the extensibility modules are called "PLUGINS". A
We may ultimately move some of the core plugins out of the core project as well -- that why I listed a few above. |
Beta Was this translation helpful? Give feedback.
-
PS .. I realize what is listed in https://github.com/Pi4J/pi4j-device-tca9548 are not currently built as Pi4J plugins. |
Beta Was this translation helpful? Give feedback.
-
I've been looking at these and I'm a bit confused. Let me explain my concrete case and we can take it from there. I'm using a CAP1166 chip which has various LED outputs on it (not so much of a problem). However, its key feature is that it is a capacitive touch sensor. What I want to achieve is a way of configuring the device and then being able to ask it to provide a DigitalInput object that I can do all the good things like add a listener to. I want to make it look as much like an ordinary DigitalInput as possible. What would be the best way to go about this? Should the CAP1166 object have a create method? How like the one that hangs of the Context object should this look like? Should be be on the default context object by adding in a new provider? How would that be done? Should it use a DigitalInputConfigBuilder? If so, where would it find one? In essence, I'm trying to determine the right way to plug this functionality into the Pi4J-v2 architecture. Any pointers would be most welcome! |
Beta Was this translation helpful? Give feedback.
-
I really like where this discussion is leading to :-) I have to admit I "pushed" @taartspi towards the example direction, but with the extra info given here by @savageautomate it is more clear now the framework really allows us to "extend" this further (and probably better) into the plugin direction. Summarized, a preferred approach would then take two paths:
I think for the examples, with the ongoing work of the FHNW students, we will have enough inside the GitHub project itself. Regarding the providers, it will indeed be a challenge to consider the documentation, testability, and support provided by the contributor to decide if we want to include this or refer to its own repository. A starting point to provide more info is available on https://pi4j.com/architecture/advanced/plugins/ but definitely will need more content. With the given info and if we fully take this approach, it would even make sense to make to move this to a main menu item with links to the own and external GitHub projects with a Pi4J plugin. |
Beta Was this translation helpful? Give feedback.
-
One of the things that i read out of this discussion, is that there is a requirement for logical devices. I.e. a touch sensor or some such. The pi4j core library currently only offers an API for buses or low level I/Os which are simple, on/off etc. Adding logical devices e.g. a touch sensor, or a display etc. should completely wrap these low level APIs and then expose an API to communicate with the logical device and not with DigitalInput or DigitalOutput. At least this is how i would like to work with these devices. This layering could then always be brought to the next level, so that then one could logically group multiple cap1166 devices if needed to provider some specific logical device. For instance when one has a picade, then one would want to detect if button 3 is pressed. Thus one would have a Picade object, and add a listener to button three:
this addListener method would then in turn add the listener to the real DigitalInput of the Pi4j core library. In my projects i work with a lot of MCP23017 devices. Here i would also have a logical MCP23017 device object, with which i would interface. It would then wrap the I2C bus and from a user of this API i would not need to use any pi4j I2C libraries. This is just my two sense and how i would like to interact with the API. What do you guys think? |
Beta Was this translation helpful? Give feedback.
-
Wow! These are much better answers than I could ever have hoped for! There's a lot to read and digest here. You mentioned the ability to have the plugins auto load. I'm unsure how that would work. How does the core system find all the plugins available and plug them in? Clearly it's added to the list of providers but I'm unsure how it would go from the named provider (e.g. In this specific case I'm much more inclined to have instantiating an object register the providers. There are two reasons for this. Firstly, the cap1166 is one of a family of devices and secondly they can have different I²C addresses. Perhaps it should have some sort of interface that for a given cap1166 (or other related device) you give it the I²C bus and address and that creates an instance. That instance might have a specific name, for example Note that I haven't mentioned outputs. That's because the outputs are more than pure digital. They can be set to on, off or pwm but there is only a single PWM value for all the outputs. It's quite a subtle chip! I think the outputs are better handled by some chip-specific methods to deal with this. |
Beta Was this translation helpful? Give feedback.
-
To bring back Pi4J to the "core", support for specific devices was removed from the library for V2.
Tom (@taartspi) created the project https://github.com/Pi4J/pi4j-device-tca9548 to illustrate how the Pi4J project still can provide device support, but as separate projects, not included in the "core".
He also created the below proposal which is a great piece of work I want to share here.
Please share your opinion on the best approach how to provide device support to the Pi4J V2 project.
Intro
Pi4J V1 had a large library of example devices. None of these were migrated to Pi4j V2.
A small sample of devices now exists in a separate Pi4J V2 git project, https://github.com/Pi4J/pi4j-device-tca9548. The intent was to create a set of examples that others would follow when they supplied more devices. These devices went through a review by some team members, comments were implemented with the exception of using ‘jcommand’ to parse user arguments. I decided jcommand was too ‘new’ to rely upon.
The following items are the remaining discussions to complete Example Devices.
Example Device Repository
Relocate the present examples. The current project name is incorrect as the contained devices have increased. Also later it will include ‘bus’ types other than I2C so various contexts will be required.
This device repo ‘repository’ should be separate from the pi4j_v2 product repo. The product repo carries with it an assumed level of testing that I believe will not exist as the number of donated example devices increases.
Minimal Requirements for Example Device
The device must use a data sheet for its implementation. The data sheet used should be documented in the README. If some registers or functions within a register are not implemented those details should be documented in the README. This requirement will result in some devices never being added, as not all manufactured willingly supply a data sheet.
Use the Maven build environment, matching the Pi4j V2.
The run.sh file using java --module-path .--module com.pi4j?????
Testing
This is more difficult to enforce. At the point in time, the device is ‘pulled’ into the repo the README examples serve as an initial test using the current level of Pi4J_V2 code. When a new version of Pi4J_V2 is released, it would be difficult to enforce all contributors to retest their devices. This fact being the main reason I stated the example device repo be separate from the product repo.
Beta Was this translation helpful? Give feedback.
All reactions