Skip to content

Commit

Permalink
More formatting changes and slight optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
jsphuebner committed Nov 19, 2024
1 parent c788cdf commit 91b26e2
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 20 deletions.
9 changes: 1 addition & 8 deletions include/digio.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,7 @@ class DigIo
* @param[in] io pin index
* @return pin value
*/
bool Get()
{
if(_invert)
{
return !(gpio_get(_port, _pin) > 0);
}
return gpio_get(_port, _pin) > 0;
}
bool Get() { return (gpio_get(_port, _pin) > 0) ^ _invert; }

/**
* Set pin high
Expand Down
24 changes: 12 additions & 12 deletions src/digio.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,24 @@ void DigIo::Configure(uint32_t port, uint16_t pin, PinMode::PinMode pinMode)
case PinMode::INPUT_PD:
/* use defaults */
break;
case PinMode::INPUT_PD_INV:
/* use defaults */
_invert = 1;
break;
case PinMode::INPUT_PD_INV:
/* use defaults */
_invert = 1;
break;
case PinMode::INPUT_PU:
val = DIG_IO_ON;
break;
case PinMode::INPUT_PU_INV:
val = DIG_IO_ON;
_invert = 1;
break;
case PinMode::INPUT_PU_INV:
val = DIG_IO_ON;
_invert = 1;
break;
case PinMode::INPUT_FLT:
cnf = GPIO_CNF_INPUT_FLOAT;
break;
case PinMode::INPUT_FLT_INV:
cnf = GPIO_CNF_INPUT_FLOAT;
_invert = 1;
break;
case PinMode::INPUT_FLT_INV:
cnf = GPIO_CNF_INPUT_FLOAT;
_invert = 1;
break;
case PinMode::INPUT_AIN:
cnf = GPIO_CNF_INPUT_ANALOG;
break;
Expand Down

0 comments on commit 91b26e2

Please sign in to comment.