From 0b7525a42e09f90afedbaa37fbdfc942b181fff1 Mon Sep 17 00:00:00 2001 From: TheIllusionist77 <113849310+TheIllusionist77@users.noreply.github.com> Date: Sat, 19 Oct 2024 15:51:50 -0400 Subject: [PATCH 01/10] Update adafruit_vl53l1x.py --- adafruit_vl53l1x.py | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/adafruit_vl53l1x.py b/adafruit_vl53l1x.py index 0faaba5..1c63a6b 100644 --- a/adafruit_vl53l1x.py +++ b/adafruit_vl53l1x.py @@ -31,7 +31,7 @@ from adafruit_bus_device import i2c_device from micropython import const -__version__ = "0.0.0+auto.0" +__version__ = "1.1.14" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_VL53L1X.git" _VL53L1X_I2C_SLAVE_DEVICE_ADDRESS = const(0x0001) @@ -46,6 +46,8 @@ _RANGE_CONFIG__VALID_PHASE_HIGH = const(0x0069) _SD_CONFIG__WOI_SD0 = const(0x0078) _SD_CONFIG__INITIAL_PHASE_SD0 = const(0x007A) +_ROI_CONFIG__USER_ROI_CENTRE_SPAD = const(0x007F) +_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE = const(0x0080) _SYSTEM__INTERRUPT_CLEAR = const(0x0086) _SYSTEM__MODE_START = const(0x0087) _VL53L1X_RESULT__RANGE_STATUS = const(0x0089) @@ -294,7 +296,35 @@ def distance_mode(self, mode): else: raise ValueError("Unsupported mode.") self.timing_budget = self._timing_budget + + def set_roi(self, x, y): + optical_center = 0 + if x > 16: + x = 16 + if y > 16: + y = 16 + if x > 10 or y > 10: + optical_center = 199 + + self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, optical_center.to_bytes()); + self._write_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE, ((y - 1) << 4 | (x - 1)).to_bytes()) + + def get_roi(self): + temp = self._read_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE); + + x = (int.from_bytes(temp) & 0x0F) + 1 + y = ((int.from_bytes(temp) & 0xF0) >> 4) + 1 + + return x, y + + def set_roi_center(self, center): + self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes()) + + def get_roi_center(self): + temp = self._read_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD) + return int.from_bytes(temp) + def _write_register(self, address, data, length=None): if length is None: length = len(data) From 28911105f47163a385266af62ae6e15b32497507 Mon Sep 17 00:00:00 2001 From: TheIllusionist77 <113849310+TheIllusionist77@users.noreply.github.com> Date: Sat, 19 Oct 2024 20:53:26 -0400 Subject: [PATCH 02/10] Update adafruit_vl53l1x.py --- adafruit_vl53l1x.py | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/adafruit_vl53l1x.py b/adafruit_vl53l1x.py index 1c63a6b..62152d3 100644 --- a/adafruit_vl53l1x.py +++ b/adafruit_vl53l1x.py @@ -296,8 +296,9 @@ def distance_mode(self, mode): else: raise ValueError("Unsupported mode.") self.timing_budget = self._timing_budget - - def set_roi(self, x, y): + + @roi_xy.setter + def roi_xy(self, x, y): optical_center = 0 if x > 16: @@ -309,19 +310,22 @@ def set_roi(self, x, y): self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, optical_center.to_bytes()); self._write_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE, ((y - 1) << 4 | (x - 1)).to_bytes()) - - def get_roi(self): + + @property + def roi_xy(self): temp = self._read_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE); x = (int.from_bytes(temp) & 0x0F) + 1 y = ((int.from_bytes(temp) & 0xF0) >> 4) + 1 return x, y - - def set_roi_center(self, center): + + @roi_center.setter + def roi_center(self, center): self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes()) - - def get_roi_center(self): + + @property + def roi_center(self): temp = self._read_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD) return int.from_bytes(temp) From 9a29c2f1a008d8364b22df0d4ab9c26fca293a94 Mon Sep 17 00:00:00 2001 From: TheIllusionist77 <113849310+TheIllusionist77@users.noreply.github.com> Date: Sat, 19 Oct 2024 21:35:40 -0400 Subject: [PATCH 03/10] Update adafruit_vl53l1x.py --- adafruit_vl53l1x.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/adafruit_vl53l1x.py b/adafruit_vl53l1x.py index 62152d3..dcfc23c 100644 --- a/adafruit_vl53l1x.py +++ b/adafruit_vl53l1x.py @@ -307,28 +307,33 @@ def roi_xy(self, x, y): y = 16 if x > 10 or y > 10: optical_center = 199 - - self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, optical_center.to_bytes()); - self._write_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE, ((y - 1) << 4 | (x - 1)).to_bytes()) + + self._write_register( + _ROI_CONFIG__USER_ROI_CENTRE_SPAD, optical_center.to_bytes() + ) + self._write_register( + _ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE, + ((y - 1) << 4 | (x - 1)).to_bytes(), + ) @property def roi_xy(self): - temp = self._read_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE); - + temp = self._read_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE) + x = (int.from_bytes(temp) & 0x0F) + 1 y = ((int.from_bytes(temp) & 0xF0) >> 4) + 1 - + return x, y @roi_center.setter def roi_center(self, center): - self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes()) + self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes()) @property def roi_center(self): - temp = self._read_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD) - return int.from_bytes(temp) - + temp = self._read_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD) + return int.from_bytes(temp) + def _write_register(self, address, data, length=None): if length is None: length = len(data) @@ -352,3 +357,4 @@ def set_address(self, new_address): _VL53L1X_I2C_SLAVE_DEVICE_ADDRESS, struct.pack(">B", new_address) ) self.i2c_device = i2c_device.I2CDevice(self._i2c, new_address) + From 075ef3e5e23c9b141cb0b39c44bbfad7dc112749 Mon Sep 17 00:00:00 2001 From: TheIllusionist77 <113849310+TheIllusionist77@users.noreply.github.com> Date: Sat, 19 Oct 2024 22:08:28 -0400 Subject: [PATCH 04/10] Update adafruit_vl53l1x.py --- adafruit_vl53l1x.py | 1 - 1 file changed, 1 deletion(-) diff --git a/adafruit_vl53l1x.py b/adafruit_vl53l1x.py index dcfc23c..e3a8067 100644 --- a/adafruit_vl53l1x.py +++ b/adafruit_vl53l1x.py @@ -357,4 +357,3 @@ def set_address(self, new_address): _VL53L1X_I2C_SLAVE_DEVICE_ADDRESS, struct.pack(">B", new_address) ) self.i2c_device = i2c_device.I2CDevice(self._i2c, new_address) - From e0de89afa47ac5620577757edbb3237b76988075 Mon Sep 17 00:00:00 2001 From: TheIllusionist77 <113849310+TheIllusionist77@users.noreply.github.com> Date: Sat, 19 Oct 2024 22:16:35 -0400 Subject: [PATCH 05/10] Update adafruit_vl53l1x.py --- adafruit_vl53l1x.py | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/adafruit_vl53l1x.py b/adafruit_vl53l1x.py index e3a8067..5b3089b 100644 --- a/adafruit_vl53l1x.py +++ b/adafruit_vl53l1x.py @@ -297,14 +297,13 @@ def distance_mode(self, mode): raise ValueError("Unsupported mode.") self.timing_budget = self._timing_budget - @roi_xy.setter - def roi_xy(self, x, y): + @set_roi_xy.setter + def set_roi_xy(self, x, y): optical_center = 0 - if x > 16: - x = 16 - if y > 16: - y = 16 + x = min(x, 16) + y = min(y, 16) + if x > 10 or y > 10: optical_center = 199 @@ -317,7 +316,7 @@ def roi_xy(self, x, y): ) @property - def roi_xy(self): + def get_roi_xy(self): temp = self._read_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE) x = (int.from_bytes(temp) & 0x0F) + 1 @@ -325,12 +324,12 @@ def roi_xy(self): return x, y - @roi_center.setter - def roi_center(self, center): + @set_roi_center.setter + def set_roi_center(self, center): self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes()) @property - def roi_center(self): + def get_roi_center(self): temp = self._read_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD) return int.from_bytes(temp) From 0bef4e610f4ad894a5ba85bfe05ef8ca2f51d8b6 Mon Sep 17 00:00:00 2001 From: TheIllusionist77 <113849310+TheIllusionist77@users.noreply.github.com> Date: Sat, 19 Oct 2024 22:22:44 -0400 Subject: [PATCH 06/10] Update adafruit_vl53l1x.py --- adafruit_vl53l1x.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/adafruit_vl53l1x.py b/adafruit_vl53l1x.py index 5b3089b..222bdb1 100644 --- a/adafruit_vl53l1x.py +++ b/adafruit_vl53l1x.py @@ -317,6 +317,7 @@ def set_roi_xy(self, x, y): @property def get_roi_xy(self): + """Returns the x and y coordinates of the sensor's region of interest""" temp = self._read_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE) x = (int.from_bytes(temp) & 0x0F) + 1 @@ -330,6 +331,7 @@ def set_roi_center(self, center): @property def get_roi_center(self): + """Returns the center of the sensor's region of interest""" temp = self._read_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD) return int.from_bytes(temp) From b3e43175c418e0cf5ea120ea15c3c474764409c4 Mon Sep 17 00:00:00 2001 From: TheIllusionist77 <113849310+TheIllusionist77@users.noreply.github.com> Date: Sat, 19 Oct 2024 22:28:36 -0400 Subject: [PATCH 07/10] Update adafruit_vl53l1x.py --- adafruit_vl53l1x.py | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/adafruit_vl53l1x.py b/adafruit_vl53l1x.py index 222bdb1..6f9b89a 100644 --- a/adafruit_vl53l1x.py +++ b/adafruit_vl53l1x.py @@ -297,6 +297,16 @@ def distance_mode(self, mode): raise ValueError("Unsupported mode.") self.timing_budget = self._timing_budget + @property + def get_roi_xy(self): + """Returns the x and y coordinates of the sensor's region of interest""" + temp = self._read_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE) + + x = (int.from_bytes(temp) & 0x0F) + 1 + y = ((int.from_bytes(temp) & 0xF0) >> 4) + 1 + + return x, y + @set_roi_xy.setter def set_roi_xy(self, x, y): optical_center = 0 @@ -315,26 +325,16 @@ def set_roi_xy(self, x, y): ((y - 1) << 4 | (x - 1)).to_bytes(), ) - @property - def get_roi_xy(self): - """Returns the x and y coordinates of the sensor's region of interest""" - temp = self._read_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE) - - x = (int.from_bytes(temp) & 0x0F) + 1 - y = ((int.from_bytes(temp) & 0xF0) >> 4) + 1 - - return x, y - - @set_roi_center.setter - def set_roi_center(self, center): - self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes()) - @property def get_roi_center(self): """Returns the center of the sensor's region of interest""" temp = self._read_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD) return int.from_bytes(temp) + @set_roi_center.setter + def set_roi_center(self, center): + self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes()) + def _write_register(self, address, data, length=None): if length is None: length = len(data) From b03f28abd78937be962e1434f33b0865595f757f Mon Sep 17 00:00:00 2001 From: TheIllusionist77 <113849310+TheIllusionist77@users.noreply.github.com> Date: Sat, 19 Oct 2024 22:34:55 -0400 Subject: [PATCH 08/10] Update adafruit_vl53l1x.py --- adafruit_vl53l1x.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/adafruit_vl53l1x.py b/adafruit_vl53l1x.py index 6f9b89a..81788cf 100644 --- a/adafruit_vl53l1x.py +++ b/adafruit_vl53l1x.py @@ -298,7 +298,7 @@ def distance_mode(self, mode): self.timing_budget = self._timing_budget @property - def get_roi_xy(self): + def roi_xy(self): """Returns the x and y coordinates of the sensor's region of interest""" temp = self._read_register(_ROI_CONFIG__USER_ROI_REQUESTED_GLOBAL_XY_SIZE) @@ -307,8 +307,8 @@ def get_roi_xy(self): return x, y - @set_roi_xy.setter - def set_roi_xy(self, x, y): + @roi_xy.setter + def roi_xy(self, x, y): optical_center = 0 x = min(x, 16) @@ -326,13 +326,13 @@ def set_roi_xy(self, x, y): ) @property - def get_roi_center(self): + def roi_center(self): """Returns the center of the sensor's region of interest""" temp = self._read_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD) return int.from_bytes(temp) - @set_roi_center.setter - def set_roi_center(self, center): + @roi_center.setter + def roi_center(self, center): self._write_register(_ROI_CONFIG__USER_ROI_CENTRE_SPAD, center.to_bytes()) def _write_register(self, address, data, length=None): From 2c9e1e143afc56569878fa7a9c6b06ac61fbb549 Mon Sep 17 00:00:00 2001 From: TheIllusionist77 <113849310+TheIllusionist77@users.noreply.github.com> Date: Sun, 20 Oct 2024 11:59:54 -0400 Subject: [PATCH 09/10] Update adafruit_vl53l1x.py --- adafruit_vl53l1x.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/adafruit_vl53l1x.py b/adafruit_vl53l1x.py index 81788cf..6050ea8 100644 --- a/adafruit_vl53l1x.py +++ b/adafruit_vl53l1x.py @@ -308,7 +308,8 @@ def roi_xy(self): return x, y @roi_xy.setter - def roi_xy(self, x, y): + def roi_xy(self, data): + x, y = data optical_center = 0 x = min(x, 16) From 6a71ae18ce4e6b1493bffe8bd9df3f055b19df29 Mon Sep 17 00:00:00 2001 From: TheIllusionist77 <113849310+TheIllusionist77@users.noreply.github.com> Date: Sat, 2 Nov 2024 15:55:44 -0400 Subject: [PATCH 10/10] Update adafruit_vl53l1x.py --- adafruit_vl53l1x.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/adafruit_vl53l1x.py b/adafruit_vl53l1x.py index 6050ea8..9e6ebfd 100644 --- a/adafruit_vl53l1x.py +++ b/adafruit_vl53l1x.py @@ -31,7 +31,7 @@ from adafruit_bus_device import i2c_device from micropython import const -__version__ = "1.1.14" +__version__ = "0.0.0+auto.0" __repo__ = "https://github.com/adafruit/Adafruit_CircuitPython_VL53L1X.git" _VL53L1X_I2C_SLAVE_DEVICE_ADDRESS = const(0x0001)