Skip to content

Commit

Permalink
♻️ (drivers): Refactor pin_is_on
Browse files Browse the repository at this point in the history
  • Loading branch information
MMyster committed Nov 15, 2022
1 parent 7927dd4 commit ae43f7c
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions drivers/CoreIOExpander/source/CoreIOExpander.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ auto CoreIOExpanderMCP23017::getModeForPin(uint16_t pin) -> PinMode
auto CoreIOExpanderMCP23017::readPin(uint16_t pin) -> int
{
_registers.gpio = readRegister(mcp23017::internal_register::GPIO);
auto value = _registers.gpio & pin;
return pin == value ? 1 : 0;
auto pin_is_on = _registers.gpio & pin;
return pin_is_on;
}

void CoreIOExpanderMCP23017::writePin(uint16_t pin, int value)
Expand Down
2 changes: 1 addition & 1 deletion drivers/CoreIOExpander/tests/CoreIOExpander_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ TEST_F(CoreIOExpanderTest, readPinHigh)
MOCK_FUNCTION_expectedCallsReadRegister(mcp23017::internal_register::GPIO, GPIO_expected_buffer);

auto output_value = expander.readPin(pin_number);
EXPECT_EQ(1, output_value);
EXPECT_EQ(pin_number, output_value);
}

TEST_F(CoreIOExpanderTest, readPinLow)
Expand Down
2 changes: 1 addition & 1 deletion drivers/CoreTouchSensor/source/CoreTouchSensor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ void CoreTouchSensor::init()

auto CoreTouchSensor::read() -> bool
{
_state = (1 == _detect_pin.read());
_state = (_detect_pin.read() != 0);
return _state;
}

Expand Down

0 comments on commit ae43f7c

Please sign in to comment.