@@ -58,12 +58,19 @@ class DigitalInOut {
5858 gpio_init_inout (&gpio, pin, direction, mode, value);
5959 }
6060
61+ /* * Class destructor, deinitialize the pin
62+ */
63+ virtual ~DigitalInOut ()
64+ {
65+ gpio_free (&gpio);
66+ }
67+
6168 /* * Set the output, specified as 0 or 1 (int)
6269 *
6370 * @param value An integer specifying the pin output value,
6471 * 0 for logical 0, 1 (or any other non-zero value) for logical 1
6572 */
66- void write (int value)
73+ virtual void write (int value)
6774 {
6875 // Thread safe / atomic HAL call
6976 gpio_write (&gpio, value);
@@ -75,33 +82,33 @@ class DigitalInOut {
7582 * an integer representing the output setting of the pin if it is an output,
7683 * or read the input if set as an input
7784 */
78- int read ()
85+ virtual int read ()
7986 {
8087 // Thread safe / atomic HAL call
8188 return gpio_read (&gpio);
8289 }
8390
8491 /* * Set as an output
8592 */
86- void output ();
93+ virtual void output ();
8794
8895 /* * Set as an input
8996 */
90- void input ();
97+ virtual void input ();
9198
9299 /* * Set the input pin mode
93100 *
94101 * @param pull PullUp, PullDown, PullNone, OpenDrain
95102 */
96- void mode (PinMode pull);
103+ virtual void mode (PinMode pull);
97104
98105 /* * Return the output setting, represented as 0 or 1 (int)
99106 *
100107 * @returns
101108 * Non zero value if pin is connected to uc GPIO
102109 * 0 if gpio object was initialized with NC
103110 */
104- int is_connected ()
111+ virtual int is_connected ()
105112 {
106113 // Thread safe / atomic HAL call
107114 return gpio_is_connected (&gpio);
0 commit comments