Skip to content

Commit b5f83b3

Browse files
committed
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.
1 parent a2a9439 commit b5f83b3

File tree

7 files changed

+842
-749
lines changed

7 files changed

+842
-749
lines changed

examples/Example01_Basic_OneShot/Example01_Basic_OneShot.ino

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ void setup() {
3838
// Initialize sensor and run default setup.
3939
if(myUVSensor.begin() == false) {
4040
Serial.println("Sensor failed to begin. Please check your wiring!");
41-
Serial.println("Spinning...");
41+
Serial.println("Halting...");
4242
while(1);
4343
}
4444

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

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

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

6666
// Read UV values.
6767
if(kSTkErrOk != myUVSensor.readAllUV())

examples/Example02_CONT_Mode/Example02_CONT_Mode.ino

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,18 @@ void setup() {
4646
// Initialize sensor and run default setup.
4747
if(myUVSensor.begin() == false) {
4848
Serial.println("Sensor failed to begin. Please check your wiring!");
49-
Serial.println("Spinning...");
49+
Serial.println("Halting...");
5050
while(1);
5151
}
5252

5353
Serial.println("Sensor began.");
5454

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

examples/Example03_SYNS_Mode/Example03_SYNS_Mode.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void setup() {
5353
// Initialize sensor and run default setup.
5454
if(myUVSensor.begin() == false) {
5555
Serial.println("Sensor failed to begin. Please check your wiring!");
56-
Serial.println("Spinning...");
56+
Serial.println("Halting...");
5757
while(1);
5858
}
5959

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

examples/Example04_SYND_Mode/Example04_SYND_Mode.ino

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ void setup() {
4646
// Initialize sensor and run default setup.
4747
if(myUVSensor.begin() == false) {
4848
Serial.println("Sensor failed to begin. Please check your wiring!");
49-
Serial.println("Spinning...");
49+
Serial.println("Halting...");
5050
while(1);
5151
}
5252

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

0 commit comments

Comments
 (0)