Skip to content

Commit 6b0165a

Browse files
committed
updated library
- added new function(I2C_ReadFirmwareData16bit) - updated function(getFwVersion) - updated comment line in examples
1 parent 9420966 commit 6b0165a

File tree

7 files changed

+52
-22
lines changed

7 files changed

+52
-22
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ This Arduino library allows you to use Deneyap Infrarad Receiver Transmitter wit
4343
- `library.properties ` General library properties for the Arduino package manager
4444

4545
## Version History
46+
1.0.2 - added new function(I2C_ReadFirmwareData16bit), updated function(getFwVersion) and comment lines
47+
4648
1.0.1 - changed example file names (KizilOtesiAlici -> KizilotesiAlici, KizilOtesiVerici -> KizilotesiVerici )
4749

4850
1.0.0 - initial release

docs/README_tr.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Bu Arduino kütüphanesi Deneyap Kızılötesi Alıcı&Verici'nin I2C çevre bir
4242
- `library.properties` Arduino yöneticisi için genel kütüphane özellikleri
4343

4444
## Sürüm Geçmişi
45+
1.0.2 - yeni fonksiyon eklendi(I2C_ReadFirmwareData16bit), fonksiyon güncellendi(getFwVersion), yorum satırları güncellendi
46+
4547
1.0.1 - örnek uygulama dosyalarının isimleri değiştirildi (KizilOtesiAlici -> KizilotesiAlici, KizilOtesiVerici -> KizilotesiVerici )
4648

4749
1.0.0 - ilk sürüm
Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
/*
22
* Kızılötesi alıcı örneği,
3-
*
43
* Bu örnekte temel konfigürasyon ayarları yapılmaktadır.
5-
* Kızılötesi alıcıdan gelen veriyi seri terminale yazdırmaktadır.
4+
* Kızılötesi alıcıdan gelen veriyi 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 Kızılötesi Alıcı&Verici için oluşturulmuştur
109
* ------> https://docs.deneyapkart.org/tr/content/contentDetail/deneyap-modul-deneyap-kzlotesi-alc-ve-verici-m53 <------
1110
* ------> https://github.com/deneyapkart/deneyap-kizilotesi-alici-verici-arduino-library <------
12-
*
13-
*/
11+
*/
1412
#include <Deneyap_KizilotesiAliciVerici.h> // Deneyap Kızılötesi Alıcı&Verici kutuphanesi eklenmesi
1513

1614
Transceiver IR; // Transceiver için class tanımlaması
@@ -20,11 +18,11 @@ void setup() {
2018
if (!IR.begin(0x22)) { // begin(slaveAdress) fonksiyonu ile cihazların haberleşmesi başlatılması
2119
delay(3000);
2220
Serial.println("I2C bağlantısı başarısız "); // I2C bağlantısı başarısız olursa seri monitore yazdırılması
23-
while (1) ;
21+
while (1);
2422
}
2523
}
2624

2725
void loop() {
28-
IR.transceiverRead(); // Alıcıdan alınan veri seri terminale yazdırıldı
26+
IR.transceiverRead(); // Alıcıdan alınan veri seri port ekranına yazdırılması
2927
delay(100); // Veri alındıktan sonra 100 ms beklemesi gerekmektedir
3028
}

examples/KizilotesiVerici/KizilotesiVerici.ino

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
/*
22
* Kızılötesi verici örneği,
3-
*
43
* Bu örnekte temel konfigürasyon ayarları yapılmaktadır.
54
* Kızılötesi alıcı butona basıldığında seçilen veriyi göndermektedir.
65
*
@@ -9,8 +8,7 @@
98
* Bu örnek Deneyap Kızılötesi Alıcı&Verici için oluşturulmuştur
109
* ------> https://docs.deneyapkart.org/tr/content/contentDetail/deneyap-modul-deneyap-kzlotesi-alc-ve-verici-m53 <------
1110
* ------> https://github.com/deneyapkart/deneyap-kizilotesi-alici-verici-arduino-library <------
12-
*
13-
*/
11+
*/
1412
#include <Deneyap_KizilotesiAliciVerici.h> // Deneyap Kızılötesi Alıcı&Verici kutuphanesi eklenmesi
1513

1614
Transceiver IR; // Transceiver için class tanımlaması

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=Deneyap Kizilotesi Alici Verici
2-
version=1.0.1
2+
version=1.0.2
33
author=Turkish Technnology Team Foundation (T3)
44
maintainer=Turkish Technnology Team Foundation (T3)
55
sentence=Arduino library for Deneyap Infrarad Receiver Transmitter

src/Deneyap_KizilotesiAliciVerici.cpp

Lines changed: 34 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
/*
22
*****************************************************************************
3-
@file Deneyap_KizilOtesiAliciVerici.cpp
3+
@file Deneyap_KizilotesiAliciVerici.cpp
44
@mainpage Deneyap Infrarad Receiver Transmitter Arduino library source file
55
@maintainer RFtek Electronics <[email protected]>
6-
@version v1.0.0
7-
@date June 29, 2022
6+
@version v1.0.2
7+
@date November 07, 2022
88
@brief Includes functions to controlDeneyap Infrarad Receiver Transmitter
99
Arduino library
1010
@@ -26,8 +26,12 @@ Library includes:
2626
*/
2727
bool Transceiver::begin(uint8_t address, TwoWire &port) {
2828
Wire.begin();
29+
#if defined(ARDUINO_DYM)
30+
Wire.setClock(100000);
31+
#else
2932
Wire.setClock(50000);
30-
_i2cAddress = address;
33+
#endif
34+
_i2cAddress = address;
3135
_i2cPort = &port;
3236
_dataPacket = {0};
3337

@@ -55,7 +59,7 @@ bool Transceiver::isConnected() {
5559
uint16_t Transceiver::getFwVersion() {
5660
_dataPacket.command = TRANSCEIVER_REQUEST_FW_VERSION;
5761
_dataPacket.dataSize = 0;
58-
return I2C_ReadData16bit(&_dataPacket);
62+
return I2C_ReadFirmwareData16bit(&_dataPacket);
5963
}
6064

6165
/**
@@ -164,6 +168,11 @@ uint8_t Transceiver::I2C_ReadData(Transceiver_DataPacket_TypeDef *dataPacket) {
164168
return 1;
165169
}
166170

171+
/**
172+
* @brief Reads 8bit data from I2C interface
173+
* @param dataPacket: includes protocol to request data
174+
* @retval I2C 8bit data
175+
*/
167176
uint8_t Transceiver::I2C_ReadData8bit(Transceiver_DataPacket_TypeDef *dataPacket) {
168177
_i2cPort->beginTransmission(_i2cAddress);
169178
_i2cPort->write(dataPacket->command);
@@ -179,8 +188,7 @@ uint8_t Transceiver::I2C_ReadData8bit(Transceiver_DataPacket_TypeDef *dataPacket
179188
* @param dataPacket: includes protocol to request data
180189
* @retval I2C 16bit data
181190
*/
182-
uint16_t Transceiver::I2C_ReadData16bit(Transceiver_DataPacket_TypeDef *dataPacket)
183-
{
191+
uint16_t Transceiver::I2C_ReadData16bit(Transceiver_DataPacket_TypeDef *dataPacket) {
184192
_i2cPort->beginTransmission(_i2cAddress);
185193
_i2cPort->write(dataPacket->command);
186194
_i2cPort->endTransmission();
@@ -193,6 +201,24 @@ uint16_t Transceiver::I2C_ReadData16bit(Transceiver_DataPacket_TypeDef *dataPack
193201
return 0;
194202
}
195203

204+
/**
205+
* @brief Reads 16bit data from I2C interface
206+
* @param dataPacket: includes protocol to request data
207+
* @retval I2C 16bit data
208+
*/
209+
uint16_t Transceiver::I2C_ReadFirmwareData16bit(Transceiver_DataPacket_TypeDef *dataPacket) {
210+
_i2cPort->beginTransmission(_i2cAddress);
211+
_i2cPort->write(dataPacket->command);
212+
_i2cPort->endTransmission();
213+
214+
if (_i2cPort->requestFrom(_i2cAddress, static_cast<uint8_t>(2)) != 0) {
215+
i2cData2 = _i2cPort->read();
216+
i2cData1 = _i2cPort->read();
217+
Serial.print("v"); Serial.print(i2cData1); Serial.print("."); Serial.println(i2cData2);
218+
}
219+
return 0;
220+
}
221+
196222
/**
197223
* @brief Sends data packet based on a custom defined protocol
198224
* @param dataPacket: includes all related data
@@ -209,4 +235,4 @@ bool Transceiver::I2C_SendDataPacket(Transceiver_DataPacket_TypeDef *dataPacket)
209235
if (_i2cPort->endTransmission() == 0)
210236
return true;
211237
return false;
212-
}
238+
}

src/Deneyap_KizilotesiAliciVerici.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
/*
22
*****************************************************************************
3-
@file Deneyap_KizilOtesiAliciVerici.h
3+
@file Deneyap_KizilotesiAliciVerici.h
44
@mainpage Deneyap Infrarad Receiver Transmitter Arduino library header file
5-
@version v1.0.0
6-
@date June 29, 2022
5+
@version v1.0.2
6+
@date November 07, 2022
77
@brief This file contains all function prototypes and macros
88
for Deneyap Infrarad Receiver Transmitter Arduino library
99
*****************************************************************************
@@ -54,6 +54,9 @@ class Transceiver {
5454
uint32_t transceiverRead();
5555
bool transceiverWrite(uint8_t data, uint8_t address = 0x44);
5656

57+
uint8_t i2cData2;
58+
uint8_t i2cData1;
59+
5760
private:
5861
TwoWire *_i2cPort; // Port selection (0 or 1)
5962
uint8_t _i2cAddress; // Device I2C address
@@ -63,7 +66,8 @@ class Transceiver {
6366
uint8_t I2C_ReadData(Transceiver_DataPacket_TypeDef *dataPacket);
6467
uint8_t I2C_ReadData8bit(Transceiver_DataPacket_TypeDef *dataPacket);
6568
uint16_t I2C_ReadData16bit(Transceiver_DataPacket_TypeDef *dataPacket);
69+
uint16_t I2C_ReadFirmwareData16bit(Transceiver_DataPacket_TypeDef *dataPacket);
6670
bool I2C_SendDataPacket(Transceiver_DataPacket_TypeDef *dataPacket);
6771
};
6872

69-
#endif /* __Deneyap_KizilotesiAliciVerici_H */
73+
#endif /* __Deneyap_KizilotesiAliciVerici_H */

0 commit comments

Comments
 (0)