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.

105 lines
2.7 KiB

  1. #
  2. # example.py
  3. # Copyright 2018 by Dave Hocker
  4. #
  5. # This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU General Public License as published by
  7. # the Free Software Foundation, version 3 of the License.
  8. #
  9. # See the LICENSE file for more details.
  10. #
  11. # Example of how to use pyudmx with a Thinpar 64 light
  12. # http://venuelightingeffects.com/wp-content/uploads/manuals/Venue_Thinpar_64_Manual_HR.pdf
  13. # 7 channel mode
  14. # Channels 1-3 are RGB
  15. # Channel 7 is the dimmer
  16. #
  17. # Requirements
  18. # A virtual environment meeting the requirements defined in requirements.txt works best.
  19. # Specifically the pyusb module must be installed.
  20. #
  21. from pyudmx import pyudmx
  22. from time import sleep
  23. def send_rgb(dev, dimmer, red, green, blue, effect):
  24. """
  25. Send a set of RGB values to the light
  26. """
  27. cv = [0 for v in range(0, 512)]
  28. cv[0] = dimmer
  29. cv[1] = red
  30. cv[2] = green
  31. cv[3] = blue
  32. cv[4] = effect
  33. print(cv)
  34. print(type(cv))
  35. sent = dev.send_multi_value(1, cv)
  36. return sent
  37. def main():
  38. """
  39. How to control a DMX light through an Anyma USB controller
  40. """
  41. # Channel value list for channels 1-512
  42. cv = [0 for v in range(0, 512)]
  43. # Create an instance of the DMX controller and open it
  44. print("Opening DMX controller...")
  45. dev = pyudmx.uDMXDevice()
  46. # This will automagically find a single Anyma-type USB DMX controller
  47. dev.open()
  48. # For informational purpose, display what we know about the DMX controller
  49. print(dev.Device)
  50. # Send messages to the light changing it to red, then green, then blue
  51. # This is the "hard way" to do it, but illustrates how it's done
  52. print("Setting to red...")
  53. cv[0] = 255 # dimmer to half value
  54. cv[1] = 255 # red
  55. sent = dev.send_multi_value(1, cv)
  56. print("Set to red")
  57. sleep(3.0)
  58. print("Setting to green...")
  59. cv[0] = 255 # dimmer to half value
  60. cv[1] = 0 # red
  61. cv[2] = 255 # green
  62. sent = dev.send_multi_value(1, cv)
  63. print("Set to green")
  64. sleep(3.0)
  65. print("Setting to blue...")
  66. cv[0] = 255 # dimmer to half value
  67. cv[1] = 0 # red
  68. cv[2] = 0 # green
  69. cv[3] = 255 # blue
  70. sent = dev.send_multi_value(1, cv)
  71. print("Set to blue")
  72. sleep(3.0)
  73. # Here's an easier way to do it
  74. print("And, again the easier way")
  75. send_rgb(dev, 255, 255, 0, 0, 0)
  76. sleep(3.0)
  77. send_rgb(dev, 255, 0, 255, 0, 0)
  78. sleep(3.0)
  79. send_rgb(dev, 255, 0, 0, 255, 0)
  80. sleep(3.0)
  81. print("Reset all channels and close..")
  82. # Turns the light off
  83. cv = [0 for v in range(0, 512)]
  84. dev.send_multi_value(1, cv)
  85. dev.close()
  86. if __name__ == "__main__":
  87. main()
  88. print("Done")