86
86
_REG_FRF_LSB = const (0x09 )
87
87
_REG_VERSION = const (0x10 )
88
88
_REG_PA_LEVEL = const (0x11 )
89
+ _REG_OCP = const (0x13 )
89
90
_REG_RX_BW = const (0x19 )
90
91
_REG_AFC_BW = const (0x1A )
91
92
_REG_RSSI_VALUE = const (0x24 )
110
111
_TEST_PA1_BOOST = const (0x5D )
111
112
_TEST_PA2_NORMAL = const (0x70 )
112
113
_TEST_PA2_BOOST = const (0x7C )
114
+ _OCP_NORMAL = const (0x1A )
115
+ _OCP_HIGH_POWER = const (0x0F )
113
116
114
117
# The crystal oscillator frequency and frequency synthesizer step size.
115
118
# See the datasheet for details of this calculation.
@@ -285,6 +288,7 @@ def __set__(self, obj: Optional["RFM69"], val: int) -> None:
285
288
dio_0_mapping = _RegisterBits (_REG_DIO_MAPPING1 , offset = 6 , bits = 2 )
286
289
287
290
# pylint: disable=too-many-statements
291
+ # pylint: disable=too-many-arguments
288
292
def __init__ ( # pylint: disable=invalid-name
289
293
self ,
290
294
spi : SPI ,
@@ -448,16 +452,17 @@ def reset(self) -> None:
448
452
self ._reset .value = False
449
453
time .sleep (0.005 ) # 5 ms
450
454
451
- def set_boost (self , setting : int ) -> None :
452
- """Set preamp boost if needed."""
453
- if self ._tx_power >= 18 :
454
- self ._write_u8 (_REG_TEST_PA1 , setting )
455
- self ._write_u8 (_REG_TEST_PA2 , setting )
455
+ def disable_boost (self ) -> None :
456
+ """Disable preamp boost."""
457
+ if self .high_power :
458
+ self ._write_u8 (_REG_TEST_PA1 , _TEST_PA1_NORMAL )
459
+ self ._write_u8 (_REG_TEST_PA2 , _TEST_PA2_NORMAL )
460
+ self ._write_u8 (_REG_OCP , _OCP_NORMAL )
456
461
457
462
def idle (self ) -> None :
458
463
"""Enter idle standby mode (switching off high power amplifiers if necessary)."""
459
464
# Like RadioHead library, turn off high power boost if enabled.
460
- self .set_boost ( _TEST_PA1_NORMAL )
465
+ self .disable_boost ( )
461
466
self .operation_mode = STANDBY_MODE
462
467
463
468
def sleep (self ) -> None :
@@ -469,7 +474,7 @@ def listen(self) -> None:
469
474
and retrieve packets as they're available.
470
475
"""
471
476
# Like RadioHead library, turn off high power boost if enabled.
472
- self .set_boost ( _TEST_PA1_NORMAL )
477
+ self .disable_boost ( )
473
478
# Enable payload ready interrupt for D0 line.
474
479
self .dio_0_mapping = 0b01
475
480
# Enter RX mode (will clear FIFO!).
@@ -480,8 +485,11 @@ def transmit(self) -> None:
480
485
entering transmit mode and more. For generating and transmitting a packet of data use
481
486
:py:func:`send` instead.
482
487
"""
483
- # Like RadioHead library, turn on high power boost if enabled.
484
- self .set_boost (_TEST_PA1_BOOST )
488
+ # Like RadioHead library, turn on high power boost if needed.
489
+ if self .high_power and (self ._tx_power >= 18 ):
490
+ self ._write_u8 (_REG_TEST_PA1 , _TEST_PA1_BOOST )
491
+ self ._write_u8 (_REG_TEST_PA2 , _TEST_PA2_BOOST )
492
+ self ._write_u8 (_REG_OCP , _OCP_HIGH_POWER )
485
493
# Enable packet sent interrupt for D0 line.
486
494
self .dio_0_mapping = 0b00
487
495
# Enter TX mode (will clear FIFO!).
0 commit comments