class ADCWiPy – analog to digital conversion 类ADCWiPy – 拟到数字的转换 =============================================

注意

This class is a non-standard ADC implementation for the WiPy. It is available simply as machine.ADC on the WiPy but is named in the documentation below as machine.ADCWiPy to distinguish it from the more general machine.ADC class. 这个类是WiPy的非标准ADC实现。 它可以简单地称为’ ‘ machine。“ADC”在WiPy上却被命名为 下面的文档为’ ‘ machine。把它和…区分开来 更普遍的:裁判:“机器。ADC <机器。ADC >”类。

Usage:: 用法:

import machine
进口机器

adc = machine.ADC()             # create an ADC object
adc = machine.ADC()             # 创建一个ADC对象
apin = adc.channel(pin='GP3')   # create an analog pin on GP3
apin = adc.channel(pin='GP3')   # 在GP3上创建一个模拟引脚
val = apin()                    # read an analog value
val = apin()                    # 读取模拟值

Constructors 构造函数 ————

class machine.ADCWiPy(id=0, \*, bits=12)

Methods 方法 ——-

ADCWiPy.channel(id, \*, pin)

Create an analog pin. If only channel ID is given, the correct pin will be selected. Alternatively, only the pin can be passed and the correct channel will be selected. Examples:: 创建模拟引脚。如果只有通道ID是给定的,正确的pin将 被选中。或者,只有大头针可以通过和正确的 频道将被选择。例子:

# all of these are equivalent and enable ADC channel 1 on GP3
# 所有这些都是等效的,并在GP3上启用ADC通道1
apin = adc.channel(1)
apin = adc.channel(pin='GP3')
apin = adc.channel(id=1, pin='GP3')
ADCWiPy.init()

Enable the ADC block. 启用ADC块。

ADCWiPy.deinit()

Disable the ADC block. 禁用ADC块。

class ADCChannel — read analog values from internal or external sources 类ADCChannel — 从内部或外部源读取模拟值 =========================================================================

ADC channels can be connected to internal points of the MCU or to GPIO pins. ADC channels are created using the ADC.channel method. ADC通道可以连接到MCU的内部点或GPIO引脚上。 ADC通道是使用ADC创建的。通道的方法。

machine.adcchannel()

Fast method to read the channel value. 快速读取通道值的方法。

adcchannel.value()

Read the channel value. 读取通道值。

adcchannel.init()

Re-init (and effectively enable) the ADC channel. 重新init(并有效地启用)ADC通道。

adcchannel.deinit()

Disable the ADC channel. 禁用ADC通道。