Пример #1
0
from time import sleep
from pyA20Lime2.gpio import gpio
from pyA20Lime2.gpio import port

__author__ = "Stefan Mavrodiev"
__copyright__ = "Copyright 2014, Olimex LTD"
__credits__ = ["Stefan Mavrodiev"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = __author__
__email__ = "*****@*****.**"

led = port.PH2

gpio.init()
gpio.setcfg(led, gpio.OUTPUT)

try:
    print("Press CTRL+C to exit")
    while True:
        gpio.output(led, 1)
        sleep(0.1)
        gpio.output(led, 0)
        sleep(0.1)

        gpio.output(led, 1)
        sleep(0.1)
        gpio.output(led, 0)
        sleep(0.1)

        sleep(0.6)
Пример #2
0
__author__ = "Stefan Mavrodiev"
__copyright__ = "Copyright 2014, Olimex LTD"
__credits__ = ["Stefan Mavrodiev"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = __author__
__email__ = "*****@*****.**"

led = connector.gpio0p0     # This is the same as port.PH2
button = connector.gpio3p40

"""Init gpio module"""
gpio.init()

"""Set directions"""
gpio.setcfg(led, gpio.OUTPUT)
gpio.setcfg(button, gpio.INPUT)

"""Enable pullup resistor"""
gpio.pullup(button, gpio.PULLUP)
#gpio.pullup(button, gpio.PULLDOWN)     # Optionally you can use pull-down resistor

try:
    print ("Press CTRL+C to exit")
    while True:
        state = gpio.input(button)      # Read button state

        """Since we use pull-up the logic will be inverted"""
        gpio.output(led, not state)

except KeyboardInterrupt:
Пример #3
0
if not os.getegid() == 0:
    sys.exit('Script must be run as root')


####
# configuration
##
enc0A = connector.gpio1p5
enc0B = connector.gpio1p7
enc0  = "/enc0"
####
# initialisation
##
gpio.init()

gpio.setcfg(enc0A, gpio.INPUT)
gpio.setcfg(enc0B, gpio.INPUT)

gpio.pullup(enc0A, gpio.PULLUP)
gpio.pullup(enc0B, gpio.PULLUP)

#def read_config (path) :



def osc_send (value,channel) :
    msg = osc_message_builder.OscMessageBuilder(address = channel)
    msg.add_arg(value, "i")
    msg = msg.build()
    client.send(msg)
Пример #4
0
from pyA20Lime2.gpio import gpio
from pyA20Lime2.gpio import port

__author__ = "Stefan Mavrodiev"
__copyright__ = "Copyright 2014, Olimex LTD"
__credits__ = ["Stefan Mavrodiev"]
__license__ = "GPL"
__version__ = "2.0"
__maintainer__ = __author__
__email__ = "*****@*****.**"


led = port.PH2

gpio.init()
gpio.setcfg(led, gpio.OUTPUT)

try:
    print ("Press CTRL+C to exit")
    while True:
        gpio.output(led, 1)
        sleep(0.1)
        gpio.output(led, 0)
        sleep(0.1)

        gpio.output(led, 1)
        sleep(0.1)
        gpio.output(led, 0)
        sleep(0.1)

        sleep(0.6)
Пример #5
0
if not os.getegid() == 0:
    sys.exit('Script must be run as root')

####
# configuration
##
enc0A = connector.gpio1p5
enc0B = connector.gpio1p7
enc0 = "/enc0"
####
# initialisation
##
gpio.init()

gpio.setcfg(enc0A, gpio.INPUT)
gpio.setcfg(enc0B, gpio.INPUT)

gpio.pullup(enc0A, gpio.PULLUP)
gpio.pullup(enc0B, gpio.PULLUP)

#def read_config (path) :


def osc_send(value, channel):
    msg = osc_message_builder.OscMessageBuilder(address=channel)
    msg.add_arg(value, "i")
    msg = msg.build()
    client.send(msg)