我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用machine.UART。
def __init__(self,port,max = 9): log.debug ("HitecServoDriver on port %s", port) self.uart = UART(port) # init with given baudrate self.uart.init(19200, 1, bits=8, parity=None, stop=2) # init with inverted lines self.sbuf = bytearray(7) self.rbuf = bytearray(7) self.sbuf[0] = 0x80 self.sbuf[5] = 0 self.sbuf[6] = 0 self.ri = 0 self.V = 0 self.I = 0 self.version = 0 self.id = 0 self.servos = [] self.positions= [] for i in range(max): self.servos.append(None) self.positions.append(0) self.allExit() # switch of power to the motors as soon as possible
def __init__(self): self.uart = UART(1, baudrate=10000, pins=(COMM_PIN, ), timeout_chars=3) self.clk_cal_factor = 1 self.uart.read() # enable the weak pull-ups control self.clearbits(OPTION_REG_ADDR, 1 << 7)
def __init__(self): self.uart = machine.UART(1, 115200)
def __init__(self, debug=True): self.sp = machine.UART(0,57600,timeout=0) esp.uart_nostdio(1) self.board=boards['arduino'] self.debug=debug flush=self.sp.read() self.digital = [Digital(self,i) for i in self.board['digital']] self.analog = [Analog(self,i) for i in self.board['analog']] #Obtain firmata version self.write(REPORT_VERSION) self.iterate()
def __init__(self,port=8999): super().__init__(port=port,name='pymata') esp.uart_nostdio(1) self.gpio2=machine.Pin(2) self.gpio2.init(machine.Pin.OUT) self.sport=machine.UART(0,57600,timeout=0) self.reset()
def __init__(self, uart=None, busy_pin=None, config=True, volume=0.5): self._volume = None if uart is None: self.uart = UART(1, 9600) # UART on self.uart.init(9600, bits=8, parity=None, stop=1) else: self.uart = uart if busy_pin is not None: busy_pin.init(mode=Pin.IN, pull=Pin.PULL_UP) self.busy_pin = busy_pin if config: self.config() if volume is not None: self.volume(volume)