当前位置: 首页>>代码示例>>Python>>正文


Python wiringpi.digitalRead方法代码示例

本文整理汇总了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) 
开发者ID:pypilot,项目名称:pypilot,代码行数:4,代码来源:servo.py

示例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) 
开发者ID:foxey,项目名称:volumio-buddy,代码行数:36,代码来源:volumio_buddy.py

示例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 
开发者ID:thk4711,项目名称:orangepi-radio,代码行数:12,代码来源:input_rot_only.py

示例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 
开发者ID:thk4711,项目名称:orangepi-radio,代码行数:16,代码来源:input_rot_only.py

示例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 
开发者ID:thk4711,项目名称:orangepi-radio,代码行数:10,代码来源:input_rot_only.py

示例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 
开发者ID:thk4711,项目名称:orangepi-radio,代码行数:10,代码来源:input_rot_only.py

示例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" 
开发者ID:thk4711,项目名称:orangepi-radio,代码行数:9,代码来源:input_rot_only.py

示例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) 
开发者ID:ul-gh,项目名称:PiPyADC,代码行数:32,代码来源:pipyadc.py


注:本文中的wiringpi.digitalRead方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。