midi-ros.py 文件源码

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

项目:makerfaire-berlin-2016-demos 作者: bitcraze 项目源码 文件源码
def handleLedMessage(message):
    if message.type == 'note_on' or message.type == 'note_off':
        h = message.note / 127.0
        s = message.velocity / 127.0

        if message.type == 'note_on':
            v = 1.0
        else:
            v = 0.0

        rgb = colorsys.hsv_to_rgb(h, s, v)

        r = int(rgb[0] * 255)
        g = int(rgb[1] * 255)
        b = int(rgb[2] * 255)
        print("LED ring r:{} g:{} b:{}".format(r, g, b))

        publishLedColor(r, g, b)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号