Skip to content

Commit eabf792

Browse files
committed
update library function
1 parent 0c6152c commit eabf792

File tree

7 files changed

+102
-98
lines changed

7 files changed

+102
-98
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Deneyap ToF Range Finder Sensor VL53L0X Arduino Library
1+
# Deneyap ToF Range Finder Sensor Arduino Library
22
[FOR TURKISH VERSION](docs/README_tr.md) ![trflag](https://github.com/deneyapkart/deneyapkart-arduino-core/blob/master/docs/tr.png)
33

44
***** Add photo ****
@@ -7,23 +7,27 @@ Arduino library for Deneyap ToF Range Finder Sensor VL53L0X
77

88
## :mag_right:Specifications
99
- `Product ID` **M06**, **mpv1.0**
10-
- `MCU` VL53L0X
10+
- `MCU` ST Microelectronics VL53L0CXV0DH/1
1111
- `Weight`
12-
- `Module Dimension`
12+
- `Module Dimension` 25,4 mm x 25,4 mm
1313
- `I2C address` 0x29
1414

1515
| Address | |
1616
| :--- | :--- |
1717
| 0x29 | default address |
1818

1919
## :closed_book:Documentation
20-
Deneyap ToF Range Finder Sensor VL53L0X
20+
[Deneyap ToF Range Finder Sensor](https://docs.deneyapkart.org/en/content/contentDetail/deneyap-module-deneyap-tof-m03)
2121

22-
[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)
22+
[Deneyap ToF Range Finder Sensor Shematic](https://cdn.deneyapkart.org/media/upload/userFormUpload/2BzP7yaI6mR6uKiXusAbPDFn6WJYzYyN.pdf)
23+
24+
[Deneyap ToF Range Finder Sensor Mechanical Drawing](https://cdn.deneyapkart.org/media/upload/userFormUpload/N7QALHBGi8NnzE6OPQASMRvJpT15uQDI.pdf)
25+
26+
[VL53L0X-dataheet](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)
2327

2428
[How to install a Arduino Library](https://docs.arduino.cc/software/ide-v1/tutorials/installing-libraries)
2529

26-
## :pushpin:Deneyap ToF Range Finder Sensor VL53L0X
30+
## :pushpin:Deneyap ToF Range Finder Sensor
2731
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.
2832

2933
## :globe_with_meridians:Repository Contents
@@ -34,12 +38,14 @@ This Arduino library allows you to use Deneyap ToF Range Finder Sensor VL53L0X w
3438
- `library.properties ` General library properties for the Arduino package manager
3539

3640
## Version History
37-
1.0.0 - initial release
41+
1.0.2 - update library function(`begin`)
3842

3943
1.0.1 - bug fix
4044

45+
1.0.0 - initial release
46+
4147
## :rocket:Hardware Connections
42-
- Deneyap ToF Range Finder Sensor VL53L0X and Board can be connected with I2C cable
48+
- Deneyap ToF Range Finder Sensor and Board can be connected with I2C cable
4349
- or 3V3, GND, SDA and SCL pins can be connected with jumper cables
4450

4551
|ToF Range Finder| Function | Board pins |

docs/README_tr.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
1-
# Deneyap Derinlik Ölçer VL53L0X Arduino Kütüphanesi
1+
# Deneyap Derinlik Ölçer Arduino Kütüphanesi
22

33
***** Fotoğraf eklenecek ****
44

55
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
9+
- `MCU` ST Microelectronics VL53L0CXV0DH/1
1010
- `Ağırlık`
11-
- `Modul Boyutları`
11+
- `Modul Boyutları` 25,4 mm x 25,4 mm
1212
- `I2C Adres` 0x29
1313

1414
| Adres | |
1515
| :--- | :--- |
1616
| 0x29 | varsayılan adres |
1717

1818
## :closed_book:Dokümanlar
19-
Deneyap Derinlik Ölçer VL53L0X
19+
[Deneyap Derinlik Ölçer](https://docs.deneyapkart.org/tr/content/contentDetail/deneyap-module-deneyap-tof-m03)
2020

21-
[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)
21+
[Deneyap Derinlik Ölçer Şematik](https://cdn.deneyapkart.org/media/upload/userFormUpload/2BzP7yaI6mR6uKiXusAbPDFn6WJYzYyN.pdf)
2222

23+
[Deneyap Derinlik Ölçer Teknik Resim](https://cdn.deneyapkart.org/media/upload/userFormUpload/N7QALHBGi8NnzE6OPQASMRvJpT15uQDI.pdf)
24+
25+
[VL53L0X-dataheet](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)
2326

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

26-
## :pushpin:Deneyap Derinlik Ölçer VL53L0X
27-
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.
29+
## :pushpin:Deneyap Derinlik Ölçer
30+
Bu Arduino kütüphanesi Deneyap Derinlik Ölçer'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.
2831

2932
## :globe_with_meridians:Repo İçeriği
3033
- `/docs` README_tr.md ve ürün fotoğrafları
@@ -34,20 +37,22 @@ Bu Arduino kütüphanesi Deneyap Derinlik Ölçer VL53L0X'nin I2C çevre birimi
3437
- `library.properties` Arduino yöneticisi için genel kütüphane özellikleri
3538

3639
## Sürüm Geçmişi
37-
1.0.0 - ilk sürüm
40+
1.0.2 - kütüphane fonksiyonu(`begin`) güncellendi
3841

3942
1.0.1 - hata giderildi
4043

44+
1.0.0 - ilk sürüm
45+
4146
## :rocket:Donanım Bağlantıları
4247
- Deneyap Derinlik Ölçer ile kullanılan geliştirme kartı I2C kablosu ile bağlanabilir
4348
- veya jumper kablolar ile 3V3, GND, SDA ve SCL bağlantıları yapılabilir.
4449

4550
| Derinlik Ölçer | Fonksiyon| Kart pinleri |
4651
| :--- | :--- | :--- |
47-
| 3.3V | Güç | 3.3V |
52+
| 3.3V |3.3V Besleme Gerilimi| 3.3V |
4853
| GND | Toprak |GND |
49-
| SDA | I2C Data | SDA pini |
50-
| SCL | I2C Clock | SCL pini|
54+
| SDA |Çift Yönlü Veri Hattı| SDA pini |
55+
| SCL |Veri Hattı Zaman Senkronizasyon İşaret| SCL pini|
5156
| XSHT | Shut Down | |
5257
| GPIO | Çıktı Kesmesi | |
5358

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,25 @@
11
/*
2-
* Derinlik Ölçme örneği,
3-
*
2+
* DerinlikOlcme örneği,
43
* Bu örnekte temel konfigürasyon ayarları yapılmaktadır.
5-
* Sensörden gelen mesafe verilerini okumaktadır. Mesafe verilerini seri terminale yazdırmaktadır.
4+
* Sensörden gelen mesafe verilerini okumaktadır. Mesafe verilerini seri port ekranına yazdırmaktadır.
65
*
76
* Bu algılayıcı I2C haberleşme protokolü ile çalışmaktadır.
87
*
98
* Bu örnek Deneyap Derinlik Ölçer için oluşturulmuştur
10-
* ------> www.....com <------ //docs
11-
* ------> https://github.com/deneyapkart/deneyap-derinlik-olcer-arduino-library <------
12-
*
9+
* ------> https://docs.deneyapkart.org/tr/content/contentDetail/deneyap-module-deneyap-tof-m03 <------
10+
* ------> https://github.com/deneyapkart/deneyap-derinlik-olcer-arduino-library <------
1311
*/
14-
#include <Deneyap_DerinlikOlcer.h> // Deneyap_DerinlikOlcer.h kütüphanesi eklenmesi
12+
#include <Deneyap_DerinlikOlcer.h> // Deneyap Derinlik Ölçer kütüphanesi eklenmesi
1513

16-
TofRangeFinder Mesafe; // TofRangeFinder için class tanımlanması
14+
TofRangeFinder TofRangeFinder; // TofRangeFinder için class tanımlanması
1715

1816
void setup() {
19-
Serial.begin(115200); // Seri haberleşme başlatılması
20-
if (!Mesafe.begin(0x29)) { // begin(slaveAdress) fonksiyonu ile cihazların haberleşmesi başlatılması
21-
Serial.println("VL53L0X I2C bağlantısı başarısız "); // I2C bağlantısı başarısız olursa seri terminale yazdırılması
22-
while(1);
23-
}
17+
Serial.begin(115200); // Seri haberleşme başlatılması
18+
TofRangeFinder.begin(0x29); // begin(slaveAdress) fonksiyonu ile cihazların haberleşmesi başlatılması
2419
}
2520

2621
void loop() {
27-
Serial.print("Uzaklık: ");
28-
Serial.println(Mesafe.ReadDistance()); // Ölçüm yapılması ve Seri Terminale veri gönderilmesi
29-
delay(50);
30-
}
22+
Serial.print("Derinlik: ");
23+
Serial.println(TofRangeFinder.ReadDistance()); // Derinliğin okunması ve seri port ekranına yazdırılması
24+
delay(50); // 50 milisaniye bekleme süresi
25+
}

keywords.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ TofRangeFinder KEYWORD1
1818
# Methods and Functions (KEYWORD2)
1919
#######################################
2020
begin KEYWORD2
21-
init KEYWORD2
2221
ReadDistance KEYWORD2
2322

2423
#######################################

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.1
2+
version=1.0.2
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: 33 additions & 35 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.1
7-
@date August 18, 2022
6+
@version v1.0.2
7+
@date September 21, 2022
88
@brief Includes functions to control Deneyap ToF Range Finder Sensor VL53L0X
99
Arduino library
1010
@@ -22,47 +22,45 @@ Library includes:
2222
* @param adress: Device adress
2323
* @retval None
2424
**/
25-
bool TofRangeFinder::begin(uint8_t i2c_addr) {
26-
uint8_t x;
27-
DevAddr = I2C_DevAddr;
25+
void TofRangeFinder::begin(uint8_t address, TwoWire &wirePort) {
26+
_address = address;
2827
Wire.begin();
29-
x = read8(TofRangeFinder_REG_IDENTIFICATION_MODEL_ID);
28+
//uint8_t x = readRegister(IDENTIFICATION_MODEL_ID);
3029
// Serial.print("Device ID: "); Serial.println(x,HEX);
3130
// Serial.println("");
32-
// if(x != 0xEE)
33-
// {
31+
// if(x != 0xEE) {
3432
// Serial.print("Read Chip ID fail!");
3533
// }
3634

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);
35+
writeRegister(0x88, 0x00);
36+
writeRegister(0x80, 0x01);
37+
writeRegister(0xFF, 0x01);
38+
writeRegister(0x00, 0x00);
39+
readRegister(0x91);
40+
writeRegister(0x91, 0x3c);
41+
writeRegister(0x00, 0x01);
42+
writeRegister(0xFF, 0x00);
43+
writeRegister(0x80, 0x00);
4644

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);
45+
writeRegister(0x80, 0x01);
46+
writeRegister(0xFF, 0x01);
47+
writeRegister(0x00, 0x00);
48+
writeRegister(0x91, 0x3c);
49+
writeRegister(0x00, 0x01);
50+
writeRegister(0xFF, 0x00);
51+
writeRegister(0x80, 0x00);
5452

55-
write8(TofRangeFinder_REG_SYSRANGE_START, TofRangeFinder_REG_SYSRANGE_MODE_BACKTOBACK);
56-
return 1;
53+
writeRegister(SYSRANGE_START, SYSRANGE_MODE_BACKTOBACK);
54+
//return true;
5755
}
5856

5957
/**
6058
* @brief
6159
* @param
6260
* @retval
6361
**/
64-
void TofRangeFinder::write8(unsigned char Reg, unsigned char byte) {
65-
Wire.beginTransmission(DevAddr);
62+
void TofRangeFinder::writeRegister(unsigned char Reg, unsigned char byte) {
63+
Wire.beginTransmission(_address);
6664
Wire.write(Reg);
6765
Wire.write((uint8_t)byte);
6866
Wire.endTransmission();
@@ -74,10 +72,10 @@ void TofRangeFinder::write8(unsigned char Reg, unsigned char byte) {
7472
* @retval
7573
**/
7674
void TofRangeFinder::readData(unsigned char Reg, unsigned char Num) {
77-
Wire.beginTransmission(DevAddr);
75+
Wire.beginTransmission(_address);
7876
Wire.write((uint8_t)Reg);
7977
Wire.endTransmission();
80-
Wire.requestFrom((uint8_t)DevAddr, (uint8_t)Num);
78+
Wire.requestFrom((uint8_t)_address, (uint8_t)Num);
8179

8280
for (int i = 0; i < Num; i++) {
8381
Data[i] = Wire.read();
@@ -90,12 +88,12 @@ void TofRangeFinder::readData(unsigned char Reg, unsigned char Num) {
9088
* @param
9189
* @retval
9290
**/
93-
uint8_t TofRangeFinder::read8(unsigned char Reg) {
91+
uint8_t TofRangeFinder::readRegister(unsigned char Reg) {
9492

95-
Wire.beginTransmission(DevAddr);
93+
Wire.beginTransmission(_address);
9694
Wire.write((uint8_t)Reg);
9795
Wire.endTransmission();
98-
Wire.requestFrom((uint8_t)DevAddr, (uint8_t)1);
96+
Wire.requestFrom((uint8_t)_address, (uint8_t)1);
9997

10098
return Wire.read();
10199
}
@@ -106,10 +104,10 @@ uint8_t TofRangeFinder::read8(unsigned char Reg) {
106104
* @retval
107105
**/
108106
float TofRangeFinder::ReadDistance() {
109-
readData(TofRangeFinder_REG_RESULT_RANGE_STATUS, 12);
107+
readData(RESULT_RANGE_STATUS, 12);
110108
distance = ((Data[10] & 0xFF) << 8) |
111109
(Data[11] & 0xFF);
112-
write8(TofRangeFinder_REG_SYSTEM_RANGE_CONFIG, 1);
110+
writeRegister(SYSTEM_RANGE_CONFIG, 1);
113111
if (distance == 20)
114112
distance = _distance;
115113
else

src/Deneyap_DerinlikOlcer.h

Lines changed: 26 additions & 25 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.1
6-
@date August 18, 2022
5+
@version v1.0.2
6+
@date September 21, 2022
77
@brief This file contains all function prototypes and macros
88
for Deneyap ToF Range Finder Sensor VL53L0X Arduino library
99
***********************************************************************************
@@ -15,38 +15,39 @@
1515
#include <Arduino.h>
1616
#include <Wire.h>
1717

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
18+
#define IDENTIFICATION_MODEL_ID 0x00c0
19+
#define IDENTIFICATION_REVISION_ID 0x00c2
20+
#define PRE_RANGE_CONFIG_VCSEL_PERIOD 0x0050
21+
#define FINAL_RANGE_CONFIG_VCSEL_PERIOD 0x0070
22+
#define SYSRANGE_START 0x0000
23+
#define RESULT_INTERRUPT_STATUS 0x0013
24+
#define RESULT_RANGE_STATUS 0x0014
25+
#define I2C_SLAVE_DEVICE_ADDRESS 0x008a
26+
#define I2C_ADDR 0x0029
27+
#define SYSTEM_RANGE_CONFIG 0x0009
28+
#define VHV_CONFIG_PAD_SCL_SDA__EXTSUP_HV 0x0089
29+
#define SYSRANGE_MODE_SINGLESHOT 0x0000
30+
#define SYSRANGE_MODE_START_STOP 0x0001
31+
#define SYSRANGE_MODE_BACKTOBACK 0x0002
32+
#define SYSRANGE_MODE_TIMED 0x0004
33+
34+
#define DEVICEMODE_SINGLE_RANGING ((uint8_t)0)
35+
#define DEVICEMODE_CONTINUOUS_RANGING ((uint8_t)1)
36+
#define DEVICEMODE_CONTINUOUS_TIMED_RANGING ((uint8_t)3)
37+
#define DEFAULT_MAX_LOOP 200
3838

3939
#define I2C_DevAddr 0x29
4040

4141
class TofRangeFinder {
4242
public:
43-
bool begin(uint8_t i2c_addr);
43+
void begin(uint8_t address, TwoWire &wirePort = Wire);
4444
float ReadDistance();
4545

4646
private:
47+
uint8_t _address;
4748
uint16_t _distance;
48-
void write8(unsigned char Reg, unsigned char byte);
49-
uint8_t read8(unsigned char Reg);
49+
void writeRegister(unsigned char Reg, unsigned char byte);
50+
uint8_t readRegister(unsigned char Reg);
5051
void readData(unsigned char Reg, unsigned char Num);
5152

5253
unsigned char DevAddr;

0 commit comments

Comments
 (0)