mirror of
https://github.com/eclipse/upm.git
synced 2025-03-15 04:57:30 +03:00
tsl2561: fix indentation, style and namespace
Signed-off-by: Brendan Le Foll <brendan.le.foll@intel.com>
This commit is contained in:
parent
685adc561b
commit
2ea12da8b8
@ -33,7 +33,8 @@
|
|||||||
using namespace upm;
|
using namespace upm;
|
||||||
|
|
||||||
|
|
||||||
TSL2561::TSL2561(int bus, uint8_t devAddr, uint8_t gain, uint8_t integrationTime) {
|
TSL2561::TSL2561(int bus, uint8_t devAddr, uint8_t gain, uint8_t integrationTime)
|
||||||
|
{
|
||||||
m_controlAddr = devAddr;
|
m_controlAddr = devAddr;
|
||||||
m_bus = bus;
|
m_bus = bus;
|
||||||
m_gain = gain ;
|
m_gain = gain ;
|
||||||
@ -73,7 +74,8 @@ TSL2561::TSL2561(int bus, uint8_t devAddr, uint8_t gain, uint8_t integrationTime
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TSL2561::~TSL2561() {
|
TSL2561::~TSL2561()
|
||||||
|
{
|
||||||
// POWER DOWN
|
// POWER DOWN
|
||||||
i2cWriteReg(REGISTER_Control,CONTROL_POWEROFF);
|
i2cWriteReg(REGISTER_Control,CONTROL_POWEROFF);
|
||||||
|
|
||||||
@ -186,7 +188,8 @@ TSL2561::getLux(int &lux)
|
|||||||
|
|
||||||
|
|
||||||
mraa_result_t
|
mraa_result_t
|
||||||
TSL2561::i2cWriteReg (uint8_t reg, uint8_t value) {
|
TSL2561::i2cWriteReg (uint8_t reg, uint8_t value)
|
||||||
|
{
|
||||||
mraa_result_t error = MRAA_SUCCESS;
|
mraa_result_t error = MRAA_SUCCESS;
|
||||||
|
|
||||||
// Start transmission to device
|
// Start transmission to device
|
||||||
@ -215,7 +218,8 @@ TSL2561::i2cWriteReg (uint8_t reg, uint8_t value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mraa_result_t
|
mraa_result_t
|
||||||
TSL2561::i2cReadReg(uint8_t reg, uint8_t &data) {
|
TSL2561::i2cReadReg(uint8_t reg, uint8_t &data)
|
||||||
|
{
|
||||||
mraa_result_t error = MRAA_SUCCESS;
|
mraa_result_t error = MRAA_SUCCESS;
|
||||||
|
|
||||||
// Start transmission to device
|
// Start transmission to device
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
* Author: Nandkishor Sonar <Nandkishor.Sonar@intel.com>
|
* Author: Nandkishor Sonar <Nandkishor.Sonar@intel.com>
|
||||||
* Copyright (c) 2014 Intel Corporation.
|
* Copyright (c) 2014 Intel Corporation.
|
||||||
*
|
*
|
||||||
* * LIGHT-TO-DIGITAL CONVERTER [TAOS-TSL2561]
|
* LIGHT-TO-DIGITAL CONVERTER [TAOS-TSL2561]
|
||||||
* Inspiration and lux calculation formulas from data sheet
|
* Inspiration and lux calculation formulas from data sheet
|
||||||
* URL: http://www.adafruit.com/datasheets/TSL2561.pdf
|
* URL: http://www.adafruit.com/datasheets/TSL2561.pdf
|
||||||
*
|
*
|
||||||
@ -32,6 +32,8 @@
|
|||||||
#include <mraa/i2c.h>
|
#include <mraa/i2c.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
|
|
||||||
|
namespace upm {
|
||||||
|
|
||||||
#define TSL2561_Address (0x29) //Device address
|
#define TSL2561_Address (0x29) //Device address
|
||||||
|
|
||||||
// Integration time
|
// Integration time
|
||||||
@ -89,9 +91,6 @@
|
|||||||
#define LUX_B8C (0x0000) // 0.000 * 2^LUX_SCALE
|
#define LUX_B8C (0x0000) // 0.000 * 2^LUX_SCALE
|
||||||
#define LUX_M8C (0x0000) // 0.000 * 2^LUX_SCALE
|
#define LUX_M8C (0x0000) // 0.000 * 2^LUX_SCALE
|
||||||
|
|
||||||
|
|
||||||
namespace upm {
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief TSL2561 Digital Light Sensor library
|
* @brief TSL2561 Digital Light Sensor library
|
||||||
* @defgroup tsl2561 libupm-tsl2561
|
* @defgroup tsl2561 libupm-tsl2561
|
||||||
@ -111,20 +110,22 @@ namespace upm {
|
|||||||
*/
|
*/
|
||||||
class TSL2561{
|
class TSL2561{
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Instanciates a TSL2561 object
|
* Instanciates a TSL2561 object
|
||||||
*
|
*
|
||||||
* @param bus number of used bus
|
* @param bus number of used bus
|
||||||
* @param devAddr address of used i2c device
|
* @param devAddr address of used i2c device
|
||||||
*/
|
* @param gain the correct gain to use
|
||||||
|
* @param integration time to use
|
||||||
|
*/
|
||||||
TSL2561(int bus=0, uint8_t devAddr=TSL2561_Address, uint8_t gain=GAIN_0X, uint8_t integrationTime=INTEGRATION_TIME1_101MS);
|
TSL2561(int bus=0, uint8_t devAddr=TSL2561_Address, uint8_t gain=GAIN_0X, uint8_t integrationTime=INTEGRATION_TIME1_101MS);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GY65 object destructor to power down TSL2561 and close i2c connection.
|
* GY65 object destructor to power down TSL2561 and close i2c connection.
|
||||||
*/
|
*/
|
||||||
~TSL2561();
|
~TSL2561();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get calculated lux reading from TSL2561
|
* Get calculated lux reading from TSL2561
|
||||||
*
|
*
|
||||||
* @param lux - place holder to receive calculated lux value from TSL2561
|
* @param lux - place holder to receive calculated lux value from TSL2561
|
||||||
@ -134,23 +135,21 @@ class TSL2561{
|
|||||||
mraa_result_t getLux(int &lux);
|
mraa_result_t getLux(int &lux);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/**
|
/**
|
||||||
* Write to TSL2561 register
|
* Write to TSL2561 register
|
||||||
*
|
*
|
||||||
* @param reg addess to write
|
* @param reg addess to write
|
||||||
* @param value to write
|
* @param value to write
|
||||||
*
|
* @return mraa_result_t
|
||||||
* Return mraa_result_t
|
|
||||||
*/
|
*/
|
||||||
mraa_result_t i2cWriteReg(uint8_t reg, uint8_t value);
|
mraa_result_t i2cWriteReg(uint8_t reg, uint8_t value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Read from TSL2561 register
|
* Read from TSL2561 register
|
||||||
*
|
*
|
||||||
* @param reg addess to read
|
* @param reg addess to read
|
||||||
* @param data byte read from the register
|
* @param data byte read from the register
|
||||||
*
|
* @return mraa_result_t
|
||||||
* Return mraa_result_t
|
|
||||||
*/
|
*/
|
||||||
mraa_result_t i2cReadReg(uint8_t reg, uint8_t &data);
|
mraa_result_t i2cReadReg(uint8_t reg, uint8_t &data);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user