Ejemplo n.º 1
0
def main():
    device = mp.APDS_9960()

    device.reset()

    device.enable_proximity_engine()
    device.wake_up()
    print(device.get_status())
    while True:
        time.sleep(.5)
        print(device.get_proximity_data())
Ejemplo n.º 2
0
def main():
    device = mp.APDS_9960()

    # reset
    device.reset()

    device.enable_gestures_engine()

    device.set_gesture_prox_enter_threshold(0)
    device.set_gesture_exit_threshold(0)

    device.wake_up()

    while True:
        for i in range(device.get_number_of_datasets_in_fifo()):
            print(device.get_gesture_data())
Ejemplo n.º 3
0
def main():
    device = mp.APDS_9960()

    device.reset()

    device.enable_als_engine()
    device.set_als_integration_time(450)
    saturation = device.get_saturation()
    device.wake_up()

    while True:
        time.sleep(.5)
        color = device.get_color_data()
        color = map(lambda val: val / saturation * 255, color)
        print(
            f"Alfa: {next(color)}  Red: {next(color)}  Green: {next(color)}  Blue: {next(color)}"
        )
Ejemplo n.º 4
0
def main():
    device = mp.APDS_9960()

    # reset
    device.reset()

    device.enable_gestures_engine()

    device.set_gesture_prox_enter_threshold(25)
    device.set_gesture_exit_threshold(20)
    device.set_gesture_exit_persistence(mp.APDS_9960.EXIT_AFTER_4_GESTURE_END)

    device.wake_up()

    while True:
        gesture_status = device.get_gesture_status()
        if gesture_status["Gesture FIFO Data"]:
            # try to detect and parse a gesture for 300 milliseconds
            detected_gestures = device.parse_gesture(300)
            print(detected_gestures)
Ejemplo n.º 5
0
def main():
    device = mp.APDS_9960()

    # reset
    device.reset()

    device.enable_gestures_engine()

    # Setup the entry condition for the gesture engine
    device.set_gesture_prox_enter_threshold(25)
    device.set_gesture_exit_threshold(20)
    device.set_gesture_exit_persistence(mp.APDS_9960.EXIT_AFTER_4_GESTURE_END)

    # Setup interrupt settings
    device.enable_gesture_interrupts()
    device.set_gesture_fifo_threshold(mp.APDS_9960.FIFO_INT_AFTER_16_DATASETS)

    # To clear the interrupt pin we have to read all datasets that are available in the fifo.
    # Since it takes a little bit of time to read alla these datasets the device may collect
    # new ones in the meantime and prevent us from clearing the interrupt ( since the fifo
    # would not be empty ). To prevent this behaviour we tell the device to enter the sleep
    # state after an interrupt occurred. The device will exit the sleep state when the interrupt
    # is cleared.
    device.set_sleep_after_interrupt(True)

    # Interrupt callback
    def on_interrupt():
        detected_gestures = device.parse_gesture_in_fifo()
        print(detected_gestures)

    device.wake_up()

    # Setup interrupt callback
    int_listener_pin = "GPIO4"
    interrupt = gpio.Button(int_listener_pin, pull_up=True)
    interrupt.when_pressed = on_interrupt

    pause()