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

Add INPUT_PULLUP support on firmdata platform #728

Draft
wants to merge 1 commit into
base: dev
Choose a base branch
from

Conversation

disaster37
Copy link

@disaster37 disaster37 commented Feb 14, 2020

Add the availability to use INPUT_PULLUP on some GPIO driver:

  • button
  • direct_pin
  • makey_button
  • pir_motion_driver

INPUT_PULLUP on arduino is use to avoid to add some resistor when yous should to read the state of button.
When INPUT_PULLUP is enable, the signal is inverted, so the platform invert signal to be transparent for user.

Sample to use it with button driver:

func main() {
        firmataAdaptor := firmata.NewAdaptor("/dev/ttyACM0")
        button := gpio.NewButtonDriverDriver(firmataAdaptor, "13")
        err := button.SetInputPullup()
        if err != nil {
          panic("Not supported by plateforme")
        }
        work := func() {
                buton.On(gpio.ButtonPush, func(data interface{}) {
                  fmt.Printf("Button pushed")
                }
        }

        robot := gobot.NewRobot("bot",
                []gobot.Connection{firmataAdaptor},
                []gobot.Device{button},
                work,
        )

        robot.Start()
}

Button must be plug on input pin and in GND instead of 5v

Add the availability to use INPUT_PULLUP on some GPIO driver:
  - button
  - direct_pin
  - makey_button
  - pir_motion_driver
@disaster37
Copy link
Author

Hi,

there are some reason to not merge this PR ?

@gen2thomas
Copy link
Collaborator

gen2thomas commented Sep 19, 2022

@disaster37 thank you for your PR. IMO this is a nice new feature, so I will try to make some suggestions to get some progress.

  • please resolve conflicts by rebase to the current state of dev
  • please revert all changes made by "go fmt" in unrelated packages, because this leads to harder review
  • please revert the change in go.sum, if this is not important for the work of your new code
  • please provide a working example in "gobot/examples" instead of (or in addition to) the sample in your description, this will help future users

Maybe I have not understand the code quite correctly, but would it be better to add an option for each input instead of introducing a new implementation for DigitalRead(), e.g. by an interface with "SetPullUp(pin string, state bool)" and "IsInputPullup()"? In general this should be possible, because the "f.Board.Pins()[p].Mode" is used in both "DigitalRead()" and "DigitalReadInputPullup()".

Instead of "go fmt" in unrelated packages and adjust/cleanup of "go.mod/go.sum" you can add an issue (maybe there is one for "go fmt") or try to solve such general format errors by a separate PR.

Although I have no firmata adaptor tested yet, thanks again for this new feature! IMO this could be also useful for other boards.

@gen2thomas
Copy link
Collaborator

I will now revert the PR back to Draft as reference

@gen2thomas gen2thomas marked this pull request as draft December 8, 2022 18:53
@gen2thomas gen2thomas added maintainer wanted the implementation was started, but for some reason not finished and removed in review labels Dec 8, 2022
@gen2thomas gen2thomas deleted the branch hybridgroup:dev May 15, 2023 16:25
@gen2thomas gen2thomas closed this May 15, 2023
@gen2thomas
Copy link
Collaborator

accidentally closed - now reopen

@gen2thomas gen2thomas reopened this May 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintainer wanted the implementation was started, but for some reason not finished
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants