/
Device.cpp
30 lines (26 loc) · 968 Bytes
/
Device.cpp
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
// Copyright 2014-2015 the project authors as listed in the AUTHORS file.
// All rights reserved. Use of this source code is governed by the
// license that can be found in the LICENSE file.
#include <unistd.h>
#include "Device.h"
Device::Device(char* topic) {
_topic = topic;
_txpin = -1;
}
void Device::sendPulseLowHigh(int lowDuration, int highDuration) {
// seems that output from transmitter is inverse of what pin is set to
digitalWrite(_txpin, HIGH );
usleep(lowDuration);
digitalWrite(_txpin, LOW);
usleep(highDuration);
}
void Device::sendPulseHighLow(int highDuration, int lowDuration) {
// seems that output from transmitter is inverse of what pin is set to
digitalWrite(_txpin, LOW );
usleep(highDuration);
digitalWrite(_txpin, HIGH);
usleep(lowDuration);
// seems like we better end up on LOW or we end up jamming the airwaves
// low must allow transmitter to float as needed
digitalWrite(_txpin, LOW);
}