diff options
| -rwxr-xr-x | calibrate.py | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/calibrate.py b/calibrate.py new file mode 100755 index 0000000..68efa41 --- /dev/null +++ b/calibrate.py @@ -0,0 +1,51 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +Example for using Helios DAC libraries in python (using C library with ctypes) + +NB: If you haven't set up udev rules you need to use sudo to run the program for it to detect the DAC. +""" + +import ctypes + +#Define point structure +class HeliosPoint(ctypes.Structure): + #_pack_=1 + _fields_ = [('x', ctypes.c_uint16), + ('y', ctypes.c_uint16), + ('r', ctypes.c_uint8), + ('g', ctypes.c_uint8), + ('b', ctypes.c_uint8), + ('i', ctypes.c_uint8)] + +#Load and initialize library +HeliosLib = ctypes.cdll.LoadLibrary("./libHeliosDacAPI.dylib") +numDevices = HeliosLib.OpenDevices() + +#WriteFrame(unsigned int dacNum, int pps, std::uint8_t flags, HeliosPoint* points, int numOfPoints); +#in 1024 points: +#scale up x from 0 to 100% +#scale down y from 0 to 100% +#scale R, G and B up from 0 to 255 4 times out of sync + +frames=[0 for x in range(1024)] +r=0 +g=85 +b=170 + +def inc8(m): + return (m+1)%256 + +for i in range(1024): + frames[i]=HeliosPoint(i*16,16383-(i*16),r,g,b,0) + r=inc8(r) + g=inc8(g) + b=inc8(b) + +try: + while True: + HeliosLib.WriteFrame(0, 20000, 0, ctypes.pointer(frames[0]), 1024) +except KeyboardInterrupt: + pass + +HeliosLib.CloseDevices() |
