Hi Eugene,
I think it was from GitHub - eugenedakin/lgpio-GPIO: Wrapper uses the new C-language gpiochip functions for the Raspberry Pi
Though I see now that github renders the md file better.
But the major thing that needs improvement is error handling, and making the code smarter to handle the possible cases. E.g,: check if the handle is invalid and then warn the user. or even better: detect whether it’s a pi5 or older, and then set the open argument accordingly. Always add error checks in the demos, even if it’s just a break cmd with a comment, so that at least one sees something in the debugger if things are not working as expected.
The point is: If you provide a lib that does things (like here, the GPIO access), then your test program needs to be perfectly handling all cases. Leaving this to the user, i.e. figuring out all the pitfalls, is okay if you provide general examples where people learn from, but if it’s the only “example” project, it needs to handle all the cases because users will try to use that as a basis for their projects - users do not read docs, they use existing code and build on it
So, if your example is incomplete, you’re not doing them a favor.
I just bring that up because I had some frustrating experiences recently with some hardware add-ons for my Pi5: An LCD and a Thermal camera. The camera, for instance, had no foolproof example that I could simply run to check whether the camera works. Instead, I was expected to install libs, compile downloads from dubious sources, including override options that were supposed to “potentially break your python installation”. In the end, I had to send the $130 module back because I was not able to even run the demo, and I was not able to figure out whether it was because I made some errors installing the software or if simply the module was defective.
So, my point is: Provide at least one demo that is foolproof, which you can always ask people to run first if they contact you if something isn’t working in their opinion. Then you can ask them to run your example and if that works, you can tell them: use that demo as an example and compare it to what you did, and find your mistake. Without having that, anyone might assume that the error is not on their side but on yours, and then you’ll have much more work to prove them wrong
Oh, reading the README again, here’s some more practical improvements:
You show quite a few commands one has to execute on the Pi - it’s not good to list them with enumerations or as tables, because they’re hard to copy then. Instead, always put those code / cmd line into either `…` or lead them with 4 spaces. There’s no need to put numbers in front. Without the numbers, it’ll be easier to copy multiple line and paste them all at once into Terminal, for instance.
An example (I’m using ``` lines before and after the comds here to mark the entire block as code. Also always add an empty line before such blocks, as it’ll conform better with markdown):
Install instructions are:
sudo apt install swig python-dev python3-dev
sudo apt install python-setuptools python3-setuptools
wget http://abyz.me.uk/lg/lg.zip
Initialize the Raspberry Pi 4 lgpio
MyChipHandle = lgGpiochipOpen(0) //dev/gpiochip0 for Raspberry Pi 4 or older
I hope this helps.
Thomas