Skip to content

Commit c198052

Browse files
committed
Merge branch 'develop' for 1.2.0 release
2 parents 7dd75b6 + c9d3080 commit c198052

File tree

377 files changed

+7794
-2994
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

377 files changed

+7794
-2994
lines changed

.github/workflows/main.yml

+9-1
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@ jobs:
1414
strategy:
1515
matrix:
1616
example: [
17+
examples/BicyclePowerDisplay/BicyclePowerDisplay.ino,
18+
examples/BicyclePowerSensor/BicyclePowerSensor.ino,
1719
examples/BicycleSpeedDisplay/BicycleSpeedDisplay.ino,
1820
examples/DeviceSearch/DeviceSearch.ino,
1921
examples/DynamicProfiles/DynamicProfiles.ino,
2022
examples/EnvironmentDisplay/EnvironmentDisplay.ino,
23+
examples/FecBikeTrainerDisplay/FecBikeTrainerDisplay.ino,
2124
examples/HeartRateDisplay/HeartRateDisplay.ino,
2225
examples/HeartRateMonitor/HeartRateMonitor.ino,
23-
examples/LEVDisplay/LEVDisplay.ino]
26+
examples/LEVDisplay/LEVDisplay.ino,
27+
examples/MuscleOxygenMonitor/MuscleOxygenMonitor.ino,
28+
examples/ShiftingShifter/ShiftingShifter.ino]
2429

2530
# Steps represent a sequence of tasks that will be executed as part of the job
2631
steps:
@@ -83,6 +88,9 @@ jobs:
8388
python -m pip install --upgrade pip
8489
pip install --upgrade platformio
8590
91+
- name: Install platform
92+
run: pio platform install native
93+
8694
- name: Install library dependencies
8795
run: pio lib -g install ANT
8896

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
.piolibdeps
33
.ycm*
44
*.swp
5+
*.DS_Store
56

67
# used for testing
78
src/main.cpp
9+
810
.DS_Store
911
.tags*
1012
tags
1113
.pio
14+
*-e
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,281 @@
1+
/***********************************
2+
* AntPlus Bicycle Power Display example
3+
*
4+
* Finds a nearby Bike Power Sensor, pairs
5+
* to it and then reads the information
6+
* out via the serial port.
7+
*
8+
* Example built for ESP32
9+
* Note: HardwareSerial required for this controller
10+
*
11+
* Author Andrew Hillier
12+
* based on the work of Curtis Malainey
13+
************************************/
14+
#include <Arduino.h>
15+
#include "ANT.h"
16+
#include "ANTPLUS.h"
17+
#include <HardwareSerial.h>
18+
19+
#define BAUD_RATE 9600
20+
#define CHANNEL_0 0
21+
#define antSerial Serial2
22+
23+
const uint8_t NETWORK_KEY[] = {0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77}; // get this from thisisant.com
24+
25+
// *************************************
26+
// Specific to test ANT+ chip and ESP32 setup
27+
const int RTS_PIN = 23;
28+
const int SUSPEND_PIN = 22;
29+
const int SLEEP_PIN = 19;
30+
const int RESET_PIN = 2;
31+
32+
// *************************************
33+
34+
ArduinoSerialAntWithCallbacks ant;
35+
AntPlusRouter router;
36+
ProfileBicyclePowerDisplay bikePower;
37+
38+
void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data);
39+
void batteryStatusDataPageHandler(BatteryStatus& msg, uintptr_t data);
40+
void manufacturerIDDataPageHandler(ManufacturersInformation& msg, uintptr_t data);
41+
void productIDDataPageHandler(ProductInformation& msg, uintptr_t data);
42+
void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnly& msg, uintptr_t data);
43+
void crankTorqueDataPageHandler(BicyclePowerStandardCrankTorque& msg, uintptr_t data);
44+
void wheelTorqueDataPageHandler(BicyclePowerStandardWheelTorque& msg, uintptr_t data);
45+
void pedalSmoothnessDataPageHandler(BicyclePowerTorqueEffectivenessAndPedalSmoothness& msg, uintptr_t data);
46+
void crankTorqueFrequencyDataPageHandler(BicyclePowerCrankTorqueFrequency& msg, uintptr_t data);
47+
48+
void bicyclePowerBatteryStatus(uint8_t flags);
49+
void printStatus(uint8_t status);
50+
51+
void setup() {
52+
53+
// Powering on the ANT+ chip
54+
// *************************************
55+
56+
pinMode(SUSPEND_PIN, OUTPUT);
57+
pinMode(SLEEP_PIN, OUTPUT);
58+
pinMode(RESET_PIN, OUTPUT);
59+
pinMode(RTS_PIN, INPUT);
60+
61+
digitalWrite(RESET_PIN, HIGH);
62+
digitalWrite(SUSPEND_PIN, HIGH);
63+
digitalWrite(SLEEP_PIN, LOW);
64+
65+
66+
// *************************************
67+
68+
antSerial.begin(BAUD_RATE);
69+
ant.setSerial(antSerial);
70+
delay(5000);
71+
72+
router.setDriver(&ant); // never touch ant again
73+
router.setAntPlusNetworkKey(NETWORK_KEY);
74+
router.setProfile(CHANNEL_0, &bikePower);
75+
// Delay after initial setup to wait for user to connect on serial
76+
77+
Serial.begin(BAUD_RATE);
78+
Serial.println("Running");
79+
bikePower.onDataPage(bicyclePowerBaseDataPageHandler);
80+
bikePower.onBatteryStatus(batteryStatusDataPageHandler);
81+
bikePower.onManufacturersInformation(manufacturerIDDataPageHandler);
82+
bikePower.onProductInformation(productIDDataPageHandler);
83+
bikePower.onBicyclePowerStandardPowerOnly(powerOnlyDataPageHandler);
84+
bikePower.onBicyclePowerStandardCrankTorque(crankTorqueDataPageHandler);
85+
bikePower.onBicyclePowerStandardWheelTorque(wheelTorqueDataPageHandler);
86+
bikePower.onBicyclePowerTorqueEffectivenessAndPedalSmoothness(pedalSmoothnessDataPageHandler);
87+
bikePower.onBicyclePowerCrankTorqueFrequency(crankTorqueFrequencyDataPageHandler);
88+
bikePower.begin();
89+
// wait for pair to complete
90+
uint8_t status = bikePower.waitForPair();
91+
// print channel status
92+
Serial.println("===========================");
93+
printStatus(status);
94+
Serial.print("Device Number: ");
95+
Serial.println(bikePower.getDeviceNumber());
96+
Serial.print("Transmisison Type: ");
97+
Serial.println(bikePower.getTransmissionType());
98+
}
99+
100+
void loop() {
101+
router.loop();
102+
}
103+
104+
void printOrInvalid(uint8_t value, uint8_t invalidValue) {
105+
if (value == invalidValue) {
106+
Serial.println("Invalid");
107+
} else {
108+
Serial.println(value);
109+
}
110+
}
111+
112+
void crankTorqueFrequencyDataPageHandler(BicyclePowerCrankTorqueFrequency& msg, uintptr_t data) {
113+
Serial.print("Slope: ");
114+
Serial.println(msg.getSlope());
115+
Serial.print("Timestamp: ");
116+
Serial.println(msg.getTimeStamp());
117+
Serial.print("Torque Ticks Stamp: ");
118+
Serial.println(msg.getTorqueTicksStamp());
119+
}
120+
121+
void batteryStatusDataPageHandler(BatteryStatus& msg, uintptr_t data) {
122+
Serial.print("Number of Batteries: ");
123+
Serial.println(msg.getNumberOfBatteries());
124+
Serial.print("Battery Identifier: ");
125+
Serial.println(msg.getBatteryIdentifier());
126+
Serial.print("Cumulative Operating Time: ");
127+
Serial.println(msg.getCumulativeOperatingTime());
128+
Serial.print("Fractional Battery Voltage: ");
129+
Serial.println(msg.getFractionalBatteryVoltage());
130+
Serial.print("Coarse Battery Voltage: ");
131+
Serial.println(msg.getCoarseBatteryVoltage());
132+
Serial.print("Battery Status: ");
133+
bicyclePowerBatteryStatus(msg.getBatteryStatus());
134+
Serial.print("Cumulative Operating Time Resolution: ");
135+
Serial.println(msg.getCumulativeOperatingTimeResolution());
136+
}
137+
138+
void manufacturerIDDataPageHandler(ManufacturersInformation& msg, uintptr_t data) {
139+
Serial.print("Hardware ID: ");
140+
Serial.println(msg.getHWRevision());
141+
Serial.print("Manufacturer ID: ");
142+
Serial.println(msg.getManufacturerID());
143+
Serial.print("Model Number: ");
144+
Serial.println(msg.getModelNumber());
145+
}
146+
147+
void productIDDataPageHandler(ProductInformation& msg, uintptr_t data) {
148+
Serial.print("Software Version Supplemental: ");
149+
Serial.println(msg.getSWRevisionSupplemental());
150+
Serial.print("Software Version: ");
151+
Serial.println(msg.getSWRevisionMain());
152+
Serial.print("Serial Number: ");
153+
Serial.println(msg.getSerialNumber());
154+
}
155+
156+
void bicyclePowerBaseDataPageHandler(AntRxDataResponse& msg, uintptr_t data) {
157+
BicyclePowerBaseMainDataPage dp = BicyclePowerBaseMainDataPage(msg);
158+
Serial.println("===========================");
159+
Serial.print("DataPage: ");
160+
Serial.println(dp.getDataPageNumber());
161+
if (dp.getDataPageNumber() >= ANTPLUS_COMMON_DATAPAGE_REQUESTDATAPAGE_NUMBER) {
162+
return;
163+
}
164+
Serial.print("Update Event Count: ");
165+
Serial.println(dp.getUpdateEventCount());
166+
}
167+
168+
void powerOnlyDataPageHandler(BicyclePowerStandardPowerOnly& msg, uintptr_t data) {
169+
Serial.print("Pedal Power: ");
170+
if (msg.getPedalPower() == ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALPOWER_NOTUSED &&
171+
msg.getPedalDifferentiation()) {
172+
Serial.println("Not Used");
173+
} else {
174+
Serial.println(msg.getPedalPower());
175+
Serial.print(" From Pedal: ");
176+
if (msg.getPedalDifferentiation() == ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_PEDALDIFFERENTIATION_RIGHT) {
177+
Serial.println("Right");
178+
} else {
179+
Serial.println("Unknown");
180+
}
181+
}
182+
Serial.print("Instantaneous Cadence: ");
183+
if (msg.getInstantaneousCadence() == ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDPOWERONLY_INSTANTANEOUSCADENCE_INVALID) {
184+
Serial.println("Invalid");
185+
} else {
186+
Serial.println(msg.getInstantaneousCadence());
187+
}
188+
Serial.print("Accumulated Power: ");
189+
Serial.println(msg.getAccumulatedPower());
190+
Serial.print("Instantaneous Power: ");
191+
Serial.println(msg.getInstantaneousPower());
192+
}
193+
194+
void crankTorqueDataPageHandler(BicyclePowerStandardCrankTorque& msg, uintptr_t data) {
195+
Serial.print("Crank Ticks: ");
196+
Serial.println(msg.getCrankTicks());
197+
Serial.print("Instantaneous Cadence: ");
198+
printOrInvalid(msg.getInstantaneousCadence(),
199+
ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDCRANKTORQUE_INSTANTANEOUSCADENCE_INVALID);
200+
Serial.print("Crank Period: ");
201+
Serial.println(msg.getCrankPeriod());
202+
Serial.print("Accumulated Torque: ");
203+
Serial.println(msg.getAccumulatedTorque());
204+
}
205+
206+
void wheelTorqueDataPageHandler(BicyclePowerStandardWheelTorque& msg, uintptr_t data) {
207+
Serial.print("Wheel Ticks: ");
208+
Serial.println(msg.getWheelTicks());
209+
Serial.print("Instantaneous Cadence: ");
210+
printOrInvalid(msg.getInstantaneousCadence(),
211+
ANTPLUS_BICYCLEPOWER_DATAPAGES_STANDARDWHEELTORQUE_INSTANTANEOUSCADENCE_INVALID);
212+
Serial.print("Wheel Period: ");
213+
Serial.println(msg.getWheelPeriod());
214+
Serial.print("Accumulated Torque: ");
215+
Serial.println(msg.getAccumulatedTorque());
216+
}
217+
218+
void pedalSmoothnessDataPageHandler(BicyclePowerTorqueEffectivenessAndPedalSmoothness& msg, uintptr_t data) {
219+
Serial.print("Left Torque Effectiveness: ");
220+
printOrInvalid(msg.getLeftTorqueEffectiveness(),
221+
ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_TORQUEEFFECTIVENESS_INVALID);
222+
Serial.print("Right Torque Effectiveness: ");
223+
printOrInvalid(msg.getRightTorqueEffectiveness(),
224+
ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_TORQUEEFFECTIVENESS_INVALID);
225+
if (msg.getRightPedalSmoothness() == ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_RIGHTPEDALSMOOTHNESS_COMBINED) {
226+
Serial.print("Combined Pedal Smoothness: ");
227+
printOrInvalid(msg.getLeftPedalSmoothness(),
228+
ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_PEDALSMOOTHNESS_INVALID);
229+
} else {
230+
Serial.print("Left Pedal Smoothness: ");
231+
printOrInvalid(msg.getLeftPedalSmoothness(),
232+
ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_PEDALSMOOTHNESS_INVALID);
233+
Serial.print("Right Pedal Smoothness: ");
234+
printOrInvalid(msg.getRightPedalSmoothness(),
235+
ANTPLUS_BICYCLEPOWER_DATAPAGES_TORQUEEFFECTIVENESSANDPEDALSMOOTHNESS_PEDALSMOOTHNESS_INVALID);
236+
}
237+
}
238+
239+
void printStatus(uint8_t status) {
240+
Serial.print("Channel Status: ");
241+
switch (status) {
242+
case CHANNEL_STATUS_UNASSIGNED:
243+
Serial.println("Unassigned");
244+
break;
245+
case CHANNEL_STATUS_ASSIGNED:
246+
Serial.println("Assigned");
247+
break;
248+
case CHANNEL_STATUS_SEARCHING:
249+
Serial.println("Searching");
250+
break;
251+
case CHANNEL_STATUS_TRACKING:
252+
Serial.println("Tracking");
253+
break;
254+
}
255+
}
256+
257+
void bicyclePowerBatteryStatus(uint8_t flags) {
258+
switch (flags) {
259+
case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_NEW:
260+
Serial.println("New");
261+
break;
262+
case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_GOOD:
263+
Serial.println("Good");
264+
break;
265+
case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_OK:
266+
Serial.println("Ok");
267+
break;
268+
case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_LOW:
269+
Serial.println("Low");
270+
break;
271+
case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_CRITICAL:
272+
Serial.println("Critical");
273+
break;
274+
case ANTPLUS_COMMON_DATAPAGE_BATTERYSTATUS_BATTERYSTATUS_INVALID:
275+
Serial.println("Invalid");
276+
break;
277+
default:
278+
Serial.println("Reserved/Unknown");
279+
break;
280+
}
281+
}

0 commit comments

Comments
 (0)