diff --git a/Adafruit_LSM303/LSM303.py b/Adafruit_LSM303/LSM303.py index d5d08de..ac46086 100644 --- a/Adafruit_LSM303/LSM303.py +++ b/Adafruit_LSM303/LSM303.py @@ -85,7 +85,7 @@ def read(self): mag = struct.unpack('>hhh', mag_raw) return (accel, mag) - def set_mag_gain(gain=LSM303_MAGGAIN_1_3): + def set_mag_gain(self,gain=LSM303_MAGGAIN_1_3): """Set the magnetometer gain. Gain should be one of the following constants: - LSM303_MAGGAIN_1_3 = +/- 1.3 (default) diff --git a/examples/simpletest.py b/examples/simpletest.py index e27a73c..449b8b9 100644 --- a/examples/simpletest.py +++ b/examples/simpletest.py @@ -12,6 +12,8 @@ # Create a LSM303 instance. lsm303 = Adafruit_LSM303.LSM303() +lsm303.set_mag_gain(Adafruit_LSM303.LSM303_MAGGAIN_1_3) + # Alternatively you can specify the I2C bus with a bus parameter: #lsm303 = Adafruit_LSM303.LSM303(busum=2)