Skip to content
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

feat: modules gpio.Button and gpio.Switch #112

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

feat: modules gpio.Button and gpio.Switch #112

wants to merge 5 commits into from

Conversation

jensdrenhaus
Copy link
Member

@jensdrenhaus jensdrenhaus commented Nov 21, 2024

This brings the first "useful" feature to the project. See #6 for some discussions about the technique to use to manipulate the GPIO pins. I came up with an approach that allows to potentially use any of the discussed solutions within the model and make it configurable.
For now, there is only one such backend implemented, which is memory mapping dev/mem.

pkg/module/gpio/gpio.go implements the general modules
pkg/module/gpio/devmem.go implements the backend

  • Add unit tests
  • Tested on Raspberry Pi

Closes #6

With the current abstraction the backend implementations of the GPIO
module include business logic. The backend abstracted the button and
switch, not the GPIO operation. Thus, the code of the module itself are
just shallow pass-through modules and new backends would need to
implement the business logic of button and switch again.

This refactoring lifts the business logic into the actual functions of
the GPIO modules and changes the interface of the backend to only
abstract the pure GPIO operation.

Signed-off-by: Jens Drenhaus <[email protected]>
This mock implementation of a dutagent session, that is passed to
modules in the Run() method, can be used for modules' unit tests.

Signed-off-by: Jens Drenhaus <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement GPIO Module
1 participant