Skip to content

Instantly share code, notes, and snippets.

@depau
Last active January 26, 2016 21:30
Show Gist options
  • Save depau/08689d6d1e58f7700e4a to your computer and use it in GitHub Desktop.
Save depau/08689d6d1e58f7700e4a to your computer and use it in GitHub Desktop.
Python APDS-9930 test program
#!/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
print "Register dump:"
a.dump_registers()
print
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