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


Python pyb.ADC属性代码示例

本文整理汇总了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. 
开发者ID:peterhinch,项目名称:micropython-fourier,代码行数:19,代码来源:dftclass.py

示例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() 
开发者ID:dhylands,项目名称:upy-examples,代码行数:23,代码来源:af_test.py

示例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() 
开发者ID:dhylands,项目名称:upy-examples,代码行数:23,代码来源:pin_dump.py

示例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 
开发者ID:peterhinch,项目名称:micropython-fourier,代码行数:14,代码来源:dftclass.py

示例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']) 
开发者ID:peterhinch,项目名称:micropython-epaper,代码行数:37,代码来源:epdpart.py

示例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 
开发者ID:peterhinch,项目名称:micropython-epaper,代码行数:30,代码来源:epd.py


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