Skip to content

Commit b5eac4d

Browse files
authored
Merge pull request #3 from naisy/naisy
Naisy
2 parents 5f4357c + 045512b commit b5eac4d

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

README.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# VL53L0X Python interface on Raspberry Pi
1+
# VL53L0X Python interface on Raspberry Pi/Jetson TX2
22

33
This project provides a simplified python interface on Raspberry Pi to the ST VL53L0X API (ST Microelectronics).
44

@@ -9,6 +9,11 @@ In order to be able to share the i2c bus with other python code that uses the i2
99
Version 1.0.2:
1010
- Add support for TCA9548A I2C Multiplexer. Tested with https://www.adafruit.com/products/2717 breakout. (johnbryanmoore)
1111
- Add python example using TCA9548A Multiplexer support (johnbryanmoore)
12+
- Add pip install support (grantramsay)
13+
- Add smbus2 support (grantramsay)
14+
- **Add smbus/smbus2 support (naisy)**
15+
- **Add gcc -fPIC flag (naisy)**
16+
- **Add I2C address change support (naisy)**
1217

1318
Version 1.0.1:
1419
- Simplify build process (svanimisetti)
@@ -39,9 +44,9 @@ Notes on using TCA9548A I2C Multiplexer:
3944
### Installation
4045
```bash
4146
# Python2
42-
pip2 install git+https://github.com/grantramsay/VL53L0X_rasp_python.git
47+
pip2 install git+https://github.com/naisy/VL53L0X_rasp_python.git
4348
# Python3
44-
pip3 install git+https://github.com/grantramsay/VL53L0X_rasp_python.git
49+
pip3 install git+https://github.com/naisy/VL53L0X_rasp_python.git
4550
```
4651

4752
### Compilation
@@ -54,7 +59,7 @@ sudo apt-get install build-essential python-dev
5459
Then use following commands to clone the repository and compile:
5560
```bash
5661
cd your_git_directory
57-
git clone https://github.com/johnbryanmoore/VL53L0X_rasp_python.git
62+
git clone https://github.com/naisy/VL53L0X_rasp_python.git
5863
cd VL53L0X_rasp_python
5964
make
6065
```

python/VL53L0X.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ def clear_interrupt(self):
204204
raise Vl53l0xError('Error clearing VL53L0X interrupt')
205205

206206
def change_address(self, new_address):
207+
if self._dev is not None:
208+
raise Vl53l0xError('Error changing VL53L0X address')
209+
210+
self._i2c.open(bus=self._i2c_bus)
211+
207212
if new_address == None:
208213
return
209214
elif new_address == self.i2c_address:
@@ -221,3 +226,5 @@ def change_address(self, new_address):
221226
self._i2c.write_byte_data(self.i2c_address, self.ADDR_I2C_SEC_ADDR, new_address)
222227

223228
self.i2c_address = new_address
229+
230+
self._i2c.close()

python/VL53L0X_example.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727

2828
# Create a VL53L0X object
2929
tof = VL53L0X.VL53L0X(i2c_bus=1,i2c_address=0x29)
30+
# I2C Address can change before tof.open()
31+
# tof.change_address(0x32)
3032
tof.open()
3133
# Start ranging
3234
tof.start_ranging(VL53L0X.Vl53l0xAccuracyMode.BETTER)

0 commit comments

Comments
 (0)