Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
cujomalainey committed Feb 5, 2018
2 parents 75034fb + 2de0df0 commit d44c8e2107c476205c7255f099bf524fb4202e02
Showing with 1,529 additions and 255 deletions.
  1. +4 −1 .gitignore
  2. +3 −2 .travis.yml
  3. +169 −0 examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino
  4. +141 −0 examples/EnvironmentDisplay/EnvironmentDisplay.ino
  5. +4 −22 examples/{HeartRateMonitor/HeartRateMonitor.ino → HeartRateDisplay/HeartRateDisplay.ino}
  6. +10 −1 src/BaseClasses/ANTPLUS_BaseProfile.cpp
  7. +13 −15 src/BaseClasses/ANTPLUS_BaseProfile.h
  8. +7 −23 src/CommonDataPages/ANTPLUS_CommonDataPageDefines.h
  9. +54 −0 src/CommonDataPages/ANTPLUS_CommonDataPagePrivateDefines.h
  10. +3 −1 src/CommonDataPages/ANTPLUS_CommonDataPages.h
  11. +18 −1 src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.cpp
  12. +18 −2 src/CommonDataPages/RX/ANTPLUS_ManufacturersInformation.h
  13. +22 −0 src/CommonDataPages/RX/ANTPLUS_ProductInformation.cpp
  14. +18 −0 src/CommonDataPages/RX/ANTPLUS_ProductInformation.h
  15. +1 −1 src/CommonDataPages/RX/ANTPLUS_RequestDataPage.cpp
  16. +2 −2 src/CommonDataPages/TX/ANTPLUS_ManufacturersInformationMsg.h
  17. +1 −0 src/CommonDataPages/TX/ANTPLUS_ProductInformationMsg.cpp
  18. +14 −0 src/CommonDataPages/TX/ANTPLUS_ProductInformationMsg.h
  19. +1 −0 src/CommonDataPages/TX/ANTPLUS_RequestDataPageMsg.cpp
  20. +3 −1 src/Profiles/ANTPLUS_Profiles.h
  21. +13 −0 src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedDefines.h
  22. +72 −0 src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedPrivateDefines.h
  23. +14 −0 src/Profiles/BicycleSpeed/ANTPLUS_BicycleSpeedProfile.h
  24. +14 −0 src/Profiles/BicycleSpeed/DataPages/ANTPLUS_ProfileBicycleSpeedDataPages.h
  25. +22 −0 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.cpp
  26. +17 −0 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPage.h
  27. +35 −0 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.cpp
  28. +21 −0 src/Profiles/BicycleSpeed/DataPages/Base/ANTPLUS_BicycleSpeedBaseMainDataPageMsg.h
  29. +18 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.cpp
  30. +14 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedBatteryStatus.h
  31. +13 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.cpp
  32. +12 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedCumulativeOperatingTime.h
  33. +5 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.cpp
  34. +11 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedDefault.h
  35. +14 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.cpp
  36. +13 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedManufacturerID.h
  37. +11 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.cpp
  38. +12 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedMotionAndSpeed.h
  39. +18 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.cpp
  40. +14 −0 src/Profiles/BicycleSpeed/DataPages/RX/ANTPLUS_BicycleSpeedProductID.h
  41. +98 −0 src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.cpp
  42. +42 −0 src/Profiles/BicycleSpeed/Display/ANTPLUS_ProfileBicycleSpeedDisplay.h
  43. +2 −2 ...ensor/ANTPLUS_ProfileHeartRateSensor.h → BicycleSpeed/Sensor/ANTPLUS_ProfileBicycleSpeedSensor.h}
  44. +7 −0 src/Profiles/Environment/ANTPLUS_EnvironmentDefines.h
  45. +65 −0 src/Profiles/Environment/ANTPLUS_EnvironmentPrivateDefines.h
  46. +14 −0 src/Profiles/Environment/ANTPLUS_EnvironmentProfile.h
  47. +10 −0 src/Profiles/Environment/DataPages/ANTPLUS_ProfileEnvironmentDataPages.h
  48. +10 −0 src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.cpp
  49. +14 −0 src/Profiles/Environment/DataPages/Base/ANTPLUS_EnvironmentBaseDataPage.h
  50. +25 −0 src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.cpp
  51. +16 −0 src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentGeneralInformation.h
  52. +27 −0 src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.cpp
  53. +16 −0 src/Profiles/Environment/DataPages/RX/ANTPLUS_EnvironmentTemperature.h
  54. +80 −0 src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.cpp
  55. +37 −0 src/Profiles/Environment/Display/ANTPLUS_ProfileEnvironmentDisplay.h
  56. +13 −0 src/Profiles/Environment/Monitor/ANTPLUS_ProfileEnvironmentMonitor.h
  57. +2 −2 src/Profiles/HeartRate/ANTPLUS_HeartRateProfile.h
  58. +107 −0 src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.cpp
  59. +47 −0 src/Profiles/HeartRate/Display/ANTPLUS_ProfileHeartRateDisplay.h
  60. +17 −89 src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.cpp
  61. +11 −39 src/Profiles/HeartRate/Monitor/ANTPLUS_ProfileHeartRateMonitor.h
  62. +0 −51 src/Profiles/HeartRate/Sensor/ANTPLUS_ProfileHeartRateSensor.cpp
@@ -3,5 +3,8 @@
.ycm*
*.swp
# used for testing
src/main.cpp
.DS_Store
.tags*
.tags*
tags
@@ -34,8 +34,9 @@ cache:
- "~/.platformio"
env:
# - PLATFORMIO_CI_SRC=examples/HeartRateSensor/HeartRateSensor.ino
- PLATFORMIO_CI_SRC=examples/HeartRateMonitor/HeartRateMonitor.ino
- PLATFORMIO_CI_SRC=examples/EnvironmentDisplay/EnvironmentDisplay.ino
- PLATFORMIO_CI_SRC=examples/HeartRateDisplay/HeartRateDisplay.ino
- PLATFORMIO_CI_SRC=examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino
install:
- pip install -U platformio
@@ -0,0 +1,169 @@
/***********************************
* AntPlus Bicycle Speed Display example
*
* Finds a nearby Bike Speed Sensor, pairs
* to it and then reads the information
* out via the serial port.
*
* Author Curtis Malainey
************************************/
#include <Arduino.h>
#include "ANT.h"
#include "ANTPLUS.h"
#define BAUD_RATE 9600
#define CHANNEL_0 0
const uint8_t NETWORK_KEY[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; // get this from thisisant.com
AntWithCallbacks ant = AntWithCallbacks();
AntPlusRouter router = AntPlusRouter();
ProfileBicycleSpeedDisplay bikeSpeed = ProfileBicycleSpeedDisplay();
void bicycleSpeedBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data);
void batteryStatusDataPageHandler(BicycleSpeedBatteryStatus& msg, uintptr_t data);
void motionAndSpeedDataPageHandler(BicycleSpeedMotionAndSpeed& msg, uintptr_t data);
void cumulativeOperatingTimeDataPageHandler(BicycleSpeedCumulativeOperatingTime& msg, uintptr_t data);
void defaultDataPageHandler(BicycleSpeedDefault& msg, uintptr_t data);
void manufacturerIDDataPageHandler(BicycleSpeedManufacturerID& msg, uintptr_t data);
void productIDDataPageHandler(BicycleSpeedProductID& msg, uintptr_t data);
void bicycleSpeedFlags(uint8_t flags);
void bicycleSpeedBatteryStatus(uint8_t flags);
void printStatus(uint8_t status);
void setup() {
Serial1.begin(BAUD_RATE);
ant.setSerial(Serial1);
delay(15000);
router.setDriver(&ant); // never touch ant again
router.setAntPlusNetworkKey(NETWORK_KEY);
router.setProfile(CHANNEL_0, &bikeSpeed);
// Delay after initial setup to wait for user to connect on serial
Serial.begin(BAUD_RATE);
Serial.println("Running");
bikeSpeed.onDataPage(bicycleSpeedBaseDataPageHandler);
bikeSpeed.onBicycleSpeedBatteryStatus(batteryStatusDataPageHandler);
bikeSpeed.onBicycleSpeedMotionAndSpeed(motionAndSpeedDataPageHandler);
bikeSpeed.onBicycleSpeedCumulativeOperatingTime(cumulativeOperatingTimeDataPageHandler);
bikeSpeed.onBicycleSpeedDefault(defaultDataPageHandler);
bikeSpeed.onBicycleSpeedManufacturerID(manufacturerIDDataPageHandler);
bikeSpeed.onBicycleSpeedProductID(productIDDataPageHandler);
bikeSpeed.begin();
// wait for pair to complete
uint8_t status = bikeSpeed.waitForPair();
// print channel status
Serial.println("===========================");
printStatus(status);
Serial.print("Device Number: ");
Serial.println(bikeSpeed.getDeviceNumber());
Serial.print("Transmisison Type: ");
Serial.println(bikeSpeed.getTransmissionType());
}
void loop() {
router.loop();
}
void batteryStatusDataPageHandler(BicycleSpeedBatteryStatus& msg, uintptr_t data) {
Serial.print("Fractional Battery Voltage: ");
Serial.println(msg.getFractionalBatteryVoltage());
Serial.print("Coarse Battery Voltage: ");
Serial.println(msg.getCoarseBatteryVoltage());
Serial.print("Battery Status: ");
bicycleSpeedBatteryStatus(msg.getBatteryStatus());
}
void motionAndSpeedDataPageHandler(BicycleSpeedMotionAndSpeed& msg, uintptr_t data) {
Serial.print("Flags: ");
bicycleSpeedFlags(msg.getFlags());
}
void cumulativeOperatingTimeDataPageHandler(BicycleSpeedCumulativeOperatingTime& msg, uintptr_t data) {
Serial.print("Cumulative Operating Time: ");
Serial.println(msg.getCumulativeOperatingTime());
}
void defaultDataPageHandler(BicycleSpeedDefault& msg, uintptr_t data) {
// All fields are reserved
}
void manufacturerIDDataPageHandler(BicycleSpeedManufacturerID& msg, uintptr_t data) {
Serial.print("Manufacturer ID LSB: ");
Serial.println(msg.getManufacturerId());
Serial.print("Serial Number: ");
Serial.println(msg.getSerialNumber());
}
void productIDDataPageHandler(BicycleSpeedProductID& msg, uintptr_t data) {
Serial.print("Hardware Version: ");
Serial.println(msg.getHardwareVersion());
Serial.print("Software Version: ");
Serial.println(msg.getSoftwareVersion());
Serial.print("Model Number: ");
Serial.println(msg.getModelNumber());
}
void bicycleSpeedBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) {
BicycleSpeedBaseMainDataPage dp = BicycleSpeedBaseMainDataPage(msg);
Serial.println("===========================");
Serial.print("DataPage: ");
Serial.println(dp.getDataPageNumber());
Serial.print("Bike Speed Event Time: ");
Serial.println(dp.getBikeSpeedEventTime());
Serial.print("Cumulative Speed Revolution Count: ");
Serial.println(dp.getCumulativeSpeedRevolutionCount());
}
void printStatus(uint8_t status) {
Serial.print("Channel Status: ");
switch (status) {
case CHANNEL_STATUS_UNASSIGNED:
Serial.println("Unassigned");
break;
case CHANNEL_STATUS_ASSIGNED:
Serial.println("Assigned");
break;
case CHANNEL_STATUS_SEARCHING:
Serial.println("Searching");
break;
case CHANNEL_STATUS_TRACKING:
Serial.println("Tracking");
break;
}
}
void bicycleSpeedFlags(uint8_t flags) {
if (flags & ANTPLUS_BICYCLESPEED_DATAPAGE_MOTIONANDSPEED_FLAGS_STOPINDICATOR) {
Serial.print("Motion Stopped");
}
Serial.println();
}
void bicycleSpeedBatteryStatus(uint8_t flags) {
switch (flags) {
case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_NEW:
Serial.println("New");
break;
case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_GOOD:
Serial.println("Good");
break;
case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_OK:
Serial.println("Ok");
break;
case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_LOW:
Serial.println("Low");
break;
case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_CRITICAL:
Serial.println("Critical");
break;
case ANTPLUS_BICYCLESPEED_DATAPAGE_BATTERSTATUS_BATTERYSTATUS_INVALID:
Serial.println("Invalid");
break;
default:
Serial.println("Reserved/Unknown");
break;
}
}
@@ -0,0 +1,141 @@
/***********************************
* AntPlus Environment Display example
*
* Finds a nearby environment monitor, pairs
* to it and then reads the information
* out via the serial port.
*
* Author Curtis Malainey
************************************/
#include <Arduino.h>
#include "ANT.h"
#include "ANTPLUS.h"
#define BAUD_RATE 9600
#define CHANNEL_0 0
const uint8_t NETWORK_KEY[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; // get this from thisisant.com
AntWithCallbacks ant = AntWithCallbacks();
AntPlusRouter router = AntPlusRouter();
ProfileEnvironmentDisplay env = ProfileEnvironmentDisplay();
void generalInformationDataPageHandler(EnvironmentGeneralInformation& msg, uintptr_t data);
void temperatureDataPageHandler(EnvironmentTemperature& msg, uintptr_t data);
void manufacturersInformationDataPageHandler(ManufacturersInformation& msg, uintptr_t data);
void productInformationDataPageHandler(ProductInformation& msg, uintptr_t data);
void printStatus(uint8_t status);
void setup() {
Serial1.begin(BAUD_RATE);
ant.setSerial(Serial1);
delay(15000);
router.setDriver(&ant); // never touch ant again
router.setAntPlusNetworkKey(NETWORK_KEY);
router.setProfile(CHANNEL_0, &env);
// Delay after initial setup to wait for user to connect on serial
Serial.begin(BAUD_RATE);
Serial.println("Running");
env.onEnvironmentGeneralInformation(generalInformationDataPageHandler);
env.onEnvironmentTemperature(temperatureDataPageHandler);
env.onManufacturersInformation(manufacturersInformationDataPageHandler);
env.onProductInformation(productInformationDataPageHandler);
env.begin();
// wait for pair to complete
uint8_t status = env.waitForPair();
// print channel status
Serial.println("===========================");
printStatus(status);
Serial.print("Device Number: ");
Serial.println(env.getDeviceNumber());
Serial.print("Transmisison Type: ");
Serial.println(env.getTransmissionType());
}
void loop() {
router.loop();
}
void generalInformationDataPageHandler(EnvironmentGeneralInformation& msg, uintptr_t data) {
Serial.println("===========================");
Serial.print("DataPage: ");
Serial.println(msg.getDataPageNumber());
Serial.print("Local Time: ");
Serial.println(msg.getTransmissionInfoLocalTime());
Serial.print("UTC Time: ");
Serial.println(msg.getTransmissionInfoUtcTime());
Serial.print("Default Transmisison Rate: ");
if (msg.getTransmissionInfoDefaultTransmissionRate() == 0) {
Serial.println("0.5Hz");
} else if (msg.getTransmissionInfoDefaultTransmissionRate() == 1) {
Serial.println("4Hz");
} else {
Serial.println("Unknown");
}
Serial.println("Supported Pages: ");
if (msg.getSupportedPages() & ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_SUPPORTEDPAGES_PAGE0SUPPORT) {
Serial.println("Page 0 Supported");
}
if (msg.getSupportedPages() & ANTPLUS_ENVIRONMENT_DATAPAGE_GENERALINFORMATION_SUPPORTEDPAGES_PAGE1SUPPORT) {
Serial.println("Page 1 Supported");
}
}
void temperatureDataPageHandler(EnvironmentTemperature& msg, uintptr_t data) {
Serial.println("===========================");
Serial.print("DataPage: ");
Serial.println(msg.getDataPageNumber());
Serial.print("Event Count: ");
Serial.println(msg.getEventCount());
Serial.print("24h Low (C): ");
Serial.println(msg.get24HourLow()*0.1);
Serial.print("24h High (C): ");
Serial.println(msg.get24HourHigh()*0.1);
Serial.print("Current Temp (C): ");
Serial.println(msg.getCurrentTemp()*0.01);
}
void manufacturersInformationDataPageHandler(ManufacturersInformation& msg, uintptr_t data) {
Serial.println("===========================");
Serial.print("DataPage: ");
Serial.println(msg.getDataPageNumber());
Serial.print("HW Revision: ");
Serial.println(msg.getHWRevision());
Serial.print("ManufacturerID: ");
Serial.println(msg.getManufacturerID());
Serial.print("Model Number: ");
Serial.println(msg.getModelNumber());
}
void productInformationDataPageHandler(ProductInformation& msg, uintptr_t data) {
Serial.println("===========================");
Serial.print("DataPage: ");
Serial.println(msg.getDataPageNumber());
Serial.print("SW Revision Supplemental: ");
Serial.println(msg.getSWRevisionSupplemental());
Serial.print("SW Revision Main: ");
Serial.println(msg.getSWRevisionMain());
Serial.print("Serial Number: ");
Serial.println(msg.getSerialNumber());
}
void printStatus(uint8_t status) {
Serial.print("Channel Status: ");
switch (status) {
case CHANNEL_STATUS_UNASSIGNED:
Serial.println("Unassigned");
break;
case CHANNEL_STATUS_ASSIGNED:
Serial.println("Assigned");
break;
case CHANNEL_STATUS_SEARCHING:
Serial.println("Searching");
break;
case CHANNEL_STATUS_TRACKING:
Serial.println("Tracking");
break;
}
}
@@ -1,7 +1,7 @@
/***********************************
* AntPlus HRMonitor example
* AntPlus HRDisplay example
*
* Finds a nearby HR sensor, pairs
* Finds a nearby HR Monitor, pairs
* to it and then reads the information
* out via the serial port.
*
@@ -18,7 +18,7 @@ const uint8_t NETWORK_KEY[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77};
AntWithCallbacks ant = AntWithCallbacks();
AntPlusRouter router = AntPlusRouter();
ProfileHeartRateMonitor hr = ProfileHeartRateMonitor();
ProfileHeartRateDisplay hr = ProfileHeartRateDisplay();
void heartRateBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data);
void batteryStatusDataPageHandler(HeartRateBatteryStatus& msg, uintptr_t data);
@@ -29,7 +29,6 @@ void manufacturerInformationDataPageHandler(HeartRateManufacturerInformation& ms
void previousHeartBeatDataPageHandler(HeartRatePreviousHeartBeat& msg, uintptr_t data);
void productInformationDataPageHandler(HeartRateProductInformation& msg, uintptr_t data);
void swimIntervalSummary(HeartRateSwimIntervalSummary& msg, uintptr_t data);
void modeSettings(ModeSettings& msg, uintptr_t data);
void heartRateFeatures(uint8_t bitfield);
void printStatus(uint8_t status);
@@ -55,7 +54,6 @@ void setup() {
hr.onHeartRatePreviousHeartBeat(previousHeartBeatDataPageHandler);
hr.onHeartRateProductInformation(productInformationDataPageHandler);
hr.onHeartRateSwimIntervalSummary(swimIntervalSummary);
hr.onModeSettings(modeSettings);
hr.begin();
// wait for pair to complete
uint8_t status = hr.waitForPair();
@@ -131,22 +129,6 @@ void swimIntervalSummary(HeartRateSwimIntervalSummary& msg, uintptr_t data) {
Serial.println(msg.getSessionAverageHeartRate());
}
void modeSettings(ModeSettings& msg, uintptr_t data) {
Serial.print("Sports Mode: ");
uint8_t sportMode = msg.getSportMode();
switch (sportMode) {
case 0x01:
Serial.println("Running");
break;
case 0x02:
Serial.println("Cycling");
break;
case 0x05:
Serial.println("Swimming");
break;
}
}
void heartRateBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) {
HeartRateBaseMainDataPage dp = HeartRateBaseMainDataPage(msg);
Serial.println("===========================");
@@ -195,4 +177,4 @@ void printStatus(uint8_t status) {
Serial.println("Tracking");
break;
}
}
}
Oops, something went wrong.

0 comments on commit d44c8e2

Please sign in to comment.