#!/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() #92,102,74 #visible= on=(85,100,70) points=[ [0.0,[0,0,0]], [0.1,[85,100,70]], [1.0,[255,255,255]]] gamma=(1.0,1.0,1.0) amount=1.0 pkeys=[] for p in points: pkeys.append(points[i][0]) for i in range(0,len(points)): if points[i][0] >= amount: if i==0: grey=points[0] break subsample=amount-p[i-1][0]/(p[i][0]-p[i-1][0]) grey=[x * subsample for x in l] (points[i][1]*subsample)+(points[i-1][1]*subsample) #Create sample frames frames = [0 for x in range(30)] frameType = HeliosPoint * 1000 x = 0 y = 0 for i in range(30): y = round(i * 0xFFF / 30) frames[i] = frameType() for j in range(1000): if (j < 500): x = round(j * 0xFFF / 500) else: x = round(0xFFF - ((j - 500) * 0xFFF / 500)) frames[i][j] = HeliosPoint(int(x),int(y), int(amount*(255-grey[0])+grey[0]), int(amount*(255-grey[1])+grey[1]), int(amount*(255-grey[2])+grey[2]), 0) #Play frames on DAC for i in range(30): for j in range(numDevices): while (HeliosLib.GetStatus(j) == 0): #Wait for ready status pass HeliosLib.WriteFrame(0, 20000, 0, ctypes.pointer(frames[i % 30]), 1000) #Send the frame HeliosLib.CloseDevices()