Skip to content

Commit

Permalink
Lev: SpeedAndDistance: Update to new datapage format
Browse files Browse the repository at this point in the history
  • Loading branch information
cujomalainey committed Feb 5, 2022
1 parent 4b75c24 commit c952166
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,30 @@
#define FUELCONSUMPTION_MASK 0x0FFF

/* Alt Speed and Distance */
LevAltSpeedDistanceInformation::LevAltSpeedDistanceInformation(AntRxDataResponse& dp) :
LevBaseSpeedDistanceInformation(dp) {}
template<class T>
LevBaseAltSpeedDistanceInformation<T>::LevBaseAltSpeedDistanceInformation() :
CoreDataPage<T>() {}

uint16_t LevAltSpeedDistanceInformation::getFuelConsumption() // in Wh/km
template<class T>
uint16_t LevBaseAltSpeedDistanceInformation<T>::getFuelConsumption() // in Wh/km
{
return this->get16BitValue(FUELCONSUMPTION_LSB_BYTE,
FUELCONSUMPTION_MSB_BYTE, FUELCONSUMPTION_MASK);
}

template class LevBaseAltSpeedDistanceInformation<BroadcastData>;
template class LevBaseAltSpeedDistanceInformation<BroadcastDataMsg>;

LevAltSpeedDistanceInformation::LevAltSpeedDistanceInformation(AntRxDataResponse& dp) :
LevBaseSpeedDistanceInformation(dp),
LevBaseAltSpeedDistanceInformation<BroadcastData>() {}

LevAltSpeedDistanceInformationMsg::LevAltSpeedDistanceInformationMsg() :
LevBaseSpeedDistanceInformationMsg(ALTSPEEDDISTANCEINFORMATION_NUMBER),
LevBaseAltSpeedDistanceInformation<BroadcastDataMsg>() {}

void LevAltSpeedDistanceInformationMsg::setFuelConsumption(uint16_t consumption) // in Wh/km
{
set16BitValue(consumption, FUELCONSUMPTION_LSB_BYTE,
FUELCONSUMPTION_MSB_BYTE, FUELCONSUMPTION_MASK);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@

#include <Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h>

class LevAltSpeedDistanceInformation : public LevBaseSpeedDistanceInformation {
template<class T>
class LevBaseAltSpeedDistanceInformation : virtual public CoreDataPage<T> {
public:
explicit LevAltSpeedDistanceInformation(AntRxDataResponse& dp);
LevBaseAltSpeedDistanceInformation();
uint16_t getFuelConsumption(); // in Wh/km
};

class LevAltSpeedDistanceInformation : public LevBaseSpeedDistanceInformation, public LevBaseAltSpeedDistanceInformation<BroadcastData> {
public:
explicit LevAltSpeedDistanceInformation(AntRxDataResponse& dp);
};

class LevAltSpeedDistanceInformationMsg : public LevBaseSpeedDistanceInformationMsg, public LevBaseAltSpeedDistanceInformation<BroadcastDataMsg> {
public:
LevAltSpeedDistanceInformationMsg();
void setFuelConsumption(uint16_t consumption); // in Wh/km
};

#endif // ANTPLUS_LEVALTSPEEDDISTANCEINFORMATION_h
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,36 @@
#define LEVSPEED_MASK 0x0FFF

/* Speed and Distance */
LevBaseSpeedDistanceInformation::LevBaseSpeedDistanceInformation(AntRxDataResponse& dp) :
LevBaseMainDataPage(dp) {}
template<class T>
LevCoreSpeedDistanceInformation<T>::LevCoreSpeedDistanceInformation() :
CoreDataPage<T>() {}

uint32_t LevBaseSpeedDistanceInformation::getOdometer() { // in km
template<class T>
uint32_t LevCoreSpeedDistanceInformation<T>::getOdometer() { // in km
return this->get32BitValue(ODOMETER_LSB_BYTE, ODOMETER_MSB_BYTE);
}

uint16_t LevBaseSpeedDistanceInformation::getLevSpeed() // in 1/10 km/h
{
template<class T>
uint16_t LevCoreSpeedDistanceInformation<T>::getLevSpeed() { // in 1/10 km/h
return this->get16BitValue(LEVSPEED_LSB_BYTE, LEVSPEED_MSB_BYTE,
LEVSPEED_MASK);
}

template class LevCoreSpeedDistanceInformation<BroadcastData>;
template class LevCoreSpeedDistanceInformation<BroadcastDataMsg>;

LevBaseSpeedDistanceInformation::LevBaseSpeedDistanceInformation(AntRxDataResponse& dp) :
LevBaseMainDataPage(dp),
LevCoreSpeedDistanceInformation<BroadcastData>() {}

LevBaseSpeedDistanceInformationMsg::LevBaseSpeedDistanceInformationMsg(uint8_t dataPageNumber) :
LevBaseMainDataPageMsg<BroadcastDataMsg>(dataPageNumber),
LevCoreSpeedDistanceInformation<BroadcastDataMsg>() {}

void LevBaseSpeedDistanceInformationMsg::setOdometer(uint32_t odometer) {
set32BitValue(odometer, ODOMETER_LSB_BYTE, ODOMETER_MSB_BYTE);
}

void LevBaseSpeedDistanceInformationMsg::setLevSpeed(uint16_t speed) {
set16BitValue(speed, LEVSPEED_LSB_BYTE, LEVSPEED_MSB_BYTE, LEVSPEED_MASK);
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,24 @@

#include <Profiles/Lev/DataPages/ANTPLUS_LevBaseMainDataPage.h>

class LevBaseSpeedDistanceInformation : public LevBaseMainDataPage {
template<class T>
class LevCoreSpeedDistanceInformation : virtual public CoreDataPage<T> {
public:
explicit LevBaseSpeedDistanceInformation(AntRxDataResponse& dp);
LevCoreSpeedDistanceInformation();
uint32_t getOdometer(); // in km
uint16_t getLevSpeed(); // in 1/10 km/h
};

class LevBaseSpeedDistanceInformation : public LevBaseMainDataPage, public LevCoreSpeedDistanceInformation<BroadcastData> {
public:
explicit LevBaseSpeedDistanceInformation(AntRxDataResponse& dp);
};

class LevBaseSpeedDistanceInformationMsg : public LevBaseMainDataPageMsg<BroadcastDataMsg>, public LevCoreSpeedDistanceInformation<BroadcastDataMsg> {
public:
LevBaseSpeedDistanceInformationMsg(uint8_t dataPageNumber);
void setOdometer(uint32_t odometer); // in km
void setLevSpeed(uint16_t speed); // in 1/10 km/h
};

#endif // ANTPLUS_LEVBASESPEEDDISTANCEINFORMATION_h
24 changes: 21 additions & 3 deletions src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,28 @@
#define REMAININGRANGE_MASK 0x0FFF

/* Speed and Distance */
LevSpeedDistanceInformation::LevSpeedDistanceInformation(AntRxDataResponse& dp) :
LevBaseSpeedDistanceInformation(dp) {}
template<class T>
LevInternalSpeedDistanceInformation<T>::LevInternalSpeedDistanceInformation() :
CoreDataPage<T>() {}

uint16_t LevSpeedDistanceInformation::getRemainingRange() { // in km
template<class T>
uint16_t LevInternalSpeedDistanceInformation<T>::getRemainingRange() { // in km
return this->get16BitValue(REMAININGRANGE_LSB_BYTE, REMAININGRANGE_MSB_BYTE,
REMAININGRANGE_MASK);
}

template class LevInternalSpeedDistanceInformation<BroadcastData>;
template class LevInternalSpeedDistanceInformation<BroadcastDataMsg>;

LevSpeedDistanceInformation::LevSpeedDistanceInformation(AntRxDataResponse& dp) :
LevBaseSpeedDistanceInformation(dp),
LevInternalSpeedDistanceInformation<BroadcastData>() {}

LevSpeedDistanceInformationMsg::LevSpeedDistanceInformationMsg() :
LevBaseSpeedDistanceInformationMsg(SPEEDDISTANCEINFORMATION_NUMBER),
LevInternalSpeedDistanceInformation<BroadcastDataMsg>() {}

void LevSpeedDistanceInformationMsg::setRemainingRange(uint16_t remainingRange) { // in km
set16BitValue(remainingRange, REMAININGRANGE_LSB_BYTE, REMAININGRANGE_MSB_BYTE,
REMAININGRANGE_MASK);
}
16 changes: 14 additions & 2 deletions src/Profiles/Lev/DataPages/ANTPLUS_LevSpeedDistanceInformation.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,22 @@

#include <Profiles/Lev/DataPages/ANTPLUS_LevBaseSpeedDistanceInformation.h>

class LevSpeedDistanceInformation : public LevBaseSpeedDistanceInformation {
template<class T>
class LevInternalSpeedDistanceInformation : virtual public CoreDataPage<T> {
public:
explicit LevSpeedDistanceInformation(AntRxDataResponse& dp);
LevInternalSpeedDistanceInformation();
uint16_t getRemainingRange(); // in km
};

class LevSpeedDistanceInformation : public LevBaseSpeedDistanceInformation, public LevInternalSpeedDistanceInformation<BroadcastData> {
public:
explicit LevSpeedDistanceInformation(AntRxDataResponse& dp);
};

class LevSpeedDistanceInformationMsg : public LevBaseSpeedDistanceInformationMsg, public LevInternalSpeedDistanceInformation<BroadcastDataMsg> {
public:
LevSpeedDistanceInformationMsg();
void setRemainingRange(uint16_t remainingRange); // in km
};

#endif // ANTPLUS_LEVSPEEDDISTANCEINFORMATION_h

0 comments on commit c952166

Please sign in to comment.