-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMOTT.h
61 lines (46 loc) · 1.17 KB
/
MOTT.h
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
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef MOTT_h
#define MOTT_h
#include "Arduino.h"
#include <TimerOne.h>
class MOTT
{
static unsigned const long ms = 1000L;
static unsigned const int SIGNAL_MAX_SIZE = 7*50;
unsigned long TIMER_TIME;
unsigned long TIMER_TIME_IN_MS;
int SIGNAL_SIZE;
bool signal[SIGNAL_MAX_SIZE];
int TX_SIGNAL_PIN;
int RX_SIGNAL_PIN;
unsigned int i;
bool sending;
//---------------------//
int largo;
bool reading_signal;
bool reading_ended;
bool samplingEnable;
private:
char ConvertBoolArrayToChar(bool arr[]);
void ConvertCharToBoolArray(char c, bool* newSignal);
int CreateBitSignalFromCharArray(char* string);
void SplitSignalIntoArrays(char* string);
bool IsSignalDetected(int sample);
void WaitForSignalEndingAfterInterrupt(char* string);
void BeginSamplingTimer();
void SendBit();
void ReadBit();
public:
MOTT();
void SetTxPin(int pin);
void SetRxPin(int pin);
void SetBitTime(double time_in_ms, void (*f)());
void SendSignal(char* string);
void SampleSignalIfDetected();
void ObtainSample(char *string);
void ResumeSampling();
bool SamplingEnded();
void EnableSampling();
void DisableSampling();
void HandleInterrupt();
};
#endif