You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.4 KiB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
  1. #!/usr/bin/python
  2. import sys #reconocer lo que hay en la terminal
  3. LED_PATH = "/sys/class/leds/beaglebone:green:usr3"
  4. def writeLED(fileName, value, path=LED_PATH):
  5. """
  6. Ayuda de la rutina
  7. writeLED(fileName, value, path=LED_PATH)
  8. """
  9. fo = open(path + fileName, "w")
  10. fo.write(value)
  11. fo.close()
  12. return
  13. def removeTrigger():
  14. writeLED("/trigger","none")
  15. return
  16. print("Starting App")
  17. if len(sys.argv)!=2:
  18. print("Incorrect number of arguments")
  19. sys.exit(2)
  20. if sys.argv[1] == "on":
  21. print("LED on \n")
  22. removeTrigger()
  23. writeLED("/brightness", "1")
  24. print("LED3 on \n")
  25. elif sys.argv[1] == "off":
  26. print("LED off \n")
  27. removeTrigger()
  28. writeLED("/brightness", "0")
  29. print("LED3 off \n")
  30. elif sys.argv[1] == "blink":
  31. print("LED blinking \n")
  32. writeLED("/trigger", "timer")
  33. writeLED("/delay_on", "500")
  34. writeLED("/delay_off", "500")
  35. elif sys.argv[1] == "help":
  36. print("This is an application to control User LED 3")
  37. print("List of commands: ")
  38. print("on - Powers on the LED")
  39. print("off - Powers off the LED")
  40. print("blink - Makes the LED blink")
  41. else:
  42. print("Error: This is not a command for this application")
  43. print("These are the commands you can use: ")
  44. print("on - Powers on the LED")
  45. print("off - Powers off the LED")
  46. print("blink - Makes the LED blink")
  47. print("Script done")