summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Redfern <tim@getdrop.com>2017-12-19 18:41:57 +0000
committerTim Redfern <tim@getdrop.com>2017-12-19 18:41:57 +0000
commit42cb3bbe4b37eae565cf8332eb847fa32077d3d4 (patch)
tree181beef70b95b95b6d301a3f72382e3a2262cc6c
initial commit
-rwxr-xr-xlibHeliosDacAPI.dylibbin0 -> 24208 bytes
-rwxr-xr-xosx_example2.py76
2 files changed, 76 insertions, 0 deletions
diff --git a/libHeliosDacAPI.dylib b/libHeliosDacAPI.dylib
new file mode 100755
index 0000000..2544dff
--- /dev/null
+++ b/libHeliosDacAPI.dylib
Binary files differ
diff --git a/osx_example2.py b/osx_example2.py
new file mode 100755
index 0000000..09f32c7
--- /dev/null
+++ b/osx_example2.py
@@ -0,0 +1,76 @@
+#!/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()