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))
joystick_color_wheel.py 文件源码
python
阅读 24
收藏 0
点赞 0
评论 0
评论列表
文章目录