@@ -12,7 +12,9 @@ bool AS726X::begin(TwoWire &wirePort, uint8_t gain, uint8_t measurementMode)
1212{
1313 _i2cPort = &wirePort;
1414 _sensorVersion = virtualReadRegister (AS726x_HW_VERSION);
15- if (_sensorVersion != 0x3E && _sensorVersion != 0x3F ) // HW version for AS7262 and AS7263
15+
16+ // HW version for AS7262, AS7263 and AS7261
17+ if (_sensorVersion != 0x3E && _sensorVersion != 0x3F && _sensorVersion != 0x40 )
1618 {
1719 return false ;
1820 }
@@ -28,12 +30,8 @@ bool AS726X::begin(TwoWire &wirePort, uint8_t gain, uint8_t measurementMode)
2830
2931 setGain (gain); // Set gain to 64x
3032
31- setMeasurementMode (measurementMode); // One-shot reading of VBGYOR
33+ setMeasurementMode (measurementMode); // One-shot mode
3234
33- if (_sensorVersion == 0 )
34- {
35- return false ;
36- }
3735 return true ;
3836}
3937
@@ -58,6 +56,12 @@ void AS726X::setMeasurementMode(uint8_t mode)
5856 virtualWriteRegister (AS726x_CONTROL_SETUP, value); // Write
5957}
6058
59+ uint8_t AS726X::getMeasurementMode ()
60+ {
61+ uint8_t value = virtualReadRegister (AS726x_CONTROL_SETUP); // Read
62+ return (value & 0b00001100 ); // Isolate BANK bits.
63+ }
64+
6165// Sets the gain value
6266// Gain 0: 1x (power-on default)
6367// Gain 1: 3.7x
@@ -74,6 +78,12 @@ void AS726X::setGain(uint8_t gain)
7478 virtualWriteRegister (AS726x_CONTROL_SETUP, value); // Write
7579}
7680
81+ uint8_t AS726X::getGain ()
82+ {
83+ uint8_t value = virtualReadRegister (AS726x_CONTROL_SETUP); // Read
84+ return (value & 0b00110000 ); // Isolate GAIN bits.
85+ }
86+
7787// Sets the integration value
7888// Give this function a uint8_t from 0 to 255.
7989// Time will be 2.8ms * [integration value]
@@ -82,6 +92,12 @@ void AS726X::setIntegrationTime(uint8_t integrationValue)
8292 virtualWriteRegister (AS726x_INT_T, integrationValue); // Write
8393}
8494
95+ uint8_t AS726X::getIntegrationTime ()
96+ {
97+ uint8_t value = virtualReadRegister (AS726x_INT_T); // Read
98+ return value;
99+ }
100+
85101void AS726X::enableInterrupt ()
86102{
87103 // Read, mask/set, write
@@ -143,6 +159,14 @@ int AS726X::getU() { return(getChannel(AS7263_U)); }
143159int AS726X::getV () { return (getChannel (AS7263_V)); }
144160int AS726X::getW () { return (getChannel (AS7263_W)); }
145161
162+ // Get the various CIE readings
163+ int AS726X::getX () { return (getChannel (AS7261_X)); }
164+ int AS726X::getY () { return (getChannel (AS7261_Y)); }
165+ int AS726X::getZ () { return (getChannel (AS7261_Z)); }
166+ int AS726X::getNir () { return (getChannel (AS7261_NIR)); }
167+ int AS726X::getDark () { return (getChannel (AS7261_DARK)); }
168+ int AS726X::getClear () { return (getChannel (AS7261_CLEAR)); }
169+
146170// A the 16-bit value stored in a given channel registerReturns
147171int AS726X::getChannel (uint8_t channelRegister)
148172{
@@ -166,6 +190,19 @@ float AS726X::getCalibratedU() { return(getCalibratedValue(AS7263_U_CAL)); }
166190float AS726X::getCalibratedV () { return (getCalibratedValue (AS7263_V_CAL)); }
167191float AS726X::getCalibratedW () { return (getCalibratedValue (AS7263_W_CAL)); }
168192
193+ float AS726X::getCalibratedX () { return (getCalibratedValue (AS7261_X_CAL)); }
194+ float AS726X::getCalibratedY () { return (getCalibratedValue (AS7261_Y_CAL)); }
195+ float AS726X::getCalibratedZ () { return (getCalibratedValue (AS7261_Z_CAL)); }
196+ float AS726X::getCalibratedX1931 () { return (getCalibratedValue (AS7261_X1931_CAL)); }
197+ float AS726X::getCalibratedY1931 () { return (getCalibratedValue (AS7261_Y1931_CAL)); }
198+ float AS726X::getCalibratedUPri1976 () { return (getCalibratedValue (AS7261_UPRI_CAL)); }
199+ float AS726X::getCalibratedVPri1976 () { return (getCalibratedValue (AS7261_VPRI_CAL)); }
200+ float AS726X::getCalibratedU1976 () { return (getCalibratedValue (AS7261_U_CAL)); }
201+ float AS726X::getCalibratedV1976 () { return (getCalibratedValue (AS7261_V_CAL)); }
202+ float AS726X::getCalibratedDUV1976 () { return (getCalibratedValue (AS7261_DUV_CAL)); }
203+ int AS726X::getCalibratedLux () { return (getChannel (AS7261_LUX_CAL)); }
204+ int AS726X::getCalibratedCCT () { return (getChannel (AS7261_CCT_CAL)); }
205+
169206// Given an address, read four uint8_ts and return the floating point calibrated value
170207float AS726X::getCalibratedValue (uint8_t calAddress)
171208{
0 commit comments