Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I've adapted some existing C code for interfacing with the tsl2561 light sensor chips over I2C. There's already a lua module for the device in the repo, but I figured this would have better performance and memory savings.
Any feedback is much appreciated.
tsl2561 module
tsl2561.init()
Description
Initializes the device on pins sdapin&sclpin. Optionally also configures the devices address and package. (Default: address pin floating (0x39) and FN package)
Syntax
tsl2561.init(sdapin, sclpin)
tsl2561.init(sdapin, sclpin, address)
tsl2561.init(sdapin, sclpin, address, package)
Parameters
Return
status: value indicating success or failure as explained below
Example
tsl2561.settiming()
Description
Sets the integration time and gain settings of the device. When init() is called, these values default to 402ms and no gain.
Syntax
tsl2561.settiming(integration, gain)
Parameters
Return
status: value indicating success or failure as explained below
Example
tsl2561.getlux()
Description
Reads sensor values from the device and returns calculated lux value.
Syntax
tsl2561.getlux()
Parameters
nil
Return
Example
tsl2561.getrawchannels()
Description
Reads the device's 2 sensors and returns their values.
Syntax
tsl2561.getrawchannels()
Parameters
nil
Return
Example