Skip to content

Commit a8a47d0

Browse files
authored
Implement the G Force Recording System (#7)
* Removed `pulseTriggered()` and added `returnString()`. (#87) * Renamed `OnUpdate` to avoid duplication. (#87) * Renamed `OnUpdate` to avoid duplication. (#87)
1 parent 44721c6 commit a8a47d0

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

keywords.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,10 @@ ArrayList KEYWORD1
22
Controller KEYWORD1
33
Device KEYWORD1
44
VoltageSensor KEYWORD1
5+
OnWheelSpeedSensorUpdate KEYWORD1
56
WheelSpeedSensor KEYWORD1
67
Peer KEYWORD1
7-
pulseTriggered KEYWORD2
8+
returnString KEYWORD2
89
returnFloat KEYWORD2
910
returnDouble KEYWORD2
1011
arraycopy KEYWORD2

src/Utils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "Utils.h"
22

3-
bool pulseTriggered(int pin) { return digitalRead(pin) == LOW; }
3+
void returnString(Peer &peer, const String &tag, const String &msg) { peer.write(tag + ":" + msg); }
44

55
void returnFloat(Peer &peer, const String &tag, float n) { peer.write(tag + ":" + n); }
66

src/Utils.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
#include "Arduino.h"
66
#include "Peer.h"
77

8-
bool pulseTriggered(int pin);
8+
void returnString(Peer &peer, const String &tag, const String &msg);
99

1010
void returnFloat(Peer &peer, const String &tag, float n);
1111

src/WheelSpeedSensor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "WheelSpeedSensor.h"
22
#include "Utils.h"
33

4-
WheelSpeedSensor::WheelSpeedSensor(const ArrayList<int> &pins, OnUpdate onUpdate) :
4+
WheelSpeedSensor::WheelSpeedSensor(const ArrayList<int> &pins, OnWheelSpeedSensorUpdate onUpdate) :
55
Device<float>(pins), _t1(0), _t2(0), _consecutive(false), _onUpdate(onUpdate) {}
66

77
void WheelSpeedSensor::initialize(const ArrayList<String> &parentTags) {
@@ -15,7 +15,7 @@ void WheelSpeedSensor::initialize(const ArrayList<String> &parentTags) {
1515
float getRPM(unsigned long t1, unsigned long t2) { return float(60000.0 / double(t2 - t1)); }
1616

1717
float WheelSpeedSensor::read() {
18-
if (pulseTriggered(_pins[0])) {
18+
if (digitalRead(_pins[0]) == LOW) {
1919
if (!_consecutive) {
2020
_consecutive = true;
2121
_t1 = _t2;

src/WheelSpeedSensor.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
#include "Device.h"
66

7-
typedef void (*OnUpdate)(float ws);
7+
typedef void (*OnWheelSpeedSensorUpdate)(float ws);
88

99
class WheelSpeedSensor : public Device<float> {
1010
protected:
1111
unsigned long _t1, _t2;
1212
bool _consecutive;
13-
const OnUpdate _onUpdate;
13+
const OnWheelSpeedSensorUpdate _onUpdate;
1414

1515
public:
16-
WheelSpeedSensor(const ArrayList<int> &pins, OnUpdate onUpdate);
16+
WheelSpeedSensor(const ArrayList<int> &pins, OnWheelSpeedSensorUpdate onUpdate);
1717
void initialize(const ArrayList<String> &parentTags) override;
1818
float read() override;
1919
};

0 commit comments

Comments
 (0)