本文整理汇总了Python中pyb.ADC属性的典型用法代码示例。如果您正苦于以下问题:Python pyb.ADC属性的具体用法?Python pyb.ADC怎么用?Python pyb.ADC使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类pyb
的用法示例。
在下文中一共展示了pyb.ADC属性的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run
# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import ADC [as 别名]
def run(self, conversion): # Uses assembler for speed
if self.popfunc is not None:
self.popfunc(self) # Populate the data (for fwd transfers, just the real data)
if conversion != REVERSE: # Forward transform: real data assumed
setarray(self.im, 0, self._length)# Fast zero imaginary data
if self.windata is not None: # Fast apply the window function
winapply(self.re, self.windata, self._length)
start = utime.ticks_us()
fft(self.ctrl, conversion)
delta = utime.ticks_diff(utime.ticks_us(), start)
if (conversion & POLAR) == POLAR: # Ignore complex conjugates, convert 1st half of arrays
topolar(self.re, self.im, self._length//2) # Fast
if conversion == DB: # Ignore conjugates: convert 1st half only
for idx, val in enumerate(self.re[0:self._length//2]):
self.re[idx] = -80.0 if val <= 0.0 else 20*math.log10(val) - self.dboffset
return delta
# Subclass for acquiring data from Pyboard ADC using read_timed() method.
示例2: pins_test
# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import ADC [as 别名]
def pins_test():
i2c = I2C(1, I2C.MASTER)
spi = SPI(2, SPI.MASTER)
uart = UART(3, 9600)
servo = Servo(1)
adc = ADC(Pin.board.X3)
dac = DAC(1)
pin = Pin('X4', mode=Pin.AF_PP, af=Pin.AF3_TIM9)
pin = Pin('Y1', mode=Pin.AF_OD, af=3)
pin = Pin('Y2', mode=Pin.OUT_PP)
pin = Pin('Y3', mode=Pin.OUT_OD, pull=Pin.PULL_UP)
pin.high()
pin = Pin('Y4', mode=Pin.OUT_OD, pull=Pin.PULL_DOWN)
pin.high()
pin = Pin('X18', mode=Pin.IN, pull=Pin.PULL_NONE)
pin = Pin('X19', mode=Pin.IN, pull=Pin.PULL_UP)
pin = Pin('X20', mode=Pin.IN, pull=Pin.PULL_DOWN)
print('===== output of pins() =====')
pins.pins()
print('===== output of af() =====')
pins.af()
示例3: pins_test
# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import ADC [as 别名]
def pins_test():
i2c = I2C(1, I2C.MASTER)
spi = SPI(2, SPI.MASTER)
uart = UART(3, 9600)
servo = Servo(1)
adc = ADC(Pin.board.X3)
dac = DAC(1)
pin = Pin('X4', mode=Pin.AF_PP, af=Pin.AF3_TIM9)
pin = Pin('Y1', mode=Pin.AF_OD, af=3)
pin = Pin('Y2', mode=Pin.OUT_PP)
pin = Pin('Y3', mode=Pin.OUT_OD, pull=Pin.PULL_UP)
pin.high()
pin = Pin('Y4', mode=Pin.OUT_OD, pull=Pin.PULL_DOWN)
pin.high()
pin = Pin('X18', mode=Pin.IN, pull=Pin.PULL_NONE)
pin = Pin('X19', mode=Pin.IN, pull=Pin.PULL_UP)
pin = Pin('X20', mode=Pin.IN, pull=Pin.PULL_DOWN)
print('===== output of pins() =====')
pins()
print('===== output of af() =====')
af()
示例4: __init__
# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import ADC [as 别名]
def __init__(self, length, adcpin, winfunc=None, timer=6):
super().__init__(length, winfunc = winfunc)
self.buff = array.array('i', (0 for x in range(self._length)))
if isinstance(adcpin, pyb.ADC):
self.adc = adcpin
else:
self.adc = pyb.ADC(adcpin)
if isinstance(timer, pyb.Timer):
self.timer = timer
else:
self.timer = pyb.Timer(timer)
self.dboffset = PYBOARD_DBOFFSET # Value for Pyboard ADC
示例5: __init__
# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import ADC [as 别名]
def __init__(self, intside, model, up_time):
self.model = model
self.compensate_temp = True if up_time is None else False
self.verbose = False
gc.collect()
self.image_0 = bytearray(BUFFER_SIZE) # 5808. Contents 0.
self.image_1 = bytearray(BUFFER_SIZE) # 5808
self.asm_data = array('i', [0, 0, 0, 0])
self.image = self.image_0
self.image_old = self.image_1
self.line_buffer = bytearray(111) # total 11727 bytes!
pins = getpins(intside, model)
self.Pin_PANEL_ON = pyb.Pin(pins['PANEL_ON'], mode = pyb.Pin.OUT_PP)
self.Pin_BORDER = pyb.Pin(pins['BORDER'], mode = pyb.Pin.OUT_PP)
self.Pin_DISCHARGE = pyb.Pin(pins['DISCHARGE'], mode = pyb.Pin.OUT_PP)
self.Pin_RESET = pyb.Pin(pins['RESET'], mode = pyb.Pin.OUT_PP)
self.Pin_BUSY = pyb.Pin(pins['BUSY'], mode = pyb.Pin.IN)
self.Pin_EPD_CS = pyb.Pin(pins['EPD_CS'], mode = pyb.Pin.OUT_PP) # cs for e-paper display
self.Pin_FLASH_CS = pyb.Pin(pins['FLASH_CS'], mode = pyb.Pin.OUT_PP) # Instantiate flash CS and set high
self.Pin_MOSI = pyb.Pin(pins['MOSI'], mode = pyb.Pin.OUT_PP)
self.Pin_SCK = pyb.Pin(pins['SCK'], mode = pyb.Pin.OUT_PP)
self.base_stage_time = 630 if up_time is None else up_time # ms
self.factored_stage_time = self.base_stage_time
self.Pin_RESET.low()
self.Pin_PANEL_ON.low()
self.Pin_DISCHARGE.low()
self.Pin_BORDER.low()
self.Pin_EPD_CS.low()
self.Pin_FLASH_CS.high()
self.spi_no = pins['SPI_BUS']
if model == EMBEDDED_ARTISTS:
self.lm75 = LM75(pins['I2C_BUS']) # early error if not working
else:
self.adc = pyb.ADC(pins['TEMPERATURE'])
示例6: __init__
# 需要导入模块: import pyb [as 别名]
# 或者: from pyb import ADC [as 别名]
def __init__(self, intside, model):
self.model = model
gc.collect()
self.image = bytearray(BYTES_PER_LINE * LINES_PER_DISPLAY)
self.linebuf = bytearray(BYTES_PER_LINE * 2 + BYTES_PER_SCAN)
pins = getpins(intside, model)
self.Pin_PANEL_ON = pyb.Pin(pins['PANEL_ON'], mode = pyb.Pin.OUT_PP)
self.Pin_BORDER = pyb.Pin(pins['BORDER'], mode = pyb.Pin.OUT_PP)
self.Pin_DISCHARGE = pyb.Pin(pins['DISCHARGE'], mode = pyb.Pin.OUT_PP)
self.Pin_RESET = pyb.Pin(pins['RESET'], mode = pyb.Pin.OUT_PP)
self.Pin_BUSY = pyb.Pin(pins['BUSY'], mode = pyb.Pin.IN)
self.Pin_EPD_CS = pyb.Pin(pins['EPD_CS'], mode = pyb.Pin.OUT_PP) # cs for e-paper display
self.Pin_FLASH_CS = pyb.Pin(pins['FLASH_CS'], mode = pyb.Pin.OUT_PP) # Instantiate flash CS and set high
self.Pin_MOSI = pyb.Pin(pins['MOSI'], mode = pyb.Pin.OUT_PP)
self.Pin_SCK = pyb.Pin(pins['SCK'], mode = pyb.Pin.OUT_PP)
self.Pin_RESET.low()
self.Pin_PANEL_ON.low()
self.Pin_DISCHARGE.low()
self.Pin_BORDER.low()
self.Pin_EPD_CS.low()
self.Pin_FLASH_CS.high()
self.spi_no = pins['SPI_BUS']
if model == EMBEDDED_ARTISTS:
self.lm75 = LM75(pins['I2C_BUS']) # early error if not working
else:
self.adc = pyb.ADC(pins['TEMPERATURE'])
# USER INTERFACE