summaryrefslogtreecommitdiff
path: root/throttle-quadrant.ino
blob: 54740d995713428392eb709a37ab3113a9738293 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "ThrottleQuadrant.hpp"

namespace {

//! The time point (in milliseconds since boot) when we last read out the data of the throttle quadrant.
auto lastReadTimePoint = 0ul;

}

void setup() {
  Serial.begin(115200);
  ThrottleQuadrant.begin(2, 3, 4);
}

void loop() {
  auto currentTimePoint = millis();

  // Read out the throttle quadrant if the minimum amount of wait time has passed.
  if ((currentTimePoint - lastReadTimePoint) >= ThrottleQuadrant.readDelayMillis) {
    auto data = ThrottleQuadrant.read();
    lastReadTimePoint = millis();
    Serial.write(reinterpret_cast<byte const *>(&data), sizeof(data));
  }
}