def __init__(self): wp.wiringPiSetup() #left 23017, for audio wp.mcp23017Setup( PB1,0x20) for pin in OUTPUT_PINS_1: wp.pinMode(pin,OUTPUT) for pin in INPUT_PINS_1: wp.pinMode(pin, INPUT) #right 23017 for 230v switching wp.mcp23017Setup( PB2,0x21) for pin in OUTPUT_PINS_2: wp.pinMode(pin,OUTPUT) for pin in INPUT_PINS_2: wp.pullUpDnControl(pin,PUD_UP) wp.pinMode(pin, INPUT) #display wp.digitalWrite(70,0) # write mode self.display1 = wp.lcdInit(2,16,8, 71,69,72,73,74,75,76,77,78,79) #connected to first expander wp.lcdClear(self.display1) #pwm driver self.pwm = PWM() self.pwm.setPWMFreq(200)
def __init__(self, lcd_rows=2, lcd_chars=16, lcd_bits=4, pin_lcd_rs=13, pin_lcd_e=14, pins_lcd_db=[11, 10, 6, 16, 0, 0, 0, 0]): """Initialize lcd and get ip address""" self.rows = lcd_rows self.chars = lcd_chars self.lcd = wiringpi.lcdInit(lcd_rows, lcd_chars, lcd_bits, pin_lcd_rs, pin_lcd_e, *pins_lcd_db) wiringpi.lcdHome(self.lcd) self.screens = { 'splash': ['GitGear.com/xfd', 'eXtremeFeedback!'], 'ip': ['IP Address:', 'Searching...'], 'text': [ 'Comming soon:', 'Customise this', 'text in Jenkins', 'from the extreme', 'feedback plugin' ], } self.lock = threading.Lock() self.io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
def lcd_init(): """Initialize lcd and get ip address""" global LCD_HANDLE, LCD_TWO LCD_HANDLE = wiringpi.lcdInit(LCD_ROWS, LCD_CHARS, LCD_BITS, PIN_LCD_RS, PIN_LCD_E, *PINS_LCD_DB) wiringpi.lcdHome(LCD_HANDLE) lcd_two = get_connection_string("eth0") LCD_LOCK.acquire() try: LCD_TWO = lcd_two finally: LCD_LOCK.release()
def gpiosetup(): global lcd wiringpi2.wiringPiSetup() wiringpi2.mcp23017Setup(AF_BASE,0x20) wiringpi2.pinMode(AF_RIGHT,0) wiringpi2.pinMode(AF_LEFT,0) wiringpi2.pinMode(AF_SELECT,0) wiringpi2.pinMode(AF_RW,1) wiringpi2.digitalWrite(AF_RW,0) #lcdInit(int rows, int cols, int bits, int rs, int strb, int d0, int d1, int d2, int d3, int d4, int d5, int d6, int d7) lcd=wiringpi2.lcdInit(2,16,4,AF_RS,AF_E,AF_DB4,AF_DB5,AF_DB6,AF_DB7,0,0,0,0)
def initLCD_DVK512(): global lcdFD RS = 3 EN = 14 D0 = 4 D1 = 12 D2 = 13 D3 = 6 wiringpi.wiringPiSetup() lcdFD = wiringpi.lcdInit(2, 16, 4, RS, EN, D0, D1, D2, D3, 0, 0, 0, 0)
def initLCD_DVK512(): global lcdFD RS = 3 EN = 14 D0 = 4 D1 = 12 D2 = 13 D3 = 6 wiringpi.wiringPiSetup() lcdFD = wiringpi.lcdInit(2, 16, 4, RS, EN, D0, D1, D2, D3, 0, 0, 0, 0);
def initLCD_Custom(): global lcdFD RS = 11 EN = 10 D0 = 0 D1 = 1 D2 = 2 D3 = 3 D4 = 4 D5 = 5 D6 = 6 D7 = 7 wiringpi.wiringPiSetup() lcdFD = wiringpi.lcdInit(2, 16, 8, RS, EN, D0, D1, D2, D3, D4, D5, D6, D7)
def initLCD_Custom(): global lcdFD RS = 11 EN = 10 D0 = 0 D1 = 1 D2 = 2 D3 = 3 D4 = 4 D5 = 5 D6 = 6 D7 = 7 wiringpi.wiringPiSetup() lcdFD = wiringpi.lcdInit(2, 16, 8, RS, EN, D0, D1, D2, D3, D4, D5, D6, D7);
def __init__(self, lcd_rows=2, lcd_chars=16, lcd_bits=4, pin_lcd_rs=13, pin_lcd_e=14, pins_lcd_db=[11,10,6,16,0,0,0,0]): """Initialize lcd and get ip address""" self.rows = lcd_rows self.chars = lcd_chars self.lcd = wiringpi.lcdInit(lcd_rows, lcd_chars, lcd_bits, pin_lcd_rs, pin_lcd_e, *pins_lcd_db) wiringpi.lcdHome(self.lcd) self.screens = { 'splash':['GitGear.com/xfd','eXtremeFeedback!'], 'ip':['IP Address:','Searching...'], 'text':['Comming soon:', 'Customise this', 'text in Jenkins', 'from the extreme', 'feedback plugin'], } self.lock = threading.Lock() self.io = wiringpi.GPIO(wiringpi.GPIO.WPI_MODE_PINS)
def lcd_setup(): wiringpi2.wiringPiSetup() global lcdHandle lcdHandle = wiringpi2.lcdInit(LCD_ROW, LCD_COL, LCD_BUS, PORT_LCD_RS, PORT_LCD_E, PORT_LCD_D4, PORT_LCD_D5, PORT_LCD_D6, PORT_LCD_D7, 0, 0, 0, 0); # set to read mode for number in led_pins: wiringpi2.pinMode(number,1) # set to write mode wiringpi2.pinMode(5,0) wiringpi2.pinMode(6,0) # clear the state lcd_clear() for i in range(0,7): lcd_led_set(i,0) return lcdHandle
'(pulsanti e interruttori sono in numero diverso)') sys.exit(0) '''parametri preimpostati all'avvio, da non modificare''' start = [datetime(year=2000,month=01,day=01) for i in range(numerozone)] end = [datetime(year=2000,month=01,day=02) for i in range(numerozone)] days = ['lunedi','martedi','mercoledi', 'giovedi','venerdi','sabato','domenica'] '''assegnazione numeri ai pin dello shift register (dal 100 in su)''' pinBase = 100 RS = pinBase + 0 E = RS + 1 DB4 = E + 1 DB5 = DB4 + 1 DB6 = DB5 + 1 DB7 = DB6 + 1 '''setup iniziale wiringpi''' wpi.wiringPiSetup() wpi.pinMode(dataPin, 1) wpi.pinMode(clockPin, 1) wpi.pinMode(latchPin, 1) '''inizializzazione shift register e lcd -- da testare''' wpi.sr595Setup(pinBase, 6, dataPin, clockPin, latchPin) lcd = wpi.lcdInit( 4, 16, 4, RS, E, DB4, DB5, DB6, DB7, 0,0,0,0 ) logtime = Queue.Queue() lcdput = Queue.Queue()
import sys import pprint infoSocket = "tcp://localhost:5550" cmdSocket = "tcp://localhost:5560" wiringpi.wiringPiSetup() # Initialize mcp3008 (same as 3004) ADC - first parm is pin base (must be > 64) # Second param is SPI bus number wiringpi.mcp3004Setup(100, 0) # Initialize LCD # 2 rows of 16 columns, driven by 4 bits # Control pins are WiringPi 15 & 16 # Data pins are WiringPi 0,1,2,3 display = wiringpi.lcdInit(2, 16, 4, 15, 16, 0, 1, 2, 3, 0, 0, 0, 0) # LCD Backlight backlightPin = 26 # GPIO12 is set to ground to turn off backlight wiringpi.pinMode(backlightPin, 1) #output wiringpi.digitalWrite(backlightPin, 0) # Init zmq context = zmq.Context() # Subscribe to all the info queues info = context.socket(zmq.SUB) info.connect(infoSocket) info.setsockopt(zmq.SUBSCRIBE, 'INF_SENSOR') info.setsockopt(zmq.SUBSCRIBE, 'INF_CURRENTWX') info.setsockopt(zmq.SUBSCRIBE, 'INF_FORECASTWX')
def lcd_init(): """Initialize lcd and get ip address""" global LCD_HANDLE LCD_HANDLE = wiringpi.lcdInit(LCD_ROWS, LCD_CHARS, LCD_BITS, PIN_LCD_RS, PIN_LCD_E, *PINS_LCD_DB) wiringpi.lcdHome(LCD_HANDLE)
import wiringpi2 as wp # to control display #set up logging logging.basicConfig(filename='/home/pi/scripts/buttonwatch.log', level=logging.DEBUG, format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') #some messages = "123456789ABCDEF0", "123456789ABCDEF0" shutdownMessage = ["Shutting down...", " ...bye bye. "] rebootMessage = ["Rebooting - ", " Back in a mo..."] # set up the display - 4 bit to save pins - apparently slower but marginal # https://projects.drogon.net/raspberry-pi/wiringpi/lcd-library/ wp.wiringPiSetup() lcd = wp.lcdInit(2, 16, 4, 11, 10, 0, 1, 2, 3, 0, 0, 0, 0) #delay 30 seconds to let things settle down! logging.debug('Starting 30 second delay to let GPIO settle down...') time.sleep(30) logging.debug('...and continuing...') #where the button is plugged in buttonPin = 4 #time limits accidental = 0.2 shutdown = 3 #set up GPIO GPIO.setmode(GPIO.BCM)
wiringpi.digitalWrite(E, OFF) wiringpi.digitalWrite(F, OFF) wiringpi.digitalWrite(G, OFF) wiringpi.digitalWrite(H, OFF) wiringpi.digitalWrite(ONE, OFF) wiringpi.digitalWrite(TWO, OFF) wiringpi.digitalWrite(THR, OFF) wiringpi.digitalWrite(FOU, OFF) wiringpi.digitalWrite(FIV, OFF) wiringpi.digitalWrite(SIX, OFF) wiringpi.digitalWrite(SEV, OFF) wiringpi.digitalWrite(EIG, OFF) wiringpi.digitalWrite(WHI, OFF) wiringpi.digitalWrite(BLA, OFF) # LCD_RS = 83 # LCD_EN = 84 # LCD_D4 = 85 # LCD_D5 = 86 # LCD_D6 = 87 # LCD_D7 = 88 lcd = wiringpi.lcdInit(2, 16, 4, LCD_RS, LCD_EN, LCD_D4, LCD_D5, LCD_D6, LCD_D7, 0, 0, 0, 0) wiringpi.lcdHome(lcd) wiringpi.lcdClear(lcd) wiringpi.lcdPosition(lcd, 0, 0) wiringpi.lcdPuts(lcd, "oh yeah!") wiringpi.lcdPosition(lcd, 0, 1) wiringpi.lcdPuts(lcd, "it works!")
import time import logging import wiringpi2 as wp # to control display #set up logging logging.basicConfig(filename='/home/pi/scripts/buttonwatch.log',level=logging.DEBUG,format='%(asctime)s %(message)s', datefmt='%m/%d/%Y %I:%M:%S %p') #some messages = "123456789ABCDEF0", "123456789ABCDEF0" shutdownMessage = ["Shutting down...", " ...bye bye. "] rebootMessage = ["Rebooting - ", " Back in a mo..."] # set up the display - 4 bit to save pins - apparently slower but marginal # https://projects.drogon.net/raspberry-pi/wiringpi/lcd-library/ wp.wiringPiSetup(); lcd = wp.lcdInit (2, 16, 4, 11,10 , 0,1,2,3,0,0,0,0) #delay 30 seconds to let things settle down! logging.debug('Starting 30 second delay to let GPIO settle down...') time.sleep(30) logging.debug('...and continuing...') #where the button is plugged in buttonPin = 4 #time limits accidental = 0.2 shutdown = 3 #set up GPIO GPIO.setmode(GPIO.BCM)
PORT_LCD_RS = 7 # GPIOY.BIT3(#83) PORT_LCD_E = 0 # GPIOY.BIT8(#88) PORT_LCD_D4 = 2 # GPIOX.BIT19(#116) PORT_LCD_D5 = 3 # GPIOX.BIT18(#115) PORT_LCD_D6 = 1 # GPIOY.BIT7(#87) PORT_LCD_D7 = 4 # GPIOX.BIT4(#104) # --Buttons PORT_LCD_5 = 5 # --LCD ##Initialise the screen wiringpi2.wiringPiSetup() # --LCD lcdHandle = wiringpi2.lcdInit(LCD_ROW, LCD_COL, LCD_BUS, PORT_LCD_RS, PORT_LCD_E, PORT_LCD_D4, PORT_LCD_D5, PORT_LCD_D6, PORT_LCD_D7, 0, 0, 0, 0) lcdRow = 0 # LCD Row lcdCol = 0 # LCD Column # --LCD # --LED LED1 = 21 wiringpi2.pinMode(LED1, 1) wiringpi2.digitalWrite(LED1, 0) LED2 = 22 wiringpi2.pinMode(LED2, 1) wiringpi2.digitalWrite(LED2, 0) LED3 = 23 wiringpi2.pinMode(LED3, 1) wiringpi2.digitalWrite(LED3, 0)
PORT_LCD_D5 = 3 # GPIOX.BIT18(#115) PORT_LCD_D6 = 1 # GPIOY.BIT7(#87) PORT_LCD_D7 = 4 # GPIOX.BIT4(#104) PORT_BUTTON1 = 5 PORT_BUTTON2 = 6 wiringpi2.wiringPiSetup() # Initialize values for pin numbering lcdHandle = wiringpi2.lcdInit( LCD_ROW, LCD_COL, LCD_BUS, # Main initialization function PORT_LCD_RS, PORT_LCD_E, PORT_LCD_D4, PORT_LCD_D5, PORT_LCD_D6, PORT_LCD_D7, 0, 0, 0, 0) lcdRow = 0 # LCD Row lcdCol = 0 # LCD Column # Working with LEDs ledPorts = [21, 22, 23, 24, 11, 26, 27] PUD_UP = 2 # Set pull-up resistor mode INPUT = 0 # We use 0 for input OUTPUT = 1 # We use 1 for output