__init__.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:picraftzero 作者: WayneKeenan 项目源码 文件源码
def blink(self, on=1, off=-1):
        """Blinks an LED by working out the correct PWM frequency/duty cycle

        @param self Object pointer.
        @param on Time the LED should stay at 100%/on
        @param off Time the LED should stay at 0%/off"""

        self.stop()

        if off == -1:
            off = on

        off = float(off)
        on = float(on)

        total = off + on

        duty_cycle = 100.0 * (on/total)

        # Use pure PWM blinking, because threads are ugly
        self.frequency(1.0/total)
        self.duty_cycle(duty_cycle)
        self.blinking = True

        return True
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号