Skip to content
Merged
Prev Previous commit
Next Next commit
Code Review update.
Update Examples to say halting rather than spinning.
Add comments about why break time is set.
Move driver to it's own underlying file.
Make getDeviceID change op mode if needed.
Add checking to setDeviceAddress.
Make runDefaultSetup change op mode if needed.
Move bulk of runDefaultSetup into the else statement so we don't do unnecessary things.
prepareMeasurement now uses references and consts.
Add comment to reset about OSR register availability.
Add human readable versions of getters for gain, cclk, convTime.
Rename original versions of those to Raw.
Remove unnecessary if's in readRawUV.
setDigitalDividerRange now defaults enabling the divider to true.
Modify Arduino begin to take in a wire port.
Remove unnecessary reset call in begin due to logic changes above.
  • Loading branch information
SFE-Brudnerd committed Dec 15, 2023
commit b5f83b3ee71c9aa7fd79b6c0cf99275638fb8786
6 changes: 3 additions & 3 deletions examples/Example01_Basic_OneShot/Example01_Basic_OneShot.ino
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ void setup() {
// Initialize sensor and run default setup.
if(myUVSensor.begin() == false) {
Serial.println("Sensor failed to begin. Please check your wiring!");
Serial.println("Spinning...");
Serial.println("Halting...");
while(1);
}

Expand All @@ -47,7 +47,7 @@ void setup() {
// Set measurement mode and change device operating mode to measure.
if(myUVSensor.prepareMeasurement(MEAS_MODE_CMD) == false) {
Serial.println("Sensor did not get set properly.");
Serial.println("Spinning...");
Serial.println("Halting...");
while(1);
}

Expand All @@ -61,7 +61,7 @@ void loop() {
Serial.println("Error starting reading!");

// Wait for a bit longer than the conversion time.
delay(2+(1 << myUVSensor.getConversionTime()));
delay(2+myUVSensor.getConversionTimeMillis());

// Read UV values.
if(kSTkErrOk != myUVSensor.readAllUV())
Expand Down
6 changes: 4 additions & 2 deletions examples/Example02_CONT_Mode/Example02_CONT_Mode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,18 @@ void setup() {
// Initialize sensor and run default setup.
if(myUVSensor.begin() == false) {
Serial.println("Sensor failed to begin. Please check your wiring!");
Serial.println("Spinning...");
Serial.println("Halting...");
while(1);
}

Serial.println("Sensor began.");

// Set the delay between measurements so that the processor can read out the
// results without interfering with the ADC.
// Set break time to 900us (112 * 8us) to account for the time it takes to poll data.
if(kSTkErrOk != myUVSensor.setBreakTime(112)) {
Serial.println("Sensor did not set break time properly.");
Serial.println("Spinning...");
Serial.println("Halting...");
while(1);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/Example03_SYNS_Mode/Example03_SYNS_Mode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ void setup() {
// Initialize sensor and run default setup.
if(myUVSensor.begin() == false) {
Serial.println("Sensor failed to begin. Please check your wiring!");
Serial.println("Spinning...");
Serial.println("Halting...");
while(1);
}

Expand All @@ -62,7 +62,7 @@ void setup() {
// Set measurement mode and change device operating mode to measure.
if(myUVSensor.prepareMeasurement(MEAS_MODE_SYNS) == false) {
Serial.println("Sensor did not get set properly.");
Serial.println("Spinning...");
Serial.println("Halting...");
while(1);
}

Expand Down
4 changes: 2 additions & 2 deletions examples/Example04_SYND_Mode/Example04_SYND_Mode.ino
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void setup() {
// Initialize sensor and run default setup.
if(myUVSensor.begin() == false) {
Serial.println("Sensor failed to begin. Please check your wiring!");
Serial.println("Spinning...");
Serial.println("Halting...");
while(1);
}

Expand All @@ -55,7 +55,7 @@ void setup() {
// Set measurement mode and change device operating mode to measure.
if(myUVSensor.prepareMeasurement(MEAS_MODE_SYND) == false) {
Serial.println("Sensor did not get set properly.");
Serial.println("Spinning...");
Serial.println("Halting...");
while(1);
}

Expand Down
Loading