コード例 #1
0
    def __init__(self, number_of_channels, enable_pin, select_pins=[], active_low=True):
        if number_of_channels > 1:
            self.number_of_channels = number_of_channels
        else:
            print "invalid number of channels: {0}".format(number_of_channels)
            return

        if 2**len(select_pins) >= number_of_channels:
            self.select_pins = []
            for i in range(0,len(select_pins)):
                self.select_pins.append(gpio.Gpio(select_pins[i]))
                self.select_pins[i].set_direction(gpio.OUTPUT)
                self.select_pins[i].set_value(gpio.LOW)
                self.current_channel = 0
        else:
            print "insufficient select pins"
            return

        self.active_low = active_low
        self.enable_pin = gpio.Gpio(enable_pin)
        self.enable_pin.set_direction(gpio.OUTPUT)
        if self.active_low:
            self.enable_pin.set_value(gpio.HIGH)
        else:
            self.enable_pin.set_value(gpio.LOW)
	self.enabled = False
コード例 #2
0
 def __init__(
     self,
     input_pin_2u5,
     input_pin_10u,
 ):
     self.input_2u5 = gpio.Gpio(input_pin_2u5)
     self.input_2u5.set_direction(gpio.INPUT)
     self.concentration_2u5_ugpm3 = 0
     self.input_10u = gpio.Gpio(input_pin_10u)
     self.input_10u.set_direction(gpio.INPUT)
     self.concentration_10u_ugpm3 = 0
コード例 #3
0
def main():
    global gpio, client, config, streaming_config
    gpio = Gpio.Gpio()

    # See http://g.co/cloud/speech/docs/languages
    # for a list of supported languages.
    # language_code = 'en-US'  # a BCP-47 language tag
    language_code = 'it-IT'  # a BCP-47 language tag

    client = speech.SpeechClient()
    config = types.RecognitionConfig(
        encoding=enums.RecognitionConfig.AudioEncoding.LINEAR16,
        sample_rate_hertz=RATE,
        language_code=language_code)
    streaming_config = types.StreamingRecognitionConfig(config=config,
                                                        interim_results=True)

    with MicrophoneStream(RATE, CHUNK) as stream:
        audio_generator = stream.generator()
        requests = (types.StreamingRecognizeRequest(audio_content=content)
                    for content in audio_generator)

        responses = client.streaming_recognize(streaming_config, requests)
        print('Ready...')
        gpio.start_speech()

        # Now, put the transcription responses to use.
        listen_print_loop(responses)
コード例 #4
0
def main():

    pin39 = gpio.Gpio("13")

    pin39.direction("out")

    for i in range(1000):
        pin39.value("1")
    pin39.value("0")

    pin39.unexport()
コード例 #5
0
ファイル: analogRead.py プロジェクト: IEEE-SB/PInG
def main():
    pinA0 = gpio.Gpio("A0")
    pinA0.direction("out")
    pinA0.value("0")

    for i in range(10):
        time.sleep(1)
        a = pinA0.get_value()
        print a

    pinA0.unexport()
コード例 #6
0
 def __init__(self, server, nowait=False):
     self.server = server
     self.gpio = gpio.Gpio(config.FRIDGE_GPIO_PIN, "fridge")
     self.integrator = utils.StepIntegrator(
         self.server.now, self.server.params.overshoot_delay)
     self.wort_valid_clock = 0
     self.fridge_valid_clock = 0
     self.fridge_on_clock = 0
     self.off()
     if nowait:
         self.fridge_off_clock = 0
コード例 #7
0
ファイル: blink.py プロジェクト: IEEE-SB/PInG
def main():

    pin39 = gpio.Gpio("13")
    pin39.direction("out")

    while True:
        pin39.value("HIGH")
        time.sleep(1)
        pin39.value("LOW")
        time.sleep(1)

    pin39.unexport()
コード例 #8
0
def main():
    
    pin9 = gpio.Gpio(9)
    
    for i in range(10):
        pin9.value(i*10)
        time.sleep(0.5)
        
    for i in range(10):
        pin9.value(100-i*10)
        time.sleep(0.5)
    
    pin9.unexport()
コード例 #9
0
ファイル: ej89.py プロジェクト: fgr-17/dassopg
import gpio as gp


salida_led = gp.Gpio(0)
salida_led.set_state(True)


print(salida_led.get_state())

コード例 #10
0
ファイル: http.py プロジェクト: IEEE-SB/PInG
def show(pin,value):
	pin = gpio.Gpio(pin)
	pin.direction("out")
	pin.value(value)
	pin.unexport()
コード例 #11
0
ファイル: main.py プロジェクト: rcvlr/audio_sim
OUT_FIFO_LEN = IN_FIFO_LEN
RADIO_FIFO_LEN = 10

# packet + ack + 2*Tifs
PACKET_DURATION = 0.564e-3  # subevent duration
CONNECTION_EVENT = 0.75 * FRAME_INTERVAL
MAX_TX_CONN_EVENT = int(CONNECTION_EVENT / PACKET_DURATION)

underflowCnt = 0
overflowCnt = 0
radioOverflow = 0

vcdFile = open("out.vcd", "w")
vcd = VCDWriter(vcdFile, timescale='1 us')

gpio0 = gpio.Gpio(0, vcd, 'producer', '!')
gpio1 = gpio.Gpio(0, vcd, 'consumer', '$')
gpio2 = gpio.Gpio(0, vcd, 'ble', '#')

# FIFO to hold packet ready to bt tx-ed or retx-ed
fifoRadio = deque([], RADIO_FIFO_LEN)


def printTime():
    """ print current time """

    print(scheduler.Scheduler.clockTime, '-' * 50)


def createPacket(payload):
    """ Create a packet with a given payload """
コード例 #12
0
import time, os, datetime
import json, requests
import notificacao, gpio
import RPi.GPIO as GPIO
from threading import Thread

notificacao = notificacao.Notificacao(0, datetime.datetime.now, 'aguardando')
gpio = gpio.Gpio(0,0,0)
botao = 16
led = 18

def button_callback(channel):
    criaNotificacao()
    time.sleep(3)
    os.system("clear")
    exibirMenu()
    
def abrirPortao():
    GPIO.output(led, 1)
    print("Portão aberto")
    time.sleep(3)
    GPIO.output(led, 0)

def criaNotificacao():
    encontrou = verificaNotificacao()
    if not encontrou:
        jNotificacao = {"status": "tocando"}
        post = requests.post("http://127.0.0.1:5000/notificacao", json=jNotificacao)
        if post.status_code != 201:
            print('POST /notificacao {}'.format(post.status_code))