本文整理匯總了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