web.py 文件源码

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

项目:Monzo-Meter 作者: d-Rickyy-b 项目源码 文件源码
def notify_particle():
    # The particle device gets notified about changes here
    peak_v = float(getRedisValue("peak"))
    balance_v = float(getRedisValue("balance"))

    # If the balance exceeds the peak/below 0, then the servo/needle might break.
    # Because of this, the angle's value gets checked before sending to particle.io
    if balance_v > peak_v:
        balance_v = peak_v
    elif balance_v < 0:
        balance_v = 0

    # Prevent division by zero
    if peak_v <= 0:
        peak_v = 1

    angle_v = angle(peak_v, balance_v)
    data = {"access_token": particle_token, "arg": angle_v}
    requests.post("https://api.particle.io/v1/devices/{}/gotoPos".format(device_id), data=data)
    return angle_v
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号