Skip to content

Commit

Permalink
made setBatteryVal() nicer to use
Browse files Browse the repository at this point in the history
  • Loading branch information
SaintSampo committed Aug 15, 2024
1 parent e53945c commit dce6e2c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions PestoLink-Receive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
2 changes: 1 addition & 1 deletion PestoLink-Receive.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit dce6e2c

Please sign in to comment.