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

proposal for a better i2c interface / sensors #45

Open
quinte17 opened this issue Dec 30, 2015 · 4 comments
Open

proposal for a better i2c interface / sensors #45

quinte17 opened this issue Dec 30, 2015 · 4 comments

Comments

@quinte17
Copy link

hey guys.

i like the idea of embd beeing a plattform for hardware guys ;)
but as much as i like the idea, when it comes to i2c i somehow dislike the interface used.
in my opinion https://github.com/davecheney/i2c has a much cleaner interface.
if you look at the example i implemented:
https://github.com/quinte17/bme280/blob/master/bme280.go
you might see what i mean.

  • sensors should not have the address hardcoded (bmp085). some sensors also support other addresses. for example the bme280 supports address 0x77 or 0x76. it depends on hw-configuration. the bus should handle the addressing.
  • many sensor registers are lined up. so you could read them all in one go.
  • use encoding/binary to transfer from []byte to a complicated struct

plz dont missunderstand this proposal. i just searched for an interface i could implement, so the sensor could be used in other places too. atm i only found embd as the only project. i believe my implementation doesnt fit well for embd.
just want to start some discussion...

yours

@tve
Copy link
Contributor

tve commented Sep 6, 2016

I don't understand "many sensor registers are lined up. so you could read them all in one go." in that you can read multiple sensor registers using:

// ReadFromReg reads n (len(value)) bytes from the given address and register.
func ReadFromReg(addr, reg byte, value []byte) error

@quinte17
Copy link
Author

quinte17 commented Sep 6, 2016

sry, my fault, I missed that one. havn't looked at all functions.

another question i have:
are there any plans to migrate to
https://github.com/golang/exp/tree/master/io/
?

@tve
Copy link
Contributor

tve commented Sep 9, 2016

I didn't know about that. What would the benefit be? It's not really clear to me who maintains that and what the plans are...

@quinte17
Copy link
Author

quinte17 commented Sep 9, 2016

Here is the thread which initially started this project.
https://groups.google.com/d/msg/golang-dev/ofaaIJPWRKg/5QuiOPlZBgAJ

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

No branches or pull requests

2 participants