Skip to content

Commit ea8c0ce

Browse files
committed
Tweak examples
Only print 1 decimal place for lux measurements Synchronize printing with integration periods in Example 2 Default integration time to 200ms in Example 2
1 parent f8d63f5 commit ea8c0ce

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

examples/qwiic_veml6030_ex1_basic_readings.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def runExample():
6161
ambient_light = light_sensor.read_light()
6262

6363
# Print measurement
64-
print("Lux:\t%.3f" % ambient_light)
64+
print("Lux:\t%.1f" % ambient_light)
6565

6666
if __name__ == '__main__':
6767
try:

examples/qwiic_veml6030_ex2_settings.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -52,14 +52,14 @@ def runExample():
5252
# Initialize the device
5353
light_sensor.begin()
5454

55-
# Set the gain. Can be any of the following:
55+
# Set the gain, can be any of the following:
5656
# 1/8, 1/4, 1, and 2
57-
gain = 0.125
57+
gain = 1
5858
light_sensor.set_gain(gain)
5959

60-
# Set the integration time in ms. Can be any of the following:
60+
# Set the integration time in ms, can be any of the following:
6161
# 25, 50, 100, 200, 400, and 800
62-
integ_time = 100
62+
integ_time = 200
6363
light_sensor.set_integ_time(integ_time)
6464

6565
# Read back the settings and print to confirm they were set correctly
@@ -73,14 +73,14 @@ def runExample():
7373

7474
# Loop forever
7575
while True:
76-
# Give some delay between prints
77-
time.sleep(1)
76+
# Wait for 1 integration time period to synchronize measurements
77+
time.sleep(integ_time / 1000)
7878

7979
# Get light measured by sensor in lux
8080
ambient_light = light_sensor.read_light()
8181

8282
# Print measurement
83-
print("Lux:\t%.3f" % ambient_light)
83+
print("Lux:\t%.1f" % ambient_light)
8484

8585
if __name__ == '__main__':
8686
try:

0 commit comments

Comments
 (0)