本文整理汇总了Python中GPIO类的典型用法代码示例。如果您正苦于以下问题:Python GPIO类的具体用法?Python GPIO怎么用?Python GPIO使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了GPIO类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Cellular_LED
def Cellular_LED(inSLED):
# This function sets the cellular LED
# Arguments:
# inStatus : GPS LED status. Pass in either 'ON' or 'OFF'
# OFF - LED always OFF
# ON - LED function ON
#
# Returns:
# 0: Pass
# -1: Exception
tmpReturn = -1
try:
#Set Stat LED to default value, 0 for OFF, 2 for ON
if (inSLED == 'ON'):
res = GPIO.setSLED(2, 10, 90)
else:
res = GPIO.setSLED(0, 10, 90)
res = ATC.sendAtCmd('AT#SLEDSAV',ATC.properties.CMD_TERMINATOR,0,20)
if (res == -1): #Errored out, 1 if no error -1 if error
return tmpReturn
tmpReturn = 0
except:
printException("Cellular_LED")
JANUS_SER.sendUART("GPS LED exception. \r\n")
return tmpReturn
示例2: checkCon
def checkCon(pin):
a = SER.send('DEBUG: Now in checkCon...\r\n')
#print '\r\ncheckCon PIN:',pin
res = MDM2.send('AT+CREG?\r',0)
res = MDM2.receive(30)
b = SER.send('DEBUG: following is result from AT+CREG?\r\n')
c = SER.send(res);
if ( (res.find('0,1') > -1) or (res.find('0,5') > -1 ) ):
return 1
ret = ''
ret = setPin(pin)
if ( ret != 1 ):
GPIO.setIOdir(19,1,1)
return -1
timer = MOD.secCounter() + 120
while ( (res.find('0,1') == -1) and (res.find('0,5') == -1 ) ):
res = MDM2.send('AT+CREG?\r',0)
res = MDM2.receive(20)
b = SER.send('DEBUG: following is result from AT+CREG?\r\n')
c = SER.send(res);
if ( MOD.secCounter() > timer ):
return -1
MOD.sleep(50)
MOD.sleep(20)
return 1
示例3: lcd_toggle_enable
def lcd_toggle_enable():
# Toggle enable
time.sleep(E_DELAY)
GPIO.output(LCD_E, True)
time.sleep(E_PULSE)
GPIO.output(LCD_E, False)
time.sleep(E_DELAY)
示例4: stopEngine
def stopEngine(sms):
Helper.writeLog('#Begin: StopEngine function')
Helper.writeLog('-Password in sms is '+sms.password)
if Password == SavedPassword and SavedPassword != 0 :
Helper.writeLog('-In Stop engine Condition')
GPSLat = getGPSLocation('Lat')
Helper.writeLog('-Latitude= '+GPSLat)
GPSLon = getGPSLocation('Lon')
Helper.writeLog('-Longitude= '+GPSLon)
Number = sms.number
GPIO.setIOvalue(8,0)
Helper.writeLog('-Before Sending the SMS')
SMSHandler.sendSMS(Number,'Your car was last seen in this location http://maps.google.com/?q='+GPSLat.rstrip().lstrip()+','+GPSLon.rstrip().lstrip())
Helper.writeLog('-Deleting SMS')
SMSHandler.deleteSMS(MessageIndex,'STP')
else :
Helper.writeLog('Deleting SMS')
SMSHandler.deleteSMS(MessageIndex,'STP 2')
示例5: setSIMSELECT
def setSIMSELECT(state):
"""Установка состояния выхода SIMSELECT
Args:
state: требуемое состояние
"""
GPIO.setIOvalue(5, state)
示例6: setOUT2
def setOUT2(state):
"""Установка состояния реле 2
Args:
state: требуемое состояние
"""
GPIO.setIOvalue(1, state)
示例7: feed
def feed():
b = GPIO.setIOvalue(11, 0)
b = GPIO.setIOvalue(12, 0)
MOD.sleep(10)
b = GPIO.setIOvalue(11, 1)
b = GPIO.setIOvalue(12, 1)
msg = "Reseting External Watchdog"
# Log.appendLog(msg)
return 1
示例8: toggleGPIO
def toggleGPIO(id,z_on,z_off,anz):
ra = ''
while anz > 0:
ra = GPIO.setIOdir(id,1,1)
MOD.sleep(z_on)
ra = GPIO.setIOdir(id,0,1)
MOD.sleep(z_off)
# flash continusly
if ( anz != 99 ):
anz = anz - 1
return ra
示例9: run
def run(self):
pp_last = None
tmp_last = None
hvgv_last = None
vv_last = None
while not self._stop.isSet(): # endless loop to read buttons
if GPIO.input(self.sw_pp_pin) != pp_last:
pp_last = GPIO.input(self.sw_pp_pin)
if pp_last:
self.queue.put("pp_on")
else:
self.queue.put("pp_off")
if GPIO.input(self.sw_tmp_pin) != tmp_last:
tmp_last = GPIO.input(self.sw_tmp_pin)
if tmp_last:
self.queue.put("tmp_on")
else:
self.queue.put("tmp_off")
if GPIO.input(self.sw_hvgv_pin) != hvgv_last:
hvgv_last = GPIO.input(self.sw_hvgv_pin)
if hvgv_last:
self.queue.put("hvgv_on")
else:
self.queue.put("hvgv_off")
if GPIO.input(self.sw_vv_pin) != vv_last:
vv_last = GPIO.input(self.sw_vv_pin)
if vv_last:
self.queue.put("vv_on")
else:
self.queue.put("vv_off")
time.sleep(0.05) # small delay to prevent excessive CPU usage
示例10: read_50PIN
def read_50PIN():
# This function receives data via External 50 pin Header Serial Port
try:
GPIO.setIOvalue(20, 0) #Set MUX SELECT, GPIO 20 value is Set to '0'
res = SER.receive(10)
except:
print 'Script encountered an exception.'
print 'Exception Type: ' + str(sys.exc_type)
print 'MODULE -> GSM864QP_SER'
print 'METHOD -> read_50PIN()'
return(res)
示例11: send_DB9
def send_DB9(inSTR):
# This function sends data via External DB9 Serial Port
try:
GPIO.setIOvalue(20, 1) #Set MUX SELECT, GPIO 20 value is Set to '1'
res = SER.send(str(inSTR))
except:
print 'Script encountered an exception.'
print 'Exception Type: ' + str(sys.exc_type)
print 'MODULE -> GSM864QP_SER'
print 'METHOD -> send_DB9()'
return(res)
示例12: getADC
def getADC():
"""Чтение значения АЦП
Returns:
Значение АЦП
"""
mV = GPIO.getADC(1)
return mV
示例13: getSK2
def getSK2():
"""Чтение состояния сухого контакта 2
Returns:
Состояние
"""
state = GPIO.getIOvalue(3)
return state
示例14: getOUT1
def getOUT1():
"""Чтение состояния реле 1
Returns:
Состояние
"""
state = GPIO.getIOvalue(6)
return state
示例15: getOUT2
def getOUT2():
"""Чтение состояния реле 2
Returns:
Состояние
"""
state = GPIO.getIOvalue(1)
return state