Example #1
0
 def __init__(self, queue):
     super().__init__()
     self.queue = queue
     GPIO.setmode(GPIO.BCM)  # Use broadcom pin numbering
     GPIO.setwarnings(False)
     port = 1
     bus = smbus.SMBus(port)
     self.apds = apds9960.APDS9960(bus)
     GPIO.setup(4, GPIO.IN)
     GPIO.add_event_detect(4, GPIO.FALLING, callback=self._gesture_handler)
     self.apds.enableGestureSensor()
Example #2
0
            print("Bas")
        if geste == Directions.DIR_NEAR:
            print("Proche")
        if geste == Directions.DIR_FAR:
            print("Loin")
        capteur_APDS9960.enableGestureSensor(True)


# Déclaration de la broche d'interruption du capteur APDS-9960
APDS9960_INT = DigitalInputDevice(SENSOR_INTERRUPT, pull_up=True)
# Précise que lorsqu'un nouveau geste sera détecté (broche d'interruption changera d'état)
# alors on exécutera la fonction 'Lecture_geste()'
APDS9960_INT.when_activated = Lecture_geste

# Déclaration de l'objet associé au capteur APDS-9960
capteur_APDS9960 = GestureSensor.APDS9960(bus=1)
# Initialisation du capteur APDS-9960
capteur_APDS9960.initDevice()
capteur_APDS9960.resetGestureParameters()
# Modification légère des paramètres pour s'adapter au module présent sur la carte (meilleurs résultats de détection)
capteur_APDS9960.setGestureGain(GGAIN_2X)
capteur_APDS9960.setGestureLEDDrive(LED_DRIVE_25MA)
# Rend le capteur APDS-9960 actif
capteur_APDS9960.enableGestureSensor(True)

# Boucle infinie d'attente d'interruption
try:
    while True:
        pass
except KeyboardInterrupt:
    capteur_APDS9960.resetGestureParameters()
import apds9960 as GestureSensor
from apds9960_constants import *
import RPi.GPIO as GPIO

SENSOR_INTERRUPT = 4


def intcallback(channel):
    #global sensor
    print("Interrupt handler called!")
    prox = sensor.readProximity()
    print("Proximity = {}".format(prox))
    sensor.clearProximityInt()


sensor = GestureSensor.APDS9960(bus=1)

sensor.initDevice()
sensor.setProximityGain(PGAIN_2X)
sensor.setProximityIntLowThreshold(0)
sensor.setProximityIntHighThreshold(100)
sensor.enableProximitySensor(1)
sensor.enableLightSensor(0)

sensor.clearProximityInt()
time.sleep(0.5)
prox = sensor.readProximity()
print("Proximity = {}".format(prox))

input("Press Enter when ready\n>")