python reader agri satpy_Python pyb.UART属性代码示例

本文整理汇总了Python中pyb.UART属性的典型用法代码示例。如果您正苦于以下问题:Python pyb.UART属性的具体用法?Python pyb.UART怎么用?Python pyb.UART使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在模块pyb的用法示例。

在下文中一共展示了pyb.UART属性的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: __init__

​点赞 7

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def __init__(self, path, trigger=None, uart="YA", baudrate=9600):

super().__init__(path)

self.button = "Scan QR code"

if simulator:

self.EOL = b"\r\n"

else:

self.EOL = b"\r"

self.data = b""

self.uart_bus = uart

self.uart = pyb.UART(uart, baudrate, read_buf_len=2048)

self.trigger = None

self.is_configured = False

if trigger is not None or simulator:

self.trigger = pyb.Pin(trigger, pyb.Pin.OUT)

self.trigger.on()

self.is_configured = True

self.scanning = False

开发者ID:cryptoadvance,项目名称:specter-diy,代码行数:21,代码来源:qr.py

示例2: init

​点赞 6

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def init(self):

if self.is_configured:

return

# if failed to configure - probably a different scanner

# in this case fallback to PIN trigger mode FIXME

self.clean_uart()

self.is_configured = self.configure()

if self.is_configured:

print("Scanner: automatic mode")

return

# Try one more time with different baudrate

self.uart = pyb.UART(self.uart_bus, 115200, read_buf_len=2048)

self.clean_uart()

self.is_configured = self.configure()

if self.is_configured:

print("Scanner: automatic mode")

return

# PIN trigger mode

self.uart = pyb.UART(self.uart_bus, 9600, read_buf_len=2048)

self.trigger = pyb.Pin(QRSCANNER_TRIGGER, pyb.Pin.OUT)

self.trigger.on()

self.is_configured = True

print("Scanner: Pin trigger mode")

开发者ID:cryptoadvance,项目名称:specter-diy,代码行数:27,代码来源:qr.py

示例3: log_kml

​点赞 6

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def log_kml(fn='/sd/log.kml', interval=10):

yellow.on() # Waiting for data

uart = pyb.UART(4, 9600, read_buf_len=200) # Data on X2

sreader = asyncio.StreamReader(uart)

gps = AS_GPS(sreader, fix_cb=toggle_led)

await gps.data_received(True, True, True, True)

yellow.off()

with open(fn, 'w') as f:

f.write(str_start)

while not sw.value():

f.write(gps.longitude_string(KML))

f.write(',')

f.write(gps.latitude_string(KML))

f.write(',')

f.write(str(gps.altitude))

f.write('\r\n')

for _ in range(interval * 10):

await asyncio.sleep_ms(100)

if sw.value():

break

f.write(str_end)

red.off()

green.on()

开发者ID:peterhinch,项目名称:micropython-async,代码行数:26,

示例4: shutdown

​点赞 6

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def shutdown():

global gps

# Normally UART is already at BAUDRATE. But if last session didn't restore

# factory baudrate we can restore connectivity in the subsequent stuck

# session with ctrl-c.

uart.init(BAUDRATE)

await asyncio.sleep(0.5)

await gps.command(FULL_COLD_START)

print('Factory reset')

gps.close() # Stop ISR

#print('Restoring default baudrate (9600).')

#await gps.baudrate(9600)

#uart.init(9600)

#gps.close() # Stop ISR

#print('Restoring default 1s update rate.')

#await asyncio.sleep(0.5)

#await gps.update_interval(1000) # 1s update rate

#print('Restoring satellite data.')

#await gps.command(as_rwGPS.DEFAULT_SENTENCES) # Restore satellite data

# Setup for tests. Red LED toggles on fix, blue on PPS interrupt.

开发者ID:peterhinch,项目名称:micropython-async,代码行数:23,

示例5: gps_test

​点赞 6

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def gps_test():

global gps, uart # For shutdown

print('Initialising')

# Adapt UART instantiation for other MicroPython hardware

uart = pyb.UART(4, 9600, read_buf_len=200)

# read_buf_len is precautionary: code runs reliably without it.

sreader = asyncio.StreamReader(uart)

swriter = asyncio.StreamWriter(uart, {})

timer = Delay_ms(cb_timeout)

sentence_count = 0

gps = GPS(sreader, swriter, local_offset=1, fix_cb=callback,

fix_cb_args=(timer,), msg_cb = message_cb)

await asyncio.sleep(2)

await gps.command(DEFAULT_SENTENCES)

print('Set sentence frequencies to default')

#await gps.command(FULL_COLD_START)

#print('Performed FULL_COLD_START')

print('awaiting first fix')

asyncio.create_task(sat_test(gps))

asyncio.create_task(stats(gps))

asyncio.create_task(navigation(gps))

asyncio.create_task(course(gps))

asyncio.create_task(date(gps))

await gps.data_received(True, True, True, True) # all messages

await change_status(gps, uart)

开发者ID:peterhinch,项目名称:micropython-async,代码行数:27,

示例6: log_kml

​点赞 6

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def log_kml(fn='/sd/log.kml', interval=10):

yellow.on() # Waiting for data

uart = pyb.UART(4, 9600, read_buf_len=200) # Data on X2

sreader = asyncio.StreamReader(uart)

gps = as_GPS.AS_GPS(sreader, fix_cb=toggle_led)

await gps.data_received(True, True, True, True)

yellow.off()

with open(fn, 'w') as f:

f.write(str_start)

while not sw.value():

f.write(gps.longitude_string(as_GPS.KML))

f.write(',')

f.write(gps.latitude_string(as_GPS.KML))

f.write(',')

f.write(str(gps.altitude))

f.write('\r\n')

for _ in range(interval * 10):

await asyncio.sleep_ms(100)

if sw.value():

break

f.write(str_end)

red.off()

green.on()

开发者ID:peterhinch,项目名称:micropython-async,代码行数:26,

示例7: shutdown

​点赞 6

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def shutdown():

global gps

# Normally UART is already at BAUDRATE. But if last session didn't restore

# factory baudrate we can restore connectivity in the subsequent stuck

# session with ctrl-c.

uart.init(BAUDRATE)

await asyncio.sleep(0.5)

await gps.command(as_rwGPS.FULL_COLD_START)

print('Factory reset')

gps.close() # Stop ISR

#print('Restoring default baudrate (9600).')

#await gps.baudrate(9600)

#uart.init(9600)

#gps.close() # Stop ISR

#print('Restoring default 1s update rate.')

#await asyncio.sleep(0.5)

#await gps.update_interval(1000) # 1s update rate

#print('Restoring satellite data.')

#await gps.command(as_rwGPS.DEFAULT_SENTENCES) # Restore satellite data

# Setup for tests. Red LED toggles on fix, blue on PPS interrupt.

开发者ID:peterhinch,项目名称:micropython-async,代码行数:23,

示例8: pins_test

​点赞 6

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [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,

示例9: main

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def main():

serial = pyb.UART(2, BAUDRATE)

lcd = STM_LCDShield()

monitor = MidiMonitor(lcd)

midiin = MidiIn(serial, monitor, debug=True)

lcd.write("MIDI Mon ")

pyb.delay(1000)

lcd.write("ready")

pyb.delay(1000)

lcd.write(" ", col=9)

while True:

midiin.poll()

pyb.delay(POLL_INTERVAL)

开发者ID:SpotlightKid,项目名称:micropython-stm-lib,代码行数:16,

示例10: main

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def main():

switch = Switch()

while not switch():

delay(200)

# Initialize UART for MIDI

uart = UART(2, baudrate=31250)

midi = MidiOut(uart)

seq = Sequencer(midi, bpm=124)

seq.play(Pattern(PATTERN), kit=9)

开发者ID:SpotlightKid,项目名称:micropython-stm-lib,代码行数:13,

示例11: main

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def main():

# Initialize UART for MIDI

uart = UART(2, baudrate=31250)

midi = MidiOut(uart)

button1 = Switch()

button2 = Pin('PC0', Pin.IN, Pin.PULL_UP)

button3 = Pin('PC1', Pin.IN, Pin.PULL_UP)

led1 = LED(1)

led2 = LED(2)

led3 = LED(3)

tune = program = 0

# send a PROGRAM CHANGE to set instrument to #0 (Grand Piano)

midi.program_change(program)

while True:

if button1():

# When button 1 is pressed, play the current tune

play(midi, TUNES[TUNENAMES[tune]], led1)

led1.off()

if not button2():

# When button 2 is pressed, select the next of the tunes

led2.on()

tune = (tune+1) % len(TUNENAMES)

delay(BLINK_DELAY)

led2.off()

if not button3():

# When button 3 is pressed, change to next program (instrument)

led3.on()

program = (program+1) % len(PROGRAMS)

midi.program_change(PROGRAMS[program])

delay(BLINK_DELAY)

led3.off()

delay(200)

开发者ID:SpotlightKid,项目名称:micropython-stm-lib,代码行数:37,

示例12: __init__

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def __init__(self, uart_no = 4):

self.uart = UART(uart_no, 9600)

self.loop = asyncio.get_event_loop()

self.swriter = asyncio.StreamWriter(self.uart, {})

self.sreader = asyncio.StreamReader(self.uart)

loop = asyncio.get_event_loop()

loop.create_task(self._run())

开发者ID:peterhinch,项目名称:micropython-samples,代码行数:9,

示例13: __init__

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def __init__(self,uartno): # pos =1 or 2 depending on skin position

self._uart = pyb.UART(uartno, 9600, read_buf_len=2048)

self.incoming_action = None

self.no_carrier_action = None

self.clip_action = None

self._clip = None

self.msg_action = None

self._msgid = 0

self.savbuf = None

self.credit = ''

self.credit_action = None

开发者ID:jeffmer,项目名称:micropython-upyphone,代码行数:13,

示例14: test

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def test(duration):

if use_utime: # Not running in low power mode

pyb.LED(3).on()

uart2 = pyb.UART(1, 115200)

uart4 = pyb.UART(4, 9600)

# Instantiate event loop before using it in Latency class

loop = asyncio.get_event_loop()

lp = Latency(50) # ms

loop.create_task(sender(uart4))

loop.create_task(receiver(uart4, uart2))

loop.run_until_complete(killer(duration))

开发者ID:peterhinch,项目名称:micropython-async,代码行数:13,

示例15: setup

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def setup():

red = pyb.LED(1)

green = pyb.LED(2)

uart = pyb.UART(UART_ID, 9600, read_buf_len=200)

sreader = asyncio.StreamReader(uart)

pps_pin = pyb.Pin(PPS_PIN, pyb.Pin.IN)

return GPS_Timer(sreader, pps_pin, local_offset=1,

fix_cb=lambda *_: red.toggle(),

pps_cb=lambda *_: green.toggle())

# Test terminator: task sets the passed event after the passed time.

开发者ID:peterhinch,项目名称:micropython-async,代码行数:13,

示例16: us_setup

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def us_setup(tick):

red = pyb.LED(1)

yellow = pyb.LED(3)

uart = pyb.UART(UART_ID, 9600, read_buf_len=200)

sreader = asyncio.StreamReader(uart)

pps_pin = pyb.Pin(PPS_PIN, pyb.Pin.IN)

return GPS_Timer(sreader, pps_pin, local_offset=1,

fix_cb=lambda *_: red.toggle(),

pps_cb=us_cb, pps_cb_args=(tick, yellow))

开发者ID:peterhinch,项目名称:micropython-async,代码行数:11,

示例17: setup

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def setup():

print('Initialising')

uart = pyb.UART(4, 9600)

sreader = asyncio.StreamReader(uart)

swriter = asyncio.StreamWriter(uart, {})

gps = as_rwGPS.GPS(sreader, swriter, local_offset=1)

await asyncio.sleep(2)

await gps.baudrate(BAUDRATE)

uart.init(BAUDRATE)

开发者ID:peterhinch,项目名称:micropython-async,代码行数:11,

示例18: gps_test

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def gps_test():

print('Initialising')

# Adapt for other MicroPython hardware

uart = pyb.UART(4, 9600, read_buf_len=200)

# read_buf_len is precautionary: code runs reliably without it.)

sreader = asyncio.StreamReader(uart)

timer = Delay_ms(timeout)

sentence_count = 0

gps = AS_GPS(sreader, local_offset=1, fix_cb=callback, fix_cb_args=(timer,))

print('awaiting first fix')

asyncio.create_task(sat_test(gps))

asyncio.create_task(stats(gps))

asyncio.create_task(navigation(gps))

asyncio.create_task(course(gps))

await date(gps)

开发者ID:peterhinch,项目名称:micropython-async,代码行数:17,

示例19: shutdown

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def shutdown():

# Normally UART is already at BAUDRATE. But if last session didn't restore

# factory baudrate we can restore connectivity in the subsequent stuck

# session with ctrl-c.

uart.init(BAUDRATE)

await asyncio.sleep(1)

await gps.command(FULL_COLD_START)

print('Factory reset')

#print('Restoring default baudrate.')

#await gps.baudrate(9600)

开发者ID:peterhinch,项目名称:micropython-async,代码行数:12,

示例20: __init__

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def __init__(self, uart_no = 4):

self.uart = UART(uart_no, 9600)

self.swriter = asyncio.StreamWriter(self.uart, {})

self.sreader = asyncio.StreamReader(self.uart)

asyncio.create_task(self._run())

开发者ID:peterhinch,项目名称:micropython-async,代码行数:7,

示例21: setup

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def setup():

red = pyb.LED(1)

blue = pyb.LED(4)

uart = pyb.UART(UART_ID, 9600, read_buf_len=200)

sreader = asyncio.StreamReader(uart)

pps_pin = pyb.Pin(PPS_PIN, pyb.Pin.IN)

return as_tGPS.GPS_Timer(sreader, pps_pin, local_offset=1,

fix_cb=lambda *_: red.toggle(),

pps_cb=lambda *_: blue.toggle())

# Test terminator: task sets the passed event after the passed time.

开发者ID:peterhinch,项目名称:micropython-async,代码行数:13,

示例22: us_setup

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def us_setup(tick):

red = pyb.LED(1)

blue = pyb.LED(4)

uart = pyb.UART(UART_ID, 9600, read_buf_len=200)

sreader = asyncio.StreamReader(uart)

pps_pin = pyb.Pin(PPS_PIN, pyb.Pin.IN)

return as_tGPS.GPS_Timer(sreader, pps_pin, local_offset=1,

fix_cb=lambda *_: red.toggle(),

pps_cb=us_cb, pps_cb_args=(tick, blue))

开发者ID:peterhinch,项目名称:micropython-async,代码行数:11,

示例23: gps_test

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def gps_test():

global gps, uart # For shutdown

print('Initialising')

# Adapt UART instantiation for other MicroPython hardware

uart = pyb.UART(4, 9600, read_buf_len=200)

# read_buf_len is precautionary: code runs reliably without it.

sreader = asyncio.StreamReader(uart)

swriter = asyncio.StreamWriter(uart, {})

timer = aswitch.Delay_ms(cb_timeout)

sentence_count = 0

gps = as_rwGPS.GPS(sreader, swriter, local_offset=1, fix_cb=callback,

fix_cb_args=(timer,), msg_cb = message_cb)

await asyncio.sleep(2)

await gps.command(as_rwGPS.DEFAULT_SENTENCES)

print('Set sentence frequencies to default')

#await gps.command(as_rwGPS.FULL_COLD_START)

#print('Performed FULL_COLD_START')

print('awaiting first fix')

loop = asyncio.get_event_loop()

loop.create_task(sat_test(gps))

loop.create_task(stats(gps))

loop.create_task(navigation(gps))

loop.create_task(course(gps))

loop.create_task(date(gps))

await gps.data_received(True, True, True, True) # all messages

loop.create_task(change_status(gps, uart))

开发者ID:peterhinch,项目名称:micropython-async,代码行数:28,

示例24: shutdown

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def shutdown():

# Normally UART is already at BAUDRATE. But if last session didn't restore

# factory baudrate we can restore connectivity in the subsequent stuck

# session with ctrl-c.

uart.init(BAUDRATE)

await asyncio.sleep(1)

await gps.command(as_rwGPS.FULL_COLD_START)

print('Factory reset')

#print('Restoring default baudrate.')

#await gps.baudrate(9600)

开发者ID:peterhinch,项目名称:micropython-async,代码行数:12,

示例25: test

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def test():

inspect(_write_packet, 64)

pyb.repl_uart(pyb.UART(4, 115200))

uart = pyb.UART(6, 1000000)

buf = bytearray(b'123456')

_write_packet(stm.USART6 | 0x80000000, buf, len(buf))

开发者ID:dhylands,项目名称:upy-examples,代码行数:8,

示例26: init

​点赞 5

# 需要导入模块: import pyb [as 别名]

# 或者: from pyb import UART [as 别名]

def init():

if True:

uart = pyb.UART(6,115200)

pyb.repl_uart(uart)

print("REPL is also on UART 6 (Y1=Tx Y2=Rx)")

if True:

bufsize = 100

print("Setting alloc_emergency_exception_buf to", bufsize)

micropython.alloc_emergency_exception_buf(bufsize)

开发者ID:dhylands,项目名称:upy-examples,代码行数:11,

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值