From 4a0f8ad72b3cc23fdffa8312d086516c64e077d2 Mon Sep 17 00:00:00 2001 From: Jacob Perron Date: Mon, 26 Aug 2019 20:36:50 -0700 Subject: [PATCH] Add API for getting left and right wheeldrop Signed-off-by: Jacob Perron --- include/create/create.h | 10 ++++++++++ src/create.cpp | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/include/create/create.h b/include/create/create.h index 1e4d262..40196c4 100644 --- a/include/create/create.h +++ b/include/create/create.h @@ -336,6 +336,16 @@ namespace create { */ bool isWheeldrop() const; + /** + * \return true if a left wheeldrop is detected, false otherwise. + */ + bool isLeftWheeldrop() const; + + /** + * \return true if a right wheeldrop is detected, false otherwise. + */ + bool isRightWheeldrop() const; + /** * \return true if left bumper is pressed, false otherwise. */ diff --git a/src/create.cpp b/src/create.cpp index eacc608..8279e2a 100644 --- a/src/create.cpp +++ b/src/create.cpp @@ -597,6 +597,26 @@ namespace create { } } + bool Create::isLeftWheeldrop() const { + if (data->isValidPacketID(ID_BUMP_WHEELDROP)) { + return (GET_DATA(ID_BUMP_WHEELDROP) & 0x08) != 0; + } + else { + CERR("[create::Create] ", "Wheeldrop sensor not supported!"); + return false; + } + } + + bool Create::isRightWheeldrop() const { + if (data->isValidPacketID(ID_BUMP_WHEELDROP)) { + return (GET_DATA(ID_BUMP_WHEELDROP) & 0x04) != 0; + } + else { + CERR("[create::Create] ", "Wheeldrop sensor not supported!"); + return false; + } + } + bool Create::isLeftBumper() const { if (data->isValidPacketID(ID_BUMP_WHEELDROP)) { return (GET_DATA(ID_BUMP_WHEELDROP) & 0x02) != 0;