joystick_color_wheel.py 文件源码

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

项目:52-Weeks-of-Pi 作者: grantwinney 项目源码 文件源码
def calculate_next_pwm_duty_cycle_for_led(angle, led):
    """
    Calculate the next PWM duty cycle value for the current LED and joystick position (angle)
    :param angle: integer, between 0-359 indicating current angle of joystick position
    :param led: 'R', 'G', 'B', indicating the LED we're interested in
    :return: integer, between 0-100 indicating the next PWM duty cycle value for the LED
    """

    angle = adjust_angle_for_perspective_of_current_led(angle, led)
    if 120 < angle < 240:
        return 0
    elif angle <= 120:
        return 100 - (angle * (100 / 120.0))
    else:
        return 100 - ((360 - angle) * (100 / 120.0))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号