def __init__(self,root,GUIcolors,pSize,ll=19,rl=26,sl=18): self.rightLight=l.light(rl) self.leftLight=l.light(ll) self.sumpLight=l.light(sl) self.rightLightSchedule=[[0,0,False]] self.leftLightSchedule=[[0,0,False]] self.sumpLightSchedule=[[0,0,False]] self.opperationStatus=False self.time=t.localtime() #3 for hour 4 for minute self.leftSchedulePlace=0 self.rightSchedulePlace=0 self.sumpSchedulePlace=0 self.thread=Thread() self.thread.start() self.thread.join() self.rLC=False self.lLC=False self.sLC=False #gui stuff self.pX=pSize[0] self.pY=pSize[1] self.root=root self.bgC=GUIcolors[0] self.fgC=GUIcolors[1] self.bdC=GUIcolors[2] self.frame=Frame() self.settupGUI() self.setupSecondGUI() self.control='' self.currentProfile=0 self.settupProfileGUI()
def op_operate_with_light(angle_qingxie=45, unlock_direction='r'): op = operate(angle_qingxie,unlock_direction) op.start() light_first = light.light("green", "sblink", 2) light_first.start() light_first.join() light_first = light.light("green", "still", 10) light_first.start() light_second.join() light_third = light.light_still("blue") light_third.start() light_third.join() op.join()
def main(): lamp = light(3, pulseFlag = True, tempFlag = True) player.playRandomMoodSong(lamp.state) tempDifference = valueTracker(30) ambientHeat = valueTracker(50) pulseMeter = valueTracker(30) #continuous loop taking value from serial port for line in port: #print "Output:" #print line values = str.split(line) ambientTemp = float(values[0]) probeTemp = float(values[1]) pulse = int(values[3]) #print temp #print sensor #print pulse #tracker updates tempValue = tempDifference.update(probeTemp-ambientTemp) if not tempValue == -1: #action on valid response: print "Current temperature Difference: " + str(tempValue) lamp.tempValue = tempValue pulseValue = pulseMeter.update(pulse) if pulseValue <= 0: #print "pulse False" lamp.pulse = False #pass else: #print "pulse True" lamp.pulse = True #lamp.pulseOnceFlag = True lamp.update() updateMusic(lamp)
import numpy as np from math import * import cv2 from point import * from light import light from player import player from surface import surface me = player() li = light() res = me.ppdist * 2 img = np.zeros((res, res, 3), np.uint8) mytri = surface('tri', point(0, 10, 0), point(10, 20, 0), point(0, 30, 10)) k = cv2.waitKey(10) & 0xFF norm = cross(sub(mytri.p2, mytri.p1), sub(mytri.p3, mytri.p1)) mnorm = norm.mod() while (k != 27): img = np.zeros((res, res, 3), np.uint8) n1 = add(mytri.p1, me.position) n2 = add(mytri.p2, me.position) n3 = add(mytri.p3, me.position) n1.project(me.ppdist) n2.project(me.ppdist) n3.project(me.ppdist) n1 = me.findfinal(n1)
from parameters import TILE_WIDTH, TILE_HEIGHT, MAP_HEIGHT, MAP_WIDTH, ENEMY_NUM # Load game essentials game.init() game.font.init() screen = game.display.set_mode((720, 480)) clock = game.time.Clock() game.display.set_caption("Duno") quit = False count = 1 # Floor count # Load game staples tile = game.image.load("floorTile.png") # Tile image stairs = game.image.load("stairs.png") # Tile image lighting = light.light() # Black image to cover the screen everything = [] # Holds all enemies, dust, and explosions font = game.font.SysFont("Ariel", 30) text = font.render("Floor " + str(count), False, (255, 255, 255)) message = None # Start playing music at the beginning of the game sound.song.play(-1) sound.song.fadeout(200000) sound.scary.play(-1, fade_ms=200000) level, rooms = events.placeRooms() # Create all of the tiles player = entity.player((rooms[0][0]) * TILE_WIDTH, (rooms[0][1]) * TILE_HEIGHT, everything) follow = camera.centerScreen(player) everything[:] = []
import barcode import light import serverAPI import datetime import LPR duration = 60 heartbeat = 60 # initialize barcode reader, vehSensor, lights barcode = barcode.barcode('/dev/ttyACM0') #barcode = barcode.barcode('/dev/tty.usbmodemfa141') vehSensor = vehSensor.vehSensor() #LPR = LPR.LPR() ledGreen = light.light(32) ledRed = light.light(33) server = serverAPI.serverAPI('lot-manager','test123','Marina Middle School') startTime = time.time() heartbeatTime = time.time() qrReg = [] checkedIn = [] checkedOut = [] print "Parq Place demo started..." # FUNCTION DEFINITIONS
pin_light = 13 pin_step = 24 #Yellow delay = 0.01 pin_direction = 23 #Orange pin_ms1 = 20 #Blue pin_ms2 = 21 #Teal #brown is ground #pin_enable = 25 #pin_reset = 22 is_light_on = False cw = True ccw = False switch = l.light(pin_switch, pin_light) stepper = ed.easydriver(pin_step, delay, pin_direction, pin_ms1, pin_ms2) HOME_POS = 0 ADS1115 = 0x01 # 16-bit ADC adc = ADS1x15(ic=ADS1115) '''Arguments to pass or set up after creating the instance. Step GPIO pin number. Delay between step pulses in seconds. Direction GPIO pin number. Microstep 1 GPIO pin number. Microstep 2 GPIO pin number. Sleep GPIO pin number. Enable GPIO pin number.
import serial import time import random from sound import soundManager from light import light from lick import lick light = light() ser = serial.Serial() ser.baudrate = 115200 ser.port = "/dev/ttyUSB0" ser.open() soundman = soundManager() pir_spot = False pir_room = False pir_spot_time = 0 pir_room_time = 0 buy_time = 0 buy_light = False lick = lick() for i in range(0, 6): ser.send("/i/s/" + str(lick.getLevel(i)) + "\r\n")
import os, time, __builtin__ import light, lightSensor, clock, musicPlayer, button, webui, curtain import RPi.GPIO as GPIO GPIO.setwarnings(False) # variables __builtin__.enableAlarm = True isplayingmusic = False # create instance of modules lightsensor = lightSensor.lightSensor(7) ledlight = light.light(3) alarmclock = clock.Clock() button = button.Button(12) musicPlayer = musicPlayer.MusicPlayer('little_love_song.mp3') curtain = curtain.curtain(700) # store instances into __builtin__ __builtin__.lightsensor = lightsensor __builtin__.ledlight = ledlight __builtin__.alarmclock = alarmclock __builtin__.button = button __builtin__.musicPlayer = musicPlayer __builtin__.curtain = curtain # for test, set the time of alarm clock alarmclock.settingAlarmClock(8,0) # start web ui (django) webui.setEnv() webui.runInBackGround()
def draw_ray(source, ins): for s in source: test = light.light(s.rect.centerx, s.rect.centery, s, s.screen) inter(test, ins)
import csv from writemod import writemod k = time.localtime() filename = str(k[1]) + '_' + str(k[2]) + '_' + str(k[3]) + '_' + str( k[4]) + '_' + str(k[3]) + '.csv' fields = [ "Hour", "Min", "Sec", "xGyro", "yGyro", "zGyro", "xAccl", "yAccel", "zAccel", "xMag", "yMag", "zMag", "Lux", "Humididty", "Pressure", "Temp", "Incedences/S" ] writemod(fields, filename) while 1: accelOut = accelmag() luxOut = light() pthOut = pth() eventCount = 456 geigerOut = geiger() time.sleep(11) k = time.localtime() Hour = str(k[3]) Min = str(k[4]) dataOut = [Hour, Min] dataOut.extend(accelOut) dataOut.extend(luxOut) dataOut.extend(pthOut) dataOut.extend(geigerOut)
import numpy as np from math import * import cv2 from point import * from light import light from player import player from surface import surface me = player() li = light() res = me.ppdist*2 img = np.zeros((res,res,3), np.uint8) mytri = surface('tri', point(0,10,0), point(10,20,0), point(0,30,10)) k = cv2.waitKey(10) & 0xFF norm = cross( sub(mytri.p2, mytri.p1), sub(mytri.p3, mytri.p1) ) mnorm = norm.mod() while(k != 27): img = np.zeros((res,res,3), np.uint8) n1 = add(mytri.p1,me.position) n2 = add(mytri.p2,me.position) n3 = add(mytri.p3,me.position) n1.project(me.ppdist) n2.project(me.ppdist) n3.project(me.ppdist) n1 = me.findfinal(n1)