STM First Test

This commit is contained in:
2024-04-16 15:52:59 +03:00
parent ff306e7fae
commit 27a5b28a17
6 changed files with 375 additions and 297 deletions

View File

@ -5,7 +5,7 @@
#define ISR_Out 10
#define TestOut 13
IR_Encoder::IR_Encoder(uint16_t addr, IR_DecoderRaw *decPair = nullptr)
IR_Encoder::IR_Encoder(uint16_t addr, IR_DecoderRaw *decPair)
{
id = addr;
this->decPair = decPair;
@ -40,7 +40,7 @@ IR_Encoder::~IR_Encoder()
delete[] bitHigh;
};
void IR_Encoder::sendData(uint16_t addrTo, uint8_t dataByte, bool needAccept = false)
void IR_Encoder::sendData(uint16_t addrTo, uint8_t dataByte, bool needAccept)
{
uint8_t *dataPtr = new uint8_t[1];
dataPtr[0] = dataByte;
@ -48,7 +48,7 @@ void IR_Encoder::sendData(uint16_t addrTo, uint8_t dataByte, bool needAccept = f
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, uint8_t len, bool needAccept)
{
if (len > bytePerPack)
{
@ -92,7 +92,7 @@ void IR_Encoder::sendData(uint16_t addrTo, uint8_t *data = nullptr, uint8_t len
rawSend(sendBuffer, packSize);
}
void IR_Encoder::sendAccept(uint16_t addrTo, uint8_t customByte = 0)
void IR_Encoder::sendAccept(uint16_t addrTo, uint8_t customByte)
{
constexpr uint8_t packsize = msgBytes + addrBytes + 1U + crcBytes;
memset(sendBuffer, 0x00, dataByteSizeMax);
@ -141,12 +141,12 @@ void IR_Encoder::sendBack(uint8_t data)
{
_sendBack(false, 0, &data, 1);
}
void IR_Encoder::sendBack(uint8_t *data = nullptr, uint8_t len = 0)
void IR_Encoder::sendBack(uint8_t *data , uint8_t len)
{
_sendBack(false, 0, data, len);
}
void IR_Encoder::sendBackTo(uint16_t addrTo, uint8_t *data = nullptr, uint8_t len = 0)
void IR_Encoder::sendBackTo(uint16_t addrTo, uint8_t *data, uint8_t len)
{
_sendBack(true, addrTo, data, len);
}
@ -210,7 +210,7 @@ void IR_Encoder::rawSend(uint8_t *ptr, uint8_t len)
setDecoder_isSending();
cli();
// noInterrupts();
sendLen = len;
toggleCounter = preambToggle; // Первая генерация для первого signal
@ -227,7 +227,7 @@ void IR_Encoder::rawSend(uint8_t *ptr, uint8_t len)
currentBitSequence = bitHigh;
isSending = true;
sei();
// interrupts();
}
void IR_Encoder::isr()
@ -332,32 +332,6 @@ void IR_Encoder::isr()
}
}
void old()
{ ///////////////////////////////////////////////////////
// void IR_Encoder::rawSend(uint8_t* ptr, uint8_t len) {
// /*tmp*/bool LOW_FIRST = false;/*tmp*/
// if (decoders != nullptr) { decoders->isPairSending = true; }
// bool prev = 1;
// bool next;
// send_EMPTY(preambPulse); // преамбула
// for (uint16_t byteNum = 0; byteNum < len; byteNum++) {
// sendByte(ptr[byteNum], &prev, LOW_FIRST);
// if (byteNum < len - 1) {
// next = ptr[byteNum + 1] & (LOW_FIRST ? 0b00000001 : 0b10000000);
// } else {
// next = 0;
// }
// addSync(&prev, &next);
// }
// if (decoders != nullptr) { decoders->isPairSending = false; }
// }
}
void IR_Encoder::sendByte(uint8_t byte, bool *prev, bool LOW_FIRST)
{
uint8_t mask = LOW_FIRST ? 0b00000001 : 0b10000000;
@ -395,7 +369,7 @@ void IR_Encoder::addSync(bool *prev, bool *next)
}
}
void IR_Encoder::send_HIGH(bool prevBite = 1)
void IR_Encoder::send_HIGH(bool prevBite)
{
// if (/* prevBite */1) {
@ -422,3 +396,10 @@ void IR_Encoder::send_EMPTY(uint8_t count)
// }
// meanderBlock(bitPauseTakts * 2 + bitActiveTakts, halfPeriod, 0); //TODO: Отодвинуть преамбулу
}
uint8_t* IR_Encoder::bitHigh = new uint8_t[2]{
(bitPauseTakts * 2) * 2 - 1,
(bitActiveTakts) * 2 - 1};
uint8_t* IR_Encoder::bitLow = new uint8_t[2]{
(bitPauseTakts + bitActiveTakts) * 2 - 1,
(bitPauseTakts) * 2 - 1};