Allow opening pipe 0 for reading. Useful if it's on a different subnet from others

This commit is contained in:
maniacbug 2011-05-12 21:46:27 -07:00
parent 4f6c4c909e
commit d8b2512e0c
2 changed files with 8 additions and 8 deletions

View File

@ -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<uint8_t*>(&value), 5);
else
write_register(child_pipe[child], reinterpret_cast<uint8_t*>(&value), 1);

6
RF24.h
View File

@ -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);