-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserial.h
57 lines (42 loc) · 1.56 KB
/
serial.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
#ifndef _REMOTEXY_MOD_SERIAL_H_
#define _REMOTEXY_MOD_SERIAL_H_
#include "RemoteXY_Serial.h"
class CRemoteXY : public CRemoteXY_Serial {
public:
#if defined(REMOTEXY_PORT__HARDSERIAL)
CRemoteXY (const void * _conf, void * _var, const char * _accessPassword, HardwareSerial * _serial, long _serialSpeed) {
initSerial (_serial, _serialSpeed);
init (_conf, _var, _accessPassword);
}
#elif defined(REMOTEXY_PORT__SOFTSERIAL)
CRemoteXY (const void * _conf, void * _var, const char * _accessPassword, uint8_t _serialRx, uint8_t _serialTx, long _serialSpeed) {
initSerial (_serialRx, _serialTx, _serialSpeed);
init (_conf, _var, _accessPassword);
}
#endif
protected:
void sendByte (uint8_t b) {
serial->write (b);
#if defined(REMOTEXY__DEBUGLOGS)
REMOTEXY__DEBUGLOGS.print(b, HEX);
REMOTEXY__DEBUGLOGS.print(' ');
#endif
}
uint8_t receiveByte () {
uint8_t b = serial->read ();
#if defined(REMOTEXY__DEBUGLOGS)
REMOTEXY__DEBUGLOGS.print(b, HEX);
REMOTEXY__DEBUGLOGS.print(' ');
#endif
return b;
}
uint8_t availableByte () {
return serial->available ();
};
};
#if defined(REMOTEXY_PORT__HARDSERIAL)
#define RemoteXY_Init() remotexy = new CRemoteXY (RemoteXY_CONF_PROGMEM, &RemoteXY, REMOTEXY_ACCESS_PASSWORD, &REMOTEXY_SERIAL, REMOTEXY_SERIAL_SPEED)
#elif defined(REMOTEXY_PORT__SOFTSERIAL)
#define RemoteXY_Init() remotexy = new CRemoteXY (RemoteXY_CONF_PROGMEM, &RemoteXY, REMOTEXY_ACCESS_PASSWORD, REMOTEXY_SERIAL_RX, REMOTEXY_SERIAL_TX, REMOTEXY_SERIAL_SPEED)
#endif
#endif //_REMOTEXY_MOD_SERIAL_H_