dereviated gpiointerface
This commit is contained in:
@@ -17,8 +17,7 @@
|
|||||||
#include <thread>
|
#include <thread>
|
||||||
#include <map>
|
#include <map>
|
||||||
|
|
||||||
#include "../utilities/GPIOInterface.h"
|
#include "../utilities/GPIOInterface.hpp"
|
||||||
|
|
||||||
#include "InputEvent.h"
|
#include "InputEvent.h"
|
||||||
#include "InputEventNotifier.h"
|
#include "InputEventNotifier.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,48 +0,0 @@
|
|||||||
|
|
||||||
/*
|
|
||||||
* GPIOInterface.cpp
|
|
||||||
*
|
|
||||||
* Created on: May 17, 2018
|
|
||||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "GPIOInterface.h"
|
|
||||||
|
|
||||||
#include "../lib/wiringPi/wiringPi.h"
|
|
||||||
|
|
||||||
GPIOInterface::GPIOInterface(std::string config_path)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
GPIOInterface::~GPIOInterface()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GPIOInterface::read_input_data()
|
|
||||||
{
|
|
||||||
return read_input_pin(input_data_address);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GPIOInterface::write_input_row(char data)
|
|
||||||
{
|
|
||||||
write_pin(input_row_address, data & 0b001);
|
|
||||||
write_pin(input_row_address, data & 0b010);
|
|
||||||
write_pin(input_row_address, data & 0b100);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GPIOInterface::write_input_col(char data)
|
|
||||||
{
|
|
||||||
write_pin(input_col_address, data & 0b001);
|
|
||||||
write_pin(input_col_address, data & 0b010);
|
|
||||||
write_pin(input_col_address, data & 0b100);
|
|
||||||
}
|
|
||||||
|
|
||||||
void GPIOInterface::write_pin(char address, bool data)
|
|
||||||
{
|
|
||||||
digitalWrite(address, data);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool GPIOInterface::read_input_pin(char address)
|
|
||||||
{
|
|
||||||
return digitalRead(address);
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
/*
|
|
||||||
* GPIOInterface.hpp
|
|
||||||
*
|
|
||||||
* Responsible for communicating with the actual GPIO hardware.
|
|
||||||
*
|
|
||||||
* Gets a JSON file with following style:
|
|
||||||
* TODO
|
|
||||||
*
|
|
||||||
* Created on: May 6, 2018
|
|
||||||
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef SRC_UTILITIES_GPIOINTERFACE_H_
|
|
||||||
#define SRC_UTILITIES_GPIOINTERFACE_H_
|
|
||||||
|
|
||||||
#include <fstream>
|
|
||||||
|
|
||||||
#include "../lib/json/json.hpp"
|
|
||||||
|
|
||||||
using namespace nlohmann;
|
|
||||||
|
|
||||||
class GPIOInterface
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
GPIOInterface(std::string config_path);
|
|
||||||
~GPIOInterface();
|
|
||||||
|
|
||||||
void write_input_row(char data);
|
|
||||||
void write_input_col(char data);
|
|
||||||
bool read_input_data();
|
|
||||||
|
|
||||||
private:
|
|
||||||
static void write_pin(char address, bool data);
|
|
||||||
static bool read_input_pin(char address);
|
|
||||||
|
|
||||||
private:
|
|
||||||
json config;
|
|
||||||
|
|
||||||
char input_row_address;
|
|
||||||
char input_col_address;
|
|
||||||
char input_data_address;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* SRC_UTILITIES_GPIOINTERFACE_H_ */
|
|
||||||
46
FlippR-Driver/src/utilities/GPIOInterface.hpp
Normal file
46
FlippR-Driver/src/utilities/GPIOInterface.hpp
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
/*
|
||||||
|
* GPIOInterface.hpp
|
||||||
|
*
|
||||||
|
* Responsible for communicating with the actual GPIO hardware.
|
||||||
|
*
|
||||||
|
* Gets a JSON file with following style:
|
||||||
|
* TODO
|
||||||
|
*
|
||||||
|
* Created on: May 6, 2018
|
||||||
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_UTILITIES_GPIOINTERFACE_HPP_
|
||||||
|
#define SRC_UTILITIES_GPIOINTERFACE_HPP_
|
||||||
|
|
||||||
|
#include <fstream>
|
||||||
|
|
||||||
|
#include "../lib/json/json.hpp"
|
||||||
|
#include "../lib/wiringPi/wiringPi.h"
|
||||||
|
|
||||||
|
using namespace nlohmann;
|
||||||
|
|
||||||
|
class GPIOInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
GPIOInterface(std::string config_path) = 0;
|
||||||
|
~GPIOInterface();
|
||||||
|
|
||||||
|
static void write_pin(char address, char data)
|
||||||
|
{
|
||||||
|
digitalWrite(address, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool read_pin(char address)
|
||||||
|
{
|
||||||
|
return digitalRead(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
json config;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SRC_UTILITIES_GPIOINTERFACE_HPP_ */
|
||||||
32
FlippR-Driver/src/utilities/InputGPIOInterface.cpp
Normal file
32
FlippR-Driver/src/utilities/InputGPIOInterface.cpp
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* InputGPIOInterface.cpp
|
||||||
|
*
|
||||||
|
* Created on: May 31, 2018
|
||||||
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||||
|
*/
|
||||||
|
#include "InputGPIOInterface.h"
|
||||||
|
|
||||||
|
|
||||||
|
class InputGPIOInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
bool InputGPIOInterface::read_input_data()
|
||||||
|
{
|
||||||
|
return read_pin(this->input_data_address);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputGPIOInterface::write_input_row(char data)
|
||||||
|
{
|
||||||
|
write_pin(this->input_row_address, data & 0b001);
|
||||||
|
write_pin(this->input_row_address, data & 0b010);
|
||||||
|
write_pin(this->input_row_address, data & 0b100);
|
||||||
|
}
|
||||||
|
|
||||||
|
void InputGPIOInterface::write_input_col(char data)
|
||||||
|
{
|
||||||
|
write_pin(this->input_col_address, data & 0b001);
|
||||||
|
write_pin(this->input_col_address, data & 0b010);
|
||||||
|
write_pin(this->input_col_address, data & 0b100);
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
29
FlippR-Driver/src/utilities/InputGPIOInterface.h
Normal file
29
FlippR-Driver/src/utilities/InputGPIOInterface.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* InputGPIOInterface.h
|
||||||
|
*
|
||||||
|
* Created on: May 31, 2018
|
||||||
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_UTILITIES_INPUTGPIOINTERFACE_H_
|
||||||
|
#define SRC_UTILITIES_INPUTGPIOINTERFACE_H_
|
||||||
|
|
||||||
|
#include "GPIOInterface.hpp"
|
||||||
|
|
||||||
|
class InputGPIOInterface : GPIOInterface
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
|
||||||
|
void write_input_row(char data);
|
||||||
|
void write_input_col(char data);
|
||||||
|
bool read_input_data();
|
||||||
|
|
||||||
|
private:
|
||||||
|
char input_row_address;
|
||||||
|
char input_col_address;
|
||||||
|
char input_data_address;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SRC_UTILITIES_INPUTGPIOINTERFACE_H_ */
|
||||||
19
FlippR-Driver/src/utilities/OutputGPIOInterface.h
Normal file
19
FlippR-Driver/src/utilities/OutputGPIOInterface.h
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
* OutputGPIOInterface.h
|
||||||
|
*
|
||||||
|
* Created on: May 31, 2018
|
||||||
|
* Author: Andreas Schneider, Johannes Wendel, Jonas Zeunert, Rafael Vinci, Dr. Franca Rupprecht
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_
|
||||||
|
#define SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_
|
||||||
|
|
||||||
|
#include "GPIOInterface.hpp"
|
||||||
|
|
||||||
|
class OutputGPIOInterface : GPIOInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif /* SRC_UTILITIES_OUTPUTGPIOINTERFACE_H_ */
|
||||||
Reference in New Issue
Block a user