You've already forked arduino-LoRa
mirror of
https://github.com/sandeepmistry/arduino-LoRa.git
synced 2025-06-14 07:02:25 +03:00
Add option to specify PA output pin in Lora.setTxPower(...) (#2)
This commit is contained in:
26
src/LoRa.cpp
26
src/LoRa.cpp
@ -297,15 +297,27 @@ void LoRaClass::sleep()
|
||||
writeRegister(REG_OP_MODE, MODE_LONG_RANGE_MODE | MODE_SLEEP);
|
||||
}
|
||||
|
||||
void LoRaClass::setTxPower(int level)
|
||||
void LoRaClass::setTxPower(int level, int outputPin)
|
||||
{
|
||||
if (level < 2) {
|
||||
level = 2;
|
||||
} else if (level > 17) {
|
||||
level = 17;
|
||||
}
|
||||
if (PA_OUTPUT_RFO_PIN == outputPin) {
|
||||
// RFO
|
||||
if (level < 0) {
|
||||
level = 0;
|
||||
} else if (level > 14) {
|
||||
level = 14;
|
||||
}
|
||||
|
||||
writeRegister(REG_PA_CONFIG, PA_BOOST | (level - 2));
|
||||
writeRegister(REG_PA_CONFIG, 0x70 | level);
|
||||
} else {
|
||||
// PA BOOST
|
||||
if (level < 2) {
|
||||
level = 2;
|
||||
} else if (level > 17) {
|
||||
level = 17;
|
||||
}
|
||||
|
||||
writeRegister(REG_PA_CONFIG, PA_BOOST | (level - 2));
|
||||
}
|
||||
}
|
||||
|
||||
void LoRaClass::setFrequency(long frequency)
|
||||
|
@ -8,6 +8,9 @@
|
||||
#define LORA_DEFAULT_RESET_PIN 9
|
||||
#define LORA_DEFAULT_DIO0_PIN 2
|
||||
|
||||
#define PA_OUTPUT_RFO_PIN 0
|
||||
#define PA_OUTPUT_PA_BOOST_PIN 1
|
||||
|
||||
class LoRaClass : public Stream {
|
||||
public:
|
||||
LoRaClass();
|
||||
@ -38,7 +41,7 @@ public:
|
||||
void idle();
|
||||
void sleep();
|
||||
|
||||
void setTxPower(int level);
|
||||
void setTxPower(int level, int outputPin = PA_OUTPUT_PA_BOOST_PIN);
|
||||
void setFrequency(long frequency);
|
||||
void setSpreadingFactor(int sf);
|
||||
void setSignalBandwidth(long sbw);
|
||||
|
Reference in New Issue
Block a user