No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

AntPlus.ino 1.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #include <USBHost_t36.h>
  2. USBHost myusb;
  3. USBHub hub1(myusb);
  4. USBHub hub2(myusb);
  5. AntPlus ant1(myusb);
  6. void setup() {
  7. while (!Serial) ; // wait for Arduino Serial Monitor
  8. Serial.println("Ant+ USB Test");
  9. myusb.begin();
  10. ant1.begin();
  11. ant1.setWheelCircumference(2.112); // wheel circumference, in meters
  12. ant1.onStatusChange(handleStatusChange);
  13. ant1.onDeviceID(handleDeviceID);
  14. ant1.onHeartRateMonitor(handleHeartRateMonitor);
  15. ant1.onSpeedCadence(handleSpeedCadence);
  16. }
  17. void loop() {
  18. myusb.Task();
  19. }
  20. void handleHeartRateMonitor(int beatsPerMinute, int milliseconds, int sequenceNumber) {
  21. Serial.print("HRM: sequence:");
  22. Serial.print(sequenceNumber);
  23. Serial.print(", interval:");
  24. Serial.print(milliseconds);
  25. Serial.print("ms, bpm:");
  26. Serial.println(beatsPerMinute);
  27. }
  28. void handleSpeedCadence(float speed, float distance, float rotationPerMinute) {
  29. Serial.print("SPDCAD: speed: ");
  30. Serial.print(speed);
  31. Serial.print(" km/h, cadence: ");
  32. Serial.print(rotationPerMinute);
  33. Serial.print("rpm, total distance: ");
  34. Serial.print(distance);
  35. Serial.println("km");
  36. }
  37. void handleStatusChange(int channel, int status) {
  38. Serial.print("Channel ");
  39. Serial.print(channel);
  40. Serial.print(" status: ");
  41. switch (status) {
  42. case 0: Serial.println("STATUS UNASSIGNED CHANNEL"); break;
  43. case 1: Serial.println("STATUS ASSIGNED CHANNEL"); break;
  44. case 2: Serial.println("STATUS SEARCHING CHANNEL"); break;
  45. case 3: Serial.println("STATUS TRACKING_CHANNEL"); break;
  46. default: Serial.println("UNKNOWN STATUS STATE");
  47. }
  48. }
  49. void handleDeviceID(int channel, int devId, int devType, int transType) {
  50. Serial.print("Device found on channel ");
  51. Serial.print(channel);
  52. Serial.print(": deviceId:");
  53. Serial.print(devId);
  54. Serial.print(", deviceType:");
  55. Serial.print(devType);
  56. Serial.print(", transType:");
  57. Serial.println(transType);
  58. }