-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathArduinoProxy.h
More file actions
48 lines (35 loc) · 1.25 KB
/
ArduinoProxy.h
File metadata and controls
48 lines (35 loc) · 1.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#pragma once
#include "config.h"
#if USE_ARDUINO_PROXY == 1
#include "IO.h"
#include "arduino/DCMotorState.h"
#include <ArduinoComm.pb.h>
#include <wiringSerial.h>
class ArduinoProxy : IO
{
public:
static ArduinoProxy *getInstance();
ArduinoProxy();
~ArduinoProxy();
void initialize() override;
void run() override;
bool isInitialized() override;
void send(const RocketryProto::ArduinoIn &c);
bool getDigitalState(int pin);
int getServoState(int pin);
DCMotorState getDCMotorState(int forwardPin, int reversePin);
int getLoadCellState();
ArduinoProxy(ArduinoProxy const &) = delete;
void operator=(ArduinoProxy const &) = delete;
private:
std::map<unsigned int, std::pair<bool, std::chrono::time_point<std::chrono::steady_clock>>> digitalStates;
std::map<unsigned int, std::pair<int, std::chrono::time_point<std::chrono::steady_clock>>> servoStates;
std::map<std::pair<unsigned int, unsigned int>, DCMotorState> dcMotorStates;
std::pair<int, std::chrono::time_point<std::chrono::steady_clock>> loadCellState;
std::mutex stateMutex;
int fd = 0;
bool inititialized = false;
std::mutex serialMutex;
void handleArduinoMessage(const RocketryProto::ArduinoOut &arduinoOut);
};
#endif