From b5b17e941e15e52297cb94dfe4de425145170c95 Mon Sep 17 00:00:00 2001 From: bgrossbo <107809951+bgrossbo@users.noreply.github.com> Date: Sun, 19 Jun 2022 20:23:19 +0200 Subject: [PATCH 1/3] Update MPU6050.py minor bug fix (missing "self" in funciton calls in get_all_data()) --- MPU6050.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/MPU6050.py b/MPU6050.py index feb5fea..1bab0c4 100644 --- a/MPU6050.py +++ b/MPU6050.py @@ -253,9 +253,9 @@ def get_gyro_data(self): def get_all_data(self): """Reads and returns all the available data.""" - temp = get_temp() - accel = get_accel_data() - gyro = get_gyro_data() + temp = self.get_temp() + accel = self.get_accel_data() + gyro = self.get_gyro_data() return [accel, gyro, temp] From 45bd00a9ee9b759dacfd1e4013f79451a274516b Mon Sep 17 00:00:00 2001 From: bgrossbo <107809951+bgrossbo@users.noreply.github.com> Date: Sun, 19 Jun 2022 21:35:19 +0200 Subject: [PATCH 2/3] Update MPU6050.py --- MPU6050.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/MPU6050.py b/MPU6050.py index 1bab0c4..a48d965 100644 --- a/MPU6050.py +++ b/MPU6050.py @@ -12,7 +12,7 @@ class MPU6050: # Global Variables GRAVITIY_MS2 = 9.80665 address = None - bus = smbus.SMBus(1) + bus = None # Scale Modifiers ACCEL_SCALE_MODIFIER_2G = 16384.0 @@ -65,9 +65,10 @@ class MPU6050: ACCEL_CONFIG = 0x1C GYRO_CONFIG = 0x1B - def __init__(self, address): + def __init__(self, address, bus_index): self.address = address - + self.bus = smbus.SMBus(bus_index) + # Wake up the MPU-6050 since it starts in sleep mode self.bus.write_byte_data(self.address, self.PWR_MGMT_1, 0x00) From ad5c606399ab96769c41f2d8326d263ebe43b237 Mon Sep 17 00:00:00 2001 From: bgrossbo <107809951+bgrossbo@users.noreply.github.com> Date: Sun, 19 Jun 2022 21:36:24 +0200 Subject: [PATCH 3/3] Update MPU6050.py --- MPU6050.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MPU6050.py b/MPU6050.py index a48d965..b39cc0d 100644 --- a/MPU6050.py +++ b/MPU6050.py @@ -65,7 +65,8 @@ class MPU6050: ACCEL_CONFIG = 0x1C GYRO_CONFIG = 0x1B - def __init__(self, address, bus_index): + def __init__(self, address, bus_index = 1): + # Set address and bus index self.address = address self.bus = smbus.SMBus(bus_index)