From d8b2512e0c391ef218e941a52dd554d0f288a199 Mon Sep 17 00:00:00 2001 From: maniacbug Date: Thu, 12 May 2011 21:46:27 -0700 Subject: [PATCH] Allow opening pipe 0 for reading. Useful if it's on a different subnet from others --- RF24.cpp | 10 +++++----- RF24.h | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/RF24.cpp b/RF24.cpp index b03307a..a6775ba 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -489,16 +489,16 @@ void RF24::openWritingPipe(uint64_t value) void RF24::openReadingPipe(uint8_t child, uint64_t value) { const uint8_t child_pipe[] = { - RX_ADDR_P1, RX_ADDR_P2, RX_ADDR_P3, RX_ADDR_P4, RX_ADDR_P5 }; + RX_ADDR_P0, RX_ADDR_P1, RX_ADDR_P2, RX_ADDR_P3, RX_ADDR_P4, RX_ADDR_P5 }; const uint8_t child_payload_size[] = { - RX_PW_P1, RX_PW_P2, RX_PW_P3, RX_PW_P4, RX_PW_P5 }; + RX_PW_P0, RX_PW_P1, RX_PW_P2, RX_PW_P3, RX_PW_P4, RX_PW_P5 }; const uint8_t child_pipe_enable[] = { - ERX_P1, ERX_P2, ERX_P3, ERX_P4, ERX_P5 }; + ERX_P0, ERX_P1, ERX_P2, ERX_P3, ERX_P4, ERX_P5 }; - if (--child < 5) + if (child < 5) { // For pipes 2-5, only write the LSB - if ( !child ) + if ( child < 2 ) write_register(child_pipe[child], reinterpret_cast(&value), 5); else write_register(child_pipe[child], reinterpret_cast(&value), 1); diff --git a/RF24.h b/RF24.h index 593e80c..c71f644 100644 --- a/RF24.h +++ b/RF24.h @@ -307,7 +307,7 @@ public: * * @see openWritingPipe * - * @warning all 5 reading pipes should share the first 32 bits. + * @warning Pipes 1-5 should share the first 32 bits. * Only the least significant byte should be unique, e.g. * * @code @@ -315,9 +315,9 @@ public: * openReadingPipe(2,0xF0F0F0F066); * @endcode * - * @todo Enforce the restriction that all pipes must share the top 32 bits + * @todo Enforce the restriction that pipes 1-5 must share the top 32 bits * - * @param number Which pipe# to open, 1-5. + * @param number Which pipe# to open, 0-5. * @param address The 40-bit address of the pipe to open. */ void openReadingPipe(uint8_t number, uint64_t address);