Python machine 模块,UART 实例源码

我们从Python开源项目中,提取了以下6个代码示例,用于说明如何使用machine.UART

项目:esp32    作者:smeenka    | 项目源码 | 文件源码
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
项目:pycom-libraries    作者:pycom    | 项目源码 | 文件源码
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)
项目:pyCom    作者:dinosd    | 项目源码 | 文件源码
def __init__(self):
        self.uart = machine.UART(1, 115200)
项目:esp    作者:mhoffma    | 项目源码 | 文件源码
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()
项目:esp    作者:mhoffma    | 项目源码 | 文件源码
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()
项目:cockle    作者:ShrimpingIt    | 项目源码 | 文件源码
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)