Last active
January 26, 2016 21:30
-
-
Save depau/08689d6d1e58f7700e4a to your computer and use it in GitHub Desktop.
Python APDS-9930 test program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
from apds9930 import APDS9930 | |
from apds9930.values import ALL, OFF | |
from time import sleep | |
busno = int(raw_input("Please select an I²C bus number: ")) | |
a = APDS9930(busno) | |
a.enable_ambient_light_sensor() | |
a.enable_proximity_sensor() | |
print "Address:\t", hex(a.address) | |
print "ID: \t", hex(a.id) | |
print "Mode: \t", bin(a.mode) | |
print "Register dump:" | |
a.dump_registers() | |
try: | |
while True: | |
print "Ambient light:", round(a.ambient_light, 1), "lux", "\tCh0 light:", a.ch0_light, "\tProximity:", a.proximity | |
sleep(1) | |
except KeyboardInterrupt: | |
a.set_mode(ALL, OFF) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment