本文整理汇总了Python中wiringpi.digitalRead方法的典型用法代码示例。如果您正苦于以下问题:Python wiringpi.digitalRead方法的具体用法?Python wiringpi.digitalRead怎么用?Python wiringpi.digitalRead使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类wiringpi
的用法示例。
在下文中一共展示了wiringpi.digitalRead方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: fault
# 需要导入模块: import wiringpi [as 别名]
# 或者: from wiringpi import digitalRead [as 别名]
def fault(self):
return wiringpi.digitalRead(self.fault_pin)
示例2: _decode_rotary
# 需要导入模块: import wiringpi [as 别名]
# 或者: from wiringpi import digitalRead [as 别名]
def _decode_rotary(self):
""" Internal class that determines the state of the switches """
# +---------+ +---------+ 0
# | | | |
# A | | | |
# | | | |
# +---------+ +---------+ +----- 1
#
# +---------+ +---------+ 0
# | | | |
# B | | | |
# | | | |
# ----+ +---------+ +---------+ 1
if self.in_critical_section == True or not self._callback_function:
return
self.in_critical_section = True
MSB = wiringpi.digitalRead(self.gpio_pin_a)
LSB = wiringpi.digitalRead(self.gpio_pin_b)
new_state = (MSB << 1) | LSB
sum = (self.prev_state << 2) | new_state
self.prev_state = new_state
self.in_critical_section = False
self.prev_direction = self.direction
if(sum == 0b1101 or sum == 0b0100 or sum == 0b0010 or sum == 0b1011):
self.direction = RotaryEncoder.LEFT
elif (sum == 0b1110 or sum == 0b0111 or sum == 0b0001 or sum == 0b1000):
self.direction = RotaryEncoder.RIGHT
else:
self.direction = RotaryEncoder.UNKNOWN
if time() - self.last_push > self.minimum_delay and self._callback_function:
self.last_push = time()
return self._callback_function(*self._callback_args)
示例3: read_encoder_1
# 需要导入模块: import wiringpi [as 别名]
# 或者: from wiringpi import digitalRead [as 别名]
def read_encoder_1():
global encoder1Pos
global encoder1PinALast
n = wiringpi.digitalRead(A_1_PIN)
if ((encoder1PinALast == LOW) and (n == HIGH)):
if(wiringpi.digitalRead(B_1_PIN) == LOW):
encoder1Pos = encoder1Pos + 1
else:
encoder1Pos = encoder1Pos - 1
encoder1PinALast = n
示例4: read_encoder_2
# 需要导入模块: import wiringpi [as 别名]
# 或者: from wiringpi import digitalRead [as 别名]
def read_encoder_2():
global encoder2Pos
global encoder2PinALast
global key_code
n = wiringpi.digitalRead(A_2_PIN)
if ((encoder2PinALast == LOW) and (n == HIGH)):
if(wiringpi.digitalRead(B_2_PIN) == LOW):
#encoder2Pos = encoder2Pos + 1
key_code = "KEY_UP"
else:
#encoder2Pos = encoder2Pos - 1
key_code = "KEY_DOWN"
#print encoder2Pos
encoder2PinALast = n
示例5: read_button_1
# 需要导入模块: import wiringpi [as 别名]
# 或者: from wiringpi import digitalRead [as 别名]
def read_button_1():
global last_button_1_state
global key_code
n = wiringpi.digitalRead(BTN_1_PIN)
if (n != last_button_1_state):
if (n == LOW):
key_code = "KEY_MENU"
last_button_1_state = n
示例6: read_button_2
# 需要导入模块: import wiringpi [as 别名]
# 或者: from wiringpi import digitalRead [as 别名]
def read_button_2():
global last_button_2_state
global key_code
n = wiringpi.digitalRead(BTN_2_PIN)
if (n != last_button_2_state):
if (n == LOW):
key_code = "KEY_PLAYPAUSE"
last_button_2_state = n
示例7: read_power_button
# 需要导入模块: import wiringpi [as 别名]
# 或者: from wiringpi import digitalRead [as 别名]
def read_power_button():
global Power_State
n = wiringpi.digitalRead(POWER_PIN)
if (n == LOW):
Power_State = "ON"
else:
Power_State = "OFF"
示例8: wait_DRDY
# 需要导入模块: import wiringpi [as 别名]
# 或者: from wiringpi import digitalRead [as 别名]
def wait_DRDY(self):
"""Delays until the configured DRDY input pin is pulled to
active logic low level by the ADS1256 hardware or until the
DRDY_TIMEOUT in seconds has passed.
Arguments: None
Returns: None
The minimum necessary DRDY_TIMEOUT when not using the hardware
pin, can be up to approx. one and a half second, see datasheet..
Manually invoking this function is necessary when using the
automatic calibration feature (ACAL flag). Then, use wait_DRDY()
after every access that changes the PGA gain bits in
ADCON register, the DRATE register or the BUFFEN flag.
"""
start = time.time()
elapsed = time.time() - start
# Waits for DRDY pin to go to active low or DRDY_TIMEOUT seconds to pass
if self.DRDY_PIN is not None:
drdy_level = wp.digitalRead(self.DRDY_PIN)
while (drdy_level == wp.HIGH) and (elapsed < self.DRDY_TIMEOUT):
elapsed = time.time() - start
drdy_level = wp.digitalRead(self.DRDY_PIN)
# Delay in order to avoid busy wait and reduce CPU load.
time.sleep(self.DRDY_DELAY)
if elapsed >= self.DRDY_TIMEOUT:
print("\nWarning: Timeout while polling configured DRDY pin!\n")
else:
time.sleep(self.DRDY_TIMEOUT)