pantilthat.light_type(pantilthat.GRB); elif( list[1] == 'RGBW' ): pantilthat.light_type(pantilthat.RGBW); elif( list[1] == 'GRBW' ): pantilthat.light_type(pantilthat.GRBW); else: print('error: light_type requires parameter RBB, GRB, RGBW or GRBW'); elif( command == 'light_mode' and len(list)>=2): if( list[1] == 'PWM' ): pantilthat.light_mode(pantilthat.PWM); elif( list[1] == 'WS2812' ): pantilthat.light_mode(pantilthat.WS2812); else: print('error: light_mode requires parameter PWM or WS2812'); elif (command == 'brightness' and len(list)>=2): pantilthat.brightness(float(list[1])); elif( command == 'set_all' and len(list)==4): pantilthat.set_all(int(list[1]), int(list[2]), int(list[3])); elif( command == 'set_all' and len(list)==5): print("setting three colours and white"); pantilthat.set_all(int(list[1]), int(list[2]), int(list[3]), int(list[4])); elif( command == 'set_pixel' and len(list)==5): pantilthat.set_pixel(int(list[1]), int(list[2]), int(list[3]), int(list[4])); elif( command == 'set_pixel' and len(list)==6): pantilthat.set_pixel(int(list[1]), int(list[2]), int(list[3]), int(list[4]), int(list[5])); elif( command == 'show'): pantilthat.show(); else: print('error processing command'); except:
#!/usr/bin/env python import math import time import pantilthat pantilthat.light_mode(pantilthat.PWM) while True: b = (math.sin(time.time() * 2) + 1) / 2 b = int(b * 255.0) t = round(time.time() * 1000) / 1000 a = round(math.sin(t) * 90) pantilthat.pan(int(a)) pantilthat.tilt(int(a)) pantilthat.brightness(b) print(a) time.sleep(0.04)
in_id = int(sys.argv[1]) in_id = (in_id - 1) % max_shelves # convert to C array notation in_pos = int(sys.argv[2]) print "searching: %i %i" % (in_id, in_pos) # find new_pan = shelves[in_id].map_pos_to_angles(in_pos) new_tilt = shelves[in_id].tilt_pos # debug print "output: %i %i" % (new_pan, new_tilt) #exit() # start laser pantilthat.light_mode(pantilthat.PWM) pantilthat.brightness(128) # do the requests pan = orig_pan pan_incr = 1 if new_pan > orig_pan else -1 while pan != new_pan: pan = pan + pan_incr #print pan pantilthat.pan(pan) tick() tilt = orig_tilt tilt_incr = 1 if new_tilt > orig_tilt else -1 while tilt != new_tilt: tilt = tilt + tilt_incr #print tilt