wip: helios_dac
This commit is contained in:
parent
6c73bd9fc2
commit
bc19e77f4f
@ -27,6 +27,8 @@ numDevices = HeliosLib.OpenDevices()
|
||||
print("Found ", numDevices, "Helios DACs")
|
||||
|
||||
|
||||
|
||||
|
||||
class TracerHelios(Tracer):
|
||||
"""A connection to a DAC."""
|
||||
|
||||
@ -44,12 +46,19 @@ class TracerHelios(Tracer):
|
||||
self.prev_x = 0
|
||||
self.prev_y = 0
|
||||
|
||||
self.min_res = 0
|
||||
self.max_res = 4095
|
||||
|
||||
# self.newstream = OnePointIterator()
|
||||
|
||||
# "Laser point List" Point generator
|
||||
# each points is yielded : Getpoints() call n times OnePoint()
|
||||
pass
|
||||
|
||||
def clip(self, number):
|
||||
return int( self.min_res if number < self.min_res else self.max_res if number > self.max_res else number)
|
||||
|
||||
|
||||
def get_points_capacity(self):
|
||||
return 1000
|
||||
|
||||
@ -87,8 +96,10 @@ class TracerHelios(Tracer):
|
||||
points = [point for point in points]
|
||||
for i, point in enumerate(points):
|
||||
x, y, r, g, b = point
|
||||
x = x if not math.isnan(x) else 0
|
||||
y = x if not math.isnan(y) else 0
|
||||
x *= 10
|
||||
y *= 10
|
||||
x = 0 if math.isnan(x) else self.clip(x)
|
||||
y = 0 if math.isnan(y) else self.clip(y)
|
||||
frame[i] = HeliosPoint(int(x), int(y), int(r), int(g), int(b), 255)
|
||||
statusAttempts = 0
|
||||
# Make 512 attempts for DAC status to be ready. After that, just give up and try to write the frame anyway
|
||||
@ -96,44 +107,15 @@ class TracerHelios(Tracer):
|
||||
statusAttempts += 1
|
||||
f = ctypes.pointer(frame)
|
||||
# int HeliosDac::WriteFrame(unsigned int devNum, unsigned int pps, std::uint8_t flags, HeliosPoint* points, unsigned int numOfPoints)
|
||||
ret_helios = HeliosLib.WriteFrame(0, 3000, 0, f, len(frame))
|
||||
# @todo : detect errors
|
||||
if ret_helios != 1:
|
||||
print(f"ERR ]Helios DAC #{self.laser_id} returned error {ret_helios}")
|
||||
# ret_helios = HeliosLib.WriteFrame(0, 3000, 0, f, len(frame))
|
||||
# # @todo : detect errors
|
||||
# if ret_helios != 1:
|
||||
# print(f"ERR ]Helios DAC #{self.laser_id} returned error {ret_helios}")
|
||||
|
||||
def get_warped_point(self, x, y):
|
||||
|
||||
# transform in one matrix, with warp !!
|
||||
# Etherpoint all transform in one matrix, with warp !!
|
||||
np_arr = np.array([(x, y, 0)])
|
||||
laser_EDH = gstt.EDH[self.laser_id]
|
||||
position = homographyp.apply(laser_EDH, np_arr)
|
||||
laser_edh = gstt.EDH[self.laser_id]
|
||||
position = homographyp.apply(laser_edh, np_arr)
|
||||
return position[0][0], position[0][1]
|
||||
|
||||
#
|
||||
# # 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), 255, 255, 255, 255)
|
||||
#
|
||||
# # Play frames on DAC
|
||||
# for i in range(150):
|
||||
# for j in range(numDevices):
|
||||
# statusAttempts = 0
|
||||
# # Make 512 attempts for DAC status to be ready. After that, just give up and try to write the frame anyway
|
||||
# while (statusAttempts < 512 and HeliosLib.GetStatus(j) != 1):
|
||||
# statusAttempts += 1
|
||||
# HeliosLib.WriteFrame(j, 30000, 0, ctypes.pointer(frames[i % 30]), 1000) # Send the frame
|
||||
#
|
||||
# HeliosLib.CloseDevices()
|
||||
|
Loading…
Reference in New Issue
Block a user