#NEWLINE# @ staticmethod #NEWLINE# def int_to_pwm( ratio , length ) : #NEWLINE# #INDENT# 'Converts a decimal between 0 and 1 to a pwm mask of whatever length\n        you want.\n\n        For example, an input ratio of .5 with a result length of 8 returns\n        10101010. And input ratio of .7 with a result length of 32 returns\n        11011011101101101101110110110110.\n\n        Another way to think about this is this method converts a decimal\n        percentage into the corresponding pwm mask.\n\n        Args:\n            ratio (float): A value between 0 and 1 that you want to convert.\n            length (int): How many digits you want in your result.\n        ' #NEWLINE# whole_num = 0 #NEWLINE# output = 0 #NEWLINE# count = 0 #NEWLINE# for _i in range ( length ) : #NEWLINE# #INDENT# count += ratio #NEWLINE# if ( int ( count ) > whole_num ) : #NEWLINE# #INDENT# output |= 1 #NEWLINE# whole_num += 1 #NEWLINE# #UNINDENT# output <<= 1 #NEWLINE# #UNINDENT# return output