示例#1
0
	def scanQ(self):
		# steps (1) and (2) before reading GPIOs
		self.__preRead()
		
		# (3) scan rows for pushed key/button
		rowHi=1
		while rowHi==1:
			for i in range(len(self.row)):
				tmpRead=wiringpi.digitalRead(self.row[i])
				if tmpRead==0:
					rowHi=0
					rowVal=i

		# (4) after finding which key/button from the row scans, convert columns to input
		for j in range(len(self.col)):
				wiringpi.pinMode(self.col[j],INPUT)

		# (5) switch the i-th row found from scan to output
		wiringpi.pinMode(self.row[rowVal],OUTPUT)
		wiringpi.digitalWrite(self.row[rowVal],HIGH)

		# (6) scan columns for still-pushed key/button
		colLo=0
		while colLo==0:
				for j in range(len(self.col)):
						tmpRead=wiringpi.digitalRead(self.col[j])
						if tmpRead==1:
							colLo=1
							colVal=j

		# reinitialize used GPIOs
		self.__postRead()

		# (7) return the symbol of pressed key from keyPad mapping
		return self.keyPad[rowVal][colVal]
示例#2
0
  def __init__(self, pinNumber):

    self.pinNumber = pinNumber

    WiringPiSingleton().setup()

    wiringpi.digitalWrite(self.pinNumber, 0)
示例#3
0
 def lock(self):
     """
     Lock the lock back. Meant to be used when program is shut down
     so that lock is not left disengaged.
     """
     import wiringpi
     wiringpi.digitalWrite(self.lockPin, 0)
示例#4
0
文件: ssr.py 项目: deba82de/kriek
	def set_state(self, state):

		self._On = state
		_state = 0
		if state:
			_state = 1
				
		if self.verbose:
			print str(self.ssr.name) + " digitalWrite: " + str(self.ssr.pin) + " " + str(_state)
		
		#save the state
		if self.ssr.state != _state:
			self.ssr.state = _state
			self.ssr.save()

		#reverse if needed
		if self.ssr.reverse_polarity and self.enabled:
			_state = not _state

		if wiringpi_available:
			wiringpi.digitalWrite(int(self.ssr.pin), _state)

		elif bbb_available:
			if _state:
				GPIO.output(self.ssr.pin, GPIO.HIGH)
			else:
				GPIO.output(self.ssr.pin, GPIO.LOW)
示例#5
0
    def display(self):
#	if self.Pos < 0 | self.Pos > 5:
#	    return
	wiringpi.digitalWrite(22, 0)
	wiringpi.shiftOut(10, 9, 1, DIGIT_VALUES.get(str(self.Value).upper()))
	wiringpi.shiftOut(10, 9, 1, self.Pos)
	wiringpi.digitalWrite(22, 1)
    def _switch(self, switch):
        self.bit = [142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 136, 128, 0, 0, 0]

        for t in range(5):
            if self.system_code[t]:
                self.bit[t] = 136
        x = 1
        for i in range(1, 6):
            if self.unit_code & x > 0:
                self.bit[4 + i] = 136
            x = x << 1

        if switch == wiringpi.HIGH:
            self.bit[10] = 136
            self.bit[11] = 142

        bangs = []
        for y in range(16):
            x = 128
            for i in range(1, 9):
                b = (self.bit[y] & x > 0) and wiringpi.HIGH or wiringpi.LOW
                bangs.append(b)
                x = x >> 1

        wiringpi.wiringPiSetupSys()
        wiringpi.pinMode(self.pin, wiringpi.OUTPUT)
        wiringpi.digitalWrite(self.pin, wiringpi.LOW)
        for z in range(self.repeat):
            for b in bangs:
                wiringpi.digitalWrite(self.pin, b)
                time.sleep(self.pulselength / 1000000.0)
示例#7
0
def led_drive(reps, multiple, direction):           # define function to drive
    for i in range(reps):                      # repetitions, single or multiple
        for port_num in direction:                  # and direction
            wiringpi.digitalWrite(port_num, 1)      # switch on an led
            sleep(0.11)                             # wait for ~0.11 seconds
            if not multiple:                        # if we're not leaving it on
                wiringpi.digitalWrite(port_num, 0)  # switch it off again
示例#8
0
 def send(self, channel, button, state):
     bin_list = self.command_as_bin_list(channel, button, state)
     packet = self.encode_packet(bin_list)
     for _ in range(self.repeat):
         for bit in packet:
             wiringpi.digitalWrite(self.pin, bit)
             wiringpi.delayMicroseconds(self.PULSE_WIDTH)
	def commandGpio(self, c):
		if c == 'w':
			if not self.isRun: 
				# Wakeup, if not run
				print 'Wakeup'
				self.isRun = True
				self.wakeup()
		elif not self.isRun:
			# nothing to do, if not run
			return
		elif c == 'q':
			# Qiut
			print 'Qiut'
			self.isRun = False
			self.quit()
		elif c == '0':
			# LED off
			print 'LED off'
			self.stopBlink()
			wiringpi.digitalWrite(self.pinLed, wiringpi.LOW) 
		elif c == '1':			
			# LED on
			print 'LED on'
			self.stopBlink()
			wiringpi.digitalWrite(self.pinLed, wiringpi.HIGH) 
		elif c == '2':
			# LED blink
			print 'LED blink'
			self.startBlink()
    def updateValue(self):
	if Globals.globSimulate:
	    val = (self.values[-1][1] if len(self.values) > 0 else 0) + random.randint(-10, 10)
	else:
	    # Send 10us pulse to trigger
	    wiringpi.digitalWrite(self.pinTrigger, 1)
	    time.sleep(0.00001)
	    wiringpi.digitalWrite(self.pinTrigger, 0)
	    start = time.time()
	    stop = 0

	    while wiringpi.digitalRead(self.pinEcho)==0:
	      start = time.time()

	    while wiringpi.digitalRead(self.pinEcho)==1:
	      stop = time.time()

	    # Calculate pulse length
	    elapsed = stop-start

	    # Distance pulse travelled in that time is time
	    # multiplied by the speed of sound (cm/s)
	    distance = elapsed * 34300

	    # That was the distance there and back so halve the value
	    val = distance / 2


	if val < 0:
	    val = 0

	currtime = int(time.time() * 1000) # this is milliseconds so JavaScript doesn't have to do this
	self.values.append([currtime, val])
	self.values = self.values[-MAXVALUES:]
	self.emit("DistanceSensor", self)
示例#11
0
 def unlock(self):
     """Unlocks lock at configured pin by pulling it high.
     """
     import wiringpi
     wiringpi.digitalWrite(self.lockPin, 1)
     time.sleep(self.lockOpenedSecs)
     wiringpi.digitalWrite(self.lockPin, 0)
def display_char(char, font=FONT):
  try:
    wiringpi.digitalWrite(DC, ON)
    spi.writebytes(font[char]+[0])

  except KeyError:
    pass # Ignore undefined characters.
示例#13
0
def flash_LED(count=5, ontime=100, offtime=200):
	"""Flash the LED count times, one for ontime ms, off for offtime ms"""
	for i in xrange(count):
		wiringpi.digitalWrite(LED_PIN, 1)
		time.sleep(ontime/1000.)
		wiringpi.digitalWrite(LED_PIN, 0)
		time.sleep(offtime/1000.)
示例#14
0
 def deactivate(self, pin):
     """ De-activate a pin """
     if settings.count_from_right:
         pin = pin
     else:
         pin = 7 - pin
     wp.digitalWrite(pin, 0)
示例#15
0
def writeNo(number, latch_pin, data_pin, clock_pin):
	if number == 0:
		number = 63
	elif number == 1:
		number = 6
	elif number == 2:
		number = 91
	elif number == 3:
		number = 79
	elif number == 4:
		number = 102
	elif number == 5:
		number = 109
	elif number == 6:
		number = 125
	elif number == 7:
		number = 7
	elif number == 8:
		number = 127
	elif number == 9:
		number = 103
	elif number == 10:
		number = 0
	else:
		number = 63


	wiringpi.digitalWrite(latch_pin, 0)
	wiringpi.shiftOut(data_pin, clock_pin, MSBFIRST, number)
	wiringpi.digitalWrite(latch_pin, 1)
def triggerRemote():
  if PI_SETUP:
    wiringpi.pinMode(CAMERA_PIN, 1)
    wiringpi.digitalWrite(CAMERA_PIN, 1)
    utilities.wait(0.1)
    wiringpi.digitalWrite(CAMERA_PIN, 0)
  else:
    print "Can't trigger remote, not pi"
	def quitLed(self):
		if self.ledThread:
			# remove LED Thread
			self.ledThread.stopBlink()
			self.ledThread.stopRun()
			time.sleep(self.TIME_QUIT)	
			self.ledThread = None
		wiringpi.digitalWrite(self.pinLed, wiringpi.LOW) 
示例#18
0
 def led(self, led_value):
     if self.ledpin == 1:
         wiringpi.pwmWrite(self.ledpin,led_value)
     else:
         if led_value == 0:
             wiringpi.digitalWrite(self.ledpin, OFF)
         else:
             wiringpi.digitalWrite(self.ledpin, ON)
示例#19
0
文件: nokiaSPI.py 项目: calexo/CaMuMa
    def display_char(self, char, font=FONT):
        if char != '\n':
          try:
              wiringpi.digitalWrite(self.dc, ON)
              self.spi.writebytes(font[char]+[0])

          except KeyError:
              self.spi.writebytes(font['_']+[0])
              pass # Ignore undefined characters.
	def __del__(self):
		
		wp.pwmWrite(self.pwm, PWM_MIN)
		wp.digitalWrite(self.outA, LOW)
		wp.digitalWrite(self.outB, LOW)

		wp.pinMode(self.pwm, INPUT_MODE)
		wp.pinMode(self.outA, INPUT_MODE)
		wp.pinMode(self.outB, INPUT_MODE)
示例#21
0
	def __preRead(self):
		# (1) set all columns as output low
		for j in range(len(self.col)):
			wiringpi.pinMode(self.col[j],OUTPUT)
			wiringpi.digitalWrite(self.col[j],LOW)

		# (2) set all rows as input
		for i in range(len(self.row)):
			wiringpi.pinMode(self.row[i],INPUT)
示例#22
0
    def activate_b(self, number):
        pin_number = 80 - number
        pin_opposite = 65 + number

        if self.v[number].get() == 0:
            self.lightsA[number].set_state(False)
            self.lightsB[number].set_state(True)
            wiringpi.digitalWrite(pin_number, 1)
            wiringpi.digitalWrite(pin_opposite, 0)
示例#23
0
    def setSpeed(self, pwm_pin, dir_pin, speed):
        """Set the motor PWM & dir based on pins and speed.
        From the mc33926 library. Thanks, Pololu. """
        dir_value = 1 if speed < 0 else 0
        speed = speed if speed > 0 else -speed
        speed = self.get_valid_speed(speed)

        wiringpi.digitalWrite(dir_pin, dir_value)
        # TODO: Change this to pwmWrite
        wiringpi.softPwmWrite(pwm_pin, speed)
示例#24
0
    def end(self, number):
        pin_number = 65 + number
        pin_opposite = 80 - number

        wiringpi.digitalWrite(pin_number, 0)
        wiringpi.digitalWrite(pin_opposite, 0)

        self.v[number].set(3)
        self.lightsA[number].set_state(False)
        self.lightsB[number].set_state(False)
示例#25
0
 def activate(self, pin):
     """ Activate a pin """
     if settings.count_from_right:
         pin = pin
     else:
         pin = 7 - pin
     if self.watchdog.watchdog_safe:
         wp.digitalWrite(pin, 1)
     else:
         wp.digitalWrite(pin, 0)
def signal(pattern):
  for p in pattern:
    wiringpi.digitalWrite(PIN,wiringpi.GPIO.HIGH)
    if p == ".":
      wiringpi.delay(DOT)
    elif p == "-":
      wiringpi.delay(DASH)
    
    wiringpi.digitalWrite(PIN,wiringpi.GPIO.LOW)
    wiringpi.delay(INTERVAL)
示例#27
0
	def lcd_data(self,value):
		#''' Write a value or list of values to the LCD in DATA mode '''
		wiringpi.digitalWrite(self.dc, ON)
		if type(value) != type([]):
			value = [value]
		self.spi.writebytes(value)
		# Calculate new row/col
		# Writing off the end of a row proceeds to the next row
		# Writing off the end of the last row proceeds to the first row
		self.row = (self.row + ((self.col + len(value)) // COLUMNS)) % ROWS
		self.col = (self.col + len(value)) % COLUMNS
示例#28
0
    def disable(self, button):
        if not WIRING_PI:
            logger.warn("Disabled but no GPIO initialized")
            return False

        pin = self.button_pin[button]

        wiringpi.pinMode(pin, 1)
        wiringpi.digitalWrite(pin, 0)

        return True
示例#29
0
def run_wiringpi(args):
    import wiringpi
    global debug, last_time
    wiringpi.wiringPiSetupGpio()
    wiringpi.pinMode(args.pinout, 1)
    while True:
        last_time = "%.9f" % shared.time()
        wiringpi.digitalWrite(args.pinout, 1)
        time.sleep(0.00001)
        wiringpi.digitalWrite(args.pinout, 0)
        if debug: print(last_time)
        time.sleep(args.interval)
    def run(self):
    	while self.keepRunning:
	    if not Globals.globSimulate:
		wiringpi.digitalWrite(self.pinTrigger, 0)

	    self.updateValue()

	    if not Globals.globSimulate:
		wiringpi.digitalWrite(self.pinTrigger, 0)

            # Allow module to settle
	    time.sleep(UPDATEINTERVAL)
示例#31
0
GPIO.pullUpDnControl(25, GPIO.PUD_UP)

# HELLO MESSAGES
print("Photo mode\n")

# MAIN PROGRAM LOOP

MODE_FLAG = 0  # [0 - photo; 1 - video; 2 - motion detector

while True:
    if (GPIO.digitalRead(25) == GPIO.LOW):
        cleanUp()
    if (GPIO.digitalRead(24) == GPIO.LOW
            and MODE_FLAG == 0):  # taking photo/video
        time.sleep(0.2)
        GPIO.digitalWrite(22, GPIO.HIGH)
        time.sleep(0.3)
        os.system('raspistill -o /home/pi/Desktop/Camera/Photos/' +
                  getFileName(True))
        print("Just took a photo!\n")
        GPIO.digitalWrite(22, GPIO.LOW)
    elif (GPIO.digitalRead(24) == GPIO.LOW and MODE_FLAG == 1):
        time.sleep(0.2)
        GPIO.digitalWrite(22, GPIO.HIGH)
        time.sleep(0.3)
        cam = PiCamera()
        cam.start_recording('/home/pi/Desktop/Camera/Videos/' +
                            getFileName(False))
        while (GPIO.digitalRead(24) == GPIO.LOW):
            pass
        cam.stop_recording()
示例#32
0
         activateLight()
         alarm = 1
     #glass sensors
     #if(received_value == or received_value == or received_value == or received_value == ):
     #   alarmLightsON()
     #    activateLight()
     #    alarm = 1
 if received_value == armCode:
     #resend arm code
     subprocess.Popen(["/home/pi/codesend", str(armCode)])
     print("armed")
     #turn on iot-433mhz
     process = subprocess.Popen(["python", "turnOnIOT433.py"],
                                bufsize=0,
                                shell=False)
     wiringpi.digitalWrite(27, 0)  # turn off green led
     wiringpi.digitalWrite(29, 1)  #turn on yellow led
     time.sleep(3)
     wiringpi.digitalWrite(29, 0)  #turn off yellow led
     wiringpi.digitalWrite(28, 1)  #turn on red led
     recieved_value = 0
     isArmed = 1
 if received_value == disarmCode:
     #turn off leds off
     if alarm:
         alarm = 0
         alarmLightsOFF()
     #resend disarm code
     subprocess.Popen(["/home/pi/codesend", str(disarmCode)])
     subprocess.Popen.kill(process)
     #kill websever
示例#33
0
import wiringpi
import time

RELAY_J5 = 37
RELAY_J4 = 31
RELAY_J3 = 15
RELAY_J2 = 7

wiringpi.wiringPiSetupPhys()
wiringpi.pinMode(RELAY_J5,1)
wiringpi.pinMode(RELAY_J4,1)
wiringpi.pinMode(RELAY_J3,1)
wiringpi.pinMode(RELAY_J2,1)

wiringpi.digitalWrite(RELAY_J5,0)
wiringpi.digitalWrite(RELAY_J4,0)
wiringpi.digitalWrite(RELAY_J3,0)
wiringpi.digitalWrite(RELAY_J2,0)

while True:
    print("ON")
    wiringpi.digitalWrite(RELAY_J5,1)
    time.sleep(1)
    print("OFF")
    wiringpi.digitalWrite(RELAY_J5,0)
    time.sleep(1)

示例#34
0
import wiringpi
from time import sleep

wiringpi.wiringPiSetupGpio()
wiringpi.pinMode(17, 1)

wiringpi.digitalWrite(17, 0)
示例#35
0
# Turns on each pin of an mcp23017 on address 0x20 ( quick2wire IO expander )
import wiringpi

pin_base = 65
i2c_addr = 0x20
pins = [65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80]

wiringpi.wiringPiSetup()
wiringpi.mcp23017Setup(pin_base, i2c_addr)

for pin in pins:
    wiringpi.pinMode(pin, 1)
    wiringpi.digitalWrite(pin, 1)
#	wiringpi.delay(1000)
#	wiringpi.digitalWrite(pin,0)
示例#36
0
 def blink(self):
     if self.isBlink:
         self.isStatus = not self.isStatus
         wiringpi.digitalWrite(self.pin, self.isStatus)
def lightsoff():
    logger.debug("lightsoff")
    wiringpi.digitalWrite(pin1, 0)
    wiringpi.digitalWrite(pin2, 0)
示例#38
0
import wiringpi, time

wiringpi.wiringPiSetupGpio()

wiringpi.pinMode(18, True)

while True:
    wiringpi.digitalWrite(18, True)
    time.sleep(0.5)
    wiringpi.digitalWrite(18, False)
    time.sleep(0.5)
    
示例#39
0
print('Setting up motor pin')
wi.pinMode(args.motor_pin, wi.GPIO.PWM_OUTPUT)

# set the PWM mode to milliseconds stype
wi.pwmSetMode(wi.GPIO.PWM_MODE_MS)

print('setting clock, range to 192, 2000')
wi.pwmSetClock(192)
wi.pwmSetRange(2000)

scale = scale_to_motor(servo_min, servo_max, args.motor_min, args.motor_max)

for i in range(0, args.cycles):

    # Indicate the motor should flow forward
    wi.digitalWrite(dir_pin, 1)
    for x in range(servo_min, servo_max, servo_step):
        print('To X: ', x)
        wi.pwmWrite(args.servo_pin, x)
        wi.pwmWrite(args.motor_pin, scale(x))
        time.sleep(.1)

    # Indicate the motor should flow backward
    wi.digitalWrite(dir_pin, 0)
    for x in range(servo_max, servo_min, servo_step):
        print('To X: ', x)
        wi.pwmWrite(args.servo_pin, x)
        wi.pwmWrite(args.motor_pin, scale(x))
        time.sleep(.1)
 def disable(self):
     wiringpi.digitalWrite(self.enable_pin, 0)
 def enable(self):
     wiringpi.digitalWrite(self.enable_pin, 1)
示例#42
0
#!/usr/bin/python

import wiringpi
import time
import sdnotify

n = sdnotify.SystemdNotifier()
n.notify("READY=1")

wiringpi.wiringPiSetupGpio()
wiringpi.pinMode(21, 1)

while True:
    wiringpi.digitalWrite(21, 1)
    time.sleep(0.1)
    wiringpi.digitalWrite(21, 0)
    time.sleep(0.1)
    wiringpi.digitalWrite(21, 1)
    time.sleep(0.1)
    wiringpi.digitalWrite(21, 0)
    time.sleep(1)
    n.notify("WATCHDOG=1")

示例#43
0
#
###################################################################################
import json, time, gpsd, requests, socket
from systemd import journal
journal.write("pyMon Starting")
from mpu6050 import mpu6050
import wiringpi as wiringpi 

wiringpi.wiringPiSetupGpio()
LEDnet = 22
LEDgps = 23
LEDsend =24
wiringpi.pinMode(LEDnet, 1)  
wiringpi.pinMode(LEDgps, 1)
wiringpi.pinMode(LEDsend, 1)
wiringpi.digitalWrite(LEDnet, 0)
wiringpi.digitalWrite(LEDgps, 0)
wiringpi.digitalWrite(LEDsend, 0)


sensor = mpu6050(0x68)

report_freq = 60*5  #Seconds between sending report
bump_debounce = 2   #  seconds between bounce alerts
rest_url  = 'https://hneve.com/log/insert.php'
tLedBlink = 1      # Running blink frequency

MPUoffax = 0
MPUoffay = 0
MPUoffaz = 0
MPUoffgx = 0
def reset():
    print "Resetting RF95"
    wiringpi.digitalWrite(RST_PIN, 0)
    time.sleep(0.150)
    wiringpi.digitalWrite(RST_PIN, 1)
    time.sleep(0.1)
示例#45
0
    def test(self):
        gpio_number = 0
        wiringpi.wiringPiSetup()

        wiringpi.pinMode(gpio_number, wiringpi.OUTPUT)
        wiringpi.digitalWrite(gpio_number, 1)
示例#46
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

# GPIOを制御するライブラリ
import wiringpi
# タイマーのライブラリ
import time

# LEDを繋いだGPIOの端子番号
led_pin = 23  # 16番端子

# GPIO初期化
wiringpi.wiringPiSetupGpio()
# GPIOを出力モード(1)に設定
wiringpi.pinMode(led_pin, 1)

# whileの処理は字下げをするとループの範囲になる(らしい)
while True:
    # GPIOを3.3VにしてLEDを点灯
    wiringpi.digitalWrite(led_pin, 1)
    # 1秒待ち
    time.sleep(1)
    # GPIOを0VにしてLEDを消灯
    wiringpi.digitalWrite(led_pin, 0)
    # 1秒待ち
    time.sleep(1)
def lightson():
    logger.debug("lightson")
    wiringpi.digitalWrite(pin1, 1)
    wiringpi.digitalWrite(pin2, 1)
示例#48
0
    def __init__(self, conf=ADS1256_default_config):
        # Set up the wiringpi object to use physical pin numbers
        wp.wiringPiSetupPhys()
        # Config and initialize the SPI and GPIO pins used by the ADC.
        # The following four entries are actively used by the code:
        self.SPI_CHANNEL  = conf.SPI_CHANNEL
        self.DRDY_PIN     = conf.DRDY_PIN
        self.CS_PIN       = conf.CS_PIN
        self.DRDY_TIMEOUT = conf.DRDY_TIMEOUT
        self.DRDY_DELAY   = conf.DRDY_DELAY

        # Only one GPIO input:
        if conf.DRDY_PIN is not None:
            self.DRDY_PIN = conf.DRDY_PIN
            wp.pinMode(conf.DRDY_PIN,  wp.INPUT)

        # GPIO Outputs. Only the CS_PIN is currently actively used. ~RESET and 
        # ~PDWN must be set to static logic HIGH level if not hardwired:
        for pin in (conf.CS_PIN,
                    conf.RESET_PIN,
                    conf.PDWN_PIN):
            if pin is not None:
                wp.pinMode(pin, wp.OUTPUT)
                wp.digitalWrite(pin, wp.HIGH)
        
        # Initialize the wiringpi SPI setup. Return value is the Linux file
        # descriptor for the SPI bus device:
        fd = wp.wiringPiSPISetupMode(
                conf.SPI_CHANNEL, conf.SPI_FREQUENCY, conf.SPI_MODE)
        if fd == -1:
            raise IOError("ERROR: Could not access SPI device file")
        
        # ADS1255/ADS1256 command timing specifications. Do not change.
        # Delay between requesting data and reading the bus for
        # RDATA, RDATAC and RREG commands (datasheet: t_6 >= 50*CLKIN period).
        self._DATA_TIMEOUT_US = int(1 + (50*1000000)/conf.CLKIN_FREQUENCY)
        # Command-to-command timeout after SYNC and RDATAC
        # commands (datasheet: t11)
        self._SYNC_TIMEOUT_US = int(1 + (24*1000000)/conf.CLKIN_FREQUENCY)
        # See datasheet ADS1256: CS needs to remain low
        # for t_10 = 8*T_CLKIN after last SCLK falling edge of a command.
        # Because this delay is longer than timeout t_11 for the
        # RREG, WREG and RDATA commands of 4*T_CLKIN, we do not need
        # the extra t_11 timeout for these commands when using software
        # chip select selection and the _CS_TIMEOUT_US.
        self._CS_TIMEOUT_US   = int(1 + (8*1000000)/conf.CLKIN_FREQUENCY)
        # When using hardware/hard-wired chip select, still a command-
        # to command timeout of t_11 is needed as a minimum for the
        # RREG, WREG and RDATA commands.
        self._T_11_TIMEOUT_US   = int(1 + (4*1000000)/conf.CLKIN_FREQUENCY)

        # Initialise class properties
        self.v_ref         = conf.v_ref

        # At hardware initialisation, a settling time for the oscillator
        # is necessary before doing any register access.
        # This is approx. 30ms, according to the datasheet.
        time.sleep(0.03)
        self.wait_DRDY()
        # Device reset for defined initial state
        self.reset()

        # Configure ADC registers:
        # Status register not yet set, only variable written to avoid multiple
        # triggering of the AUTOCAL procedure by changing other register flags
        self._status       = conf.status
        # Class properties now configure registers via their setter functions
        self.mux           = conf.mux
        self.adcon         = conf.adcon
        self.drate         = conf.drate
        self.gpio          = conf.gpio
        self.status        = conf.status
def program_cleanup():
    logger.debug("cleanup")
    wiringpi.digitalWrite(pin1, 0)
    wiringpi.digitalWrite(pin2, 0)
    wiringpi.pinMode(pin1, 0)
    wiringpi.pinMode(pin2, 0)
示例#50
0
 def power_down(self):
     pi.digitalWrite(self.SCK, pi.LOW)
     pi.digitalWrite(self.SCK, pi.HIGH)
     time.sleep(0.0001)
示例#51
0
import wiringpi
from time import sleep

wiringpi.wiringPiSetup()  # Use WiringPi numbering

PIN_NUMBER = 4

wiringpi.pinMode(PIN_NUMBER, 1)  # Set LED pin to 1 ( OUTPUT )

while True:
    print("Setting LED on")
    wiringpi.digitalWrite(PIN_NUMBER, 0)  # Write 0 ( LOW ) to LED pin
    sleep(1)
    print("Setting LED off")
    wiringpi.digitalWrite(PIN_NUMBER, 1)  # Write 1 ( HIGH ) to LED pin
    sleep(1)
示例#52
0
def alarmLightsOFF():
    wiringpi.digitalWrite(27, 0)  # turn off green led
    wiringpi.digitalWrite(28, 0)  # turn off red led
    wiringpi.digitalWrite(29, 0)  # turn off yellow led
            self.function(*self.args, **self.kwargs)
            self.finished.wait(self.interval)


import datetime
currentDT = datetime.datetime.now()

segments = (27, 22, 5, 6, 26, 20, 21)
digitZero = (1, 1, 1, 1, 1, 1, 0)
digitOne = (0, 1, 1, 0, 0, 0, 0)
digitTwo = (1, 1, 0, 1, 1, 0, 1)
digitEight = (1, 1, 1, 1, 1, 1, 1)
digitNine = (1, 1, 1, 1, 0, 1, 1)
for segment in segments:
    wiringpi.pinMode(segment, 1)
    wiringpi.digitalWrite(segment, 0)

red_light_port = 12
white_light_port = 4
green_light_port = 17

wiringpi.wiringPiSetupGpio()
wiringpi.pinMode(green_light_port, 1)  # sets GPIO 24 to output
wiringpi.pinMode(red_light_port, 1)
wiringpi.pinMode(white_light_port, 1)

global lock
lock = 0

import subprocess
while True:
示例#54
0
import sys
import wiringpi as pi, time

args = sys.argv
shootsec = int(args[1])

motor1_pin = 22
motor2_pin = 24

pi.wiringPiSetupGpio()
pi.pinMode(motor1_pin, 1)
pi.pinMode(motor2_pin, 1)

pi.digitalWrite(motor1_pin, 1)
pi.digitalWrite(motor2_pin, 0)
time.sleep(shootsec)

pi.digitalWrite(motor1_pin, 0)
pi.digitalWrite(motor2_pin, 0)
示例#55
0
 def _chip_select(self):
     # If chip select hardware pin is connected to SPI bus hardware pin or
     # hardwired to GND, do nothing.
     if self.CS_PIN is not None:
         wp.digitalWrite(self.CS_PIN, wp.LOW)
示例#56
0
 def power_up(self):
     pi.digitalWrite(self.SCK, pi.LOW)
     time.sleep(0.0001)
示例#57
0
 def stop(self):
     #ストップ
     pi.digitalWrite(self.a_phase, 0)
     pi.digitalWrite(self.a_enbl, 0)
示例#58
0
PIN_7 = 10
PIN_8 = 6
PIN_9 = 5
PIN_10 = 4
PIN_11 = 1
PIN_12 = 16
PIN_13 = 15
# Pins 14-16 were not connected in the 16 pin connector
# In current implementation, 3.3V will be directly wired to the 16th pin and GND to the 15th pin

wiringpi.wiringPiSetup()

wiringpi.pinMode(EN,1)
wiringpi.pinMode(STEP_1,1)
wiringpi.pinMode(DIR_1,1)
wiringpi.digitalWrite(DIR_1,1)
wiringpi.pinMode(STEP_2,1)
wiringpi.pinMode(DIR_2,1)
wiringpi.digitalWrite(DIR_2,1)
wiringpi.pinMode(STEP_3,1)
wiringpi.pinMode(DIR_3,1)
wiringpi.digitalWrite(DIR_3,1)
wiringpi.pinMode(STEP_4,1)
wiringpi.pinMode(DIR_4,1)
wiringpi.digitalWrite(DIR_4,1)
#wiringpi.pinMode(ALARM_LED,1)
#wiringpi.pinMode(PIN_1,0)
#wiringpi.pinMode(PIN_2,0)
wiringpi.pinMode(PIN_5,1)
wiringpi.pinMode(PIN_6,1)
wiringpi.pinMode(PIN_3,1)
示例#59
0
    def setup_US_ports(self):
        wiringpi.wiringPiSetupGpio()
        wiringpi.pinMode(self.US_ECHO, wiringpi.GPIO.INPUT)

        wiringpi.pinMode(self.US_TRIG, wiringpi.GPIO.OUTPUT)
        wiringpi.digitalWrite(self.US_TRIG, wiringpi.GPIO.LOW)
示例#60
0
def alarmLightsON():
    wiringpi.digitalWrite(27, 1)  # turn on green led
    wiringpi.digitalWrite(28, 1)  # turn on red led
    wiringpi.digitalWrite(29, 1)  # turn on yellow led