-
Notifications
You must be signed in to change notification settings - Fork 0
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
Should record definitions be moved out of impl and into clj-bots.gpio ns? #2
Comments
So, my thinking was that the GPIOPin protocol is what's most important, the SysfsGPIOPin record is there as a means to keep all of the internal workings of the sysfs implementation together. At some point, I'm gonna take a swing at using JNA to bind directly to the C impl of the GPIO code which would get it's own record but impl the same GPIOPin protocol. Eventually, there will be some sort of function in clj-bots.gpio that will take care of what impl to use, I just haven't gotten around to researching/impling it. I figured I'd get enough done so that I could pop a repl on the BBB and start testing the sysfs impl. As for BBB/Pi specific stuff, the sysfs gpio code should be the same everywhere, so it should be it's own library. Once that gets ironed out and solidified, I figured there would be a BBB/Pi specific library that gives you all the device specific convenience functions, eg mapping the BBB "header_pin" strings to the actual underlying pin, functions for manipulating specific hardware (eg the onboard LEDs), etc. the BBB library is what would become "bonejure", with gpio as a dependency. Gotta think of a catchy name for the Pi Library. |
Oh, also, ideally, the end user of the lib will never need to know about SysfsGPIOPin or that it even exists, they would simply say "I want impl x" and they know they get a GPIOPin back. |
AAAAAAND one last thing. Regarding abstracting the underlying implementation. My thoughts were that the |
Absolutely agree on keeping separate records implementing the same protocol and having a function that dispatches on which record to use. However, there are problems with circular namespacing in clojure. Currently, the As for |
FWIW, I just pushed up a rough sketch of a |
My inclination would have been to do so, and leave only the nuts and bolts functions (
fopen
,fclose
,keyword-to-state
, etc) in theimpl
ns. My thought on this is that it would be nice to have a constructor function which either had an:impl
arg, or looked for some*default-implementation*
var (along the lines of thecore.matrix
set-current-implementation
function). We could of course keep thegpio
lib more bare bones, and leave these sort of niceties to the BBB and Pi specific libraries, but then we'd potentially be implementing the same stuff twice (assuming we or others get to Pi).Welcome your thoughts on this.
The text was updated successfully, but these errors were encountered: