projects
/
EVA-2020-02-2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Transitional fix for new LTR559 library
[EVA-2020-02-2.git]
/
examples
/
light.py
diff --git
a/examples/light.py
b/examples/light.py
index aa895f1131a9fcd96ed1e893460f5907156af449..b18a78b5a1754b84c49d77b39ab11f853eb73359 100755
(executable)
--- a/
examples/light.py
+++ b/
examples/light.py
@@
-1,20
+1,31
@@
#!/usr/bin/env python
import time
#!/usr/bin/env python
import time
-import ltr559
+import logging
+try:
+ # Transitional fix for breaking change in LTR559
+ from ltr559 import LTR559
+ ltr559 = LTR559()
+except ImportError:
+ import ltr559
+
+logging.basicConfig(
+ format='%(asctime)s.%(msecs)03d %(levelname)-8s %(message)s',
+ level=logging.INFO,
+ datefmt='%Y-%m-%d %H:%M:%S')
-
print
("""light.py - Print readings from the LTR559 Light & Proximity sensor.
+
logging.info
("""light.py - Print readings from the LTR559 Light & Proximity sensor.
Press Ctrl+C to exit!
Press Ctrl+C to exit!
-
+
""")
try:
while True:
lux = ltr559.get_lux()
prox = ltr559.get_proximity()
""")
try:
while True:
lux = ltr559.get_lux()
prox = ltr559.get_proximity()
-
print
("""Light: {:05.02f} Lux
+
logging.info
("""Light: {:05.02f} Lux
Proximity: {:05.02f}
""".format(lux, prox))
time.sleep(1.0)
Proximity: {:05.02f}
""".format(lux, prox))
time.sleep(1.0)