Skip to content

Commit 45c35d2

Browse files
committed
Fixed a bug in previoius commit, that makes the duty cycle become 0 if youput
the specified value from 'max_level' as 'level' by letting it only go to 1 less
1 parent 7c6b045 commit 45c35d2

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

‎pcduino/pwm.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ def analog_write(pin, value):
2525
if value < 0 or value > MAX_PWM_LEVEL:
2626
raise ValueError("value must be between 0 and %s" % MAX_PWM_LEVEL)
2727

28-
map_level = (max_value * value) // MAX_PWM_LEVEL
28+
map_level = ((max_value-1) * value) // MAX_PWM_LEVEL
2929
#// because python 3 compatibility
30-
#for some reason 255 becomes 0 (overflow?)
30+
#-1 because if it puts max_value the duty cycle somehow becomes 0
3131

3232
#disable -> change level -> enable , as requested by documentation
3333
with open(os.path.join(path, 'enable', ending), 'w+') as f:

0 commit comments

Comments
 (0)