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
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值