move configuring to separate function instead of in constructor
This commit is contained in:
2026-02-14 14:31:16 +01:00
parent 8e5b75e2d3
commit 84b1ccd7d0
2 changed files with 14 additions and 8 deletions
+12 -7
View File
@@ -61,8 +61,19 @@ void gpiod_chip_close(struct gpiod_chip *chip)
}
#endif
GPIO::GPIO(Direction dir, uint8_t gpio, bool state, QObject *parent) : QObject(parent), m_offset(gpio)
GPIO::GPIO(QObject *parent) : QObject(parent), m_offset(0)
{
}
GPIO::~GPIO()
{
gpiod_line_request_release(m_request);
}
void GPIO::configure_pin(Direction dir, uint8_t gpio, bool state = false)
{
m_offset = gpio;
if (dir == Direction::Output)
{
m_request = request_output_line("/dev/gpiochip0", gpio, (enum gpiod_line_value)state, "unisim_cpp");
@@ -81,12 +92,6 @@ GPIO::GPIO(Direction dir, uint8_t gpio, bool state, QObject *parent) : QObject(p
}
}
}
GPIO::~GPIO()
{
gpiod_line_request_release(m_request);
}
void GPIO::set_value(bool value)
{
#if __aarch64__