Adafruit_Sensor.cpp 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #include "Adafruit_Sensor.h"
  2. /**************************************************************************/
  3. /*!
  4. @brief Prints sensor information to serial console
  5. */
  6. /**************************************************************************/
  7. void Adafruit_Sensor::printSensorDetails(void) {
  8. sensor_t sensor;
  9. getSensor(&sensor);
  10. Serial.println(F("------------------------------------"));
  11. Serial.print(F("Sensor: "));
  12. Serial.println(sensor.name);
  13. Serial.print(F("Type: "));
  14. switch ((sensors_type_t)sensor.type) {
  15. case SENSOR_TYPE_ACCELEROMETER:
  16. Serial.print(F("Acceleration (m/s2)"));
  17. break;
  18. case SENSOR_TYPE_MAGNETIC_FIELD:
  19. Serial.print(F("Magnetic (uT)"));
  20. break;
  21. case SENSOR_TYPE_ORIENTATION:
  22. Serial.print(F("Orientation (degrees)"));
  23. break;
  24. case SENSOR_TYPE_GYROSCOPE:
  25. Serial.print(F("Gyroscopic (rad/s)"));
  26. break;
  27. case SENSOR_TYPE_LIGHT:
  28. Serial.print(F("Light (lux)"));
  29. break;
  30. case SENSOR_TYPE_PRESSURE:
  31. Serial.print(F("Pressure (hPa)"));
  32. break;
  33. case SENSOR_TYPE_PROXIMITY:
  34. Serial.print(F("Distance (cm)"));
  35. break;
  36. case SENSOR_TYPE_GRAVITY:
  37. Serial.print(F("Gravity (m/s2)"));
  38. break;
  39. case SENSOR_TYPE_LINEAR_ACCELERATION:
  40. Serial.print(F("Linear Acceleration (m/s2)"));
  41. break;
  42. case SENSOR_TYPE_ROTATION_VECTOR:
  43. Serial.print(F("Rotation vector"));
  44. break;
  45. case SENSOR_TYPE_RELATIVE_HUMIDITY:
  46. Serial.print(F("Relative Humidity (%)"));
  47. break;
  48. case SENSOR_TYPE_AMBIENT_TEMPERATURE:
  49. Serial.print(F("Ambient Temp (C)"));
  50. break;
  51. case SENSOR_TYPE_OBJECT_TEMPERATURE:
  52. Serial.print(F("Object Temp (C)"));
  53. break;
  54. case SENSOR_TYPE_VOLTAGE:
  55. Serial.print(F("Voltage (V)"));
  56. break;
  57. case SENSOR_TYPE_CURRENT:
  58. Serial.print(F("Current (mA)"));
  59. break;
  60. case SENSOR_TYPE_COLOR:
  61. Serial.print(F("Color (RGBA)"));
  62. break;
  63. case SENSOR_TYPE_TVOC:
  64. Serial.print(F("Total Volatile Organic Compounds (ppb)"));
  65. break;
  66. case SENSOR_TYPE_VOC_INDEX:
  67. Serial.print(F("Volatile Organic Compounds (Index)"));
  68. break;
  69. case SENSOR_TYPE_NOX_INDEX:
  70. Serial.print(F("Nitrogen Oxides (Index)"));
  71. break;
  72. }
  73. Serial.println();
  74. Serial.print(F("Driver Ver: "));
  75. Serial.println(sensor.version);
  76. Serial.print(F("Unique ID: "));
  77. Serial.println(sensor.sensor_id);
  78. Serial.print(F("Min Value: "));
  79. Serial.println(sensor.min_value);
  80. Serial.print(F("Max Value: "));
  81. Serial.println(sensor.max_value);
  82. Serial.print(F("Resolution: "));
  83. Serial.println(sensor.resolution);
  84. Serial.println(F("------------------------------------\n"));
  85. }