Exemplo n.º 1
0
    def __init__(self):
        # set all pins to -1 (nothing selected), this is just information no real action on pins will be performed
        self.declaredPins = []
        for a in range(32):
            self.declaredPins.append(-1)

        self.pwmPrecision = 255
        numberOfTries = 1000
        cnt = 0
        closed = True
        # This array will keep interrupt object on corresponding pin number
        self.interrupts = []
        for i in range(32):
            self.interrupts.append(None)

        while closed:
            try:
                self.u = IoBoard()
                print "opened port"
                closed = False
                weioRunnerGlobals.WEIO_SERIAL_LINKED = True
            except IoTPy_APIError, e:  # seems can't establish connection with the UPER board
                #details = e.args[0]
                closed = True
                weioRunnerGlobals.WEIO_SERIAL_LINKED = False
                cnt = cnt + 1
                if (cnt > numberOfTries):
                    closed = False
                    print "uper not present"
Exemplo n.º 2
0
 def __init__(self):
     self.declaredPins = []
     self.pwmPrecision = 255
     numberOfTries = 1000
     cnt = 0
     closed = True
     while closed:
         try:
             self.u = IoBoard()
             print "opened port"
             closed = False
             weioRunnerGlobals.WEIO_SERIAL_LINKED = True
         except IoTPy_APIError, e:  # seems can't establish connection with the UPER board
             #details = e.args[0]
             closed = True
             weioRunnerGlobals.WEIO_SERIAL_LINKED = False
             cnt = cnt + 1
             if (cnt > numberOfTries):
                 closed = False
                 print "uper not present"
Exemplo n.º 3
0
Arquivo: adc.py Projeto: seipekm/weio
#
# Authors :
# Uros PETREVSKI <*****@*****.**>
# Drasko DRASKOVIC <*****@*****.**>
#
###
"""
Simple ADC value reading example with IoTPy.
"""
from time import sleep
from IoTPy.pyuper.ioboard import IoBoard
from IoTPy.pyuper.adc import ADC
from IoTPy.pyuper.utils import IoTPy_APIError, die

try:
    u = IoBoard()
except IoTPy_APIError, e:  # seems can't establish connection with the board
    details = e.args[0]
    die(details)

try:  # let's try to attach ADC object to non ADC pin
    a = u.get_pin(ADC, 27)
except IoTPy_APIError, e:  # got an exception, pin capabilities must be different from requested
    details = e.args[0]
    print details

with u.get_pin(ADC, 24) as adc_pin:
    for i in range(10):
        val = adc_pin.read()
        print "RAW ADC value:", val,
        voltage = 5.0 / 1024 * val