Skip to content

Commit

Permalink
Make certain DigitalOut methods virtual
Browse files Browse the repository at this point in the history
  • Loading branch information
AGlass0fMilk committed Jun 29, 2020
1 parent a6207ca commit b09b4ac
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/DigitalOut.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,17 @@ class DigitalOut {
gpio_init_out_ex(&gpio, pin, value);
}

virtual ~DigitalOut()
{
gpio_free(&gpio);
}

/** Set the output, specified as 0 or 1 (int)
*
* @param value An integer specifying the pin output value,
* 0 for logical 0, 1 (or any other non-zero value) for logical 1
*/
void write(int value)
virtual void write(int value)
{
// Thread safe / atomic HAL call
gpio_write(&gpio, value);
Expand All @@ -87,7 +92,7 @@ class DigitalOut {
* an integer representing the output setting of the pin,
* 0 for logical 0, 1 for logical 1
*/
int read()
virtual int read()
{
// Thread safe / atomic HAL call
return gpio_read(&gpio);
Expand All @@ -99,7 +104,7 @@ class DigitalOut {
* Non zero value if pin is connected to uc GPIO
* 0 if gpio object was initialized with NC
*/
int is_connected()
virtual int is_connected()
{
// Thread safe / atomic HAL call
return gpio_is_connected(&gpio);
Expand Down

0 comments on commit b09b4ac

Please sign in to comment.