Skip to content

Commit 38b1205

Browse files
authored
Fix print pretty (#707)
* fix "primary mode" output * testing proposal from #706 * Update printPrettyDetails() docs
1 parent cc45e56 commit 38b1205

File tree

2 files changed

+24
-6
lines changed

2 files changed

+24
-6
lines changed

RF24.cpp

+18-5
Original file line numberDiff line numberDiff line change
@@ -619,16 +619,29 @@ void RF24::printPrettyDetails(void) {
619619
"\r\n"), (char*)pgm_read_ptr(&rf24_feature_e_str_P[(bool)(features & _BV(EN_ACK_PAY)) * 1]));
620620

621621
uint8_t dynPl = read_register(DYNPD);
622-
uint8_t autoAck = read_register(EN_AA);
623622
printf_P(PSTR("Dynamic Payloads\t"
624623
PRIPSTR
625624
"\r\n"), (char*)pgm_read_ptr(&rf24_feature_e_str_P[(dynPl && (features &_BV(EN_DPL))) * 1]));
626-
printf_P(PSTR("Auto Acknowledgment\t"
627-
PRIPSTR
628-
"\r\n"), (char*)pgm_read_ptr(&rf24_feature_e_str_P[(bool)(autoAck & 1) * 1]));
625+
626+
uint8_t autoAck = read_register(EN_AA);
627+
if (autoAck == 0x3F || autoAck == 0) {
628+
// all pipes have the same configuration about auto-ack feature
629+
printf_P(PSTR("Auto Acknowledgment\t"
630+
PRIPSTR
631+
"\r\n"), (char*)pgm_read_ptr(&rf24_feature_e_str_P[(bool)(autoAck) * 1]));
632+
} else {
633+
// representation per pipe
634+
printf_P(PSTR("Auto Acknowledgment\t= 0b%c%c%c%c%c%c\r\n"),
635+
(char)((bool)(autoAck & _BV(ENAA_P5)) + 48),
636+
(char)((bool)(autoAck & _BV(ENAA_P4)) + 48),
637+
(char)((bool)(autoAck & _BV(ENAA_P3)) + 48),
638+
(char)((bool)(autoAck & _BV(ENAA_P2)) + 48),
639+
(char)((bool)(autoAck & _BV(ENAA_P1)) + 48),
640+
(char)((bool)(autoAck & _BV(ENAA_P0)) + 48));
641+
}
629642

630643
config_reg = read_register(NRF_CONFIG);
631-
printf_P(PSTR("Primary Mode\t\t= %cX\r\n"), config_reg & _BV(PWR_UP) ? 'T' : 'R');
644+
printf_P(PSTR("Primary Mode\t\t= %cX\r\n"), config_reg & _BV(PRIM_RX) ? 'R' : 'T');
632645
print_address_register(PSTR("TX address\t"), TX_ADDR);
633646

634647
uint8_t openPipes = read_register(EN_RXADDR);

RF24.h

+6-1
Original file line numberDiff line numberDiff line change
@@ -478,7 +478,7 @@ class RF24 {
478478
* differs from printDetails() because it makes the information more
479479
* understandable without having to look up the datasheet or convert
480480
* hexadecimal to binary. Only use this function if your application can
481-
* spare a few extra bytes of memory.
481+
* spare extra bytes of memory.
482482
*
483483
* @warning Does nothing if stdout is not defined. See fdevopen in stdio.h
484484
* The printf.h file is included with the library for Arduino.
@@ -490,6 +490,11 @@ class RF24 {
490490
* ...
491491
* }
492492
* @endcode
493+
*
494+
* @note If the automatic acknowledgements feature is configured differently
495+
* for each pipe, then a binary representation is used in which bits 0-5
496+
* represent pipes 0-5 respectively. A `0` means the feature is disabled and
497+
* a `1` means the feature is enabled.
493498
*/
494499
void printPrettyDetails(void);
495500

0 commit comments

Comments
 (0)