sparkfun / SparkFun_Toolkit

Toolkit of common functionality for use within SparkFun Libraries
https://docs.sparkfun.com/SparkFun_Toolkit/
MIT License
2 stars 0 forks source link

Add writeWord writeBlock #34

Closed edspark closed 3 months ago

edspark commented 4 months ago

This adds two new functions that target the same functionality as writeByte(): writeWord() and writeBlock(). The intent is to be able to send data over I2C without indexing to a register. This is helpful in the case where the device simply expects I2C commands over I2C. Examples of this include products like the new Ultrasonic Distance Sensor, Quad Relay, Qwiic Twist, Qwiic RFID, etc. Basically devices, at least in the examples I listed, that have micro-controllers that act as peripherals.

sfe-SparkFro commented 4 months ago

Haven't reviewed, but in testing the Ultrasonic Arduino lib, I get the following warning:

c:\Users\Dryw\Documents\Arduino\libraries\SparkFun_Toolkit\src\sfeTkArdI2C.cpp: In member function 'virtual sfeTkError_t sfeTkArdI2C::writeBlock(const uint8_t*, size_t)':
c:\Users\Dryw\Documents\Arduino\libraries\SparkFun_Toolkit\src\sfeTkArdI2C.cpp:129:9: error: unused variable 'nData' [-Werror=unused-variable]
  129 |     int nData = 0;
      |         ^~~~~
cc1plus.exe: some warnings being treated as errors

I strongly recommend setting "Compiler warnings" in Arduino to "All" so these warnings show up

edspark commented 4 months ago

I've been using the arduino-cli and didn't even think to increase verbosity! I will do that!

edspark commented 4 months ago

I added a few more methods for reading from a device without a register parameter. This compliments the previously added write methods. I have enabled warnings to makes sure I didn't miss those, and I've also adjusted the language around the description of the new and existing methods in the pull request. Many apologies for the disjointed manner of this pull request.

edspark commented 3 months ago

Can I get another look at this? There's a library that is dependent on these functions going live this week. Thanks!

edspark commented 3 months ago

Issues addressed, may I get another look @gigapod? Thank you!