Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add isFifo() methods #849

Merged
merged 8 commits into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions RF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1372,6 +1372,20 @@ bool RF24::rxFifoFull()

/****************************************************************************/

uint8_t RF24::isFifo(bool about_tx)
{
return static_cast<uint8_t>((read_register(FIFO_STATUS) >> (4 * about_tx)) & 3);
}

/****************************************************************************/

bool RF24::isFifo(bool about_tx, bool check_empty)
{
return static_cast<bool>(isFifo(about_tx) & _BV(!check_empty));
}

/****************************************************************************/

bool RF24::txStandBy()
{

Expand Down
18 changes: 18 additions & 0 deletions RF24.h
Original file line number Diff line number Diff line change
Expand Up @@ -784,6 +784,24 @@ class RF24
*/
bool rxFifoFull();

/**
* @param about_tx `true` focuses on the TX FIFO, `false` focuses on the RX FIFO
* @return
* - `0` if the specified FIFO is neither full nor empty.
* - `1` if the specified FIFO is empty.
* - `2` if the specified FIFO is full.
*/
uint8_t isFifo(bool about_tx);

/**
* @param about_tx `true` focuses on the TX FIFO, `false` focuses on the RX FIFO
* @param check_empty
* - `true` checks if the specified FIFO is empty
* - `false` checks is the specified FIFO is full.
* @return A boolean answer to the question "is the [TX/RX] FIFO [empty/full]?"
*/
bool isFifo(bool about_tx, bool check_empty);

/**
* Enter low-power mode
*
Expand Down
2 changes: 2 additions & 0 deletions docs/sphinx/classRF24.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ FIFO Management
.. doxygenfunction:: RF24::rxFifoFull
.. doxygenfunction:: RF24::flush_tx
.. doxygenfunction:: RF24::flush_rx
.. doxygenfunction:: RF24::isFifo (bool about_tx)
.. doxygenfunction:: RF24::isFifo (bool about_tx, bool check_empty)

Ambiguous Signal Detection
**************************
Expand Down
6 changes: 4 additions & 2 deletions pyRF24/pyRF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ bool write_wrap2(RF24& ref, bp::object buf, const bool multicast)
return ref.write(get_bytes_or_bytearray_str(buf), get_bytes_or_bytearray_ln(buf), multicast);
}

void writeAckPayload_wrap(RF24& ref, uint8_t pipe, bp::object buf)
bool writeAckPayload_wrap(RF24& ref, uint8_t pipe, bp::object buf)
{
ref.writeAckPayload(pipe, get_bytes_or_bytearray_str(buf), get_bytes_or_bytearray_ln(buf));
return ref.writeAckPayload(pipe, get_bytes_or_bytearray_str(buf), get_bytes_or_bytearray_ln(buf));
}

bool writeFast_wrap1(RF24& ref, bp::object buf)
Expand Down Expand Up @@ -309,6 +309,8 @@ BOOST_PYTHON_MODULE(RF24)
.def("reUseTX", &RF24::reUseTX)
.def("read", &read_wrap, (bp::arg("maxlen")))
.def("rxFifoFull", &RF24::rxFifoFull)
.def("isFifo", (uint8_t(::RF24::*)(bool))(&::RF24::isFifo), (bp::arg("about_tx")))
.def("isFifo", (bool (::RF24::*)(bool, bool))(&::RF24::isFifo), (bp::arg("about_tx"), bp::arg("check_empty")))
.def("setAddressWidth", &RF24::setAddressWidth)
.def("setAutoAck", (void (::RF24::*)(bool))(&::RF24::setAutoAck), (bp::arg("enable")))
.def("setAutoAck", (void (::RF24::*)(::uint8_t, bool))(&::RF24::setAutoAck), (bp::arg("pipe"), bp::arg("enable")))
Expand Down