Python pyb.ADC Examples
The following are 6
code examples of pyb.ADC().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
pyb
, or try the search function
.
Example #1
Source File: dftclass.py From micropython-fourier with MIT License | 6 votes |
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.
Example #2
Source File: af_test.py From upy-examples with MIT License | 6 votes |
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()
Example #3
Source File: pin_dump.py From upy-examples with MIT License | 6 votes |
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()
Example #4
Source File: dftclass.py From micropython-fourier with MIT License | 5 votes |
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
Example #5
Source File: epdpart.py From micropython-epaper with Apache License 2.0 | 5 votes |
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'])
Example #6
Source File: epd.py From micropython-epaper with Apache License 2.0 | 5 votes |
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