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

JavaScript: Add I2C support #259

Merged
merged 13 commits into from
Oct 20, 2024
Merged

Conversation

jamisonderek
Copy link
Contributor

@jamisonderek jamisonderek commented Oct 12, 2024

What's new

  • Adds the ability to interact with I2C devices (pins 15/16) using APIs for isDeviceReady, read, write and writeRead.
  • Sample script uses inexpensive AT24C32 EEPROM for API demonstration (used in some SAO badges)
  • Sample script writes some data at EEPROM address 0x0000, reads from 0x0001 and continues reading from 0x0004.

For the reviewer

  • I've uploaded the firmware with this patch to a device and verified its functionality
  • I've confirmed the bug to be fixed / feature to be stable

Copy link
Member

@Willy-JL Willy-JL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll get the arraybuf changes implemented myself, other feedback needs some discussion 😄

applications/system/js_app/modules/js_i2c.c Outdated Show resolved Hide resolved
applications/system/js_app/modules/js_i2c.c Outdated Show resolved Hide resolved
applications/system/js_app/modules/js_i2c.c Outdated Show resolved Hide resolved
applications/system/js_app/modules/js_i2c.c Outdated Show resolved Hide resolved
applications/system/js_app/modules/js_i2c.c Outdated Show resolved Hide resolved
applications/system/js_app/modules/js_i2c.c Outdated Show resolved Hide resolved
Copy link
Member

@Willy-JL Willy-JL left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jamisonderek let me know what you think of the changes I made and please check if still works correctly (i dont have i2c devices to test), then if all is ok we can merge.

thanks!

@jamisonderek
Copy link
Contributor Author

image

Works great, thanks for the improvements! I also verified it works using the Uint8Array as well for the tx data.

  • i2c.write(addr, Uint8Array([0x00, 0x00, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47]));
  • let data_buf = i2c.writeRead(addr, Uint8Array([0x00, 0x01]), 3, 100);

@Willy-JL Willy-JL merged commit e682b6b into Next-Flip:dev Oct 20, 2024
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants