Skip to content

Commit

Permalink
need to test py wrapper
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Apr 11, 2021
1 parent befe021 commit 1f0335b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,5 @@ examples_linux/**/*
doxygenAction
.vscode/
*venv
*env
*.pyc
31 changes: 18 additions & 13 deletions pyRF24/pyRF24.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,14 +126,16 @@ bp::tuple available_wrap(RF24& ref)
return bp::make_tuple(result, pipe);
}

void setPALevel_wrap(RF24& ref, rf24_pa_dbm_e level) {
void setPALevel_wrap(RF24& ref, rf24_pa_dbm_e level)
{
ref.setPALevel(level, 1);
}

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(txStandBy_wrap1, RF24::txStandBy,
0, 2)
BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(txStandBy_wrap1, RF24::txStandBy, 0, 2)
//BOOST_PYTHON_FUNCTION_OVERLOADS(txStandBy_wrap2, RF24::txStandBy, 1, 2)

BOOST_PYTHON_MEMBER_FUNCTION_OVERLOADS(begin_wrap, RF24::begin, 0, 2)

// ******************** enums **************************
// from both RF24 and bcm2835
//
Expand Down Expand Up @@ -239,33 +241,36 @@ bp::enum_< bcm2835SPIChipSelect>("bcm2835SPIChipSelect")

#endif // BCM2835_H

bp::enum_<rf24_crclength_e>("rf24_crclength_e").value("RF24_CRC_DISABLED", RF24_CRC_DISABLED).value("RF24_CRC_8", RF24_CRC_8).value(
"RF24_CRC_16", RF24_CRC_16).export_values()
;
bp::enum_<rf24_crclength_e>("rf24_crclength_e")
.value("RF24_CRC_DISABLED", RF24_CRC_DISABLED)
.value("RF24_CRC_8", RF24_CRC_8)
.value("RF24_CRC_16", RF24_CRC_16)
.export_values();

bp::enum_<rf24_datarate_e>("rf24_datarate_e")
bp::enum_<rf24_datarate_e>("rf24_datarate_e")
.value("RF24_1MBPS", RF24_1MBPS)
.value("RF24_2MBPS", RF24_2MBPS)
.value("RF24_250KBPS", RF24_250KBPS)
.export_values();

bp::enum_<rf24_pa_dbm_e>("rf24_pa_dbm_e")
bp::enum_<rf24_pa_dbm_e>("rf24_pa_dbm_e")
.value("RF24_PA_MIN", RF24_PA_MIN)
.value("RF24_PA_LOW", RF24_PA_LOW)
.value("RF24_PA_HIGH", RF24_PA_HIGH)
.value("RF24_PA_MAX", RF24_PA_MAX)
.value("RF24_PA_ERROR", RF24_PA_ERROR)
.export_values();

// ******************** RF24 class **************************
//
bp::class_< RF24 >("RF24", bp::init< uint8_t, uint8_t >((bp::arg("_cepin"), bp::arg("_cspin"))))
// ******************** RF24 class **************************
//
bp::class_< RF24 >("RF24", bp::init< bp::optional< uint16_t, uint16_t > >((bp::arg("_cepin"), bp::arg("_cspin"))))
#if defined (RF24_LINUX) && !defined (MRAA)
.def(bp::init< uint8_t, uint8_t, uint32_t >((bp::arg("_cepin"), bp::arg("_cspin"), bp::arg("spispeed"))))
.def(bp::init< bp::optional< uint16_t, uint16_t, uint32_t > >((bp::arg("_cepin"), bp::arg("_cspin"), bp::arg("spispeed"))))
#endif
.def("available", (bool (::RF24::*)())(&::RF24::available))
.def("available_pipe", &available_wrap) // needed to rename this method as python does not allow such overloading
.def("begin", &RF24::begin)
.def("begin", (bool (::RF24::*)(uint16_t, uint16_t))(&RF24::begin), begin_wrap(bp::arg("_cepin"), bp::arg("_cspin")))
.def("closeReadingPipe", &RF24::closeReadingPipe)
.def("disableCRC", &RF24::disableCRC)
.def("enableAckPayload", &RF24::enableAckPayload)
Expand Down Expand Up @@ -311,7 +316,7 @@ bp::enum_< bcm2835SPIChipSelect>("bcm2835SPIChipSelect")
.def("txStandBy", (bool (::RF24::*)(::uint32_t, bool))(&RF24::txStandBy), txStandBy_wrap1(bp::args("timeout", "startTx")))
.def("whatHappened", &whatHappened_wrap)
.def("startConstCarrier", &RF24::startConstCarrier, (bp::arg("level"), bp::arg("channel")))
.def("stopConstCarrier",&RF24::stopConstCarrier)
.def("stopConstCarrier", &RF24::stopConstCarrier)
.def("write", &write_wrap1, (bp::arg("buf")))
.def("write", &write_wrap2, (bp::arg("buf"), bp::arg("multicast")))
.def("writeAckPayload", writeAckPayload_wrap, (bp::arg("pipe"), bp::arg("buf")))
Expand Down

0 comments on commit 1f0335b

Please sign in to comment.