Пример #1
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
Пример #2
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
Пример #3
0
def lcd_init(a_RS, a_E, a_D4, a_D5, a_D6, a_D7, a_Back):
    global LCD_RS
    global LCD_E
    global LCD_D4
    global LCD_D5
    global LCD_D6
    global LCD_D7
    global LCD_Back
    LCD_RS = a_RS
    LCD_E = a_E
    LCD_D4 = a_D4
    LCD_D5 = a_D5
    LCD_D6 = a_D6
    LCD_D7 = a_D7
    LCD_Back = a_Back
    #  GPIO.toggle_debug()
    GPIO.setmode(GPIO.BOARD)
    GPIO.setwarnings(False)

    # Main program block
    GPIO.setup(LCD_RS, GPIO.OUT)  # RS
    GPIO.setup(LCD_E, GPIO.OUT)  # E
    GPIO.setup(LCD_D4, GPIO.OUT)  # DB4
    GPIO.setup(LCD_D5, GPIO.OUT)  # DB5
    GPIO.setup(LCD_D6, GPIO.OUT)  # DB6
    GPIO.setup(LCD_D7, GPIO.OUT)  # DB7
    GPIO.setup(LCD_Back, GPIO.OUT)  # Backlight enable
    # Initialise display
    lcd_byte(0x33, LCD_CMD)  # 110011 Initialise
    lcd_byte(0x32, LCD_CMD)  # 110010 Initialise
    lcd_byte(0x06, LCD_CMD)  # 000110 Cursor move direction
    lcd_byte(0x0C, LCD_CMD)  # 001100 Display On,Cursor Off, Blink Off
    lcd_byte(0x28, LCD_CMD)  # 101000 Data length, number of lines, font size
    lcd_byte(0x01, LCD_CMD)  # 000001 Clear display
    time.sleep(E_DELAY)
Пример #4
0
    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)
Пример #5
0
def initBuzzer():

    buzzer_gpio = app.brewapp_config.get("BUZZER_GPIO", None)
    app.logger.info("BUZZER GPIO: " + str(buzzer_gpio))
    try:
        if buzzer_gpio is not None:
            GPIO.setmode(GPIO.BCM)
            GPIO.setup(buzzer_gpio, GPIO.OUT)

    except Exception as e:
        app.logger.error(e)
Пример #6
0
 def __init__(self, pinA, pinB, button, callback):
     self.pinA = pinA
     self.pinB = pinB
     self.button = button
     self.callback = callback
     GPIO.setmode(GPIO.BCM)
     GPIO.setwarnings(False)
     GPIO.setup(self.pinA, GPIO.IN, pull_up_down=GPIO.PUD_UP)
     GPIO.setup(self.pinB, GPIO.IN, pull_up_down=GPIO.PUD_UP)
     GPIO.setup(self.button, GPIO.IN, pull_up_down=GPIO.PUD_UP)
     GPIO.add_event_detect(self.pinA, GPIO.FALLING, callback=self.switch_event)
     GPIO.add_event_detect(self.pinB, GPIO.FALLING, callback=self.switch_event)
     GPIO.add_event_detect(self.button, GPIO.BOTH, callback=self.button_event, bouncetime=200)
Пример #7
0
    def __init__(self, spi_bus, spi_device, reset_pin):
        self.spi = spidev.SpiDev()
        self.spi.open(spi_bus, spi_device)
        self.reset_pin = reset_pin

        if hasattr(GPIO, "setmode"):
            GPIO.setmode(GPIO.BOARD)

        try:
            GPIO.setup(self.reset_pin, GPIO.OUT)
        except:
            pass

        GPIO.output(self.reset_pin, GPIO.HIGH)
        self.RC522_Init()
Пример #8
0
config = SafeConfigParser()
config.read(sys.argv[1])
sensor_pin = "XIO-P1"
#sensor_pin = config.getint('main', 'SENSOR_PIN')
begin_seconds = config.getint('main', 'SECONDS_TO_START')
end_seconds = config.getint('main', 'SECONDS_TO_END')
pushbullet_api_key = config.get('pushbullet', 'API_KEY')
pushbullet_api_key2 = config.get('pushbullet', 'API_KEY2')
start_message = config.get('main', 'START_MESSAGE')
end_message = config.get('main', 'END_MESSAGE')
twitter_api_key = config.get('twitter', 'api_key')
twitter_api_secret = config.get('twitter', 'api_secret')
twitter_access_token = config.get('twitter', 'access_token')
twitter_access_token_secret = config.get('twitter', 'access_token_secret')
#slack_api_token = config.get('slack', 'api_token')
#slack_webhook = config.get('slack','webhook_url')
iftt_maker_channel_event = config.get('iftt', 'maker_channel_event')
iftt_maker_channel_key = config.get('iftt', 'maker_channel_key')

send_alert(config.get('main', 'BOOT_MESSAGE'))

GPIO.setwarnings(False)
GPIO.setmode(GPIO.BCM)
GPIO.setup(sensor_pin, GPIO.IN, pull_up_down=GPIO.PUD_DOWN)
GPIO.add_event_detect(sensor_pin, GPIO.RISING)
GPIO.add_event_callback(sensor_pin, vibrated)

print 'Running config file {} monitoring GPIO pin {}'\
      .format(sys.argv[1], str(sensor_pin))
threading.Timer(1, heartbeat).start()
Пример #9
0
#import paho.mqtt.client as mqtt
#from hostdef import *
from subprocess import call
import CHIP_IO.GPIO as GPIO  ##import GPIO library
GPIO.setmode(GPIO.BOARD)  ##use board pin bumbering
GPIO.setup("CSID1", GPIO.OUT)  ##set pin XIO-P3 to out
GPIO.outout("CSID1", True)  ##Turn on GPIO pin XIO-P3