You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

gpiomanager.cpp 456B

1234567891011121314151617181920212223242526
  1. #include "gpiomanager.h"
  2. #include <wiringPi.h>
  3. GpioManager::GpioManager(QObject *parent) : InputManager(parent)
  4. {
  5. }
  6. GpioManager::~GpioManager()
  7. {
  8. }
  9. bool GpioManager::init(const QVariant &pins)
  10. {
  11. if (wiringPiSetupPhys())
  12. return false;
  13. auto list = pins.toList();
  14. foreach (auto pin, list)
  15. pinMode(pin.toInt(), INPUT);
  16. return true;
  17. }
  18. QVariant GpioManager::read(const QVariant &pin)
  19. {
  20. return digitalRead(pin.toInt());
  21. }