Skip to content

Commit 0c6152c

Browse files
committed
bug fix
1 parent 1b2b5a8 commit 0c6152c

File tree

5 files changed

+124
-122
lines changed

5 files changed

+124
-122
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Arduino library for Deneyap ToF Range Finder Sensor VL53L0X
77

88
## :mag_right:Specifications
99
- `Product ID` **M06**, **mpv1.0**
10-
- `MCU` VL53L0X, STM8S003F3
10+
- `MCU` VL53L0X
1111
- `Weight`
1212
- `Module Dimension`
1313
- `I2C address` 0x29
@@ -24,7 +24,7 @@ Deneyap ToF Range Finder Sensor VL53L0X
2424
[How to install a Arduino Library](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries)
2525

2626
## :pushpin:Deneyap ToF Range Finder Sensor VL53L0X
27-
This Arduino library allows you to use DDeneyap ToF Range Finder Sensor VL53L0X with I2C peripheral. You can use this library in your projects with any Arduino compatible board with I2C peripheral.
27+
This Arduino library allows you to use Deneyap ToF Range Finder Sensor VL53L0X with I2C peripheral. You can use this library in your projects with any Arduino compatible board with I2C peripheral.
2828

2929
## :globe_with_meridians:Repository Contents
3030
- `/docs ` README_tr.md and product photos
@@ -36,6 +36,8 @@ This Arduino library allows you to use DDeneyap ToF Range Finder Sensor VL53L0X
3636
## Version History
3737
1.0.0 - initial release
3838

39+
1.0.1 - bug fix
40+
3941
## :rocket:Hardware Connections
4042
- Deneyap ToF Range Finder Sensor VL53L0X and Board can be connected with I2C cable
4143
- or 3V3, GND, SDA and SCL pins can be connected with jumper cables

docs/README_tr.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ Deneyap Derinlik Ölçer VL53L0X için Arduino kütüphanesidir.
66

77
## :mag_right:Özellikler
88
- `Ürün ID` **M06**, **mpv1.0**
9-
- `MCU` VL53L0X, STM8S003F3
9+
- `MCU` VL53L0X
1010
- `Ağırlık`
1111
- `Modul Boyutları`
1212
- `I2C Adres` 0x29
@@ -21,7 +21,7 @@ Deneyap Derinlik Ölçer VL53L0X
2121
[VL53L0X](https://www.st.com/content/ccc/resource/technical/document/datasheet/group3/b2/1e/33/77/c6/92/47/6b/DM00279086/files/DM00279086.pdf/jcr:content/translations/en.DM00279086.pdf)
2222

2323

24-
[Arduino Kütüphanesi Nasıl İndirilir](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries)
24+
[Arduino IDE'de Kütüphane Nasıl İndirilir](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries)
2525

2626
## :pushpin:Deneyap Derinlik Ölçer VL53L0X
2727
Bu Arduino kütüphanesi Deneyap Derinlik Ölçer VL53L0X'nin I2C çevre birimi ile kullanılmasını sağlar. Arduino ile uyumlu, I2C çevre birimine sahip herhangi bir geliştirme kartı ile bu kütüphaneyi projelerinizde kullanabilirsiniz.
@@ -36,9 +36,11 @@ Bu Arduino kütüphanesi Deneyap Derinlik Ölçer VL53L0X'nin I2C çevre birimi
3636
## Sürüm Geçmişi
3737
1.0.0 - ilk sürüm
3838

39+
1.0.1 - hata giderildi
40+
3941
## :rocket:Donanım Bağlantıları
4042
- Deneyap Derinlik Ölçer ile kullanılan geliştirme kartı I2C kablosu ile bağlanabilir
41-
- veya jumper kablolar ile ile 3V3, GND, SDA ve SCL bağlantıları yapılabilir.
43+
- veya jumper kablolar ile 3V3, GND, SDA ve SCL bağlantıları yapılabilir.
4244

4345
| Derinlik Ölçer | Fonksiyon| Kart pinleri |
4446
| :--- | :--- | :--- |

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Deneyap Derinlik Olcer
2-
version=1.0.0
2+
version=1.0.1
33
author=RFtek Electronics <[email protected]>
44
maintainer=Turkish Technnology Team Foundation (T3)
55
sentence=Arduino library for Deneyap ToF Range Finder Sensor VL53L0X

src/Deneyap_DerinlikOlcer.cpp

Lines changed: 80 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
@file Deneyap_DerinlikOlcer.cpp
44
@mainpage Deneyap ToF Range Finder Sensor VL53L0X Arduino library source file
55
@maintainer RFtek Electronics <[email protected]>
6-
@version v1.0.0
7-
@date June 23, 2022
6+
@version v1.0.1
7+
@date August 18, 2022
88
@brief Includes functions to control Deneyap ToF Range Finder Sensor VL53L0X
99
Arduino library
1010
@@ -18,103 +18,101 @@ Library includes:
1818
#include "Deneyap_DerinlikOlcer.h"
1919

2020
/**
21-
* @brief I2C initialization and read check
22-
* @param adress: Device adress
23-
* @retval None
24-
**/
25-
bool TofRangeFinder::begin(uint8_t address, TwoWire &wirePort) {
26-
_address = address;
27-
Wire.begin();
28-
Wire.beginTransmission(address);
29-
if (!Wire.endTransmission())
30-
return true;
31-
return false;
32-
}
21+
* @brief I2C initialization and read check
22+
* @param adress: Device adress
23+
* @retval None
24+
**/
25+
bool TofRangeFinder::begin(uint8_t i2c_addr) {
26+
uint8_t x;
27+
DevAddr = I2C_DevAddr;
28+
Wire.begin();
29+
x = read8(TofRangeFinder_REG_IDENTIFICATION_MODEL_ID);
30+
// Serial.print("Device ID: "); Serial.println(x,HEX);
31+
// Serial.println("");
32+
// if(x != 0xEE)
33+
// {
34+
// Serial.print("Read Chip ID fail!");
35+
// }
3336

34-
/**
35-
* @brief
36-
* @param
37-
* @retval
38-
**/
39-
bool TofRangeFinder::init() {
40-
begin(_address);
41-
write8(0x88, 0x00);
42-
write8(0x80, 0x01);
43-
write8(0xFF, 0x01);
44-
write8(0x00, 0x00);
45-
read8(0x91);
46-
write8(0x91, 0x3c);
47-
write8(0x00, 0x01);
48-
write8(0xFF, 0x00);
49-
write8(0x80, 0x00);
37+
write8(0x88, 0x00);
38+
write8(0x80, 0x01);
39+
write8(0xFF, 0x01);
40+
write8(0x00, 0x00);
41+
read8(0x91);
42+
write8(0x91, 0x3c);
43+
write8(0x00, 0x01);
44+
write8(0xFF, 0x00);
45+
write8(0x80, 0x00);
5046

51-
write8(0x80, 0x01);
52-
write8(0xFF, 0x01);
53-
write8(0x00, 0x00);
54-
write8(0x91, 0x3c);
55-
write8(0x00, 0x01);
56-
write8(0xFF, 0x00);
57-
write8(0x80, 0x00);
47+
write8(0x80, 0x01);
48+
write8(0xFF, 0x01);
49+
write8(0x00, 0x00);
50+
write8(0x91, 0x3c);
51+
write8(0x00, 0x01);
52+
write8(0xFF, 0x00);
53+
write8(0x80, 0x00);
5854

59-
write8(VL53L0X_REG_SYSRANGE_START, VL53L0X_REG_SYSRANGE_MODE_BACKTOBACK);
60-
return 1;
55+
write8(TofRangeFinder_REG_SYSRANGE_START, TofRangeFinder_REG_SYSRANGE_MODE_BACKTOBACK);
56+
return 1;
6157
}
6258

6359
/**
64-
* @brief
65-
* @param
66-
* @retval
67-
**/
60+
* @brief
61+
* @param
62+
* @retval
63+
**/
6864
void TofRangeFinder::write8(unsigned char Reg, unsigned char byte) {
69-
Wire.beginTransmission(_address);
70-
Wire.write(Reg);
71-
Wire.write((uint8_t)byte);
72-
Wire.endTransmission();
65+
Wire.beginTransmission(DevAddr);
66+
Wire.write(Reg);
67+
Wire.write((uint8_t)byte);
68+
Wire.endTransmission();
7369
}
7470

7571
/**
76-
* @brief
77-
* @param
78-
* @retval
79-
**/
72+
* @brief
73+
* @param
74+
* @retval
75+
**/
8076
void TofRangeFinder::readData(unsigned char Reg, unsigned char Num) {
81-
Wire.beginTransmission(_address);
82-
Wire.write((uint8_t)Reg);
83-
Wire.endTransmission();
84-
Wire.requestFrom((uint8_t)_address, (uint8_t)Num);
77+
Wire.beginTransmission(DevAddr);
78+
Wire.write((uint8_t)Reg);
79+
Wire.endTransmission();
80+
Wire.requestFrom((uint8_t)DevAddr, (uint8_t)Num);
8581

86-
for (int i = 0; i < Num; i++) {
87-
Data[i] = Wire.read();
88-
delay(1);
89-
}
82+
for (int i = 0; i < Num; i++) {
83+
Data[i] = Wire.read();
84+
delay(1);
85+
}
9086
}
9187

9288
/**
93-
* @brief
94-
* @param
95-
* @retval
96-
**/
89+
* @brief
90+
* @param
91+
* @retval
92+
**/
9793
uint8_t TofRangeFinder::read8(unsigned char Reg) {
98-
Wire.beginTransmission(_address);
99-
Wire.write((uint8_t)Reg);
100-
Wire.endTransmission();
101-
Wire.requestFrom((uint8_t)_address, (uint8_t)1);
102-
return Wire.read();
94+
95+
Wire.beginTransmission(DevAddr);
96+
Wire.write((uint8_t)Reg);
97+
Wire.endTransmission();
98+
Wire.requestFrom((uint8_t)DevAddr, (uint8_t)1);
99+
100+
return Wire.read();
103101
}
104102

105103
/**
106-
* @brief
107-
* @param
108-
* @retval
109-
**/
104+
* @brief
105+
* @param
106+
* @retval
107+
**/
110108
float TofRangeFinder::ReadDistance() {
111-
readData(VL53L0X_REG_RESULT_RANGE_STATUS, 12);
112-
distance = ((Data[10] & 0xFF) << 8) |
113-
(Data[11] & 0xFF);
114-
write8(VL53L0X_REG_SYSTEM_RANGE_CONFIG, 1);
115-
if (distance == 20)
116-
distance = _distance;
117-
else
118-
_distance = distance;
119-
return distance / 40;
120-
}
109+
readData(TofRangeFinder_REG_RESULT_RANGE_STATUS, 12);
110+
distance = ((Data[10] & 0xFF) << 8) |
111+
(Data[11] & 0xFF);
112+
write8(TofRangeFinder_REG_SYSTEM_RANGE_CONFIG, 1);
113+
if (distance == 20)
114+
distance = _distance;
115+
else
116+
_distance = distance;
117+
return distance / 40;
118+
}

src/Deneyap_DerinlikOlcer.h

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
***********************************************************************************
33
@file Deneyap_DerinlikOlcer.h
44
@mainpage Deneyap ToF Range Finder Sensor VL53L0X Arduino library header file
5-
@version v1.0.0
6-
@date June 23, 2022
5+
@version v1.0.1
6+
@date August 18, 2022
77
@brief This file contains all function prototypes and macros
88
for Deneyap ToF Range Finder Sensor VL53L0X Arduino library
99
***********************************************************************************
@@ -15,43 +15,43 @@
1515
#include <Arduino.h>
1616
#include <Wire.h>
1717

18-
#define VL53L0X_REG_IDENTIFICATION_MODEL_ID 0x00c0
19-
#define VL53L0X_REG_IDENTIFICATION_REVISION_ID 0x00c2
20-
#define VL53L0X_REG_PRE_RANGE_CONFIG_VCSEL_PERIOD 0x0050
21-
#define VL53L0X_REG_FINAL_RANGE_CONFIG_VCSEL_PERIOD 0x0070
22-
#define VL53L0X_REG_SYSRANGE_START 0x0000
23-
#define VL53L0X_REG_RESULT_INTERRUPT_STATUS 0x0013
24-
#define VL53L0X_REG_RESULT_RANGE_STATUS 0x0014
25-
#define VL53L0X_REG_I2C_SLAVE_DEVICE_ADDRESS 0x008a
26-
#define VL53L0X_I2C_ADDR 0x0029
27-
#define VL53L0X_REG_SYSTEM_RANGE_CONFIG 0x0009
28-
#define VL53L0X_REG_VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV 0x0089
29-
#define VL53L0X_REG_SYSRANGE_MODE_SINGLESHOT 0x0000
30-
#define VL53L0X_REG_SYSRANGE_MODE_START_STOP 0x0001
31-
#define VL53L0X_REG_SYSRANGE_MODE_BACKTOBACK 0x0002
32-
#define VL53L0X_REG_SYSRANGE_MODE_TIMED 0x0004
33-
34-
#define VL53L0X_DEVICEMODE_SINGLE_RANGING ((uint8_t)0)
35-
#define VL53L0X_DEVICEMODE_CONTINUOUS_RANGING ((uint8_t)1)
36-
#define VL53L0X_DEVICEMODE_CONTINUOUS_TIMED_RANGING ((uint8_t)3)
37-
#define VL53L0X_DEFAULT_MAX_LOOP 200
18+
#define TofRangeFinder_REG_IDENTIFICATION_MODEL_ID 0x00c0
19+
#define TofRangeFinder_REG_IDENTIFICATION_REVISION_ID 0x00c2
20+
#define TofRangeFinder_REG_PRE_RANGE_CONFIG_VCSEL_PERIOD 0x0050
21+
#define TofRangeFinder_REG_FINAL_RANGE_CONFIG_VCSEL_PERIOD 0x0070
22+
#define TofRangeFinder_REG_SYSRANGE_START 0x0000
23+
#define TofRangeFinder_REG_RESULT_INTERRUPT_STATUS 0x0013
24+
#define TofRangeFinder_REG_RESULT_RANGE_STATUS 0x0014
25+
#define TofRangeFinder_REG_I2C_SLAVE_DEVICE_ADDRESS 0x008a
26+
#define TofRangeFinder_I2C_ADDR 0x0029
27+
#define TofRangeFinder_REG_SYSTEM_RANGE_CONFIG 0x0009
28+
#define TofRangeFinder_REG_VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV 0x0089
29+
#define TofRangeFinder_REG_SYSRANGE_MODE_SINGLESHOT 0x0000
30+
#define TofRangeFinder_REG_SYSRANGE_MODE_START_STOP 0x0001
31+
#define TofRangeFinder_REG_SYSRANGE_MODE_BACKTOBACK 0x0002
32+
#define TofRangeFinder_REG_SYSRANGE_MODE_TIMED 0x0004
33+
34+
#define TofRangeFinder_DEVICEMODE_SINGLE_RANGING ((uint8_t)0)
35+
#define TofRangeFinder_DEVICEMODE_CONTINUOUS_RANGING ((uint8_t)1)
36+
#define TofRangeFinder_DEVICEMODE_CONTINUOUS_TIMED_RANGING ((uint8_t)3)
37+
#define TofRangeFinder_DEFAULT_MAX_LOOP 200
38+
39+
#define I2C_DevAddr 0x29
3840

3941
class TofRangeFinder {
4042
public:
41-
bool begin(uint8_t address, TwoWire &wirePort = Wire);
42-
bool init();
43-
float ReadDistance();
43+
bool begin(uint8_t i2c_addr);
44+
float ReadDistance();
4445

4546
private:
46-
uint8_t _address;
47-
uint16_t _distance;
48-
void write8(unsigned char Reg, unsigned char byte);
49-
uint8_t read8(unsigned char Reg);
50-
void readData(unsigned char Reg, unsigned char Num);
51-
52-
unsigned char DevAddr;
53-
unsigned char Data[16];
54-
uint16_t distance;
47+
uint16_t _distance;
48+
void write8(unsigned char Reg, unsigned char byte);
49+
uint8_t read8(unsigned char Reg);
50+
void readData(unsigned char Reg, unsigned char Num);
51+
52+
unsigned char DevAddr;
53+
unsigned char Data[16];
54+
uint16_t distance;
5555
};
5656

5757
#endif

0 commit comments

Comments
 (0)