Skip to content

Commit

Permalink
Fiexd missing
Browse files Browse the repository at this point in the history
  • Loading branch information
lewisxhe committed Sep 13, 2023
1 parent 58133e2 commit 8bea678
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ void setup()
SAMPLING_X1_4
*/
light.setSampling(SensorCM32181::SAMPLING_X2,
SensorCM32181::INTEGRATION_TIME_400MS,
true);
SensorCM32181::INTEGRATION_TIME_400MS
);

// Set high and low thresholds. If the threshold is higher or lower than the set threshold, an interrupt will be triggered.
uint16_t lowThresholdRaw = 100;
Expand All @@ -84,12 +84,16 @@ void setup()

//Power On sensor
light.powerOn();

// Turn on interrupt
light.enableINT();
}


void loop()
{
if (digitalRead(SENSOR_IRQ) == LOW) {
int pinVal = digitalRead(SENSOR_IRQ) ;
if (pinVal == LOW) {

// After triggering the interrupt, the interrupt status must be read
SensorCM32181::InterruptEvent event = light.getIrqStatus();
Expand All @@ -116,7 +120,7 @@ void loop()
// Get conversion data , The manual does not provide information on how to obtain the
// calibration value, now use the calibration value 0.28 provided by the manual
float lux = light.getLux();
Serial.printf("IRQ:%d RAW:%u Lux:%.2f\n", digitalRead(SENSOR_IRQ), raw, lux);
Serial.printf("IRQ:%d RAW:%u Lux:%.2f\n", pinVal, raw, lux);


// Turn on interrupts
Expand Down
5 changes: 2 additions & 3 deletions src/SensorCM32181.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,15 @@ class SensorCM32181 :
}

void setSampling(Sampling tempSampling = SAMPLING_X1,
IntegrationTime int_time = INTEGRATION_TIME_200MS,
bool enable_interrupt = false)
IntegrationTime int_time = INTEGRATION_TIME_200MS
)
{
uint16_t data;
readRegister(CM32181_REG_ALS_CONF, (uint8_t *)&data, 2);
data &= ~(0x03 << 11);
data |= tempSampling << 11;
data &= ~(0xF << 6);
data |= int_time << 6;
bitWrite(data, 1, enable_interrupt);
readRegister(CM32181_REG_ALS_CONF, (uint8_t *)&data, 2);
}

Expand Down

0 comments on commit 8bea678

Please sign in to comment.