warthog618 / gpio

A native Go library for Raspberry Pi GPIO
MIT License
123 stars 9 forks source link

Getting the pin number in the watcher handler #2

Closed depili closed 5 years ago

depili commented 5 years ago

Currently the Pin struct doesn't export a way of getting the pin number that caused to watcher handler to run.

This makes writing generic handlers impossible.

Adding a reader to the Pin struct for the internal pin value would make things way easier. Something like

func (pin *Pin) Pin() uint8 {
  return pin.pin
}

Another option would be to export the pin field, but then it would be possible to set that value externally.

warthog618 commented 5 years ago

True enough. Added Pin in 183f0efb.

depili commented 5 years ago

Thank you.