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

I2C result code #1780

Open
whaleygeek opened this issue Jan 4, 2019 · 0 comments
Open

I2C result code #1780

whaleygeek opened this issue Jan 4, 2019 · 0 comments

Comments

@whaleygeek
Copy link
Contributor

Is your feature request related to a problem? Please describe.
I want to write a scanner to identify which I2C addresses are available on the I2C bus, to confirm if my device is good.

Describe the solution you'd like
I want the last I2C error/ok result code stored in a last_i2c_result variable, so that each call to any I2C routine can then check if the transfer worked or failed

Describe alternatives you've considered
I hacked a version of the existing i2c_write routine to achieve this, code as below

function write(address: number, value: number, format: NumberFormat, repeated?: boolean): void {
    let buf = control.createBuffer(pins.sizeOf(format))
    buf.setNumber(format, 0, value)
    let res = pins.i2cWriteBuffer(address, buf, repeated)
    basic.showNumber(res)

}
basic.forever(function () {
    write(64, 0, NumberFormat.UInt8BE)
    basic.pause(250)
})

Additional context
The result code from i2c.read and i2c.write cpp routines is not returned in the .ts wrappers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants