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;