[PHY] Reworked macro configuration system

This commit is contained in:
jgromes 2023-11-27 21:17:58 +01:00
parent 074b707924
commit 395101ec20
2 changed files with 14 additions and 14 deletions

View file

@ -4,7 +4,7 @@
PhysicalLayer::PhysicalLayer(float step, size_t maxLen) {
this->freqStep = step;
this->maxPacketLength = maxLen;
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
this->bufferBitPos = 0;
this->bufferWritePos = 0;
#endif
@ -24,7 +24,7 @@ int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) {
}
// dynamically allocate memory
#if defined(RADIOLIB_STATIC_ONLY)
#if RADIOLIB_STATIC_ONLY
char str[RADIOLIB_STATIC_ARRAY_SIZE];
#else
char* str = new char[len];
@ -38,7 +38,7 @@ int16_t PhysicalLayer::transmit(__FlashStringHelper* fstr, uint8_t addr) {
// transmit string
int16_t state = transmit(str, addr);
#if !defined(RADIOLIB_STATIC_ONLY)
#if !RADIOLIB_STATIC_ONLY
delete[] str;
#endif
return(state);
@ -68,7 +68,7 @@ int16_t PhysicalLayer::receive(String& str, size_t len) {
size_t length = len;
// build a temporary buffer
#if defined(RADIOLIB_STATIC_ONLY)
#if RADIOLIB_STATIC_ONLY
uint8_t data[RADIOLIB_STATIC_ARRAY_SIZE + 1];
#else
uint8_t* data = NULL;
@ -101,7 +101,7 @@ int16_t PhysicalLayer::receive(String& str, size_t len) {
}
// deallocate temporary buffer
#if !defined(RADIOLIB_STATIC_ONLY)
#if !RADIOLIB_STATIC_ONLY
delete[] data;
#endif
@ -175,7 +175,7 @@ int16_t PhysicalLayer::readData(String& str, size_t len) {
}
// build a temporary buffer
#if defined(RADIOLIB_STATIC_ONLY)
#if RADIOLIB_STATIC_ONLY
uint8_t data[RADIOLIB_STATIC_ARRAY_SIZE + 1];
#else
uint8_t* data = new uint8_t[length + 1];
@ -198,7 +198,7 @@ int16_t PhysicalLayer::readData(String& str, size_t len) {
}
// deallocate temporary buffer
#if !defined(RADIOLIB_STATIC_ONLY)
#if !RADIOLIB_STATIC_ONLY
delete[] data;
#endif
@ -366,7 +366,7 @@ int16_t PhysicalLayer::startDirect() {
return(state);
}
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
int16_t PhysicalLayer::available() {
return(this->bufferWritePos);
}
@ -477,7 +477,7 @@ void PhysicalLayer::clearChannelScanAction() {
}
#if defined(RADIOLIB_INTERRUPT_TIMING)
#if RADIOLIB_INTERRUPT_TIMING
void PhysicalLayer::setInterruptSetup(void (*func)(uint32_t)) {
Module* mod = getMod();
mod->TimerSetupCb = func;

View file

@ -380,7 +380,7 @@ class PhysicalLayer {
*/
int16_t startDirect();
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
/*!
\brief Set sync word to be used to determine start of packet in direct reception mode.
\param syncWord Sync word bits.
@ -463,7 +463,7 @@ class PhysicalLayer {
*/
virtual void clearChannelScanAction();
#if defined(RADIOLIB_INTERRUPT_TIMING)
#if RADIOLIB_INTERRUPT_TIMING
/*!
\brief Set function to be called to set up the timing interrupt.
@ -480,18 +480,18 @@ class PhysicalLayer {
#endif
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
protected:
void updateDirectBuffer(uint8_t bit);
#endif
#if !defined(RADIOLIB_GODMODE)
#if !RADIOLIB_GODMODE
private:
#endif
float freqStep;
size_t maxPacketLength;
#if !defined(RADIOLIB_EXCLUDE_DIRECT_RECEIVE)
#if !RADIOLIB_EXCLUDE_DIRECT_RECEIVE
uint8_t bufferBitPos;
uint8_t bufferWritePos;
uint8_t bufferReadPos;