コード例 #1
0
ファイル: chip.py プロジェクト: illperipherals/AlexaPi
	def indicate_setup_failure(self):
		while True:
			for _ in range(0, 5):
				time.sleep(.1)
				GPIO.output(self.__pconfig['rec_light'], GPIO.HIGH)
				time.sleep(.1)
				GPIO.output(self.__pconfig['rec_light'], GPIO.LOW)
コード例 #2
0
def xfer2(byte_list):
    """Transfer a list of bytes and store the returned values"""
    stored_bytes = []
    for byte in byte_list:
        temp_byte = byte
        store_byte = 0x00
        for i in np.arange(8):
            store_byte *= 2

            if temp_byte & 0b10000000 > 0:
                GPIO.output(PIN_SDI, GPIO.HIGH)
            else:
                GPIO.output(PIN_SDI, GPIO.LOW)
            temp_byte*=2
                
            #time.sleep(0.001)
            GPIO.output(PIN_SCK, GPIO.HIGH)
            #time.sleep(0.001)
            if GPIO.input(PIN_SDO):
                store_byte += 1
            GPIO.output(PIN_SCK, GPIO.LOW)

        GPIO.output(PIN_SDI, GPIO.LOW)
        stored_bytes.append(store_byte)

    return stored_bytes
コード例 #3
0
ファイル: chip_gpio.py プロジェクト: Manuel83/craftbeerpi
    def init(self):
        app.logger.info("INIT GPIO")
        try:
            app.logger.info(app.brewapp_hardware_config)
            for h, hw in app.brewapp_hardware_config.items():
                app.logger.info(hw)

                g = hw["config"]["switch"]
                app.logger.info(g)

                if not g:
                    continue

                app.logger.info("SETUP HARDWARE: " + str(h) + " GPIO: " + str(g))
                GPIO.setup(g, GPIO.OUT)

                if self.getConfigValue(h, "inverted", False):
                    app.logger.warning("SETUP INVERTED")
                    GPIO.output(g, GPIO.HIGH)
                else:
                    app.logger.warning("SETUP NOT INVERTED")
                    GPIO.output(g, GPIO.LOW)

            app.brewapp_gpio = True
            self.state = True
            app.logger.info("ALL GPIO INITIALIZED")

        except Exception as e:
            app.logger.error("SETUP GPIO FAILD " + str(e))
            app.brewapp_gpio = False
            self.state = False
コード例 #4
0
 def act(self, client_address, state, name):
     print "State", state, "from client @", client_address
     GPIO.setmode(GPIO.BOARD) ## Use board pin numbering
     GPIO.setup(str(sys.argv[3]), GPIO.OUT)   ## Setup GPIO Pin to OUTPUT
     GPIO.output(str(sys.argv[3]), not state) ## State is true/false
     GPIO.cleanup(str(sys.argv[3]))
     return True
コード例 #5
0
ファイル: rfid.py プロジェクト: drbobbob/rfidreader
 def open_door(self):
     logger.info("door is open")
     GPIO.output(self.pin, False)
     #time.sleep(self.openduration)
     time.sleep(10.0)
     logger.info("door is closed")
     GPIO.output(self.pin, True)
コード例 #6
0
ファイル: burnGPIO.py プロジェクト: danjperron/burnLVP
def Setup_Interface():
  GPIO.setwarnings(False)
  GPIO.setmode(GPIO.BOARD)
  MGPIO.setup(PIC_MCLR,GPIO.OUT)
  MGPIO.output(PIC_MCLR,False)
  MGPIO.setup(PIC_CLK,GPIO.OUT)
  MGPIO.setup(PIC_DATA,GPIO.OUT)
  MGPIO.setup(PIC_PGM,GPIO.OUT)
コード例 #7
0
ファイル: chip.py プロジェクト: illperipherals/AlexaPi
	def setup(self):
		GPIO.setwarnings(False)
		GPIO.cleanup()
		GPIO.setup(self.__pconfig['button'], GPIO.IN, pull_up_down=GPIO.PUD_UP)
		GPIO.setup(self.__pconfig['rec_light'], GPIO.OUT) # lights'], GPIO.OUT)
		GPIO.setup(self.__pconfig['plb_light'], GPIO.OUT) # lights'], GPIO.OUT)
		GPIO.output(self.__pconfig['rec_light'], GPIO.LOW)
		GPIO.output(self.__pconfig['plb_light'], GPIO.LOW)
コード例 #8
0
ファイル: board_config_CHIP.py プロジェクト: buzali/pySX127x
 def led_on(value=0):
     """ Switch the proto shields LED
     :param value: 0/1 for off/on. Default is 1.
     :return: value
     :rtype : int
     """
     GPIO.output(BOARD.LED, value)
     return value
コード例 #9
0
ファイル: start.py プロジェクト: pimpmypixel/dejavu
def blinkLed(blinks):
    GPIO.setup("XIO-P0", GPIO.OUT)
    for j in range(1, blinks):
        GPIO.output("XIO-P0", GPIO.LOW)
        time.sleep(0.05)
        GPIO.output("XIO-P0", GPIO.HIGH)
        time.sleep(0.05)
    GPIO.cleanup()
    return
コード例 #10
0
ファイル: rfid.py プロジェクト: drbobbob/rfidreader
    def setup_gpio(self):

        GPIO.setwarnings(False)
        try:
            GPIO.setmode(GPIO.BOARD)
        except AttributeError:
            pass
        GPIO.setup(self.pin, GPIO.OUT)
        GPIO.output(self.pin, True)
コード例 #11
0
ファイル: gptest.py プロジェクト: cornbreadheadman/CHIP_IO
def loopfunction():
    print "LOOP FUNCTION"
    for i in xrange(20):
        if i % 2:
            print "SETTING CSID0 LOW"
            GPIO.output("CSID0",GPIO.LOW)
        else:
            print "SETTING CSID0 HIGH"
            GPIO.output("CSID0",GPIO.HIGH)
        print "SLEEPING"
        time.sleep(1)
コード例 #12
0
def setup():
    """Setup GPIO ports"""
    print("Setting up SPI GPIO connections..."),
    #Setup GPIO pins
    GPIO.setup(PIN_SDI, GPIO.OUT)
    GPIO.setup(PIN_SDO, GPIO.IN)
    GPIO.setup(PIN_SCK, GPIO.OUT)

    #Initialize output pins
    GPIO.output(PIN_SDI, GPIO.LOW)
    GPIO.output(PIN_SCK, GPIO.LOW)
    print("[DONE]")
コード例 #13
0
ファイル: start.py プロジェクト: slimjim2234/car_remote_start
def sequence():
  # run-start position
  print("Run-Start Position")
  GPIO.output(gpioRunStart, GPIO.HIGH)
  confirmation(gpioRunStart)
  time.sleep(sleepRunStart)

  # run position 
  print("Run Position")
  GPIO.output(gpioRun, GPIO.HIGH)
  confirmation(gpioRun)
  time.sleep(sleepRun)

  # Start it!
  print("Start position")
  if Am_I_Serious():
    print("Cranking!!!")
    GPIO.output(gpioIgnitionStart, GPIO.HIGH)
    confirmation(gpioIgnitionStart)
    time.sleep(sleepIgnitionStart)
    GPIO.output(gpioIgnitionStart, GPIO.LOW)
    confirmation(gpioIgnitionStart)
  else:
    print("no balls, get some and try again later")

  # Press enter to stop car
  gotinput("Started! Press enter to stop the jeep....")
  
  clear()
コード例 #14
0
ファイル: board_config_CHIP.py プロジェクト: buzali/pySX127x
 def setup():
     """ Configure the CHIP GPIOs
     :rtype : None
     """
     # LED
     GPIO.setup(BOARD.LED, GPIO.OUT)
     GPIO.output(BOARD.LED, 1)
     # switch
     GPIO.setup(BOARD.SWITCH, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
     # DIOx
     for gpio_pin in [BOARD.DIO0, BOARD.DIO1, BOARD.DIO2, BOARD.DIO3]:
         GPIO.setup(gpio_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
     # blink 2 times to signal the board is set up
     BOARD.blink(.1, 2)
コード例 #15
0
ファイル: gptest.py プロジェクト: HeatfanJohn/CHIP_IO
def loopfunction():
    print("LOOP FUNCTION START")
    for i in xrange(4):
        if loopfunction_exit:
            break
        if i % 2:
            mystr = "SETTING CSID0 LOW (i=%d)" % i
            print(mystr)
            GPIO.output("CSID0", GPIO.LOW)
        else:
            mystr = "SETTING CSID0 HIGH (i=%d)" % i
            print(mystr)
            GPIO.output("CSID0", GPIO.HIGH)
        print(" LOOP FUNCTION SLEEPING")
        time.sleep(1)
コード例 #16
0
ファイル: chip_gpio.py プロジェクト: Manuel83/craftbeerpi
    def switchOFF(self, device):
        app.logger.info("GPIO OFF" + str(device))
        if not app.brewapp_gpio:
            app.logger.warning("GPIO TEST MODE ACTIVE. GPIO is not switched off" + str(device))
            return

        switch_name = self.getConfigValue(device, "switch", None)
        if switch_name is None:
            app.logger.warning("SWITCH NOT FOUND IN CONFIG")

        if self.getConfigValue(device, "inverted", False):
            app.logger.warning("SWITCH OFF - Inverted")
            GPIO.output(switch_name, GPIO.HIGH)
        else:
            app.logger.warning("SWITCH OFF - Not Inverted")
            GPIO.output(switch_name, GPIO.LOW)
コード例 #17
0
ファイル: blink.py プロジェクト: trafferty/utils
def blink(n, f):
    t = (1.0/f) / 2.0
    GPIO.output("CSID0", 0)
    for x in range(n+1):
        GPIO.output("CSID0", 1)
        time.sleep(t)
        GPIO.output("CSID0", 0)
        time.sleep(t)
コード例 #18
0
def update_clock_leds():
    binary_time = get_binary_time()

    print_time(binary_time)
    #load values into pins
    for index in range(0,6):
        GPIO.output(hour_leds[index], binary_time["hour"][index])
        GPIO.output(minute_leds[index], binary_time["minute"][index])
        GPIO.output(second_leds[index], binary_time["second"][index])
コード例 #19
0
def P0_control(value):
    GPIO.output('XIO-P0', value)
    return GPIO.input('XIO-P0')
コード例 #20
0
def readADC(dout,pd_sck,gain_select):

    if not isReady(dout): # If data pin is low, ADC is ready
        data = []
        for i in range(0,24): # do 24 times
            # Pulse the ADC once
            GPIO.output(pd_sck,GPIO.HIGH) # push to high to get the value
            data.append(GPIO.input(dout)) # read value from ADC and append to data
            GPIO.output(pd_sck,GPIO.LOW) # end low

        if gain_select == 128:  # if you want 128 gain pulse one more time. 25 times total
            GPIO.output(pd_sck,GPIO.HIGH) # Pulse
            GPIO.output(pd_sck,GPIO.LOW)

        if gain_select == 64: # if you want 32 gain, channel B pulse two more times. 26 times total
            for i in range(0,2): # do 2 times
                GPIO.output(pd_sck,GPIO.HIGH) # Pulse
                GPIO.output(pd_sck,GPIO.LOW)

        if gain_select == 32: # if you want 64 gain pulse three more times. 27 times total
            for i in range(0,3): # do 3 times
                GPIO.output(pd_sck,GPIO.HIGH) # Pulse
                GPIO.output(pd_sck,GPIO.LOW)

        print(data)
        data = 0 # Clear data for next read
    
    else:
        print('ADC is not ready!') # If data pin is high, ADC is not ready
コード例 #21
0
#!/usr/bin/env  python3

import CHIP_IO.GPIO as GPIO
import CHIP_IO.Utilities

red = "XIO-P1"
yellow = "XIO-P0"

GPIO.cleanup(red)
GPIO.cleanup(yellow)
CHIP_IO.Utilities.unexport_all()

GPIO.setup(red, GPIO.OUT)
GPIO.setup(yellow, GPIO.OUT)

GPIO.output(red, GPIO.LOW)
GPIO.output(yellow, GPIO.LOW)

GPIO.cleanup(red)
GPIO.cleanup(yellow)
CHIP_IO.Utilities.unexport_all()

コード例 #22
0
# Import Library
import CHIP_IO.GPIO as GPIO
import time

# Setup Pins
print(" ")
print("Keurig 2.0 HACKED")
print("Please wait...")
GPIO.setup("GPIO4", GPIO.OUT)  #XIO-P5 Handle
GPIO.setup("GPIO6", GPIO.OUT)  #XIO-P7 Button
GPIO.output("GPIO4", GPIO.HIGH)
GPIO.output("GPIO6", GPIO.HIGH)
time.sleep(1)

# Start Brew Sequence
print("Brewing")
GPIO.output("GPIO4", GPIO.LOW)
time.sleep(1)
print("Handle Activated")
GPIO.output("GPIO4", GPIO.HIGH)
time.sleep(4)

print("Button Activated")
GPIO.output("GPIO6", GPIO.LOW)
time.sleep(1)

GPIO.output("GPIO4", GPIO.HIGH)
GPIO.output("GPIO6", GPIO.HIGH)
time.sleep(1)

print("All Done")
コード例 #23
0
ファイル: gptest.py プロジェクト: cornbreadheadman/CHIP_IO
            print "SETTING CSID0 HIGH"
            GPIO.output("CSID0",GPIO.HIGH)
        print "SLEEPING"
        time.sleep(1)
    
print "SETUP XIO-P0"
GPIO.setup("XIO-P0", GPIO.IN)

print "SETUP CSID0"
GPIO.setup("CSID0", GPIO.OUT)

# VERIFY SIMPLE FUNCTIONALITY
print "VERIFY SIMPLE FUNCTIONALITY"

print "READING XIO-PI"
GPIO.output("CSID0", GPIO.HIGH)
print "HIGH", GPIO.input("XIO-P0")

GPIO.output("CSID0", GPIO.LOW)
print "LOW", GPIO.input("XIO-P0")

# ==============================================
# EDGE DETECTION - AP-EINT1
print "SETTING UP EDGE DETECTION ON AP-EINT1"
GPIO.setup("AP-EINT1", GPIO.IN)
GPIO.add_event_detect("AP-EINT1",GPIO.FALLING)

print "VERIFYING EDGE DETECT"
f = open("/sys/class/gpio/gpio193/edge","r")
edge = f.read()
f.close()
コード例 #24
0
ファイル: chip.py プロジェクト: illperipherals/AlexaPi
	def indicate_recording(self, state=True):
		GPIO.output(self.__pconfig['rec_light'], GPIO.HIGH if state is True else GPIO.LOW)
コード例 #25
0
ファイル: chip.py プロジェクト: illperipherals/AlexaPi
	def cleanup(self):
		GPIO.remove_event_detect(self.__pconfig['button'])

		GPIO.output(self.__pconfig['rec_light'], GPIO.LOW)
		GPIO.output(self.__pconfig['plb_light'], GPIO.LOW)
コード例 #26
0
ファイル: nopeustesti.py プロジェクト: bearocious/Nopeustesti
def lediKiinni(mikaledi):
    GPIO.output("XIO-P" + str(mikaledi + 1), 1)
    return None
コード例 #27
0
ファイル: nopeustesti.py プロジェクト: bearocious/Nopeustesti
def lediPaalle(mikaledi):
    GPIO.output("XIO-P" + str(mikaledi + 1), 0)
    return None
コード例 #28
0
# the following assumes that an LED is run from VCC to xio-p0 with its cathode in the latter
# ie: pulling pin low turns LED on, setting high turns it off

import CHIP_IO.GPIO as GPIO

GPIO.setup("XIO-P0", GPIO.OUT)
GPIO.output("XIO-P0", GPIO.LOW)
コード例 #29
0
ファイル: blackbox.py プロジェクト: tychobarendse/terminalbox
from luma.core.interface.serial import i2c
from luma.core.render import canvas
from luma.oled.device import ssd1306
import os.path
from luma.core.render import canvas
from PIL import ImageFont, ImageDraw
import serial
import time
import keypad as key
import nmcli
from ESPSSD import Screen
key.Setup()

enableGPS = "XIO-P0"
GPIO.setup(enableGPS, GPIO.OUT, initial=1)
GPIO.output(enableGPS, GPIO.LOW)  #pull GND pin NEO-6M down to enable module
print "GPS enabled............."
time.sleep(2)

Oled = i2c(port=1, address=0x3C)
device = ssd1306(Oled)

GPGLL = ""  #Geographic Position, Latitude / Longitude and time
GPRMC = ""  #Recommended minimum specific GPS/Transit data
GPVTG = ""  #Track made good and ground speed
GPGGA = ""  #Global Positioning System Fix Data
GPGSA = ""  #GPS DOP and active satellites
GPGSV = ""  #GPS Satellites in view
timeZone = 1
speed = "0"
Latitude = "XXXXXXXXXXXX"
コード例 #30
0
#!/usr/bin/python3

import CHIP_IO.GPIO as GPIO
import sys
import time

IN = sys.argv[1]

try:
    IN = int(IN)
except:
    print('could not convert to int. Default 1')
    IN = 1

P1 = "XIO-P7"
P2 = "XIO-P6"

GPIO.setup(P1, GPIO.OUT)
GPIO.setup(P2, GPIO.OUT)

a = True
while True:
    GPIO.output(P1, a)
    GPIO.output(P2, not a)
    time.sleep(float(1 / IN))
    a = not a
コード例 #31
0
def on_message(client, userdata, msg_raw):
    msg = msg_raw.payload.rstrip('\t\r\n\0').split(
        '||')  #Split rate data and speech data
    #print(msg_raw.topic+" "+msg[0]+" "+msg[1])                                                 #Debug
    #Converting data into integers from -100 to 100
    if msg[0] == "disconnect":  # Debug
        client.disconnect()
    elif msg_raw.topic == "romibo/emotion":
        file = open("emotion.txt", "w")
        file.write(msg[0])
        file.close()
        print("emotion received")
    elif msg_raw.topic == "romibo/action":
        x = int(float(msg[0]) * 100)
        y = int(float(msg[1]) * 100)
        L_mag = int(L_mag_calculation(x, y))
        R_mag = int(R_mag_calculation(x, y))
        print("L: " + str(L_mag) + "||R:" + str(R_mag))

        #left motor
        if L_mag > 0:
            #set to forward
            GPIO.output(en_l_fw, 1)
            GPIO.output(en_l_bw, 0)
        elif L_mag <= 0:
            #set to backward
            GPIO.output(en_l_fw, 0)
            GPIO.output(en_l_bw, 1)

        #set velocity via duty cycle
        SPWM.set_duty_cycle(left, abs(L_mag))

        #right motor
        if R_mag > 0:
            #set to forward
            GPIO.output(en_r_fw, 1)
            GPIO.output(en_r_bw, 0)
        elif R_mag <= 0:
            #set to backward
            GPIO.output(en_r_fw, 0)
            GPIO.output(en_r_bw, 1)

        #set velocity via duty cycle
        SPWM.set_duty_cycle(right, abs(R_mag))
コード例 #32
0
ファイル: start.py プロジェクト: slimjim2234/car_remote_start
def flipOn(inGPIO):
  GPIO.output(inGPIO, GPIO.HIGH)
コード例 #33
0
ファイル: cycle.py プロジェクト: trafferty/utils
def cycle(num_loops, loop_time_s, num_cycles, freq):
    time_between_cycles = (1.0/freq)
    doLog("Starting, %d loops.  freq=%.2f, time_between_cycles=%f, num_cycles=%d" % (num_loops, freq, time_between_cycles, num_cycles))
    GPIO.output("CSID0", 0)
    GPIO.output("CSID1", 0)
    for loop_cnt in range(num_loops):
        start_ts = time.time()
        for cycle_cnt in range(num_cycles):
            GPIO.output("CSID0", 1)
            GPIO.output("CSID1", 1)
            time.sleep(time_between_cycles/2.0)
            GPIO.output("CSID0", 0)
            GPIO.output("CSID1", 0)
            time.sleep(time_between_cycles/2.0)
            doLog("  ...cycle complete: %d" % (cycle_cnt))
        doLog("...loop complete: %d" % (loop_cnt))
        while ((time.time() - start_ts) < (loop_time_s-0.002)):
            time.sleep(0.004)
コード例 #34
0
 def on(self, color):
     GPIO.output(self.led[color], GPIO.LOW)
コード例 #35
0
ファイル: rfid.py プロジェクト: drbobbob/rfidreader
 def blink_door(self):
     GPIO.output(self.pin, False)
     time.sleep(0.1)
     GPIO.output(self.pin, True)
コード例 #36
0
 def off(self, color):
     GPIO.output(self.led[color], GPIO.HIGH)
コード例 #37
0
 def cleanup(self):
     # GPIO.cleanup() << SEGFAULT
     GPIO.output("XIO-P3", GPIO.HIGH)
コード例 #38
0
ファイル: SevSeg.py プロジェクト: 16pj/CHIPstuff
 def on(self, pins):
     for pin in pins:
         GPIO.output(pin, GPIO.HIGH)
コード例 #39
0
ファイル: crazy.py プロジェクト: Breq16/christmas-tree
 def flip(self, value):
     io.output(self.pin, not value)
コード例 #40
0
ファイル: SevSeg.py プロジェクト: 16pj/CHIPstuff
 def off(self, pins):
     for pin in pins:
         GPIO.output(pin, GPIO.LOW)
コード例 #41
0
def transmit_code(code):
    '''Transmit a chosen code string using the GPIO transmitter'''
    #    GPIO.setmode(GPIO.BCM)
    GPIO.setup(TRANSMIT_PIN, GPIO.OUT)
    for t in range(NUM_ATTEMPTS):
        for i in code:
            if i == '1':
                GPIO.output(TRANSMIT_PIN, 1)
                time.sleep(.00055)
                GPIO.output(TRANSMIT_PIN, 0)
            elif i == '2':
                GPIO.output(TRANSMIT_PIN, 0)
                time.sleep(.00011)
                GPIO.output(TRANSMIT_PIN, 1)
            elif i == '3':
                GPIO.output(TRANSMIT_PIN, 0)
                time.sleep(.000303)
                GPIO.output(TRANSMIT_PIN, 1)
            elif i == '4':
                GPIO.output(TRANSMIT_PIN, 1)
                time.sleep(.00011)
                GPIO.output(TRANSMIT_PIN, 0)
            elif i == '5':
                GPIO.output(TRANSMIT_PIN, 1)
                time.sleep(.00029)
                GPIO.output(TRANSMIT_PIN, 0)
            else:
                continue
        GPIO.output(TRANSMIT_PIN, 0)
    GPIO.cleanup()
コード例 #42
0
def send(cmd):
    gpio.output(cmd, gpio.LOW)
    time.sleep(.3)
    gpio.output(cmd, gpio.HIGH)
コード例 #43
0
ファイル: phone_in.py プロジェクト: kylestew/EchoesOnTheWire
	def off_hook(self, channel):
		# handset off hook == 0 (closed)
		state = GPIO.input(channel)
		GPIO.output(LED, GPIO.LOW if state else GPIO.HIGH)
		logging.debug('handset is: ' + str(state))
		self.client.send_message("/handset", state)
コード例 #44
0
ファイル: test.py プロジェクト: KoljaWindeler/CHIP_relay
import CHIP_IO.GPIO as GPIO
import time

GPIO.setup("XIO-P0", GPIO.OUT)
GPIO.setup("XIO-P2", GPIO.OUT)
GPIO.setup("XIO-P4", GPIO.OUT)
GPIO.setup("XIO-P6", GPIO.OUT)
time.sleep(3)

GPIO.output("XIO-P0", GPIO.HIGH)
time.sleep(1)
GPIO.output("XIO-P2", GPIO.HIGH)
time.sleep(1)
GPIO.output("XIO-P4", GPIO.HIGH)
time.sleep(1)
GPIO.output("XIO-P6", GPIO.HIGH)

time.sleep(3)

GPIO.output("XIO-P0", GPIO.LOW)
time.sleep(1)
GPIO.output("XIO-P2", GPIO.LOW)
time.sleep(1)
GPIO.output("XIO-P4", GPIO.LOW)
time.sleep(1)
GPIO.output("XIO-P6", GPIO.LOW)
コード例 #45
0
 def power_up(self):
     GPIO.output(self.CSID1, False)
     time.sleep(0.01)
     return True
コード例 #46
0
def drive(speed, direction=0):
    log.debug("Driving %s %s".format(speed, direction))
    if speed > 0:
        GPIO.output("LCD-D20", GPIO.LOW)
        GPIO.output("LCD-D22", GPIO.HIGH if direction > 0 else GPIO.LOW)
        GPIO.output("LCD-CLK", GPIO.LOW if direction < 0 else GPIO.HIGH)
        GPIO.output("LCD-VSYNC", GPIO.HIGH)
        GPIO.output("LCD-D18", GPIO.HIGH)
    elif speed < 0:
        GPIO.output("LCD-D20", GPIO.LOW if direction > 0 else GPIO.HIGH)
        GPIO.output("LCD-D22", GPIO.HIGH)
        GPIO.output("LCD-CLK", GPIO.LOW)
        GPIO.output("LCD-VSYNC", GPIO.HIGH if direction < 0 else GPIO.LOW)
        GPIO.output("LCD-D18", GPIO.HIGH)
    else: # brake
        GPIO.output("LCD-D20", GPIO.LOW)
        GPIO.output("LCD-D22", GPIO.HIGH)
        GPIO.output("LCD-CLK", GPIO.LOW)
        GPIO.output("LCD-VSYNC", GPIO.HIGH)
        GPIO.output("LCD-D18", GPIO.HIGH)
コード例 #47
0
ファイル: start.py プロジェクト: slimjim2234/car_remote_start
def clear():
  for i in gpio:
    GPIO.output(i, GPIO.LOW)
コード例 #48
0
def coast():
    log.debug("Putting motor controller to sleep")
    GPIO.output("LCD-D18", GPIO.LOW)
コード例 #49
0
    def _read(self):
        GPIO.output(self.CSID1, False)  # start by setting the pd_sck to false
        ready_counter = 0  # init the counter to 0
        while (not self._ready() and ready_counter <= 40):
            time.sleep(0.01)  # sleep for 10 ms because data is not ready
            ready_counter += 1  # increment counter
            if ready_counter == 50:  # if counter reached max value then return False
                if self._debug_mode:
                    print('self._read() not ready after 40 trials\n')
                return False

        # read first 24 bits of data
        data_in = 0  # 2's complement data from hx 711
        for i in range(24):
            start_counter = time.perf_counter()  # start timer
            GPIO.output(self.CSID1, True)  # request next bit from hx 711
            GPIO.output(self.CSID1, False)
            end_counter = time.perf_counter()  # stop timer
            if end_counter - start_counter >= 0.00006:  # check if the hx 711 did not turn off...
                # if pd_sck pin is HIGH for 60 us and more than the HX 711 enters power down mode.
                if self._debug_mode:
                    print('Not enough fast while reading data')
                    print('Time elapsed: ' + str(end_counter - start_counter))
                return False
            # Shift the bits as they come to data_in variable.
            # Left shift by one bit then bitwise OR with the new bit.
            data_in = (data_in << 1) | GPIO.input(self.CSID0)

        if self._wanted_channel == 'A' and self._gain_channel_A == 128:
            if not self._set_channel_gain(1):  # send only one bit which is 1
                return False  # return False because channel was not set properly
            else:
                self._current_channel = 'A'  # else set current channel variable
                self._gain_channel_A = 128  # and gain
        elif self._wanted_channel == 'A' and self._gain_channel_A == 64:
            if not self._set_channel_gain(3):  # send three ones
                return False  # return False because channel was not set properly
            else:
                self._current_channel = 'A'  # else set current channel variable
                self._gain_channel_A = 64
        else:
            if not self._set_channel_gain(2):  # send two ones
                return False  # return False because channel was not set properly
            else:
                self._current_channel = 'B'  # else set current channel variable

        if self._debug_mode:  # print 2's complement value
            print('Binary value as it has come: ' + str(bin(data_in)) + '\n')

        #check if data is valid
        if (data_in == 0x7fffff
                or  # 0x7fffff is the highest possible value from hx711
                data_in == 0x800000
            ):  # 0x800000 is the lowest possible value from hx711
            if self._debug_mode:
                print('Invalid data detected: ' + str(data_in) + '\n')
            return False  # rturn false because the data is invalid

        # calculate int from 2's complement
        signed_data = 0
        if (
                data_in & 0x800000
        ):  # 0b1000 0000 0000 0000 0000 0000 check if the sign bit is 1. Negative number.
            signed_data = -(
                (data_in ^ 0xffffff) + 1)  # convert from 2's complement to int
        else:  # else do not do anything the value is positive number
            signed_data = data_in

        if self._debug_mode:
            print('Converted 2\'s complement value: ' + str(signed_data) +
                  '\n')

        return signed_data
コード例 #50
0
ファイル: pins.py プロジェクト: djlad/internetbot
def set_pin(pin_num, on_off):
    pin_name = "XIO-P{}".format(pin_num)
    gpio.setup(pin_name, gpio.OUT)
    gpio.output(pin_name, int(on_off))
    gpio.cleanup(pin_name)
コード例 #51
0
ファイル: rfid.py プロジェクト: brettcvz/soundbyte
 def cleanup(self):
     self.listening = False
     GPIO.output(self.reset_pin, GPIO.LOW)
     GPIO.cleanup()
コード例 #52
0
ファイル: sumorobot.py プロジェクト: artizirk/sumochip
 def value(self, val):
     if self.direction != "out":
         self.direction = "out"
         GPIO.setup(self.pin, GPIO.OUT)
     GPIO.output(self.pin, GPIO.HIGH if val else GPIO.LOW)
コード例 #53
0
ファイル: test.py プロジェクト: KoljaWindeler/CHIP_relay
import CHIP_IO.GPIO as GPIO
import time

GPIO.setup("XIO-P0", GPIO.OUT)
GPIO.setup("XIO-P2", GPIO.OUT)
GPIO.setup("XIO-P4", GPIO.OUT)
GPIO.setup("XIO-P6", GPIO.OUT)
time.sleep(3)


GPIO.output("XIO-P0", GPIO.HIGH)
time.sleep(1)
GPIO.output("XIO-P2", GPIO.HIGH)
time.sleep(1)
GPIO.output("XIO-P4", GPIO.HIGH)
time.sleep(1)
GPIO.output("XIO-P6", GPIO.HIGH)

time.sleep(3)

GPIO.output("XIO-P0", GPIO.LOW)
time.sleep(1)
GPIO.output("XIO-P2", GPIO.LOW)
time.sleep(1)
GPIO.output("XIO-P4", GPIO.LOW)
time.sleep(1)
GPIO.output("XIO-P6", GPIO.LOW)

コード例 #54
0
ファイル: digits.py プロジェクト: mellotanica/chip_presepio
        ":" : [3, 8]
}


all_leds = [x for x in pin_map.keys()]

full_digits = []
for d in digit_maps:
    full_digits.append([x for x in d.values()])

for i in pin_map.values():
    gpio.cleanup(i)
CHIP_IO.Utilities.unexport_all()
for i in pin_map.values():
    gpio.setup(i, gpio.OUT)
    gpio.output(i, gpio.HIGH)

def turnon(n):
    global pin_map
    if type(n) is list:
        for l in n:
            gpio.output(pin_map[l], gpio.LOW)
    else:
        turnon([n])

def turnoff(n):
    global pin_map
    if type(n) is list:
        for l in n:
            gpio.output(pin_map[l], gpio.HIGH)
    else:
コード例 #55
0
ファイル: chip.py プロジェクト: illperipherals/AlexaPi
	def indicate_setup_success(self):
		for _ in range(0, 5):
			time.sleep(.1)
			GPIO.output(self.__pconfig['plb_light'], GPIO.HIGH)
			time.sleep(.1)
			GPIO.output(self.__pconfig['plb_light'], GPIO.LOW)
コード例 #56
0
ファイル: sumorobot.py プロジェクト: puskyer/sumochip
 def value(self, val):
     if self.direction != "out":
         self.direction = "out"
         GPIO.setup(self.pin, GPIO.OUT)
     GPIO.output(self.pin, GPIO.HIGH if val else GPIO.LOW)
コード例 #57
0
ファイル: chip.py プロジェクト: illperipherals/AlexaPi
	def indicate_playback(self, state=True):
		GPIO.output(self.__pconfig['plb_light'], GPIO.HIGH if state is True else GPIO.LOW)
コード例 #58
0
# the following assumes that an LED is run from VCC to xio-p0 with its cathode in the latter
# ie: pulling pin low turns LED on, setting high turns it off

import CHIP_IO.GPIO as GPIO
GPIO.setup("XIO-P0", GPIO.OUT)
GPIO.output("XIO-P0", GPIO.HIGH)

コード例 #59
0
ファイル: hpwm_test.py プロジェクト: m-long/chip
# Initialize hardware pwm thorugh the OM
OM.enable_debug()
OM.load("PWM0")

# Test it loaded properly
if (OM.get_pwm_loaded()):
    print("PWM OM Successfully loaded...")

# Setup the pins
GPIO.setup("XIO-P0", GPIO.OUT)
GPIO.setup("XIO-P1", GPIO.OUT)
PWM.start("PWM0", 100, 100, 0)

# Run the test
try:
    GPIO.output("XIO-P0", GPIO.HIGH)
    GPIO.output("XIO-P1", GPIO.LOW)

    print("Testing duty cycle...")

    # Test duty cycle
    #    for x in range(0,100):
    #        SPWM.set_duty_cycle("PWM0", x)
    #        print(x)
    #        time.sleep(.1)

    # Test frequency
    PWM.set_duty_cycle("PWM0", 100)
    print("Testing frequency at 100% duty")
    for f in range(100, 5000, 100):
        PWM.set_frequency("PWM0", f)
コード例 #60
0
class ThreadedTCPServer(socketserver.ThreadingMixIn, socketserver.TCPServer):
    pass


try:
    #Setup and start http server
    httpServer = ThreadedTCPServer(("", 80), GetHandler)
    http_server_thread = threading.Thread(target=httpServer.serve_forever)
    http_server_thread.daemon = True
    http_server_thread.start()

    #Setup each GPIO pin that has a door attached
    for door in gpioGarageDoors:
        GPIO.setup(door, GPIO.OUT)
        GPIO.output(door, GPIO.HIGH)

    logging.info('Beginning Pirage loop')

    while True:
        print("Running...")
        time.sleep(60)

        #Handle all errors so loop does not end
        #except Exception as e:
        #    logging.exception("Error in loop: " + e)

finally:
    #Close down http server and GPIO registrations
    httpServer.shutdown()
    httpServer.server_close()