From dce6e2c0263b779c97808b5bd744883bf851f16b Mon Sep 17 00:00:00 2001 From: Jacob Williams <47766188+BotSpace@users.noreply.github.com> Date: Thu, 15 Aug 2024 18:53:21 -0400 Subject: [PATCH] made setBatteryVal() nicer to use --- PestoLink-Receive.cpp | 6 ++++-- PestoLink-Receive.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/PestoLink-Receive.cpp b/PestoLink-Receive.cpp index 8d1665f..ecf4d0f 100644 --- a/PestoLink-Receive.cpp +++ b/PestoLink-Receive.cpp @@ -81,6 +81,8 @@ bool PestoLinkParser::buttonHeld(uint8_t button_num) { return (bool)((raw_buttons >> (button_num)) & 0x01); } -void PestoLinkParser::setBatteryVal(uint8_t battery_val){ - this->_batteryVal = battery_val; +void PestoLinkParser::setBatteryVal(float battery_val){ + uint8_t batteryByte = 255.0 * battery_val / 12.0; + + this->_batteryVal = batteryByte; } \ No newline at end of file diff --git a/PestoLink-Receive.h b/PestoLink-Receive.h index 99e1569..c402622 100644 --- a/PestoLink-Receive.h +++ b/PestoLink-Receive.h @@ -13,7 +13,7 @@ class PestoLinkParser { float getAxis(uint8_t button_num); uint8_t getRawAxis(uint8_t button_num); bool buttonHeld(uint8_t button_num); - void setBatteryVal(uint8_t battery_val); + void setBatteryVal(float battery_val); private: uint8_t _batteryVal = 0;