mirror of
https://github.com/Sani7/remote-ui.git
synced 2026-10-27 06:01:14 +01:00
gpio
move configuring to separate function instead of in constructor
This commit is contained in:
+12
-7
@@ -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__
|
||||
|
||||
@@ -50,8 +50,9 @@ class GPIO : public QObject
|
||||
Input,
|
||||
Output
|
||||
};
|
||||
explicit GPIO(Direction dir, uint8_t gpio, bool state = false, QObject *parent = nullptr);
|
||||
explicit GPIO(QObject *parent = nullptr);
|
||||
~GPIO();
|
||||
void configure_pin(Direction dir, uint8_t gpio, bool state = false);
|
||||
void set_value(bool val);
|
||||
bool value();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user