forked from doudar/SmartSpin2k
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFlywheelData.cpp
37 lines (27 loc) · 898 Bytes
/
FlywheelData.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
31
32
33
34
35
36
37
/*
* Copyright (C) 2020 Anthony Doud & Joel Baranick
* All rights reserved
*
* SPDX-License-Identifier: GPL-2.0-only
*/
#include "endian.h"
#include "sensors/FlywheelData.h"
bool FlywheelData::hasHeartRate() { return false; }
bool FlywheelData::hasCadence() { return this->hasData; }
bool FlywheelData::hasPower() { return this->hasData; }
bool FlywheelData::hasSpeed() { return false; }
int FlywheelData::getHeartRate() { return INT_MIN; }
float FlywheelData::getCadence() { return this->cadence; }
int FlywheelData::getPower() { return this->power; }
float FlywheelData::getSpeed() { return nanf(""); }
void FlywheelData::decode(uint8_t *data, size_t length) {
if (data[0] == 0xFF) {
power = get_be16(&data[3]); // uint16 big-endian at ofs 3
cadence = data[12];
hasData = true;
} else {
cadence = nanf("");
power = INT_MIN;
hasData = false;
}
}