def __init__(self,DEBUG=False):
   self.DEBUG=DEBUG
   wiringpi2.wiringPiSPISetup(SPI_CS,SPI_SPEED)
   self.sendCmd(MAX7219_SCANLIMIT, 8)   # enable outputs
   self.sendCmd(MAX7219_DECODEMODE, 0)  # no digit decode
   self.sendCmd(MAX7219_DISPLAYTEST, 0) # display test off
   self.clear()
   self.brightness(7)                   # brightness 0-15
   self.sendCmd(MAX7219_SHUTDOWN, 1)    # start display
 def __init__(self, ce_channel, speed):
     self.ce_channel = ce_channel
     os.system('gpio load spi')
     wiringpi.wiringPiSetup()
     error = wiringpi.wiringPiSPISetup(ce_channel,speed)
     if (error == -1):
         raise SetupException('Error while SPI setup')
     print('InterfaceSPI initalized (CE_%d, speed:%.1fMHz)' % (ce_channel, speed * 0.000001))
示例#3
0
    def setup(self):
        if wiringpi2.wiringPiSPISetup(0, 900000) == -1:
            return False

        # disable nss pullups
        wiringpi2.pullUpDnControl(self.ADC_NSS, wiringpi2.GPIO.PUD_OFF)
        # cycle NSS to ensure state in adc chip
        self._adc_deselect()
        self._adc_select()
        self._adc_deselect()
        return True
示例#4
0
def telmin():
    REF=3.3  # 5.p or 3.3
    mode=1
    w.wiringPiSetup()
    w.wiringPiSPISetup(0,1000000)
    w.pinMode(0,1)
    w.pinMode(2,1)
    w.pinMode(1,2)
    #w.softPwmCreate(1,0,100)
    w.softPwmCreate(2,0,100)

    w.digitalWrite(0,1)
    
    while 1:
        data1 = MCP3008(1)
        data7 = MCP3008(7)
        time.sleep(0.01)
        data11 = int(data1)-860;
        w.softPwmWrite(2,data11)
        data71 = int(((data7/20)*5.8)-225)
        w.pwmWrite(1,data71*10)
        print('%4.2f'%data11,'%4.2f'%data71,'%.2f'%(data1/1024*REF),"volt",'%.2f'%(data7/1024*REF),"volt")
示例#5
0
    def __init__(self):
        # Set up the wiringpi object to use physical pin numbers
        wp.wiringPiSetupPhys()

        # Initialize the DRDY pin
        wp.pinMode(self.DRDY_PIN, wp.INPUT)

        # Initialize the reset pin
        wp.pinMode(self.RESET_PIN, wp.OUTPUT)
        wp.digitalWrite(self.RESET_PIN, wp.HIGH)

        # Initialize PDWN pin
        wp.pinMode(self.PDWN_PIN, wp.OUTPUT)
        wp.digitalWrite(self.PDWN_PIN, wp.HIGH)

        # Initialize CS pin
        wp.pinMode(self.CS_PIN, wp.OUTPUT)
        wp.digitalWrite(self.CS_PIN, wp.HIGH)

        # Initialize the wiringpi SPI setup
        spi_success = wp.wiringPiSPISetup(self.SPI_CHANNEL, self.SPI_FREQUENCY) 
        debug_print("SPI success " + str(spi_success))
示例#6
0
文件: bsp.py 项目: mnowotka/epyper
def init():
    """   
       BSP initialize function. Must be called before any other BSP related
       functions.
    
    """
    global gI2cFd

    if wiringpi2.wiringPiSetup() < 0:
        print "bsp_init: failed to initialize wiringPi"
        return -1
        
    gI2cFd = wiringpi2.wiringPiI2CSetup(LM75A_I2C_ADDR)
    
    if gI2cFd < 0:
        print "bsp_init: failed to initialize I2C"
        return -1
    
    if wiringpi2.wiringPiSPISetup(0, 1000000) < 0:
        print "bsp_init: failed to initialize SPI"
        return -1
    
    return 0
示例#7
0
def init():
    """   
       BSP initialize function. Must be called before any other BSP related
       functions.
    
    """
    global gI2cFd

    if wiringpi2.wiringPiSetup() < 0:
        print "bsp_init: failed to initialize wiringPi"
        return -1

    gI2cFd = wiringpi2.wiringPiI2CSetup(LM75A_I2C_ADDR)

    if gI2cFd < 0:
        print "bsp_init: failed to initialize I2C"
        return -1

    if wiringpi2.wiringPiSPISetup(0, 1000000) < 0:
        print "bsp_init: failed to initialize SPI"
        return -1

    return 0
示例#8
0
#!/usr/bin/python3
# spiTest.py
import wiringpi2

print("Add SPI Loopback - connect P1-Pin19 and P1-Pin21")
print("[Press Enter to continue]")
input()
wiringpi2.wiringPiSPISetup(1,500000)
buffer=str.encode("HELLO")
print("Buffer sent %s" % buffer)
wiringpi2.wiringPiSPIDataRW(1,buffer)
print("Buffer received %s" % buffer)
print("Remove the SPI Loopback")
print("[Press Enter to continue]")
input()
buffer=str.encode("HELLO")
print("Buffer sent %s" % buffer)
wiringpi2.wiringPiSPIDataRW(1,buffer)
print("Buffer received %s" % buffer)
#End
示例#9
0
    def initialise(self):
        u'''Initialises the gpio pins, the SPI interface and configures
        the rfm22 module
        '''
        wiringpi.wiringPiSetup()
        wiringpi.wiringPiSPISetup(RFM22_SPI_CHANNEL, 10000000)
        RPIO.setup(RFM22_NIRQ_GPIO_BCM_PIN, RPIO.IN)
        RPIO.cleanup_interrupts()
        RPIO.add_interrupt_callback(RFM22_NIRQ_GPIO_BCM_PIN,
                                    nirq_callback,
                                    edge='falling')

        wiringpi.pinMode(RFM22_SDN_GPIO_PIN, OUTPUT)
        wiringpi.pinMode(RFM22_TXEN_GPIO_PIN, OUTPUT)
        wiringpi.pinMode(RFM22_RXEN_GPIO_PIN, OUTPUT)

        self.__rx_ant_off()
        self.__tx_ant_off()
        self.__sdn_off()
        time.sleep(0.1)  #reset module
        self.__sdn_on()
        #Wait 100ms to give rfm22 time to wake up
        time.sleep(0.1)

        #Read out chip version via SPI
        version = self.__read(self.__DEVICE_VERSION)
        debug_log("RFM22 chip version:", version)
        if (version[1] != 0):
            debug_log("SPI Communication working!")

        #Reset all registers, software reset
        self.__write(self.__OPERATING_FUNCTION_CONTROL_1, 0x80)

        #Wait 20ms to let the module boot up
        time.sleep(0.02)
        u'''Enable FIFO under/overflow, external, packet send,
        received and crc error interrupt.'''
        self.__write(self.__INTERRUPT_ENABLE_1, 0x87)
        u'''Enable rssi interrupt'''
        #self.__write(self.__INTERRUPT_ENABLE_2, 0x10) #Raspberry PI does not react fast enough to read correct value
        u'''Switch to ready mode.  200us to tx or rx'''
        self.__write(self.__OPERATING_FUNCTION_CONTROL_1, 0x01)

        self.__write(self.__CRYSTAL_OSCILLATOR_LOAD, 0x7f)
        u'''Enable AFC'''
        self.__write(self.__AFC_LOOP_GEARSHIFT_OVERRIDE, 0x40)
        u'''Set AFC timing'''
        self.__write(self.__AFC_TIMING_CONTROL, 0x0A)
        self.__write(self.__CLOCK_RECOVERY_GEARSHIFT_OVERRIDE, 0x05)
        u'''Set IF filter bandwidth'''
        self.__write(self.__IF_FILTER_BANDWIDTH, 0x9A)
        u'''Set clock recovery oversampling rate'''
        self.__write(self.__CLOCK_RECOVERY_OVERSAMPLING_RATIO, 0x3C)
        self.__write(self.__CLOCK_RECOVERY_OFFSET_2, 0x02)
        self.__write(self.__CLOCK_RECOVERY_OFFSET_1, 0x22)
        self.__write(self.__CLOCK_RECOVERY_OFFSET_0, 0x22)

        self.__write(self.__CLOCK_RECOVERY_TIMING_LOOP_GAIN_1, 0x07)
        self.__write(self.__CLOCK_RECOVERY_TIMING_LOOP_GAIN_0, 0xFF)
        u'''Set AFC Limiter'''
        self.__write(self.__AFC_LIMITER, 0x48)
        u'''Set RSSI threshold for clear channel assessment'''
        self.__write(self.__RSSI_THRESSHOLF_FOR_CLEAR_CHANNEL_INDICATOR,
                     self.__RSSI_CLEAR_CHANNEL_THRESHOLD)
        u'''RX, TX packet handling, enable CCIT CRC'''
        self.__write(self.__DATA_ACCESS_CONTROL, 0xAC)
        u'''Header check, valid for broadcast or check byte'''
        self.__write(self.__HEADER_CONTROL_1, 0xFF)
        u'''4 byte header (Header 3,2,1,0) and 2 byte sync (Synchronization Word 3,2) '''
        self.__write(self.__HEADER_CONTROL_2, 0x42)
        u'''Synchronization words'''
        self.__write(self.__SYNC_WORD_3, self.__PACKET_SYNC_BYTE_3)
        self.__write(self.__SYNC_WORD_2, self.__PACKET_SYNC_BYTE_2)
        self.__write(self.__SYNC_WORD_1, self.__PACKET_SYNC_BYTE_1)
        self.__write(self.__SYNC_WORD_0, self.__PACKET_SYNC_BYTE_0)
        u'''Transmit header'''
        self.__write(self.__TRANSMIT_HEADER_3, self.__TRANSMIT_HEADER_BYTE_3)
        self.__write(self.__TRANSMIT_HEADER_2, self.__TRANSMIT_HEADER_BYTE_2)
        self.__write(self.__TRANSMIT_HEADER_1, self.__TRANSMIT_HEADER_BYTE_1)
        self.__write(self.__TRANSMIT_HEADER_0, self.__TRANSMIT_HEADER_BYTE_0)

        self.__write(self.__CHECK_HEADER_3, self.__TRANSMIT_HEADER_BYTE_3)
        self.__write(self.__CHECK_HEADER_2, self.__TRANSMIT_HEADER_BYTE_2)
        self.__write(self.__CHECK_HEADER_1, self.__TRANSMIT_HEADER_BYTE_1)
        self.__write(self.__CHECK_HEADER_0, self.__TRANSMIT_HEADER_BYTE_0)
        u'''Check header enable mask, 0xFF means all bits of the corresponding
         * header will be checked. '''
        self.__write(self.__HEADER_ENABLE_3, 0xFF)
        self.__write(self.__HEADER_ENABLE_2, 0xFF)
        self.__write(self.__HEADER_ENABLE_1, 0xFF)
        self.__write(self.__HEADER_ENABLE_0, 0xFF)
        u'''Switch on automatic RX gain control'''
        self.__write(self.__AGC_OVERRIDE_1, 0x60)
        u'''TODO: example check agc override Register 0x6a does not exist. Data sheet wrong?'''
        u'''Set TX power and  LNA controller on if RFM22 != TX
         * TXPower         equals
         * -1dbm        0x00
         *  2dbm        0x01   set to 2dbm
         *  5dbm        0x02
         *  8dbm        0x03
         *  11dbm       0x04
         *  14dbm       0x05
         *  17dbm       0x06
         *  20dbm       0x07
         * '''
        self.__write(self.__TX_POWER, (0x01 | 0x80))
        u'''Set TX data rate to 0x199a =  100 kbps.
         * Datarate calculation:
         * TX_DR = 10^6 * 0x199a / 2^16 '''
        self.__write(self.__TX_DATA_RATE_1, 0x19)
        #Bits 15:8
        self.__write(self.__TX_DATA_RATE_0, 0x9a)
        #Bits 7:0
        u'''Modulation control, manchester data inversion.'''
        self.__write(self.__MODULATION_MODE_CONTROL_1, 0x0C)
        u'''Modulation control, FIFO Mode, GFSK '''
        self.__write(self.__MODULATION_MODE_CONTROL_2, 0x23)
        u'''Frequency deviation 50kHz
         * deviation = 625 * 0x50'''
        self.__write(self.__FREQUENCY_DEVIATION, 0x50)
        u'''Select frequency band, high band = >480 < 960 MHz,
         * 860- 879.9MHz
         * Regulations: 869,4 869,65 at 500mW ERP < 10%
         * '''
        self.__write(self.__FREQUENCY_BAND_SELECT, 0x73)

        self.__write(self.__NOMINAL_CARRIER_FREQUENCY_1, 0x76)

        self.__write(self.__NOMINAL_CARRIER_FREQUENCY_0, 0xC0)
        u'''Set carrier '''
        debug_log(u"RFM22 initialised")
示例#10
0
def open(ch):
    wiringpi2.wiringPiSPISetup(ch, 4000)
示例#11
0
# Arduino  <  >     PI
# 11                MOSI
# 12                MISO
# 13                SCLK
# DO NOT FORGET 3.3V <> 5V bi-directional level convert to avoid fried pi

# Jonathan H 11/09/2013

import wiringpi2
import sys
import Tkinter as tki # tkinter in Python 3
from time import sleep
print sys.version

wiringpi2.wiringPiSPISetup(1,2000000) #2MHZ = SPI_CLOCK_DIV8; (16Mhz/8)

# Class to replace missing switch/case functionality 
# http://code.activestate.com/recipes/410692/
class switch(object):
    def __init__(self, value):
        self.value = value
        self.fall = False

    def __iter__(self):
        """Return the match method once, then stop"""
        yield self.match
        raise StopIteration
    
    def match(self, *args):
        """Indicate whether or not to enter a case suite"""
示例#12
0
    def initialise(self):
        u'''Initialises the gpio pins, the SPI interface and configures
        the rfm22 module
        '''
        wiringpi.wiringPiSetup() 
        wiringpi.wiringPiSPISetup(RFM22_SPI_CHANNEL,10000000) 
        RPIO.setup(RFM22_NIRQ_GPIO_BCM_PIN, RPIO.IN)
        RPIO.cleanup_interrupts()
        RPIO.add_interrupt_callback(RFM22_NIRQ_GPIO_BCM_PIN, nirq_callback, edge='falling')
         
        wiringpi.pinMode(RFM22_SDN_GPIO_PIN, OUTPUT)
        wiringpi.pinMode(RFM22_TXEN_GPIO_PIN, OUTPUT)
        wiringpi.pinMode(RFM22_RXEN_GPIO_PIN, OUTPUT)
          
        self.__rx_ant_off()
        self.__tx_ant_off()
        self.__sdn_off()
        time.sleep(0.1) #reset module
        self.__sdn_on()
        #Wait 100ms to give rfm22 time to wake up
        time.sleep(0.1)
       
        #Read out chip version via SPI
        version = self.__read(self.__DEVICE_VERSION)
        debug_log("RFM22 chip version:", version)
        if (version[1] != 0):
            debug_log("SPI Communication working!")

        #Reset all registers, software reset
        self.__write(self.__OPERATING_FUNCTION_CONTROL_1, 0x80)
        
        #Wait 20ms to let the module boot up
        time.sleep(0.02)

        u'''Enable FIFO under/overflow, external, packet send,
        received and crc error interrupt.'''
        self.__write(self.__INTERRUPT_ENABLE_1, 0x87)
        
        u'''Enable rssi interrupt'''
        #self.__write(self.__INTERRUPT_ENABLE_2, 0x10) #Raspberry PI does not react fast enough to read correct value
        
        u'''Switch to ready mode.  200us to tx or rx'''
        self.__write(self.__OPERATING_FUNCTION_CONTROL_1, 0x01)

        self.__write(self.__CRYSTAL_OSCILLATOR_LOAD, 0x7f);  
    
        u'''Enable AFC'''
        self.__write(self.__AFC_LOOP_GEARSHIFT_OVERRIDE, 0x40);
    
        u'''Set AFC timing'''
        self.__write(self.__AFC_TIMING_CONTROL, 0x0A);  
        self.__write(self.__CLOCK_RECOVERY_GEARSHIFT_OVERRIDE, 0x05);
    
        u'''Set IF filter bandwidth'''
        self.__write(self.__IF_FILTER_BANDWIDTH, 0x9A);
    
        u'''Set clock recovery oversampling rate'''
        self.__write(self.__CLOCK_RECOVERY_OVERSAMPLING_RATIO, 0x3C);
        self.__write(self.__CLOCK_RECOVERY_OFFSET_2, 0x02);
        self.__write(self.__CLOCK_RECOVERY_OFFSET_1, 0x22);
        self.__write(self.__CLOCK_RECOVERY_OFFSET_0, 0x22);
    
        self.__write(self.__CLOCK_RECOVERY_TIMING_LOOP_GAIN_1, 0x07);
        self.__write(self.__CLOCK_RECOVERY_TIMING_LOOP_GAIN_0, 0xFF);
    
        u'''Set AFC Limiter'''
        self.__write(self.__AFC_LIMITER, 0x48);
    
        u'''Set RSSI threshold for clear channel assessment'''
        self.__write(self.__RSSI_THRESSHOLF_FOR_CLEAR_CHANNEL_INDICATOR, self.__RSSI_CLEAR_CHANNEL_THRESHOLD);
    
        u'''RX, TX packet handling, enable CCIT CRC'''
        self.__write(self.__DATA_ACCESS_CONTROL, 0xAC);
    
        u'''Header check, valid for broadcast or check byte'''
        self.__write(self.__HEADER_CONTROL_1, 0xFF);
    
        u'''4 byte header (Header 3,2,1,0) and 2 byte sync (Synchronization Word 3,2) '''
        self.__write(self.__HEADER_CONTROL_2, 0x42);
    
        u'''Synchronization words'''
        self.__write(self.__SYNC_WORD_3, self.__PACKET_SYNC_BYTE_3);
        self.__write(self.__SYNC_WORD_2, self.__PACKET_SYNC_BYTE_2);
        self.__write(self.__SYNC_WORD_1, self.__PACKET_SYNC_BYTE_1);
        self.__write(self.__SYNC_WORD_0, self.__PACKET_SYNC_BYTE_0);
    
        u'''Transmit header'''
        self.__write(self.__TRANSMIT_HEADER_3, self.__TRANSMIT_HEADER_BYTE_3);
        self.__write(self.__TRANSMIT_HEADER_2, self.__TRANSMIT_HEADER_BYTE_2);
        self.__write(self.__TRANSMIT_HEADER_1, self.__TRANSMIT_HEADER_BYTE_1);
        self.__write(self.__TRANSMIT_HEADER_0, self.__TRANSMIT_HEADER_BYTE_0);
    
        self.__write(self.__CHECK_HEADER_3, self.__TRANSMIT_HEADER_BYTE_3);
        self.__write(self.__CHECK_HEADER_2, self.__TRANSMIT_HEADER_BYTE_2);
        self.__write(self.__CHECK_HEADER_1, self.__TRANSMIT_HEADER_BYTE_1);
        self.__write(self.__CHECK_HEADER_0, self.__TRANSMIT_HEADER_BYTE_0);
    
        u'''Check header enable mask, 0xFF means all bits of the corresponding
         * header will be checked. '''
        self.__write(self.__HEADER_ENABLE_3, 0xFF);
        self.__write(self.__HEADER_ENABLE_2, 0xFF);
        self.__write(self.__HEADER_ENABLE_1, 0xFF);
        self.__write(self.__HEADER_ENABLE_0, 0xFF);
    
        u'''Switch on automatic RX gain control'''
        self.__write(self.__AGC_OVERRIDE_1, 0x60);
        u'''TODO: example check agc override Register 0x6a does not exist. Data sheet wrong?'''
    
        u'''Set TX power and  LNA controller on if RFM22 != TX
         * TXPower         equals
         * -1dbm        0x00
         *  2dbm        0x01   set to 2dbm
         *  5dbm        0x02
         *  8dbm        0x03
         *  11dbm       0x04
         *  14dbm       0x05
         *  17dbm       0x06
         *  20dbm       0x07
         * '''
        self.__write(self.__TX_POWER, (0x01|0x80));
    
        u'''Set TX data rate to 0x199a =  100 kbps.
         * Datarate calculation:
         * TX_DR = 10^6 * 0x199a / 2^16 '''
        self.__write(self.__TX_DATA_RATE_1, 0x19); #Bits 15:8
        self.__write(self.__TX_DATA_RATE_0, 0x9a); #Bits 7:0
    
        u'''Modulation control, manchester data inversion.'''    
        self.__write(self.__MODULATION_MODE_CONTROL_1, 0x0C);
    
        u'''Modulation control, FIFO Mode, GFSK '''
        self.__write(self.__MODULATION_MODE_CONTROL_2, 0x23);
    
        u'''Frequency deviation 50kHz
         * deviation = 625 * 0x50'''
        self.__write(self.__FREQUENCY_DEVIATION, 0x50);
    
        u'''Select frequency band, high band = >480 < 960 MHz,
         * 860- 879.9MHz
         * Regulations: 869,4 869,65 at 500mW ERP < 10%
         * '''
        self.__write(self.__FREQUENCY_BAND_SELECT, 0x73);
    
        self.__write(self.__NOMINAL_CARRIER_FREQUENCY_1, 0x76);
    
        self.__write(self.__NOMINAL_CARRIER_FREQUENCY_0, 0xC0);
        u'''Set carrier '''
        debug_log(u"RFM22 initialised")
示例#13
0
        max7219WriteReg(i, font_en_8x8.data[index][i-1])

# Display char of font lib on MAX7219
def max7219DiplayMxChar(char):
    for i in range(1, 9):
        max7219WriteReg(i, font_en_8x8.data[ord(char)-32][i-1])

# Init GPIO to wiringPi pin mode
io = wpi.GPIO(wpi.GPIO.WPI_MODE_PINS)
# Init CS#
io.pinMode(SPI_CS_Pin, io.OUTPUT)
io.digitalWrite(SPI_CS_Pin, io.HIGH)
time.sleep(0.2)

# Init SPI0 for MAX7219
spi = wpi.wiringPiSPISetup(0, 1000000)
if spi<0:
    print("SPI init error!")
    exit(1)
print("SPI init OK!")

# Init MAX7219
max7219Init()
print("MAX7219 init OK!")

# Display font lib
print("Starting display...")
while True:
    for i in range(0, 95):
#        print(i)
        max7219DiplayMxRaw(i)        
示例#14
0
 def open_port(self):
     self.port = wiringpi2.wiringPiSPISetup(self.spi_name, 125000)
     self.blank()
#!/usr/bin/env python

import wiringpi2

setupres = wiringpi2.wiringPiSPISetup(0, 5000)

while True:
    command = raw_input("Data to write?")
    written = wiringpi2.wiringPiSPIDataRW(0, command+'\n')
示例#16
0
 def __init__(self):
     self.outBuf = []
     self.fd = wiringpi2.wiringPiSPISetup(SPI_CHANNEL, SPI_SPEED)
示例#17
0
def sendCode(c):
    import wiringpi2
    fd = wiringpi2.wiringPiSPISetup(0,500000)
    os.write(fd, getCode(*c))
    os.close(fd)
示例#18
0
 def __init__(self):
     self.outBuf = []
     self.fd = wiringpi2.wiringPiSPISetup(SPI_CHANNEL, SPI_SPEED)
示例#19
0
 def __init__(self, channel=0, speed=1000000, display_count=1, keep_alive=False):
     self.__channel = channel
     self.setDisplayCount(display_count)
     self.keep_alive = keep_alive
     wiringpi2.wiringPiSPISetup(self.__channel, speed)
     self.__display = 0 # Starts on display 0
示例#20
0
import wiringpi2 as wiringpi
import RPi.GPIO as GPIO
import time
import io

GPIO.setmode(GPIO.BCM)
GPIO.setwarnings(False)

c0 = wiringpi.wiringPiSPISetup(0, 8000000)
print "Inital Result : ", c0


#Making array each IC is addressed by pin_base[IC#-1]
PIN_BASE = 65
pin_base = [PIN_BASE, PIN_BASE+16, PIN_BASE+32, PIN_BASE+48, PIN_BASE+64, PIN_BASE+80, PIN_BASE+96, PIN_BASE+112, PIN_BASE+128, PIN_BASE+144, PIN_BASE+160, PIN_BASE+176]

#doing setup for each individual IC
wiringpi.mcp23s17Setup(pin_base[0], 0, 0x10)    #IC 0  (LEDs 1-4)   (Pins 65-80)
wiringpi.mcp23s17Setup(pin_base[1], 0, 0x11)    #IC 1  (LEDs 5-8)   (Pins 81-96)
wiringpi.mcp23s17Setup(pin_base[2], 0, 0x12)    #IC 2  (LEDs 9-12)  (Pins 97-112)
wiringpi.mcp23s17Setup(pin_base[3], 0, 0x13)    #IC 3  (LEDs 13-16) (Pins 113-128)
wiringpi.mcp23s17Setup(pin_base[4], 0, 0x14)    #IC 4  (LEDs 17-20) (Pins 129-144)
wiringpi.mcp23s17Setup(pin_base[5], 0, 0x15)    #IC 5  (LEDs 21-24) (Pins 145-160)
wiringpi.mcp23s17Setup(pin_base[6], 1, 0x10)    #IC 6  (LEDs 25-28) (Pins 161-176)
wiringpi.mcp23s17Setup(pin_base[7], 1, 0x11)    #IC 7  (LEDs 29-32) (Pins 177-192)
wiringpi.mcp23s17Setup(pin_base[8], 1, 0x12)    #IC 8  (LEDs 33-36) (Pins 193-208)
wiringpi.mcp23s17Setup(pin_base[9], 1, 0x13)    #IC 9  (LEDs 37-40) (Pins 209-224)
wiringpi.mcp23s17Setup(pin_base[10], 1, 0x14)   #IC 10 (LEDs 41-44) (Pins 225-240)
wiringpi.mcp23s17Setup(pin_base[11], 1, 0x15)   #IC 11 (LEDs 45-48) (Pins 241-256)

示例#21
0
 def open_port(self):
     self.port = wiringpi2.wiringPiSPISetup(self.spi_name, 125000)
     self.blank()
示例#22
0
def sync():
    import wiringpi2
    fd = wiringpi2.wiringPiSPISetup(0,500000)
    os.write(fd, "\0"*257)
    os.close(fd)
示例#23
0
 def __init__(self):
     self.counter = 0
     self.devices = []
     wiringpi.wiringPiSetup()
     wiringpi.wiringPiSPISetup(self.SPI_CHANNEL, self.SPI_SPEED)