コード例 #1
0
ファイル: leaplaser.py プロジェクト: topher515/laser-fingers
def main(args):


    if len(args) == 0:
        OSC = False
    else:
        OSC = True
        hostname = args[0]
        port = args[1]


    if OSC:
        listener = PointStreamingOSCLeapListener(hostname=hostname, port=port,
                    x_mm_min=-100, x_mm_max=100,
                    y_mm_min=100, y_mm_max=300)

    else:
        listener = PointStreamingLeapListener(x_mm_min=-100, x_mm_max=100,
                    y_mm_min=100, y_mm_max=300)

    controller = Leap.Controller()
    controller.add_listener(listener)
    try:

        while True:

            d = dac.DAC(dac.find_first_dac())
            try:
                d.play_stream(listener)
            except Exception as e:
                print e

    finally:
        controller.remove_listener(listener)
コード例 #2
0
ファイル: test.py プロジェクト: litghost/etherdream_toys
def main():
    a, bp = dac.find_first_dac()
    d = dac.DAC(a)

    scale = .35
    pps = 20000

    target = liblo.Address(a, 60000)
    liblo.send(target, "/geom/tl", int(-1), int(1))
    liblo.send(target, "/geom/tr", int(1), int(1))
    liblo.send(target, "/geom/bl", int(-1), int(-1))
    liblo.send(target, "/geom/br", int(1), int(-1))
    liblo.send(target, "/geom/pps", pps)
    liblo.send(target, "/geom/size", scale)

    with open('ildatest.ild', 'rb') as f:
        frames = list(readFrames(f))

    def stream_points():
        while True:
            for f in frames:
                for p in f.iterPoints():
                    yield p.encode()

    itr = iter(stream_points())

    d.play_iter(pps, bp.buffer_capacity, itr)
コード例 #3
0
ファイル: leaplaser.py プロジェクト: topher515/laser-fingers
def asteroids_test():
    from entities.ship import Ship
    d = dac.DAC(dac.find_first_dac())
    box = PointStream()
    s = Ship(0, 0, CMAX/2, CMAX/2, CMAX/2)
    s.theta = 0.5
    box.objects.append(s)
    d.play_stream(box)
コード例 #4
0
def dac_thread():
    while True:
        try:
            d = dac.DAC(dac.find_first_dac())
            d.play_stream(laser)
        except Exception as e:

            import sys, traceback
            print '\n---------------------'
            print 'Exception: %s' % e
            print '- - - - - - - - - - -'
            traceback.print_tb(sys.exc_info()[2])
            print "\n"
            pass
コード例 #5
0
ファイル: main.py プロジェクト: tmpbci/emptylaser
def dac_thread():

	while True:
		try:

			d = dac.DAC(dac.find_first_dac())
			d.play_stream(laser)

		except Exception as e:

			import sys, traceback
			print '\n---------------------'
			print 'Exception: %s' % e
			print '- - - - - - - - - - -'
			traceback.print_tb(sys.exc_info()[2])
			print "\n"
			pass
コード例 #6
0
ファイル: main.py プロジェクト: topher515/laser-fingers
def dac_thread():
    global DRAW

    while True:
        try:

            d = dac.DAC(dac.find_first_dac())
            d.play_stream(ps)

        except Exception as e:

            # import sys, traceback
            # print '\n---------------------'
            # print 'Exception: %s' % e
            # print '- - - - - - - - - - -'
            # traceback.print_tb(sys.exc_info()[2])
            # print "\n"
            raise
コード例 #7
0
    def playshow(self, scale, pps):
        a, bp = dac.find_first_dac()
        d = dac.DAC(a)

        target = liblo.Address(a, 60000)
        liblo.send(target, "/geom/tl", int(-1), int(1))
        liblo.send(target, "/geom/tr", int(1), int(1))
        liblo.send(target, "/geom/bl", int(-1), int(-1))
        liblo.send(target, "/geom/br", int(1), int(-1))
        liblo.send(target, "/geom/pps", pps)
        liblo.send(target, "/geom/size", scale)

        def fun(t):
            self.phase[0] = (self.phase[0] + self.freq)
            self.phase[1] = (self.phase[1] + (1 - self.k) / self.k * self.freq)
            self.phase[2] = (self.phase[2] + self.rot_freq)
            x = self.R * ((1 - self.k) * cos(self.phase[0]) +
                          self.l * self.k * cos(self.phase[1]))
            y = self.R * ((1 - self.k) * sin(self.phase[0]) -
                          self.l * self.k * sin(self.phase[1]))

            x_rot = x * cos(self.phase[2]) - y * sin(self.phase[2])
            y_rot = x * sin(self.phase[2]) + y * cos(self.phase[2])

            x_rot = min(COORD_MAX, max(COORD_MIN, x_rot))
            y_rot = min(COORD_MAX, max(COORD_MIN, y_rot))

            return x_rot, y_rot

        def stream_points():
            t = 0

            while True:
                x, y = fun(t)
                p = (x, y, 0, 0, COORD_MAX)
                yield p

                self.recv(0)

                t += 1

        itr = iter(stream_points())

        d.play_iter(pps, bp.buffer_capacity, itr)
コード例 #8
0
    def playshow(self, scale, pps):
        a, bp = dac.find_first_dac()
        d = dac.DAC(a)

        target = liblo.Address(a, 60000)
        liblo.send(target, "/geom/tl", int(-1), int(1))
        liblo.send(target, "/geom/tr", int(1), int(1))
        liblo.send(target, "/geom/bl", int(-1), int(-1))
        liblo.send(target, "/geom/br", int(1), int(-1))
        liblo.send(target, "/geom/pps", pps)
        liblo.send(target, "/geom/size", scale)

        phase = [0, 0]

        def fun():
            phase[0] += self.freq
            phase[1] += self.freq2
            x = COORD_MAX*(sin(phase[0])+sin(phase[1]+self.offset))/2
            y = 0

            x_rot = x*cos(self.rot)-y*sin(self.rot)
            y_rot = x*sin(self.rot)+y*cos(self.rot)

            return x_rot, y_rot


        def stream_points():
            last_dwell = 0
            while True:
                x, y = fun()
                yield (x, y, 0, 0, COORD_MAX)

                self.recv(0)

        itr = iter(stream_points())

        d.play_iter(pps, bp.buffer_capacity, itr)
コード例 #9
0
import ILDA
from ILDA import readFrames
import dac

#dac.find_dac()

if __name__ == "__main__":

    if len(sys.argv) < 2:
        print "Usage:"
        print sys.argv[0] + " filename"
        exit(0)
    filename = sys.argv[1]

    print "Finding DAC..."
    d = dac.DAC(dac.find_first_dac())
    print "DAC found!"

    print "Opening: " + filename
    f = open(filename, 'rb')
    print "Opened!"


    
    while True:
        f = open(sys.argv[1], 'rb')
        for num, t in enumerate(readFrames(f)):
            print "table #" + str(num) + " "
            #print t
            #print "  with points:"
            #for p in t.iterPoints():
コード例 #10
0
ファイル: square.py プロジェクト: andz82/lazor
class SquarePointStream(object):
    def produce(self):
        pmax = 15000
        pstep = 750
        cmax = 65535
        while True:
            for x in xrange(-pmax, pmax, pstep):
                yield (x, pmax, cmax, 0, 0)
            for y in xrange(pmax, -pmax, -pstep):
                yield (pmax, y, 0, cmax, 0)
            for x in xrange(pmax, -pmax, -pstep):
                yield (x, -pmax, 0, 0, cmax)
            for y in xrange(-pmax, pmax, pstep):
                yield (-pmax, y, cmax, cmax, cmax)

    def __init__(self):
        self.stream = self.produce()

    def read(self, n):
        return [self.stream.next() for i in xrange(n)]


class NullPointStream(object):
    def read(self, n):
        return [(0, 0, 0, 0, 0)] * n


d = dac.DAC(dac.find_first_dac())

d.play_stream(SquarePointStream())
コード例 #11
0
 def search_dac(self):
     import dac
     print "Finding dac..."
     self.dac_ip = dac.find_first_dac()
     print "Found DAC at " + str(self.dac_ip)
     self.ui.edit_ip.setText(str(self.dac_ip))
コード例 #12
0
ファイル: leaplaser.py プロジェクト: topher515/laser-fingers
def max_box():
    d = dac.DAC(dac.find_first_dac())
    box = ColorfulSquarePointStream()
    box.hmax = 19348
    d.play_stream(box)