periph / devices

Go·Hardware·Lean - Device drivers
https://periph.io
Apache License 2.0
85 stars 42 forks source link

added support for EP0099 #5

Closed cadusk closed 3 years ago

cadusk commented 3 years ago

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

googlebot commented 3 years ago

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).

:memo: Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

codecov-io commented 3 years ago

Codecov Report

Merging #5 (ccc1c29) into main (296894b) will increase coverage by 0.1%. The diff coverage is 82.9%.

Impacted file tree graph

@@           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     
Impacted Files Coverage Δ
ep0099/ep0099.go 82.9% <82.9%> (ø)
lepton/lepton.go 85.7% <0.0%> (-1.4%) :arrow_down:
as7262/as7262.go 98.0% <0.0%> (-1.0%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 296894b...ccc1c29. Read the comment docs.

cadusk commented 3 years ago

I like this approach, I just don't see how to figure out which channel we're referring to in method Out since we're passing the index to the array, not to dev.

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. I am happy with the results so far and am ok with merging it like this.

maruel commented 3 years ago

One last point: do you mind following the instruction at https://github.com/periph/devices/pull/5#issuecomment-775185342?

maruel commented 3 years ago

gohci

maruel commented 3 years ago

Thanks!