-
Notifications
You must be signed in to change notification settings - Fork 46
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
added support for EP0099 #5
Conversation
EP0099 is a stackable 4-channel relay hat that communicates with platforms via i2c interface. Manufacturer: 52pi Wiki page: https://wiki.52pi.com/index.php/DockerPi_4_Channel_Relay_SKU:_EP-0099
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed (or fixed any issues), please reply here with What to do if you already signed the CLAIndividual signers
Corporate signers
ℹ️ Googlers: Go here for more info. |
Codecov Report
@@ Coverage Diff @@
## main #5 +/- ##
=======================================
+ Coverage 63.2% 63.3% +0.1%
=======================================
Files 46 47 +1
Lines 4034 4069 +35
=======================================
+ Hits 2549 2574 +25
- Misses 1357 1364 +7
- Partials 128 131 +3
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm fine with committing as is or with optional changes, as you prefer.
ep0099/ep0099.go
Outdated
@@ -32,7 +32,7 @@ func New(bus i2c.Bus, address uint16) (*Dev, error) { | |||
|
|||
d := &Dev{ | |||
i2c: i2c.Dev{Bus: bus, Addr: address}, | |||
state: buildChannelsList(), | |||
state: [4]State{StateOff, StateOff, StateOff, StateOff}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the default so you can skip the whole line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this makes sense. will remove it.
I like this approach, I just don't see how to figure out which channel we're referring to in method type (r *Relay) Out(l gpio.Level) error {
_, err := d.i2c.Write([]byte{channel, byte(StateOn)})
r.state = StateOn
return err
} I've been learning a lot with this PR, maybe there's a way to figure out what channel would be without looping through Relays and comparing d to items in the array. Maybe this solution needs some more thinking. |
One last point: do you mind following the instruction at #5 (comment)? |
gohci |
Thanks! |
EP0099 is a stackable 4-channel relay hat that communicates with
platforms via i2c interface.
Manufacturer: 52pi
Wiki page: https://wiki.52pi.com/index.php/DockerPi_4_Channel_Relay_SKU:_EP-0099