예제 #1
0
파일: openDoor.py 프로젝트: lbbit/GodDoor
def openDoor():
    gpio.setup(62, 'out')
    gpio.setwarnings(False)
    print 'Set gpio62 as 1\n'
    gpio.set(62, 1)
    time.sleep(1)
    gpio.set(62, 0)
예제 #2
0
def run():
    global mgui
    mgui = GUI.MainGUI(data_model)

    data_model.append(dataobject.DataObject(1, 1))

    modules.append(api_sl.SL_APIrequester(data_model[0]))

    data_model.append(dataobject.DataObject(2, 0))

    modules.append(api_kth.KTH_APIrequester(data_model[1]))

    data_model.append(dataobject.DataObject(2, 1))

    modules.append(api_smhi.SMHI_APIrequester(data_model[2]))

    #request data from each active API module
    for i in range(0, len(modules)):
        modules[i].request()
        threads.append(threading.Thread(target=modules[i].run))
        threads[i].setDaemon(True)
        threads[i].start()

    gpio.set(modules)
    PIRthread = threading.Thread(target=gpio.run)
    PIRthread.setDaemon(True)
    PIRthread.start()

    mgui.start()
예제 #3
0
def init():
    gpio.export(SELECT_GPIO)
    gpio.export(ENABLE_GPIO)
    gpio.set_dir(SELECT_GPIO, "out")
    gpio.set_dir(ENABLE_GPIO, "out")
    gpio.set(SELECT_GPIO, 0)
    gpio.set(ENABLE_GPIO, 1)
 def _set_state(self, name, state):
     g = self.gpios[name]
     gpio_num = g["num"]
     if not g["exported"]:
         gpio.setup(gpio_num, gpio.OUT)
         g["exported"] = True
     g["state"] = state
     gpio.set(gpio_num, state)
예제 #5
0
	def toggle(self):
		
		if gpio.read(57) == 0:
			gpio.set(57, 1)
		elif gpio.read(57) == 1:
			gpio.set(57, 0)
		else:
			pass
예제 #6
0
파일: main.py 프로젝트: samkaufman01/pyLCI
def dcdc_off_on():
    global dcdc_exported
    if not dcdc_exported:
        #DC-DC GPIO not yet set up
        gpio.setup(dcdc_gpio, gpio.OUT)
        dcdc_exported = True
    gpio.set(dcdc_gpio, True)
    sleep(0.5)
    gpio.set(dcdc_gpio, False)
예제 #7
0
 def gpio_setup(self):
     """This sets the GPIO registers up"""
     for key, val in  self.status_register.items():
         gpio.setup(val, "in")
     for key, val in  self.reset_register.items():
         gpio.setup(val, "out")
     for key, val in  self.control_register.items():
         gpio.setup(val, "out")
         gpio.set(val, self.control_register_local[key])
예제 #8
0
 def reset(self):
     #self.RST = m.Gpio(36)
     #self.RST.dir(m.DIR_OUT)
     #self.RST.write(0)   # reset the device
     gpio.setup(GPIO_RESET_PIN, gpio.OUT)
     gpio.set(GPIO_RESET_PIN, 0)
     time.sleep(0.01)
     gpio.set(GPIO_RESET_PIN, 1)
     #self.RST.write(1)   # let the device out of reset
     time.sleep(2.01)  # wait for the CC1110 to come up
예제 #9
0
def toggle(pin):

    if gpio.read(pin) == 0:
        gpio.setup(pin, gpio.OUT)
        gpio.set(pin, 1)
    elif gpio.read(pin) == 1:
        gpio.setup(pin, gpio.OUT)
        gpio.set(pin, 0)
    else:
        print('There was some sort of error, are you using the right pin?')
    print(gpio.read(pin))
예제 #10
0
 def set_state(self, state):
     if not self.gpio_exported:
         gpio.setup(self.gpio_num, gpio.OUT)
         self.gpio_exported = True
     self.gpio_state = state
     if self.switch_types[self.hw_v] == "gpio_inverted":
         gpio.set(self.gpio_num, not state)
     elif self.switch_types[self.hw_v] == "gpio":
         gpio.set(self.gpio_num, state)
     else:
         raise NotImplementedException("DC-DC switch type not supported!")
예제 #11
0
파일: test_gpio.py 프로젝트: darcyg/gpio
 def test_basic(self):
     # with mock_open you have to remember that all files are the same
     # mock object.
     mopen = mock_open(read_data='0')
     with patch(bins + '.open', mopen, create=True) as m:
         gpio.setup(0, gpio.OUT)
         gpio.set(0, 0)
     assertInitialized(self, m)
     # So, "value" could be "direction" or any other file
     written = mockargs(gpio._open[0]['value'].write)
     expected = [('0',), ('out',), ('0',)]
     assertInitialized(self, m)
     self.assertListEqual(written, expected)
예제 #12
0
 def test_basic(self):
     # with mock_open you have to remember that all files are the same
     # mock object.
     mopen = mock_open(read_data='0')
     with patch(bins + '.open', mopen, create=True) as m:
         gpio.setup(0, gpio.OUT)
         gpio.set(0, 0)
     assertInitialized(self, m)
     # So, "value" could be "direction" or any other file
     written = mockargs(gpio._open[0]['value'].write)
     expected = [('0',), ('out',), ('0',)]
     assertInitialized(self, m)
     self.assertListEqual(written, expected)
예제 #13
0
 def set_rgb(self, *colors):
     if len(colors) != 3 or any([type(color)!=int for color in colors]):
         raise TypeError("set_rgb expects three integer arguments - red, green and blue values!")
     if any([color<0 or color>255 for color in colors]):
         raise ValueError("set_rgb expects integers in range from 0 to 255!")
     if self.led_type in ["gpio", "gpio_inverted"]: #HW versions that have GPIO-controlled LED
         gpios = self.get_rgb_gpios()
         for i, gpio_num in enumerate(gpios):
             gpio_state = colors[i]>0 #Only 0 and 255 are respected
             if self.led_type == "gpio_inverted": gpio_state = not gpio_state
             gpio.set(gpio_num, gpio_state)
     else:
         raise NotImplementedException("LED control type not supported!")
예제 #14
0
파일: josh.py 프로젝트: sobi-wan/helmet
def updateIndicators(stop_event):
    blinker = 0
    while not stop_event.wait(0.1):
        v = read(button_switch)
        #print "button-switch", v
        if v:  ##disabled the blinker## and blinker<15:
            set(led_red, 0)
        else:
            set(led_red, 1)
        blinker = blinker + 1
        if blinker >= 20:
            blinker = 0
    print 'updateIndicators thread has terminated.'
예제 #15
0
def get_gsm_reset_gpio():
    hw_revs = [["Gamma", "gamma"], ["Delta/Delta-B", "delta"]]
    gpios = {"gamma":502, "delta":496}
    assert(all([hwr[1] in gpios.keys() for hwr in hw_revs])) # check after editing
    hwr = Listbox(hw_revs, i, o, name="Hardware setup app GSM FW picker").activate()
    if not hwr:
        return None
    if hwr == "delta":
        # Enable UARTs
        gpio.setup(500, gpio.OUT)
        gpio.set(500, False)
    gp = gpios[hwr]
    return gp
예제 #16
0
def gpioread():
    keys = []
    for writeport in range(80, 87):
        if writeport == 86:
            writeport = 136
        gpio.set(writeport, 1)
        time.sleep(0.002)
        key = 0
        for readport in range(135, 127, -1):
            key = (key << 1) + gpio.read(readport)
        key = ~((key ^ (key >> 1)) & 0x1f ^ (key >> 1)) & 0x7f
        keys.append(key)
        gpio.set(writeport, 0)
    return keys
 def set_rgb(self, *colors):
     """Sets the color of the led from RGB values [0-255] range"""
     colors = [int(c) for c in colors]
     if len(colors) != 3 or any([type(color) != int for color in colors]):
         raise TypeError(
             "set_rgb expects three integer arguments - red, green and blue values!"
         )
     if any([color < 0 or color > 255 for color in colors]):
         raise ValueError(
             "set_rgb expects integers in range from 0 to 255!")
     gpios = self._get_rgb_gpios()
     for i, gpio_num in enumerate(gpios):
         gpio_state = colors[i] < 255  # Only 0 and 255 are respected
         gpio.set(gpio_num, gpio_state)
예제 #18
0
    def writeCommandToModbus(self, data):
        # delay
        time.sleep(.02)
        ser = self.serial
        dataList = getCRC16(data)
        # write
        GPIO.set(self.tr, 0)
        ser.write(dataList)
        ser.flush()

        # read
        GPIO.set(self.tr, 1)
        # the first three numbers for the fixed code, the last two numbers CRC code
        words = dataList[5]  # words length
        length = 3 + words * 2 + 2
        response = ser.read(length)  # send command to meter and get response
        # Convert hex string to array
        response = array.array('B', response)

        return response
예제 #19
0
	def run(self, recording_length=-1):
		# recording_length: time (in sec) to spend recording data.
		# -1: record for indefinite amount of time, until terminated by pressing 'q' or powering off the system

		# initialize video capture
		cap = cv2.VideoCapture(0)

		data = []
		recording_start = datetime.datetime.now()
		prevTime = datetime.datetime.now()
		timeLastUsed = datetime.datetime.now()
		finished = False
		alarm_signal = 0
		
		#gpio stuff
		gpio.setup(57, gpio.OUT)
		gpio.set(57, 0)
		
		i = 0
		
		#aruco stuff
		square_length = 6.35
		markerLength = 5.08
		dictionary = cv2.aruco.Dictionary_get(aruco.DICT_6X6_250) #AR tag dictionary
		board = cv2.aruco.CharucoBoard_create(4,2,square_length,markerLength,dictionary)


		while not finished:
			
			#show video with alarm state
		
			ret, frame = cap.read()
			gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
			res = cv2.aruco.detectMarkers(gray,dictionary) #output: corners, ids,rejected imgpts
 			cv2.aruco.drawDetectedMarkers(gray,res[0],res[1])
			cv2.putText(frame, "Alarm is %s" %alarm_signal, (10,100), cv2.FONT_HERSHEY_COMPLEX_SMALL, 1, (255,0,0))
			cv2.imshow('frame',gray)

    		i += 1
예제 #20
0
 def focusAuto(self):
     self.contour = True
     self.focus_in.setEnabled(False)
     self.focus_out.setEnabled(False)
     self.focus_auto.setEnabled(False)
     gpio.set(self.focuserRUN, 0)
     gpio.set(self.focuserIN, 0)
     gpio.set(self.focuserOUT, 0)
     tr = threading.Thread(target=self.autoFocus)
     tr.start()
예제 #21
0
파일: eq.py 프로젝트: chrisy/pfft
def read():
	# Send a reset signal
	gpio.set(24, 1)
	gpio.set(23, 1)
	gpio.set(23, 0)
	gpio.set(24, 0)

	l = []
	r = []

	for i in range(7):
		gpio.set(23, 1)
		gpio.set(23, 0)
		l.append(adc.read(2))
		r.append(adc.read(3))

	return [l, r]
예제 #22
0
 def V7_INIT_B_set(self, value):
     gpio.set(self.reset_register.get("V7_INIT_B"), value)
예제 #23
0
import gpio
import time

for i in range(10, 14):
    gpio.setup(i, 'out')

for i in range(0, 100):
    for i in range(10, 14):
        gpio.set(i, 1)
        time.sleep(0.3)
    for i in range(10, 14):
        gpio.set(i, 0)
        time.sleep(0.3)
예제 #24
0
 def LPMODE1_set(self, value):
     self.control_register_local["LPMODE1"]=value
     gpio.set(self.control_register.get("LPMODE1"), value)
예제 #25
0
파일: led.py 프로젝트: chrisy/pfft
def rgb_reset():
	buf = []
	for i in range(rgb_clear_count):
		buf.append(0)
	gpio.set(25, 1)
	spi.xfer2(buf, speed, 500, bpw)
예제 #26
0
파일: led.py 프로젝트: chrisy/pfft
def led_send(values):
	gpio.set(25, 0)
	spi.xfer2(values, speed, 500, bpw)
예제 #27
0
 def V7_PRG_ZY_set(self, value):
     gpio.set(self.reset_register.get("V7_PRG_ZY"), value)
예제 #28
0
파일: led.py 프로젝트: chrisy/pfft
def rgb_send(values):
	gpio.set(25, 1)
	spi.xfer2(values, speed, 500, bpw)
	rgb_reset()
예제 #29
0
 def MODPRSL1_set(self, value):
     self.control_register_local["MODPRSL1"]=value
     gpio.set(self.control_register.get("MODPRSL1"), value)
예제 #30
0
 def RESETL1_set(self, value):
     gpio.set(self.reset_register.get("RESETL1"), value)
예제 #31
0
 def ZYNC_FW_RST_N_set(self, value):
     gpio.set(self.reset_register.get("ZYNC_FW_RST_N"), value)
예제 #32
0
    def set_flash(self, value):
        
        if value == 1:
            gpio.set(self.control_register.get("FSEL_1_DE"), 0)
            self.control_register_local["FSEL_1_DE"] = 0
            gpio.set(self.control_register.get("FSEL_0_DE"), 0)
            self.control_register_local["FSEL_0_DE"] = 0
            self.selected_flash = value

        if value == 2:
            gpio.set(self.control_register.get("FSEL_1_DE"), 0)
            self.control_register_local["FSEL_1_DE"] = 0
            gpio.set(self.control_register.get("FSEL_0_DE"), 1)
            self.control_register_local["FSEL_0_DE"] = 1
            self.selected_flash = value
            
        if value == 3:
            gpio.set(self.control_register.get("FSEL_1_DE"), 1)
            self.control_register_local["FSEL_1_DE"] = 1
            gpio.set(self.control_register.get("FSEL_0_DE"), 0)
            self.control_register_local["FSEL_0_DE"] = 0
            self.selected_flash = value

        if value == 4:
            gpio.set(self.control_register.get("FSEL_1_DE"), 1)
            self.control_register_local["FSEL_1_DE"] = 1
            gpio.set(self.control_register.get("FSEL_0_DE"), 1)
            self.control_register_local["FSEL_0_DE"] = 1
            self.selected_flash = value
        else:
            print("Not a valid number, no change!")
예제 #33
0
 def P1V0_EN_ZYNC_set(self, value):
     self.control_register_local["P1V0_EN_ZYNC"]=value
     gpio.set(self.control_register.get("P1V0_EN_ZYNC"), value)
예제 #34
0
파일: main.py 프로젝트: samkaufman01/pyLCI
def dcdc_off():
    global dcdc_exported
    if not dcdc_exported:
        gpio.setup(dcdc_gpio, gpio.OUT)
        dcdc_exported = True
    gpio.set(dcdc_gpio, True)
예제 #35
0
 def QSFP_I2C_SEL0_set(self, value):
     self.control_register_local["QSFP_I2C_SEL0"]=value
     gpio.set(self.control_register.get("QSFP_I2C_SEL0"), value)