Pi Servo pHAT python error on declaration of PiServoHat

Hello,

using Ubuntu MATE 18.04 on a rPi 3B and trying to get ServoHat up and running. Following this tutorial:

https://learn.sparkfun.com/tutorials/pi … n-examples

I verified i2c is activated, and running i2c detect -y 1 shows 0x40 marked with a 40

Have a basic test program, that looks like:

import pi_servo_hat
import time

test = pi_servo_hat.PiServoHat()
test.restart()

when i run it I get the below error:

Traceback (most recent call last):
File "/home/pzpi/repos/hello_servo_world.py", line 4, in <module>
    test=pi_servo_hat.PiServoHat()
  File "/usr/local/lib/python2.7/dist-packages/pi_servo_hat.py", line 169, in __init__
    self.set_pwm_frequency(_DEFAULT_SERVO_FREQUENCY)
  File "/usr/local/lib/python2.7/dist-packages/pi_servo_hat.py", line 249, in set_pwm_frequency
    if self.PCA9685.set_pre_scale(frequency) == True:
  File "/usr/local/lib/python2.7/dist-packages/qwiic_pca9685.py", line 1301, in set_pre_scale
    self._i2c.writeByte(self.address, PRE_SCALE, pwmPreScale)
  File "/usr/local/lib/python2.7/dist-packages/qwiic_i2c/linux_i2c.py", line 226, in writeByte
    return self.i2cbus.write_byte_data(address, commandCode, value)
  File "/usr/local/lib/python2.7/dist-packages/smbus2/smbus2.py", line 454, in write_byte_data
    msg.data.contents.byte = value
TypeError: int expected instead of float

clearly somewhere the wrong value is being passed, but not sure how to troubleshoot this as it seems the error is in the library provided? any help would be great, thank you!

ok i think i solved it.

i had to manually go into smbus2.py and change all the

msg.data.contents.byte = value
``` lines to ```
msg.data.contents.byte = int(value)

then there were some areas in pi_servo_hat.py i had to modify to convert ints to floats such as in the move_servo_position function as values were being treated as ints, so were getting a 0 value when they should have gotten a low decimal value (e.g. period, m, etc.).

I kinda know python but not well enough to know all the nuances, could this be because i am using python 2.7 instead of python3+? Using 2.7 because its what ros melodic uses.