mirror of
https://github.com/Show-maket/IR-protocol.git
synced 2025-06-28 05:09:40 +00:00
Compare commits
1 Commits
AVR-Point_
...
main
Author | SHA1 | Date | |
---|---|---|---|
37522f974f |
@ -18,8 +18,6 @@
|
|||||||
#define INFO "IR_FOX TEST"
|
#define INFO "IR_FOX TEST"
|
||||||
#define SERIAL_SPEED 115200
|
#define SERIAL_SPEED 115200
|
||||||
|
|
||||||
constexpr uint8_t cmd_for_car = CarCmd::stop_Tmp_H_S; // <<<<<<<<< CMD FOR CAR
|
|
||||||
|
|
||||||
//////////////// Var /////////////////
|
//////////////// Var /////////////////
|
||||||
|
|
||||||
IR_Decoder decForward(2, 555);
|
IR_Decoder decForward(2, 555);
|
||||||
@ -193,9 +191,6 @@ void setup() {
|
|||||||
bool testLed = false;
|
bool testLed = false;
|
||||||
uint32_t testLed_timer;
|
uint32_t testLed_timer;
|
||||||
|
|
||||||
bool responsponse_f = false;
|
|
||||||
uint32_t responsponse_tim;;
|
|
||||||
|
|
||||||
void loop() {
|
void loop() {
|
||||||
// digitalToggle(LoopOut);
|
// digitalToggle(LoopOut);
|
||||||
Timer::tick();
|
Timer::tick();
|
||||||
@ -233,11 +228,7 @@ void loop() {
|
|||||||
if(testLed && millis() - testLed_timer > 100){
|
if(testLed && millis() - testLed_timer > 100){
|
||||||
testLed=false;
|
testLed=false;
|
||||||
digitalWrite(12, LOW);
|
digitalWrite(12, LOW);
|
||||||
}
|
|
||||||
|
|
||||||
if(responsponse_f && millis() - responsponse_tim > 100) {
|
|
||||||
responsponse_f=false;
|
|
||||||
encForward.sendData(IR_Broadcast, cmd_for_car);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -246,6 +237,7 @@ void loop() {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//test
|
//test
|
||||||
void status(IR_Decoder& dec) {
|
void status(IR_Decoder& dec) {
|
||||||
if (dec.gotData.available() && dec.gotData.getAddrFrom() != 42) {
|
if (dec.gotData.available() && dec.gotData.getAddrFrom() != 42) {
|
||||||
@ -254,8 +246,8 @@ void status(IR_Decoder& dec) {
|
|||||||
testLed = true;
|
testLed = true;
|
||||||
testLed_timer = millis();
|
testLed_timer = millis();
|
||||||
|
|
||||||
responsponse_f = true;
|
encForward.sendData(IR_Broadcast, CarCmd::stop); //<<<<<<<<<<<<<<<<<<<<<<<<<<< CMD IS HERE
|
||||||
responsponse_tim = testLed_timer;
|
|
||||||
|
|
||||||
String str;
|
String str;
|
||||||
if (/* dec.gotData.getDataPrt()[1] */1) {
|
if (/* dec.gotData.getDataPrt()[1] */1) {
|
||||||
|
@ -48,7 +48,10 @@ void IR_Encoder::sendData(uint16_t addrTo, uint8_t dataByte, bool needAccept = f
|
|||||||
delete[] dataPtr;
|
delete[] dataPtr;
|
||||||
}
|
}
|
||||||
|
|
||||||
void IR_Encoder::sendData(uint16_t addrTo, uint8_t *data = nullptr, uint8_t len = 0, bool needAccept = false)
|
void IR_Encoder::sendData(uint16_t addrTo, uint8_t *data = nullptr, uint8_t len = 0, bool needAccept = false){
|
||||||
|
sendData(id, addrTo, data, len, needAccept);
|
||||||
|
}
|
||||||
|
void IR_Encoder::sendData(uint16_t addrFrom, uint16_t addrTo, uint8_t *data = nullptr, uint8_t len = 0, bool needAccept = false)
|
||||||
{
|
{
|
||||||
if (len > bytePerPack)
|
if (len > bytePerPack)
|
||||||
{
|
{
|
||||||
@ -65,8 +68,8 @@ void IR_Encoder::sendData(uint16_t addrTo, uint8_t *data = nullptr, uint8_t len
|
|||||||
sendBuffer[0] = msgType;
|
sendBuffer[0] = msgType;
|
||||||
|
|
||||||
// addr_self
|
// addr_self
|
||||||
sendBuffer[1] = id >> 8 & 0xFF;
|
sendBuffer[1] = addrFrom >> 8 & 0xFF;
|
||||||
sendBuffer[2] = id & 0xFF;
|
sendBuffer[2] = addrFrom & 0xFF;
|
||||||
|
|
||||||
// addr_to
|
// addr_to
|
||||||
sendBuffer[3] = addrTo >> 8 & 0xFF;
|
sendBuffer[3] = addrTo >> 8 & 0xFF;
|
||||||
|
@ -4,13 +4,13 @@
|
|||||||
// TODO: Отложенная передача после завершения приема
|
// TODO: Отложенная передача после завершения приема
|
||||||
|
|
||||||
class IR_DecoderRaw;
|
class IR_DecoderRaw;
|
||||||
class IR_Encoder : IR_FOX
|
class IR_Encoder : public IR_FOX
|
||||||
{
|
{
|
||||||
friend IR_DecoderRaw;
|
friend IR_DecoderRaw;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
private:
|
private:
|
||||||
uint16_t id; /// @brief Адрес передатчика
|
// uint16_t id; /// @brief Адрес передатчика
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/// @brief Класс передатчика
|
/// @brief Класс передатчика
|
||||||
@ -49,6 +49,7 @@ public:
|
|||||||
|
|
||||||
void sendData(uint16_t addrTo, uint8_t dataByte, bool needAccept = false);
|
void sendData(uint16_t addrTo, uint8_t dataByte, bool needAccept = false);
|
||||||
void sendData(uint16_t addrTo, uint8_t *data = nullptr, uint8_t len = 0, bool needAccept = false);
|
void sendData(uint16_t addrTo, uint8_t *data = nullptr, uint8_t len = 0, bool needAccept = false);
|
||||||
|
void sendData(uint16_t addrFrom, uint16_t addrTo, uint8_t *data = nullptr, uint8_t len = 0, bool needAccept = false);
|
||||||
|
|
||||||
void sendAccept(uint16_t addrTo, uint8_t customByte = 0);
|
void sendAccept(uint16_t addrTo, uint8_t customByte = 0);
|
||||||
void sendRequest(uint16_t addrTo);
|
void sendRequest(uint16_t addrTo);
|
||||||
|
Reference in New Issue
Block a user