Example #1
0
 def __init__(self,host='localhost',port=3636,apikey=None):
     self.host=host
     self.port=port
     self.apikey=apikey
     self.clientsocket=None
     self.socketfile=None
     self.update_interval=0.2 
     self.cyborgs=get_all_cyborgs()
Example #2
0
 def __init__(self, host='localhost', port=3636, apikey=None):
     self.host = host
     self.port = port
     self.apikey = apikey
     self.clientsocket = None
     self.socketfile = None
     self.update_interval = 0.2
     self.cyborgs = get_all_cyborgs()
Example #3
0
def main():
    
    cyborgs=get_all_cyborgs()
    if len(cyborgs)==0:
        print("no cyborgs found :(")
        sys.exit(1)
    
    monitor = PeakMonitor(SINK_NAME, METER_RATE)
    for sample in monitor:
        sample=sample
        if sample>255:
            sample=255
        for cy in cyborgs:
            cy.set_rgb_color(sample,0,sample)        
Example #4
0
def main():

    cyborgs = get_all_cyborgs()
    if len(cyborgs) == 0:
        print("no cyborgs found :(")
        sys.exit(1)

    monitor = PeakMonitor(SINK_NAME, METER_RATE)
    for sample in monitor:
        sample = sample
        if sample > 255:
            sample = 255
        for cy in cyborgs:
            cy.set_rgb_color(sample, 0, sample)
Example #5
0
"""

import sys
import os
from pycyborg import get_all_cyborgs

try:
  raw_input
except NameError:
  pass
else:
  def input(msg=''):
    return(raw_input(msg))

	
cyborgs=get_all_cyborgs()

positions={
      'CENTER':{'hscan':'33.3 66.6','vscan':'33.3 66.6'},
      'N':{'hscan':'33.3 66.6','vscan':'0 33.3'},
      'NE':{'hscan':'66.6 100','vscan':'0 33.3'},          
      'E':{'hscan':'66.6 100','vscan':'33.3 66.6'},
      'SE':{'hscan':'66.6 100','vscan':'66.6 100'},
      'S':{'hscan':'33.3 66.6','vscan':'66.6 100'},
      'SW':{'hscan':'0 33.3','vscan':'66.6 100'},
      'W':{'hscan':'0 33.3','vscan':'33.3 66.6'},
      'NW':{'hscan':'0 33.3','vscan':'0 33.3'},
    }

def bobloop():
    for cy in cyborgs:
Example #6
0
#!/usr/bin/env python
import logging
logging.basicConfig(level=logging.DEBUG)
logging.info('Started')
from pycyborg import get_all_cyborgs

if __name__ == '__main__':
    cyborgs = get_all_cyborgs()
    print("found and initialized %s cyborg ambx gaming lights" %
          (len(cyborgs)))
    if len(cyborgs) != 0:
        logging.info('Using %s', cyborgs[0].usbdev.backend.__module__)

    counter = 0
    for cy in cyborgs:
        counter += 1
        print("Cyborg %s: " % counter)
        print(cy)
        cy.set_intensity(50)
        cy.set_rgb_color(255, 255, 255)
        cy.transition_to(255, 0, 0, duration=0.3)
        cy.transition_to(0, 255, 0, duration=0.3)
        cy.transition_to(0, 0, 255, duration=0.3)
        cy.transition_to(0, 0, 0, duration=0.3)
        print("")
Example #7
0
    def play(self,offset=0,end=None):
        trb=None
        pygame.mixer.init()
        
        #load track with sound to get total length
        soundfile=self.soundfile
        totalpos=int(pygame.mixer.Sound(soundfile).get_length()*1000)
        totalpos_str=self._ms_to_minsec(totalpos)
        pygame.mixer.music.load(soundfile)
        secoffset=int(offset/1000.0)
        pygame.mixer.music.play(0,secoffset)
        ticktime=0.001
        lightsoff=LightState(0,0,0)
                

        display=PGdisplay()
        
        
        savedpositions=[]
        
        cyborgs=get_all_cyborgs()
        num_cyborgs=len(cyborgs)
        cont=True
        try:
            while cont:
                if not pygame.mixer.music.get_busy():
                    break
                
                ts=pygame.mixer.music.get_pos()+offset
                
                if end!=None and ts>=end:
                    break
                
                states=[]
                for light in range(self.get_num_lights()):
                    state=self.get_state(ts-self.audiodelay_offset, light)
                    if state==None:
                        state=lightsoff
                    states.append(state)
                    
                    
                    if light<num_cyborgs:
                        cyborgs[light].set_rgb_color(state.r,state.g,state.b)
                
                message="Track: %s msec=%s time=%s\n"%(soundfile,totalpos,totalpos_str)     
                message+="Position: %s\n"%(ts)
                message+="Time: %s\n"%(self._ms_to_minsec(ts))
                key=display.update(message, states)
                if key==pygame.K_c:
                    savedpositions.append(ts)
                time.sleep(ticktime)
        except KeyboardInterrupt:
            pass
        except Exception:
            trb=traceback.format_exc()
        for cyborg in cyborgs:
            cyborg.lights_off()
        
        if trb!=None:
            print trb
        
        if len(savedpositions)>0:
            print "Saved positions: %s"%savedpositions
            for s in savedpositions:
                print """show.set_color(%s,lightlist,color,duration) #%s """%(s,self._ms_to_minsec(s))
Example #8
0
         print "intensity must be 0-100"
         optionparser.print_help()
         sys.exit(1)
 
 pos=None
 if options.position!=None:
     pos=options.position.upper()
     if pos not in POSITION:
         print "position must be one of: center,n,ne,e,se,s,sw,w,nw"
         optionparser.print_help()
         sys.exit(1)
     
 #end arg checking
 
 
 cyborgs=get_all_cyborgs(lights_off=False)
 if options.verbose:
     print "Found %s cyborgs"%len(cyborgs)
 
 #filter by position
 if pos!=None:
     lst=[]
     for cyborg in cyborgs:
         if cyborg.position==pos:
             lst.append(cyborg)
     
     cyborgs=lst
     
 if options.num!=None:
     try:
         onlyone=cyborgs[options.num]
Example #9
0
        if options.intensity < 0 or options.intensity > 100:
            print("intensity must be 0-100")
            optionparser.print_help()
            sys.exit(1)

    pos = None
    if options.position != None:
        pos = options.position.upper()
        if pos not in POSITION:
            print("position must be one of: center,n,ne,e,se,s,sw,w,nw")
            optionparser.print_help()
            sys.exit(1)

    #end arg checking

    cyborgs = get_all_cyborgs(lights_off=False)
    if options.verbose:
        print("Found %s cyborgs" % len(cyborgs))

    #filter by position
    if pos != None:
        lst = []
        for cyborg in cyborgs:
            if cyborg.position == pos:
                lst.append(cyborg)

        cyborgs = lst

    if options.num != None:
        try:
            onlyone = cyborgs[options.num]
Example #10
0
    def play(self,offset=0,end=None):
        trb=None
        pygame.mixer.init()
        
        #load track with sound to get total length
        soundfile=self.soundfile
        totalpos=int(pygame.mixer.Sound(soundfile).get_length()*1000)
        totalpos_str=self._ms_to_minsec(totalpos)
        pygame.mixer.music.load(soundfile)
        secoffset=int(offset/1000.0)
        pygame.mixer.music.play(0,secoffset)
        ticktime=0.001
        lightsoff=LightState(0,0,0)
                

        display=PGdisplay()
        
        
        savedpositions=[]
        
        cyborgs=get_all_cyborgs()
        num_cyborgs=len(cyborgs)
        cont=True
        try:
            while cont:
                if not pygame.mixer.music.get_busy():
                    break
                
                ts=pygame.mixer.music.get_pos()+offset
                
                if end!=None and ts>=end:
                    break
                
                states=[]
                for light in range(self.get_num_lights()):
                    state=self.get_state(ts-self.audiodelay_offset, light)
                    if state==None:
                        state=lightsoff
                    states.append(state)
                    
                    
                    if light<num_cyborgs:
                        cyborgs[light].set_rgb_color(state.r,state.g,state.b)
                
                message="Track: %s msec=%s time=%s\n"%(soundfile,totalpos,totalpos_str)     
                message+="Position: %s\n"%(ts)
                message+="Time: %s\n"%(self._ms_to_minsec(ts))
                key=display.update(message, states)
                if key==pygame.K_c:
                    savedpositions.append(ts)
                time.sleep(ticktime)
        except KeyboardInterrupt:
            pass
        except Exception:
            trb=traceback.format_exc()
        for cyborg in cyborgs:
            cyborg.lights_off()
        
        if trb!=None:
            print(trb)
        
        if len(savedpositions)>0:
            print("Saved positions: %s"%savedpositions)
            for s in savedpositions:
                print("""show.set_color(%s,lightlist,color,duration) #%s """%(s,self._ms_to_minsec(s)))