47 lines
787 B
C++
47 lines
787 B
C++
/*
|
|
* PinController.cpp
|
|
*
|
|
* Created on: Jun 15, 2018
|
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert
|
|
*/
|
|
|
|
#include "PinController.h"
|
|
|
|
#include "utility/config.h"
|
|
|
|
#include "wiringPi/wiringPi.h"
|
|
#include "json/json.hpp"
|
|
|
|
namespace flippR_driver
|
|
{
|
|
|
|
std::once_flag PinController::GPIO_LIB_INITIALIZED;
|
|
|
|
PinController::PinController()
|
|
{
|
|
std::call_once(GPIO_LIB_INITIALIZED, wiringPiSetup);
|
|
}
|
|
|
|
void PinController::initialize_input_pin(uint8_t address)
|
|
{
|
|
pinMode(address, INPUT);
|
|
}
|
|
|
|
void PinController::initialize_output_pin(uint8_t address)
|
|
{
|
|
pinMode(address, OUTPUT);
|
|
}
|
|
|
|
void PinController::write_pin(uint8_t address, bool value)
|
|
{
|
|
digitalWrite(address, value);
|
|
}
|
|
|
|
bool PinController::read_pin(uint8_t address)
|
|
{
|
|
return PULLDOWN == digitalRead(address);
|
|
}
|
|
|
|
|
|
}
|