-
Notifications
You must be signed in to change notification settings - Fork 196
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
feat(as7262): init driver for new device #592
base: dev
Are you sure you want to change the base?
Conversation
@JohnTrunix can you please make sure to add both an example for use and smoke test for this new device? Thank you! |
Well, I added an example and the smoketest. Workflow passes but without success:
As I contribute first time and also first time to some hardware related stuff can someone point out my problem(s):
Would be verry happy to get some insights on that issue, thanks! |
It is probably too large to work on an Arduino Uno. Try switching to a different board for the smoke test. |
Or just avoid using |
But this would mean, that in prod this feature wouldn't work with an arduino uno? |
The Arduino Uno has so little RAM that reflection is too big for it. Solution: don't use |
@JohnTrunix have you received the physical sensor for testing yet? |
No unfortunately not, hopefully in the middle of this week. Otherwise, I can test the driver at the end of September because I will be on vacation for two weeks. |
d18a337 fixes smoketest for arduino uno |
Short update: I have the sensor, but currently it's not working. I might have some bugs/errors in my drivers code. Will try to fix it in the next few days, but it will probably be end of September (holidays). |
Thanks @JohnTrunix looking forward to when you get this working. |
Well, after 10h+ I have gained a comprehensive understanding of the virtual registers and functionality of the sensor. I am now working on implementing all other features and configurations, this will probably take a while. If there is an urgency for a release, feel free to prioritize other PRs for the upcoming release cycle. |
@deadprogram or someone else, I'm hard stuck and would appreciate some help: Status: everything is implemented, config, led setup and one time read of a virtual byte register works Context: Reading a byte from the virtual register (implemented according to the pseudocode in the datasheet):
func (d *Device) readByte(reg byte) byte {
d.buf[0] = 0b00000000
for {
if d.writeReady() {
break
}
}
legacy.WriteRegister(d.bus, d.Address, WriteReg, []byte{reg})
for {
if d.readReady() {
break
}
}
legacy.ReadRegister(d.bus, d.Address, ReadReg, d.buf)
return d.buf[0]
} My test code reads the temperature register because it is only 1 byte in size (not like the light value registers which are 4 bytes long and have to be read 4 bytes ascending). This shows the error better, because otherwise the sensor gets stuck when reading the second byte of a light value. Test Code: ...
var (
i2c = machine.I2C0
sensor = as7262.New(i2c)
)
func main() {
i2c.Configure(machine.I2CConfig{Frequency: machine.KHz * 100})
sensor.Configure(true, 64, 17.857, 2)
//sensor.ConfigureLed(12.5, true, 8, true)
println("Starting ...")
for {
println("Value: ", sensor.Temperature())
time.Sleep(time.Millisecond * 800)
}
} So I have been debugging for the past week and have not been able to figure out why this error is occurring. As I mentioned earlier, my experience is very limited. Perhaps you guys have a better understanding or know where the problem might be. My guess is that this sensor is using a different I2C "style/flavour". |
Hey guys!
This is my first time contributing to an open source project. I have implemented a driver for the AS7262 according to the data sheet.
Note
adt7410 uses
"tinygo.org/x/drivers/internal/legacy"
so does as7262 but should work later in release with"tinygo.org/x/drivers"
Example:
adt7410.go on dev branch line 56-60
adt7410.go on release branch line 55-59
If you have any questions or feedback, please contact me! Thanks