Running Demo Codes

To run the demo code, perform the following on VisionFive 2 Debian:

  1. Locate to the directory where the test code, edge_detection_with_waiting_time.py, exists:
    1. Execute the following command to get the directory where VisionFive.gpio exists:
      pip show VisionFive.gpio
      Result:
      Location: /usr/local/lib64/python3.9/site-packages
      Note:

      The actual output depends on how the application is installed.

    2. Execute the following to enter the directory, for example, /usr/local/lib64/python3.9/site-packages as indicated in the previous step output:
      cd /usr/local/lib64/python3.9/site-packages
    3. Execute the following command to enter the sample-code directory:
      cd ./VisionFive/sample-code/
  2. Under the sample-code directory, execute the following command to execute the demo code:
    sudo python edge_detection_with_waiting_time.py

    Alternatively, you can execute the following command:

    sudo python3 edge_detection_with_waiting_time.py
    Result:
    • The terminal displays as follows:
      # python3 edge_detection_with_waiting_time.py 
      *-----------------------Case 1-----------------------------------------------------*
      Note: don't press the key on pin 37 once within 5 seconds !!!
    • After waiting for 5 seconds, the terminal displays as follows:
      Edge hasn't been detected within 5 seconds  while setting 5 seconds to timeout.
      The return value of GPIO.event_detected(37) within 5 seconds: False
      
      *-----------------------Case 2-----------------------------------------------------------------------*
      Please press the key on pin 37 once at any time !!!
    • Finally press the button, and the terminal displays as follows:
      Edge has detected while setting -1 to timeout,
      timeout -1 means waiting until edge is detected.
      
      The return value (True) of GPIO.event_detected(37) should be True.
      The return value (False) of GPIO.event_detected(37) should be False, because of the secondly reading.