From 2ea57daf1aa62896f76fb1b2aa44193fa78df0fd Mon Sep 17 00:00:00 2001 From: Jake Keller Date: Wed, 30 Sep 2020 16:30:49 -0400 Subject: [PATCH 1/5] Add function to soft reset the device The function mimics VL53L1_software_reset() from vl53l1_api_core.c/h --- qwiic_vl53l1x.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/qwiic_vl53l1x.py b/qwiic_vl53l1x.py index e1f6459..d550307 100644 --- a/qwiic_vl53l1x.py +++ b/qwiic_vl53l1x.py @@ -601,6 +601,27 @@ def init_sensor(self, address): + # VL53L1X_api_core.h functions + ############################################################################### + ############################################################################### + + def soft_reset(self): + """ + This function causes the device to perform a soft reset + """ + self_status = 0 + + self.status = self.__i2cWrite(self.address, SOFT_RESET, 0) + if (not self.status): + self.time.sleep(0.001) + if (not self.status): + self.status = self.__i2cWrite(self.address, SOFT_RESET, 1) + + return self.status + + + + # VL53L1X_api.h functions ############################################################################### ############################################################################### From 0e7d7bb6b7e576d02a2c1238ce757316912b559a Mon Sep 17 00:00:00 2001 From: Jake Keller Date: Wed, 30 Sep 2020 16:52:54 -0400 Subject: [PATCH 2/5] Convert spaces to tabs --- qwiic_vl53l1x.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/qwiic_vl53l1x.py b/qwiic_vl53l1x.py index d550307..9e3b7c5 100644 --- a/qwiic_vl53l1x.py +++ b/qwiic_vl53l1x.py @@ -605,20 +605,20 @@ def init_sensor(self, address): ############################################################################### ############################################################################### - def soft_reset(self): - """ - This function causes the device to perform a soft reset - """ - self_status = 0 - - self.status = self.__i2cWrite(self.address, SOFT_RESET, 0) - if (not self.status): - self.time.sleep(0.001) - if (not self.status): - self.status = self.__i2cWrite(self.address, SOFT_RESET, 1) - - return self.status - + def soft_reset(self): + """ + This function causes the device to perform a soft reset + """ + self_status = 0 + + self.status = self.__i2cWrite(self.address, SOFT_RESET, 0) + if (not self.status): + self.time.sleep(0.001) + if (not self.status): + self.status = self.__i2cWrite(self.address, SOFT_RESET, 1) + + return self.status + From 5f3d4e6bf15c5ee24445b5a59c85491e95aedd34 Mon Sep 17 00:00:00 2001 From: Jake Keller Date: Wed, 30 Sep 2020 16:58:28 -0400 Subject: [PATCH 3/5] Fix missing 'nbytes' argument in soft_reset() --- qwiic_vl53l1x.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qwiic_vl53l1x.py b/qwiic_vl53l1x.py index 9e3b7c5..f13d2f5 100644 --- a/qwiic_vl53l1x.py +++ b/qwiic_vl53l1x.py @@ -611,11 +611,11 @@ def soft_reset(self): """ self_status = 0 - self.status = self.__i2cWrite(self.address, SOFT_RESET, 0) + self.status = self.__i2cWrite(self.address, SOFT_RESET, 0, 1) if (not self.status): self.time.sleep(0.001) if (not self.status): - self.status = self.__i2cWrite(self.address, SOFT_RESET, 1) + self.status = self.__i2cWrite(self.address, SOFT_RESET, 1, 1) return self.status From 76fb37b6660fa48f44954f0b666f73f30b1ec35a Mon Sep 17 00:00:00 2001 From: Jake Keller Date: Wed, 30 Sep 2020 17:12:00 -0400 Subject: [PATCH 4/5] Fix typo in soft_reset() --- qwiic_vl53l1x.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qwiic_vl53l1x.py b/qwiic_vl53l1x.py index f13d2f5..76e3ee4 100644 --- a/qwiic_vl53l1x.py +++ b/qwiic_vl53l1x.py @@ -613,7 +613,7 @@ def soft_reset(self): self.status = self.__i2cWrite(self.address, SOFT_RESET, 0, 1) if (not self.status): - self.time.sleep(0.001) + time.sleep(0.001) if (not self.status): self.status = self.__i2cWrite(self.address, SOFT_RESET, 1, 1) From 3e01fb5eea0b76e292e6465c434dd63602857647 Mon Sep 17 00:00:00 2001 From: Jake Keller Date: Wed, 30 Sep 2020 18:10:36 -0400 Subject: [PATCH 5/5] Increase sensor_init() timeout delay --- qwiic_vl53l1x.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qwiic_vl53l1x.py b/qwiic_vl53l1x.py index 76e3ee4..3cfc7f3 100644 --- a/qwiic_vl53l1x.py +++ b/qwiic_vl53l1x.py @@ -675,7 +675,7 @@ def sensor_init(self): while(tmp == 0): tmp = self.check_for_data_ready() timeout = timeout + 1 - if (timeout > 50): + if (timeout > 500): self.status = VL53L1_ERROR_TIME_OUT return self.status