• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python micropython.alloc_emergency_exception_buf函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中micropython.alloc_emergency_exception_buf函数的典型用法代码示例。如果您正苦于以下问题:Python alloc_emergency_exception_buf函数的具体用法?Python alloc_emergency_exception_buf怎么用?Python alloc_emergency_exception_buf使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: test

def test():
    """Test program - assumes X2 is jumpered to X1."""
    micropython.alloc_emergency_exception_buf(100)

    print("Starting tach")
    tach = Tachometer(timer_num=2, channel_num=1, pin_name='X1')

    print("Starting pulses")
    t5 = pyb.Timer(5, freq=4)
    oc_pin = pyb.Pin.board.X2
    oc = t5.channel(2, pyb.Timer.OC_TOGGLE, pin=oc_pin)

    for freq in range(0, 600, 100):
        if freq == 0:
            freq = 1
        else:
            t5.freq(freq * 4)   # x 2 for toggle, x2 for 2 pulses_per_rev
        pyb.delay(1000)
        print("RPM =",  tach.rpm(), "Freq =", freq, " as RPM =", freq * 60)

    # stop the pulses
    print("Stopping pulses")
    oc_pin.init(pyb.Pin.OUT_PP)
    # wait for 1.5 seconds
    pyb.delay(1500)
    print("RPM =",  tach.rpm())
    print("RPM =",  tach.rpm())

    print("Starting pulses again")
    # start the pulses up again
    oc = t5.channel(2, pyb.Timer.OC_TOGGLE, pin=oc_pin)
    pyb.delay(2000)
    print("RPM =",  tach.rpm())
    print("RPM =",  tach.rpm())
开发者ID:AbhinayBandaru,项目名称:upy-examples,代码行数:34,代码来源:Tach.py


示例2: main

def main():
    micropython.alloc_emergency_exception_buf(100)
    print('simp here')
    beam = LaserBeam('X1', 'X11')
    deck = CL1('X17', 'X18', 'X19', 'X20', 'X21', 'X22')
    piano = Piano(beam)
    lights = Lights(beam, deck)
    pushbutton = Switch()
    verbose = False

    def show():
        lights.update()
        if not verbose:
            return
        print('{}: laser {}'.format(ticks_ms(), beam.interrupted()), end=' ')
        sleep(0.1)
        print('deck %s' % deck.status(), end=' ')
        if piano.playing():
            print('Piano being played', end='')
        print()

    sleep(1)                    # stabilize
    while True:
        show()
        if piano.playing() and not deck.recording():
            deck.record()
            print("record")
            while piano.playing():
                show()
            deck.stop()
            print("stop")
开发者ID:pramasoul,项目名称:pyboard-music-detector,代码行数:31,代码来源:simp.py


示例3: init

def init():
    if False:
        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:chinadsf,项目名称:upy-examples,代码行数:9,代码来源:boot.py


示例4: demo

    def demo():
        # This example requires a servo on X1 and a signal (from a radio) on X4.
        micropython.alloc_emergency_exception_buf(100)

        in_ppm = Ppm(pyb.Pin.board.X4, pyb.Servo(1))

        while True:
            # wait forever
            pyb.delay(200)
            print("%d%% %d deg %d speed (%s) %d us" % (in_ppm.percent(), in_ppm.angle(), in_ppm.speed(), "True" if in_ppm.switch() else "False", in_ppm.pulse_width))
开发者ID:jeffeb3,项目名称:cppm_micropython,代码行数:10,代码来源:cppm.py


示例5: __init__

 def __init__(self, pin, mode, pull, customcallback = None, timeout = None):
     super().__init__()
     if not Pinblock.initialised:
         import pyb
         import micropython
         micropython.alloc_emergency_exception_buf(100) 
         Pinblock.initialised = True
     self.customcallback = customcallback
     if timeout is None:
         self.forever = True
     else:
         self.setdelay(timeout)
     self.irq = pyb.ExtInt(pin, mode, pull, self.intcallback) # Porting: needs adaptation
开发者ID:Usagimimi,项目名称:Micropython-scheduler,代码行数:13,代码来源:usched.py


示例6: __init__

    def __init__(self):
        #com1 = pyb.USB_VCP()  # A Virtual COM port
        self.mpu = MPU9250('y')
        self.mpu.sample_rate = 254
        self.mpu.accel_filter_range = 5
        self.mpu.gyro_filter_range = 2
        self.led1 = pyb.LED(1)
        self.led2 = pyb.LED(2)
        self.led3 = pyb.LED(3)
        self.led4 = pyb.LED(4)
        self.led3.on()
        self.kalmanX = kalmanFilter()
        self.led4.on()
        self.timeX = pyb.micros()
        self.kalmanY = kalmanFilter()
        self.timeY = pyb.micros()
        self.kalmanZ = kalmanFilter()
        self.timeZ =  pyb.micros()
        micropython.alloc_emergency_exception_buf(5)
        self.led4.on()


        self.display = NextionUartDriver.NextionDisplay(1,115200)
开发者ID:toppixx,项目名称:Quadcopter,代码行数:23,代码来源:test.py


示例7: MutexException

import pyb, micropython, array, uctypes
micropython.alloc_emergency_exception_buf(100)

class MutexException(OSError):
    pass

class Mutex:
    @micropython.asm_thumb
    def _acquire(r0, r1):       # Spinlock: wait on the semaphore. Return on success.
        label(LOOP)
        ldr(r0, [r1, 0])        # Wait for lock to be zero
        cmp(r0, 0)
        bne(LOOP)               # Another process has the lock: spin on it
        cpsid(0)                # OK, we have lock  at this instant disable interrupts
        ldr(r0, [r1, 0])        # and re-check in case an interrupt occurred
        cmp(r0, 0)
        itt(ne)                 # if someone got in first re-enable ints
        cpsie(0)                # and start polling again
        b(LOOP)
        mov(r0, 1)              # We have an exclusive access
        str(r0, [r1, 0])        # set the lock
        cpsie(0)

    @micropython.asm_thumb
    def _attempt(r0, r1):       # Nonblocking. Try to lock. Return 0 on success, 1 on fail
        cpsid(0)                # disable interrupts
        ldr(r0, [r1, 0])
        cmp(r0, 0)
        bne(FAIL)               # Another process has the lock: fail
        mov(r2, 1)              # No lock
        str(r2, [r1, 0])        # set the lock
开发者ID:fojie,项目名称:micropython-samples,代码行数:31,代码来源:mutex.py


示例8: main

def main():
    micropython.alloc_emergency_exception_buf(100)
    print('simp here')
    beam = LaserBeam('X1', 'X11')
    mic = Mic('X12')
    deck = CL1('X17', 'X18', 'X19', 'X20', 'X21', 'X22')
    piano = Piano(mic, beam)
    lights = Lights(mic, beam, deck)
    pushbutton = Switch()
    verbose = False

    def was_show(): # BAD
        lights.update()
        #if pushbutton():
        if True:
            print('laser {}, mic {}'.format(beam.interrupted(), mic.excited()), end=' ')
            print('deck %s' % deck.status(), end=' ')
            if piano.playing():
                print('Piano being played', end='')
            print()

    def show():
        lights.update()
        print('laser {}'.format(beam.interrupted()), end=' ')
        print('deck %s' % deck.status(), end=' ')
        if piano.playing():
            print('Piano being played', end='')
        print()

    def s11(): # BAD
        mic.excited()
        print('deck %s' % deck.status())

    def s12(): # ok
        mic.excited()
        sleep(0.1)
        print('deck %s' % deck.status())

    def s13(): # BAD
        mic.excited()
        sleep(0.001)
        print('deck %s' % deck.status())

    def s14(): # BAD: prints "deck" (or maybe "deck ") only
        mic.excited()
        sleep(0.01)
        print('deck %s' % deck.status())

    def s15(): # BAD
        mic.excited()
        gc.collect()
        print('deck %s' % deck.status())

    def foo(): # ok
        print('deck %s' % deck.status(), end=' ')

    sleep(1)                    # stabilize
    while True:
        show()
        if piano.playing() and not deck.recording():
            deck.record()
            print("record")
            while piano.playing():
                show()
            deck.stop()
            print("stop")
开发者ID:pramasoul,项目名称:pyboard-music-detector,代码行数:66,代码来源:bug.py


示例9: __init__

import time
import machine
import micropython
from machine import Pin
# HC-SR04 ultrasonic sensor
# 2 pins: Trigger and Echo
# Trigger triggers the wave to get the distance
# Echo listen to the wave 'comeback'
# To trigger: send during 10us a HIGH signal on the Trigger
# Then, on echo, the signal is HIGH while listening to the wave comeback
# Formulae to calculate: t * 10^-2 * 1,7

micropython.alloc_emergency_exception_buf(100)	# To allow error trace in IRQ handler
	
MIN_TO_SEC = 60			# Number of sec in 1 min
SEC_TO_USEC = 1000		# Number of msec in 1 sec

TRIGGER_TIME = 100 		# Trigger time during which send the HIGH signal
TRIGGER_PIN = 'GP11'	# Pin associated to the trigger 
ECHO_PIN = 'GP12'		# Pin associated to the echo

LOW = 0
HIGH = 1

class DistanceSensor:
	def __init__(self, triggerGPIO, echoGPIO):
		self.triggerPin = Pin(triggerGPIO, mode = Pin.OUT)
		self.echoPin = Pin(echoGPIO, mode = Pin.IN)
		# The var to know if we have 28 or 028 in the decimal part
		self.mm_decimal = ""
		# Distance initated to -1 while nothing
开发者ID:gabriel-farache,项目名称:homautomation,代码行数:31,代码来源:HC-SR04.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python micropython.const函数代码示例发布时间:2022-05-27
下一篇:
Python bottle.template函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap