[SX127x] Added setLowBatteryThreshold (#925)
This commit is contained in:
parent
30961964c5
commit
842c54849d
3 changed files with 41 additions and 8 deletions
|
@ -182,6 +182,7 @@ setFifoFullAction KEYWORD2
|
||||||
clearFifoFullAction KEYWORD2
|
clearFifoFullAction KEYWORD2
|
||||||
fifoAdd KEYWORD2
|
fifoAdd KEYWORD2
|
||||||
fifoGet KEYWORD2
|
fifoGet KEYWORD2
|
||||||
|
setLowBatteryThreshold KEYWORD2
|
||||||
|
|
||||||
# RF69-specific
|
# RF69-specific
|
||||||
setAESKey KEYWORD2
|
setAESKey KEYWORD2
|
||||||
|
|
|
@ -1714,4 +1714,26 @@ float SX127x::getRSSI(bool packet, bool skipReceive, int16_t offset) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int16_t SX127x::setLowBatteryThreshold(int8_t level, uint32_t pin) {
|
||||||
|
// check disable
|
||||||
|
if(level < 0) {
|
||||||
|
return(this->mod->SPIsetRegValue(RADIOLIB_SX127X_REG_LOW_BAT, RADIOLIB_SX127X_LOW_BAT_OFF, 3, 3));
|
||||||
|
}
|
||||||
|
|
||||||
|
// enable detector and set the threshold
|
||||||
|
int16_t state = this->mod->SPIsetRegValue(RADIOLIB_SX127X_REG_LOW_BAT, RADIOLIB_SX127X_LOW_BAT_ON | level, 3, 0);
|
||||||
|
RADIOLIB_ASSERT(state);
|
||||||
|
|
||||||
|
// set DIO mapping
|
||||||
|
switch(pin) {
|
||||||
|
case(0):
|
||||||
|
return(this->mod->SPIsetRegValue(RADIOLIB_SX127X_REG_DIO_MAPPING_1, RADIOLIB_SX127X_DIO0_PACK_TEMP_CHANGE_LOW_BAT, 7, 6));
|
||||||
|
case(3):
|
||||||
|
return(this->mod->SPIsetRegValue(RADIOLIB_SX127X_REG_DIO_MAPPING_1, RADIOLIB_SX127X_DIO3_CONT_TEMP_CHANGE_LOW_BAT, 1, 0));
|
||||||
|
case(4):
|
||||||
|
return(this->mod->SPIsetRegValue(RADIOLIB_SX127X_REG_DIO_MAPPING_2, RADIOLIB_SX127X_DIO4_PACK_TEMP_CHANGE_LOW_BAT, 7, 6));
|
||||||
|
}
|
||||||
|
return(RADIOLIB_ERR_INVALID_DIO_PIN);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -472,14 +472,14 @@
|
||||||
// RADIOLIB_SX127X_REG_LOW_BAT
|
// RADIOLIB_SX127X_REG_LOW_BAT
|
||||||
#define RADIOLIB_SX127X_LOW_BAT_OFF 0b00000000 // 3 3 low battery detector disabled
|
#define RADIOLIB_SX127X_LOW_BAT_OFF 0b00000000 // 3 3 low battery detector disabled
|
||||||
#define RADIOLIB_SX127X_LOW_BAT_ON 0b00001000 // 3 3 low battery detector enabled
|
#define RADIOLIB_SX127X_LOW_BAT_ON 0b00001000 // 3 3 low battery detector enabled
|
||||||
#define RADIOLIB_SX127X_LOW_BAT_TRIM_1_695_V 0b00000000 // 2 0 battery voltage threshold: 1.695 V
|
#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_1_695_V 0b00000000 // 2 0 battery voltage threshold: 1.695 V
|
||||||
#define RADIOLIB_SX127X_LOW_BAT_TRIM_1_764_V 0b00000001 // 2 0 1.764 V
|
#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_1_764_V 0b00000001 // 2 0 1.764 V
|
||||||
#define RADIOLIB_SX127X_LOW_BAT_TRIM_1_835_V 0b00000010 // 2 0 1.835 V (default)
|
#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_1_835_V 0b00000010 // 2 0 1.835 V (default)
|
||||||
#define RADIOLIB_SX127X_LOW_BAT_TRIM_1_905_V 0b00000011 // 2 0 1.905 V
|
#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_1_905_V 0b00000011 // 2 0 1.905 V
|
||||||
#define RADIOLIB_SX127X_LOW_BAT_TRIM_1_976_V 0b00000100 // 2 0 1.976 V
|
#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_1_976_V 0b00000100 // 2 0 1.976 V
|
||||||
#define RADIOLIB_SX127X_LOW_BAT_TRIM_2_045_V 0b00000101 // 2 0 2.045 V
|
#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_2_045_V 0b00000101 // 2 0 2.045 V
|
||||||
#define RADIOLIB_SX127X_LOW_BAT_TRIM_2_116_V 0b00000110 // 2 0 2.116 V
|
#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_2_116_V 0b00000110 // 2 0 2.116 V
|
||||||
#define RADIOLIB_SX127X_LOW_BAT_TRIM_2_185_V 0b00000111 // 2 0 2.185 V
|
#define RADIOLIB_SX127X_LOW_BAT_THRESHOLD_2_185_V 0b00000111 // 2 0 2.185 V
|
||||||
|
|
||||||
// RADIOLIB_SX127X_REG_IRQ_FLAGS_1
|
// RADIOLIB_SX127X_REG_IRQ_FLAGS_1
|
||||||
#define RADIOLIB_SX127X_FLAG_MODE_READY 0b10000000 // 7 7 requested mode is ready
|
#define RADIOLIB_SX127X_FLAG_MODE_READY 0b10000000 // 7 7 requested mode is ready
|
||||||
|
@ -1216,6 +1216,16 @@ class SX127x: public PhysicalLayer {
|
||||||
*/
|
*/
|
||||||
int16_t setRSSIThreshold(float dbm);
|
int16_t setRSSIThreshold(float dbm);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\brief Set low battery indicator threshold.
|
||||||
|
\param level Battery threshold level (one of RADIOLIB_SX127X_LOW_BAT_THRESHOLD_*),
|
||||||
|
or -1 to disable the detector. Disabled by default. Note that this will not attach any interrupts!
|
||||||
|
\param pin DIO pin number which will be used to signal low battery. Only DIO0/4 can be used
|
||||||
|
(in packet mode) or DIO3/4 (in continuous mode). Ignored when disabling the detector.
|
||||||
|
\returns \ref status_codes
|
||||||
|
*/
|
||||||
|
int16_t setLowBatteryThreshold(int8_t level, uint32_t pin = RADIOLIB_NC);
|
||||||
|
|
||||||
#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
|
#if !RADIOLIB_GODMODE && !RADIOLIB_LOW_LEVEL
|
||||||
protected:
|
protected:
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue