Adafruit Library
WipperSnapper_I2C_Driver.h
Go to the documentation of this file.
1 
16 #ifndef WipperSnapper_I2C_Driver_H
17 #define WipperSnapper_I2C_Driver_H
18 
19 #include <Adafruit_Sensor.h>
20 #include <Arduino.h>
21 
22 #define PERIOD_24HRS_AGO_MILLIS (millis() - (24 * 60 * 60 * 1000))
23 
25 /**************************************************************************/
29 /**************************************************************************/
31 
32 public:
33  /*******************************************************************************/
41  /*******************************************************************************/
42  WipperSnapper_I2C_Driver(TwoWire *i2c, uint16_t sensorAddress) {
43  _i2c = i2c;
44  _sensorAddress = sensorAddress;
45  }
46 
47  /*******************************************************************************/
51  /*******************************************************************************/
53 
54  /*******************************************************************************/
59  /*******************************************************************************/
60  bool begin() { return false; }
61 
62  /*******************************************************************************/
70  /*******************************************************************************/
71  void setSensorPeriod(float period,
72  wippersnapper_i2c_v1_SensorType sensorType) {
73  long sensorPeriod = (long)period * 1000;
74 
75  switch (sensorType) {
76  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE:
77  _tempSensorPeriod = sensorPeriod;
78  break;
79  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY:
80  _humidSensorPeriod = sensorPeriod;
81  break;
82  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PRESSURE:
83  _pressureSensorPeriod = sensorPeriod;
84  break;
85  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_CO2:
86  _CO2SensorPeriod = sensorPeriod;
87  break;
88  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_ECO2:
89  _ECO2SensorPeriod = sensorPeriod;
90  break;
91  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_TVOC:
92  _TVOCSensorPeriod = sensorPeriod;
93  break;
94  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_ALTITUDE:
95  _altitudeSensorPeriod = sensorPeriod;
96  break;
97  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE:
98  _objectTempSensorPeriod = sensorPeriod;
99  break;
100  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_LIGHT:
101  _lightSensorPeriod = sensorPeriod;
102  break;
103  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PM10_STD:
104  _PM10SensorPeriod = sensorPeriod;
105  break;
106  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PM25_STD:
107  _PM25SensorPeriod = sensorPeriod;
108  break;
109  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PM100_STD:
110  _PM100SensorPeriod = sensorPeriod;
111  break;
112  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_UNITLESS_PERCENT:
113  _unitlessPercentPeriod = sensorPeriod;
114  break;
115  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_VOLTAGE:
116  _voltagePeriod = sensorPeriod;
117  break;
118  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_CURRENT:
119  _currentPeriod = sensorPeriod;
120  break;
121  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PROXIMITY:
122  _proximitySensorPeriod = sensorPeriod;
123  break;
124  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_RAW:
125  _rawSensorPeriod = sensorPeriod;
126  break;
127  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT:
128  _ambientTempFPeriod = sensorPeriod;
129  break;
130  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE_FAHRENHEIT:
131  _objectTempFPeriod = sensorPeriod;
132  break;
133  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_GAS_RESISTANCE:
134  _gasResistancePeriod = sensorPeriod;
135  break;
136  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_NOX_INDEX:
137  _NOxIndexPeriod = sensorPeriod;
138  break;
139  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_VOC_INDEX:
140  _VOCIndexPeriod = sensorPeriod;
141  break;
142  default:
143  break;
144  }
145  }
146 
147  /*******************************************************************************/
154  /*******************************************************************************/
155  void
156  configureDriver(wippersnapper_i2c_v1_I2CDeviceInitRequest *msgDeviceInitReq) {
157  int propertyIdx = 0; // contains the amount of i2c sensors in the
158  // msgDeviceInitReq to configure
159  while (propertyIdx < msgDeviceInitReq->i2c_device_properties_count) {
161  msgDeviceInitReq->i2c_device_properties[propertyIdx].sensor_period,
162  msgDeviceInitReq->i2c_device_properties[propertyIdx].sensor_type);
163  ++propertyIdx;
164  }
165  }
166 
167  /*******************************************************************************/
172  /*******************************************************************************/
173  uint16_t getI2CAddress() { return _sensorAddress; }
174 
175  /****************************** SENSOR_TYPE: CO2
176  * *******************************/
177  /*********************************************************************************/
183  /*********************************************************************************/
184  virtual long getSensorCO2Period() { return _CO2SensorPeriod; }
185 
186  /*********************************************************************************/
192  /*********************************************************************************/
193  virtual long getSensorCO2PeriodPrv() { return _CO2SensorPeriodPrv; }
194 
195  /*******************************************************************************/
201  /*******************************************************************************/
202  virtual void setSensorCO2PeriodPrv(long period) {
203  _CO2SensorPeriodPrv = period;
204  }
205 
206  /*******************************************************************************/
214  /*******************************************************************************/
215  virtual bool getEventCO2(sensors_event_t *co2Event) {
216  (void)
217  co2Event; // Parameter is intentionally unused in this virtual function.
218  return false;
219  }
220 
221  /****************************** SENSOR_TYPE: ECO2
222  * *******************************/
223  /*********************************************************************************/
229  /*********************************************************************************/
230  virtual long getSensorECO2Period() { return _ECO2SensorPeriod; }
231 
232  /*********************************************************************************/
238  /*********************************************************************************/
239  virtual long getSensorECO2PeriodPrv() { return _ECO2SensorPeriodPrv; }
240 
241  /*******************************************************************************/
247  /*******************************************************************************/
248  virtual void setSensorECO2PeriodPrv(long period) {
249  _ECO2SensorPeriodPrv = period;
250  }
251 
252  /*******************************************************************************/
260  /*******************************************************************************/
261  virtual bool getEventECO2(sensors_event_t *eco2Event) {
262  (void)eco2Event; // Parameter is intentionally unused in this virtual
263  // function.
264  return false;
265  }
266 
267  /****************************** SENSOR_TYPE: TVOC
268  * *******************************/
269  /*********************************************************************************/
275  /*********************************************************************************/
276  virtual long getSensorTVOCPeriod() { return _TVOCSensorPeriod; }
277 
278  /*********************************************************************************/
284  /*********************************************************************************/
285  virtual long getSensorTVOCPeriodPrv() { return _TVOCSensorPeriodPrv; }
286 
287  /*******************************************************************************/
293  /*******************************************************************************/
294  virtual void setSensorTVOCPeriodPrv(long period) {
295  _TVOCSensorPeriodPrv = period;
296  }
297 
298  /*******************************************************************************/
306  /*******************************************************************************/
307  virtual bool getEventTVOC(sensors_event_t *tvocEvent) {
308  (void)tvocEvent; // Parameter is intentionally unused in this virtual
309  // function.
310  return false;
311  }
312 
313  /********************** SENSOR_TYPE: AMBIENT TEMPERATURE (°C)
314  * ***********************/
315  /*********************************************************************************/
321  /*********************************************************************************/
323 
324  /*********************************************************************************/
331  /*********************************************************************************/
333 
334  /*******************************************************************************/
342  /*******************************************************************************/
343  virtual void setSensorAmbientTempPeriodPrv(long periodPrv) {
344  _tempSensorPeriodPrv = periodPrv;
345  }
346 
347  /*******************************************************************************/
356  /*******************************************************************************/
357  virtual bool getEventAmbientTemp(sensors_event_t *tempEvent) {
358  (void)tempEvent; // Parameter is intentionally unused in this virtual
359  // function.
360  return false;
361  }
362 
363  /************************* SENSOR_TYPE: RELATIVE_HUMIDITY
364  * ***********************/
365  /*********************************************************************************/
371  /*********************************************************************************/
373 
374  /*********************************************************************************/
380  /*********************************************************************************/
382  return _humidSensorPeriodPrv;
383  }
384 
385  /*******************************************************************************/
391  /*******************************************************************************/
392  virtual void setSensorRelativeHumidityPeriodPrv(long periodPrv) {
393  _humidSensorPeriodPrv = periodPrv;
394  }
395 
396  /*******************************************************************************/
405  /*******************************************************************************/
406  virtual bool getEventRelativeHumidity(sensors_event_t *humidEvent) {
407  (void)humidEvent; // Parameter is intentionally unused in this virtual
408  // function.
409  return false;
410  }
411 
412  /**************************** SENSOR_TYPE: PRESSURE
413  * ****************************/
414  /*********************************************************************************/
420  /*********************************************************************************/
422 
423  /*********************************************************************************/
429  /*********************************************************************************/
431 
432  /*******************************************************************************/
438  /*******************************************************************************/
439  virtual void setSensorPressurePeriodPrv(long period) {
440  _pressureSensorPeriodPrv = period;
441  }
442 
443  /*******************************************************************************/
452  /*******************************************************************************/
453  virtual bool getEventPressure(sensors_event_t *pressureEvent) {
454  (void)pressureEvent; // Parameter is intentionally unused in this virtual
455  // function.
456  return false;
457  }
458 
459  /**************************** SENSOR_TYPE: Altitude
460  * ****************************/
461  /*********************************************************************************/
467  /*********************************************************************************/
469 
470  /*********************************************************************************/
476  /*********************************************************************************/
478 
479  /*******************************************************************************/
485  /*******************************************************************************/
486  virtual void setSensorAltitudePeriodPrv(long period) {
487  _altitudeSensorPeriodPrv = period;
488  }
489 
490  /*******************************************************************************/
499  /*******************************************************************************/
500  virtual bool getEventAltitude(sensors_event_t *altitudeEvent) {
501  (void)altitudeEvent; // Parameter is intentionally unused in this virtual
502  // function.
503  return false;
504  }
505 
506  /**************************** SENSOR_TYPE: Object_Temperature
507  * ****************************/
508  /*********************************************************************************/
515  /*********************************************************************************/
517 
518  /*********************************************************************************/
525  /*********************************************************************************/
528  }
529 
530  /*******************************************************************************/
537  /*******************************************************************************/
538  virtual void setSensorObjectTempPeriodPrv(long period) {
540  }
541 
542  /*******************************************************************************/
551  /*******************************************************************************/
552  virtual bool getEventObjectTemp(sensors_event_t *objectTempEvent) {
553  (void)objectTempEvent; // Parameter is intentionally unused in this virtual
554  // function.
555  return false;
556  }
557 
558  /**************************** SENSOR_TYPE: LIGHT
559  * ****************************/
560  /*********************************************************************************/
567  /*********************************************************************************/
568  virtual long getSensorLightPeriod() { return _lightSensorPeriod; }
569 
570  /*********************************************************************************/
577  /*********************************************************************************/
579 
580  /*******************************************************************************/
587  /*******************************************************************************/
588  virtual void setSensorLightPeriodPrv(long period) {
589  _lightSensorPeriodPrv = period;
590  }
591 
592  /*******************************************************************************/
601  /*******************************************************************************/
602  virtual bool getEventLight(sensors_event_t *lightEvent) {
603  (void)lightEvent; // Parameter is intentionally unused in this virtual
604  // function.
605  return false;
606  }
607 
608  /**************************** SENSOR_TYPE: PM10_STD
609  * ****************************/
610  /*********************************************************************************/
617  /*********************************************************************************/
618  virtual long getSensorPM10_STDPeriod() { return _PM10SensorPeriod; }
619 
620  /*********************************************************************************/
627  /*********************************************************************************/
629 
630  /*******************************************************************************/
637  /*******************************************************************************/
638  virtual void setSensorPM10_STDPeriodPrv(long period) {
639  _PM10SensorPeriodPrv = period;
640  }
641 
642  /*******************************************************************************/
651  /*******************************************************************************/
652  virtual bool getEventPM10_STD(sensors_event_t *pm10StdEvent) {
653  (void)pm10StdEvent; // Parameter is intentionally unused in this virtual
654  // function.
655  return false;
656  }
657 
658  /**************************** SENSOR_TYPE: PM25_STD
659  * ****************************/
660  /*********************************************************************************/
667  /*********************************************************************************/
668  virtual long getSensorPM25_STDPeriod() { return _PM25SensorPeriod; }
669 
670  /*********************************************************************************/
677  /*********************************************************************************/
679 
680  /*******************************************************************************/
687  /*******************************************************************************/
688  virtual void setSensorPM25_STDPeriodPrv(long period) {
689  _PM25SensorPeriodPrv = period;
690  }
691 
692  /*******************************************************************************/
701  /*******************************************************************************/
702  virtual bool getEventPM25_STD(sensors_event_t *pm25StdEvent) {
703  (void)pm25StdEvent; // Parameter is intentionally unused in this virtual
704  // function.
705  return false;
706  }
707 
708  /**************************** SENSOR_TYPE: PM100_STD
709  * ****************************/
710  /*********************************************************************************/
717  /*********************************************************************************/
718  virtual long getSensorPM100_STDPeriod() { return _PM100SensorPeriod; }
719 
720  /*********************************************************************************/
727  /*********************************************************************************/
729 
730  /*******************************************************************************/
737  /*******************************************************************************/
738  virtual void setSensorPM100_STDPeriodPrv(long period) {
739  _PM100SensorPeriodPrv = period;
740  }
741 
742  /*******************************************************************************/
751  /*******************************************************************************/
752  virtual bool getEventPM100_STD(sensors_event_t *pm100StdEvent) {
753  (void)pm100StdEvent; // Parameter is intentionally unused in this virtual
754  // function.
755  return false;
756  }
757 
758  /**************************** SENSOR_TYPE: UNITLESS_PERCENT
759  * ****************************/
760  /*********************************************************************************/
767  /*********************************************************************************/
769  return _unitlessPercentPeriod;
770  }
771 
772  /*********************************************************************************/
779  /*********************************************************************************/
782  }
783 
784  /*******************************************************************************/
791  /*******************************************************************************/
792  virtual void setSensorUnitlessPercentPeriodPrv(long period) {
793  _unitlessPercentPeriodPrv = period;
794  }
795 
796  /*******************************************************************************/
805  /*******************************************************************************/
806  virtual bool getEventUnitlessPercent(sensors_event_t *unitlessPercentEvent) {
807  (void)unitlessPercentEvent; // Parameter is intentionally unused in this
808  // virtual function.
809  return false;
810  }
811 
812  /**************************** SENSOR_TYPE: VOLTAGE
813  * ****************************/
814  /*********************************************************************************/
820  /*********************************************************************************/
821  virtual long getSensorVoltagePeriod() { return _voltagePeriod; }
822 
823  /*********************************************************************************/
829  /*********************************************************************************/
830  virtual long getSensorVoltagePeriodPrv() { return _voltagePeriodPrv; }
831 
832  /*******************************************************************************/
838  /*******************************************************************************/
839  virtual void setSensorVoltagePeriodPrv(long period) {
840  _voltagePeriodPrv = period;
841  }
842 
843  /*******************************************************************************/
852  /*******************************************************************************/
853  virtual bool getEventVoltage(sensors_event_t *voltageEvent) {
854  (void)voltageEvent; // Parameter is intentionally unused in this virtual
855  // function.
856  return false;
857  }
858 
859  /**************************** SENSOR_TYPE: CURRENT
860  * ****************************/
861  /*********************************************************************************/
867  /*********************************************************************************/
868  virtual long getSensorCurrentPeriod() { return _currentPeriod; }
869 
870  /*********************************************************************************/
876  /*********************************************************************************/
877  virtual long getSensorCurrentPeriodPrv() { return _currentPeriodPrv; }
878 
879  /*******************************************************************************/
885  /*******************************************************************************/
886  virtual void setSensorCurrentPeriodPrv(long period) {
887  _currentPeriodPrv = period;
888  }
889 
890  /*******************************************************************************/
899  /*******************************************************************************/
900  virtual bool getEventCurrent(sensors_event_t *currentEvent) {
901  (void)currentEvent; // Parameter is intentionally unused in this virtual
902  // function.
903  return false;
904  }
905 
906  /****************************** SENSOR_TYPE: Raw
907  * *******************************/
908  /*********************************************************************************/
914  /*********************************************************************************/
915  virtual long getSensorRawPeriod() { return _rawSensorPeriod; }
916 
917  /*********************************************************************************/
923  /*********************************************************************************/
924  virtual long getSensorRawPeriodPrv() { return _rawSensorPeriodPrv; }
925 
926  /*******************************************************************************/
932  /*******************************************************************************/
933  virtual void setSensorRawPeriodPrv(long period) {
934  _rawSensorPeriodPrv = period;
935  }
936 
937  /*******************************************************************************/
945  /*******************************************************************************/
946  virtual bool getEventRaw(sensors_event_t *rawEvent) {
947  (void)
948  rawEvent; // Parameter is intentionally unused in this virtual function.
949  return false;
950  }
951 
952  /****************************** SENSOR_TYPE: Ambient Temp (°F)
953  * *******************************/
954 
955  /*******************************************************************************/
960  /*******************************************************************************/
961  virtual void disableAmbientTempF() { _ambientTempFPeriod = 0.0L; }
962 
963  /*********************************************************************************/
970  /*********************************************************************************/
972 
973  /*********************************************************************************/
980  /*********************************************************************************/
982  return _ambientTempFPeriodPrv;
983  }
984 
985  /*******************************************************************************/
993  /*******************************************************************************/
994  virtual void setSensorAmbientTempFPeriodPrv(long period) {
995  _ambientTempFPeriodPrv = period;
996  }
997 
998  /*******************************************************************************/
1008  /*******************************************************************************/
1009  virtual bool getEventAmbientTempF(sensors_event_t *AmbientTempFEvent) {
1010  // obtain ambient temp. in °C
1011  if (!getEventAmbientTemp(AmbientTempFEvent))
1012  return false;
1013  // convert event from °C to °F
1014  AmbientTempFEvent->temperature =
1015  (AmbientTempFEvent->temperature * 9.0) / 5.0 + 32;
1016  return true;
1017  }
1018 
1019  /****************************** SENSOR_TYPE: Object Temp (°F)
1020  * *******************************/
1021  /*********************************************************************************/
1028  /*********************************************************************************/
1030 
1031  /*********************************************************************************/
1038  /*********************************************************************************/
1040 
1041  /*******************************************************************************/
1049  /*******************************************************************************/
1050  virtual void setSensorObjectTempFPeriodPrv(long period) {
1051  _objectTempFPeriodPrv = period;
1052  }
1053 
1054  /*******************************************************************************/
1064  /*******************************************************************************/
1065  virtual bool getEventObjectTempF(sensors_event_t *objectTempFEvent) {
1066  // obtain ambient temp. in °C
1067  if (!getEventObjectTemp(objectTempFEvent))
1068  return false;
1069  // convert event from °C to °F
1070  objectTempFEvent->temperature =
1071  (objectTempFEvent->temperature * 9.0) / 5.0 + 32.0;
1072  return true;
1073  }
1074 
1075  /****************************** SENSOR_TYPE: Gas Resistance (ohms)
1076  * *******************************/
1077  /*********************************************************************************/
1084  /*********************************************************************************/
1086 
1087  /*********************************************************************************/
1094  /*********************************************************************************/
1096  return _gasResistancePeriodPrv;
1097  }
1098 
1099  /*******************************************************************************/
1107  /*******************************************************************************/
1108  virtual void setSensorGasResistancePeriodPrv(long period) {
1109  _gasResistancePeriodPrv = period;
1110  }
1111 
1112  /*******************************************************************************/
1121  /*******************************************************************************/
1122  virtual bool getEventGasResistance(sensors_event_t *gasEvent) {
1123  (void)
1124  gasEvent; // Parameter is intentionally unused in this virtual function.
1125  return false;
1126  }
1127 
1128  /****************************** SENSOR_TYPE: NOx Index (index)
1129  * *******************************/
1130  /*********************************************************************************/
1137  /*********************************************************************************/
1138  virtual long getSensorNOxIndexPeriod() { return _NOxIndexPeriod; }
1139 
1140  /*********************************************************************************/
1147  /*********************************************************************************/
1149 
1150  /*******************************************************************************/
1158  /*******************************************************************************/
1159  virtual void setSensorNOxIndexPeriodPrv(long period) {
1160  _NOxIndexPeriodPrv = period;
1161  }
1162 
1163  /*******************************************************************************/
1172  /*******************************************************************************/
1173  virtual bool getEventNOxIndex(sensors_event_t *gasEvent) {
1174  (void)
1175  gasEvent; // Parameter is intentionally unused in this virtual function.
1176  return false;
1177  }
1178 
1179  /****************************** SENSOR_TYPE: VOC Index (index)
1180  * *******************************/
1181  /*********************************************************************************/
1188  /*********************************************************************************/
1189  virtual long getSensorVOCIndexPeriod() { return _VOCIndexPeriod; }
1190 
1191  /*********************************************************************************/
1198  /*********************************************************************************/
1200 
1201  /*******************************************************************************/
1209  /*******************************************************************************/
1210  virtual void setSensorVOCIndexPeriodPrv(long period) {
1211  _VOCIndexPeriodPrv = period;
1212  }
1213 
1214  /*******************************************************************************/
1223  /*******************************************************************************/
1224  virtual bool getEventVOCIndex(sensors_event_t *gasEvent) {
1225  (void)
1226  gasEvent; // Parameter is intentionally unused in this virtual function.
1227  return false;
1228  }
1229 
1230  /**************************** SENSOR_TYPE: PROXIMITY
1231  * ****************************/
1232  /*******************************************************************************/
1236  /*******************************************************************************/
1237  virtual void enableSensorProximity() {};
1238 
1239  /*******************************************************************************/
1243  /*******************************************************************************/
1245 
1246  /*********************************************************************************/
1253  /*********************************************************************************/
1255 
1256  /*******************************************************************************/
1263  /*******************************************************************************/
1264  virtual void setSensorProximityPeriod(long period) {
1265  if (period == 0)
1267  _proximitySensorPeriod = period;
1268  }
1269 
1270  /*********************************************************************************/
1277  /*********************************************************************************/
1279 
1280  /*******************************************************************************/
1287  /*******************************************************************************/
1288  virtual void setSensorProximityPeriodPrv(long period) {
1289  _proximitySensorPeriodPrv = period;
1290  }
1291 
1292  /*******************************************************************************/
1301  /*******************************************************************************/
1302  virtual bool getEventProximity(sensors_event_t *proximityEvent) {
1303  (void)proximityEvent; // Parameter is intentionally unused in this virtual
1304  // function.
1305  return false;
1306  }
1307 
1308  /*******************************************************************************/
1315  /*******************************************************************************/
1316  virtual void updateSensorProximity(float period) {
1317  setSensorProximityPeriod(period);
1318  }
1319 
1320 protected:
1321  TwoWire *_i2c;
1322  uint16_t _sensorAddress;
1324  0L;
1327  long _humidSensorPeriod =
1329  0L;
1332  long _pressureSensorPeriod =
1334  0L;
1337  long _CO2SensorPeriod =
1339  0L;
1343  0L;
1347  0L;
1351  0L;
1354  long _objectTempSensorPeriod = 0L;
1359  long _lightSensorPeriod =
1361  0L;
1364  long _PM10SensorPeriod =
1366  0L;
1370  0L;
1374  0L;
1377  long _unitlessPercentPeriod =
1379  0L;
1382  long _voltagePeriod =
1384  0L;
1387  long _currentPeriod =
1389  0L;
1392  long _rawSensorPeriod =
1394  0L;
1398  long _ambientTempFPeriodPrv =
1401  long _objectTempFPeriod = 0L;
1403  long _objectTempFPeriodPrv =
1406  long _gasResistancePeriod = 0L;
1411  long _NOxIndexPeriod =
1413  0L;
1416  long _VOCIndexPeriod =
1418  0L;
1421  long _proximitySensorPeriod =
1423  0L;
1426 };
1428 
1429 #endif // WipperSnapper_I2C_Driver_H
long _unitlessPercentPeriod
The time period between reading the unitless % sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1378
virtual long getSensorUnitlessPercentPeriodPrv()
Base implementation - Returns the previous time interval at which the unitless % sensor was queried l...
Definition: WipperSnapper_I2C_Driver.h:780
virtual long getSensorLightPeriodPrv()
Base implementation - Returns the previous time interval at which the light sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:578
virtual long getSensorObjectTempPeriodPrv()
Base implementation - Returns the previous time interval at which the object temperature sensor was q...
Definition: WipperSnapper_I2C_Driver.h:526
virtual bool getEventPM10_STD(sensors_event_t *pm10StdEvent)
Base implementation - Reads a object pm10 std. sensor and converts the reading into the expected SI u...
Definition: WipperSnapper_I2C_Driver.h:652
virtual void updateSensorProximity(float period)
Updates the properties of a proximity sensor.
Definition: WipperSnapper_I2C_Driver.h:1316
long _PM10SensorPeriod
The time period between reading the pm25 sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1365
uint16_t getI2CAddress()
Gets the I2C device&#39;s address.
Definition: WipperSnapper_I2C_Driver.h:173
virtual long getSensorPM25_STDPeriod()
Base implementation - Returns the object pm25 standard sensors&#39; period, if set.
Definition: WipperSnapper_I2C_Driver.h:668
virtual void setSensorObjectTempFPeriodPrv(long period)
Sets a timestamp for when the object temperature sensor (°F) was queried.
Definition: WipperSnapper_I2C_Driver.h:1050
long _PM100SensorPeriod
The time period between reading the pm100_std sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1373
#define PERIOD_24HRS_AGO_MILLIS
Used for last sensor read time, initially set 24hrs ago (max period)
Definition: WipperSnapper_I2C_Driver.h:22
virtual void setSensorVOCIndexPeriodPrv(long period)
Sets a timestamp for when the object VOC Index sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:1210
long _currentPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1390
virtual long getSensorPressurePeriod()
Base implementation - Returns the pressure sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:421
virtual long getSensorTVOCPeriodPrv()
Base implementation - Returns the previous time interval at which the TVOC sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:285
virtual void setSensorAmbientTempFPeriodPrv(long period)
Sets a timestamp for when the ambient temperature sensor (°F) was queried.
Definition: WipperSnapper_I2C_Driver.h:994
virtual bool getEventPM100_STD(sensors_event_t *pm100StdEvent)
Base implementation - Reads a object pm100 std. sensor and converts the reading into the expected SI ...
Definition: WipperSnapper_I2C_Driver.h:752
virtual long getSensorCurrentPeriod()
Base implementation - Returns the current sensor&#39;s period.
Definition: WipperSnapper_I2C_Driver.h:868
virtual long getSensorRelativeHumidityPeriodPrv()
Base implementation - Returns the previous time interval at which the humidity sensor was queried las...
Definition: WipperSnapper_I2C_Driver.h:381
long _altitudeSensorPeriod
The time period between reading the altitude sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1350
virtual long getSensorVOCIndexPeriod()
Base implementation - Returns the VOC Index sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:1189
virtual long getSensorTVOCPeriod()
Base implementation - Returns the TVOC sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:276
virtual void setSensorProximityPeriodPrv(long period)
Sets a timestamp for when the proximity sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:1288
virtual bool getEventCO2(sensors_event_t *co2Event)
Gets a sensor&#39;s CO2 value.
Definition: WipperSnapper_I2C_Driver.h:215
virtual long getSensorAmbientTempPeriod()
Base implementation - Returns the ambient temperature (°C) sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:322
virtual long getSensorPM100_STDPeriodPrv()
Base implementation - Returns the previous time interval at which the pm100 std. sensor was queried l...
Definition: WipperSnapper_I2C_Driver.h:728
virtual long getSensorAmbientTempPeriodPrv()
Base implementation - Returns the previous time interval at which the ambient temperature sensor (°C)...
Definition: WipperSnapper_I2C_Driver.h:332
virtual bool getEventPM25_STD(sensors_event_t *pm25StdEvent)
Base implementation - Reads a object pm25 std. sensor and converts the reading into the expected SI u...
Definition: WipperSnapper_I2C_Driver.h:702
virtual bool getEventNOxIndex(sensors_event_t *gasEvent)
Base implementation - Reads a NOx Index sensor and converts the reading into the expected SI unit...
Definition: WipperSnapper_I2C_Driver.h:1173
virtual long getSensorECO2PeriodPrv()
Base implementation - Returns the previous time interval at which the eCO2 sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:239
long _currentPeriod
The time period between reading the current sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1388
long _NOxIndexPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1414
long _objectTempSensorPeriod
Definition: WipperSnapper_I2C_Driver.h:1355
long _TVOCSensorPeriod
The time period between reading the TVOC sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1346
long _ambientTempFPeriod
Definition: WipperSnapper_I2C_Driver.h:1397
virtual long getSensorUnitlessPercentPeriod()
Base implementation - Returns the object unitless % sensor period, if set.
Definition: WipperSnapper_I2C_Driver.h:768
virtual long getSensorCO2Period()
Base implementation - Returns the co2 sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:184
virtual void setSensorTVOCPeriodPrv(long period)
Sets a timestamp for when the TVOC sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:294
long _VOCIndexPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1419
virtual void setSensorVoltagePeriodPrv(long period)
Sets a timestamp for when the voltage sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:839
virtual void setSensorAltitudePeriodPrv(long period)
Sets a timestamp for when the Altitude sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:486
virtual bool getEventProximity(sensors_event_t *proximityEvent)
Base implementation - Reads a proximity sensor and converts the reading into the expected SI unit...
Definition: WipperSnapper_I2C_Driver.h:1302
long _tempSensorPeriod
The time period between reading the temperature sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1323
virtual bool getEventRelativeHumidity(sensors_event_t *humidEvent)
Base implementation - Reads a humidity sensor and converts the reading into the expected SI unit...
Definition: WipperSnapper_I2C_Driver.h:406
virtual void setSensorNOxIndexPeriodPrv(long period)
Sets a timestamp for when the object NOx Index sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:1159
virtual ~WipperSnapper_I2C_Driver()
Destructor for an I2C sensor.
Definition: WipperSnapper_I2C_Driver.h:52
long _unitlessPercentPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1380
virtual long getSensorAmbientTempFPeriodPrv()
Base implementation - Returns the previous time interval at which the ambient temperature sensor (°F)...
Definition: WipperSnapper_I2C_Driver.h:981
long _voltagePeriod
The time period between reading the voltage sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1383
bool begin()
Initializes the I2C sensor and begins I2C.
Definition: WipperSnapper_I2C_Driver.h:60
virtual long getSensorAmbientTempFPeriod()
Base implementation - Returns the ambient temperature (°F) sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:971
virtual bool getEventAmbientTempF(sensors_event_t *AmbientTempFEvent)
Helper function to obtain a sensor&#39;s ambient temperature value in °F. Requires getEventAmbientTemp() ...
Definition: WipperSnapper_I2C_Driver.h:1009
long _TVOCSensorPeriodPrv
The time when the TVOC sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1348
WipperSnapper_I2C_Driver(TwoWire *i2c, uint16_t sensorAddress)
Instanciates an I2C sensor.
Definition: WipperSnapper_I2C_Driver.h:42
virtual void disableAmbientTempF()
Disables the device&#39;s ambient temperature (°F) sensor, if it exists.
Definition: WipperSnapper_I2C_Driver.h:961
Base class for I2C Drivers.
Definition: WipperSnapper_I2C_Driver.h:30
virtual bool getEventAltitude(sensors_event_t *altitudeEvent)
Base implementation - Reads a Altitude sensor and converts the reading into the expected SI unit...
Definition: WipperSnapper_I2C_Driver.h:500
long _pressureSensorPeriod
The time period between reading the pressure sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1333
virtual bool getEventVOCIndex(sensors_event_t *gasEvent)
Base implementation - Reads a VOC Index sensor and converts the reading into the expected SI unit...
Definition: WipperSnapper_I2C_Driver.h:1224
long _objectTempFPeriod
Definition: WipperSnapper_I2C_Driver.h:1402
long _ambientTempFPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1399
long _ECO2SensorPeriodPrv
The time when the eCO2 sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1344
long _gasResistancePeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1409
long _humidSensorPeriod
The time period between reading the humidity sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1328
virtual void setSensorPM100_STDPeriodPrv(long period)
Sets a timestamp for when the light sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:738
virtual long getSensorLightPeriod()
Base implementation - Returns the object light sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:568
long _PM100SensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1375
virtual long getSensorRelativeHumidityPeriod()
Base implementation - Returns the humidity sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:372
virtual bool getEventUnitlessPercent(sensors_event_t *unitlessPercentEvent)
Base implementation - Reads a object unitless % std. sensor and converts the reading into the expecte...
Definition: WipperSnapper_I2C_Driver.h:806
virtual long getSensorPM25_STDPeriodPrv()
Base implementation - Returns the previous time interval at which the pm25 std. sensor was queried la...
Definition: WipperSnapper_I2C_Driver.h:678
virtual bool getEventTVOC(sensors_event_t *tvocEvent)
Gets a sensor&#39;s TVOC value.
Definition: WipperSnapper_I2C_Driver.h:307
uint16_t _sensorAddress
The I2C driver&#39;s unique I2C address.
Definition: WipperSnapper_I2C_Driver.h:1322
virtual long getSensorAltitudePeriodPrv()
Base implementation - Returns the previous time interval at which the Altitude sensor was queried las...
Definition: WipperSnapper_I2C_Driver.h:477
virtual void setSensorECO2PeriodPrv(long period)
Sets a timestamp for when the eCO2 sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:248
virtual long getSensorGasResistancePeriodPrv()
Base implementation - Returns the previous time interval at which the gas resistance sensor (ohms) wa...
Definition: WipperSnapper_I2C_Driver.h:1095
long _gasResistancePeriod
Definition: WipperSnapper_I2C_Driver.h:1407
virtual long SensorProximityPeriodPrv()
Base implementation - Returns the previous time interval at which the proximity sensor was queried la...
Definition: WipperSnapper_I2C_Driver.h:1278
virtual long getSensorPM100_STDPeriod()
Base implementation - Returns the object pm100 standard sensors&#39; period, if set.
Definition: WipperSnapper_I2C_Driver.h:718
long _humidSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1330
virtual long getSensorVoltagePeriod()
Base implementation - Returns the voltage sensor&#39;s period.
Definition: WipperSnapper_I2C_Driver.h:821
virtual void setSensorPM10_STDPeriodPrv(long period)
Sets a timestamp for when the light sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:638
long _objectTempSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1357
virtual long getSensorPM10_STDPeriodPrv()
Base implementation - Returns the previous time interval at which the pm10 std. sensor was queried la...
Definition: WipperSnapper_I2C_Driver.h:628
long _objectTempFPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1404
long _lightSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1362
virtual bool getEventECO2(sensors_event_t *eco2Event)
Gets a sensor&#39;s eCO2 value.
Definition: WipperSnapper_I2C_Driver.h:261
virtual void setSensorPM25_STDPeriodPrv(long period)
Sets a timestamp for when the light sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:688
void setSensorPeriod(float period, wippersnapper_i2c_v1_SensorType sensorType)
Sets the sensor&#39;s period, provided a wippersnapper_i2c_v1_SensorType.
Definition: WipperSnapper_I2C_Driver.h:71
virtual void setSensorObjectTempPeriodPrv(long period)
Sets a timestamp for when the object temperature sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:538
virtual long getSensorPressurePeriodPrv()
Base implementation - Returns the previous time interval at which the pressure sensor was queried las...
Definition: WipperSnapper_I2C_Driver.h:430
virtual void setSensorPressurePeriodPrv(long period)
Sets a timestamp for when the pressure sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:439
virtual void setSensorRelativeHumidityPeriodPrv(long periodPrv)
Sets a timestamp for when the temperature sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:392
virtual bool getEventPressure(sensors_event_t *pressureEvent)
Base implementation - Reads a pressure sensor and converts the reading into the expected SI unit...
Definition: WipperSnapper_I2C_Driver.h:453
virtual long getSensorCurrentPeriodPrv()
Base implementation - Returns the previous time interval at which the current sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:877
virtual long getSensorGasResistancePeriod()
Base implementation - Returns the gas resistance (ohms) sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:1085
virtual long getSensorAltitudePeriod()
Base implementation - Returns the Altitude sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:468
virtual bool getEventLight(sensors_event_t *lightEvent)
Base implementation - Reads a object light sensor and converts the reading into the expected SI unit...
Definition: WipperSnapper_I2C_Driver.h:602
long _VOCIndexPeriod
The time period between reading the VOC Index sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1417
virtual bool getEventGasResistance(sensors_event_t *gasEvent)
Base implementation - Reads a gas resistance sensor and converts the reading into the expected SI uni...
Definition: WipperSnapper_I2C_Driver.h:1122
virtual bool getEventAmbientTemp(sensors_event_t *tempEvent)
Base implementation - Reads an ambient temperature sensor (°C). Expects value to return in the proper...
Definition: WipperSnapper_I2C_Driver.h:357
virtual long getSensorObjectTempFPeriod()
Base implementation - Returns the object temperature (°F) sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:1029
long _CO2SensorPeriodPrv
The time when the CO2 sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1340
long _lightSensorPeriod
The time period between reading the light sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1360
void configureDriver(wippersnapper_i2c_v1_I2CDeviceInitRequest *msgDeviceInitReq)
Uses an I2CDeviceInitRequest message to configure the sensors belonging to the driver.
Definition: WipperSnapper_I2C_Driver.h:156
virtual void enableSensorProximity()
Enables the device&#39;s proximity sensor, if it exists.
Definition: WipperSnapper_I2C_Driver.h:1237
virtual long getSensorNOxIndexPeriodPrv()
Base implementation - Returns the previous time interval at which the NOx Index sensor was queried la...
Definition: WipperSnapper_I2C_Driver.h:1148
virtual void setSensorUnitlessPercentPeriodPrv(long period)
Sets a timestamp for when the unitless % sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:792
virtual void setSensorCO2PeriodPrv(long period)
Sets a timestamp for when the co2 sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:202
virtual long getSensorRawPeriod()
Base implementation - Returns the raw sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:915
virtual void setSensorRawPeriodPrv(long period)
Sets a timestamp for when the raw sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:933
virtual long getSensorObjectTempPeriod()
Base implementation - Returns the object temperature sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:516
virtual void setSensorAmbientTempPeriodPrv(long periodPrv)
Sets a timestamp for when the ambient temperature sensor (°C) was queried.
Definition: WipperSnapper_I2C_Driver.h:343
long _voltagePeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1385
long _rawSensorPeriod
The time period between reading the Raw sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1393
virtual long getSensorCO2PeriodPrv()
Base implementation - Returns the previous time interval at which the co2 sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:193
virtual long getSensorECO2Period()
Base implementation - Returns the eCO2 sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:230
virtual void disableSensorProximity()
Disables the device&#39;s object proximity sensor, if it exists.
Definition: WipperSnapper_I2C_Driver.h:1244
virtual bool getEventObjectTempF(sensors_event_t *objectTempFEvent)
Helper function to obtain a sensor&#39;s object temperature value in °F. Requires getEventObjectTemp() to...
Definition: WipperSnapper_I2C_Driver.h:1065
long _rawSensorPeriodPrv
The time when the Raw sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1395
long _PM25SensorPeriod
The time period between reading the pm25 sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1369
long _tempSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1325
long _PM10SensorPeriodPrv
The time when the pm25 sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1367
long _CO2SensorPeriod
The time period between reading the CO2 sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1338
virtual long getSensorPM10_STDPeriod()
Base implementation - Returns the object pm10 standard sensors&#39; period, if set.
Definition: WipperSnapper_I2C_Driver.h:618
virtual long getSensorObjectTempFPeriodPrv()
Base implementation - Returns the previous time interval at which the object temperature sensor (°F) ...
Definition: WipperSnapper_I2C_Driver.h:1039
long _proximitySensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1424
virtual bool getEventObjectTemp(sensors_event_t *objectTempEvent)
Base implementation - Reads a object temperature sensor and converts the reading into the expected SI...
Definition: WipperSnapper_I2C_Driver.h:552
virtual long getSensorVoltagePeriodPrv()
Base implementation - Returns the previous time interval at which the voltage sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:830
long _ECO2SensorPeriod
The time period between reading the eCO2 sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1342
long _proximitySensorPeriod
The time period between reading the proximity sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1422
virtual long getSensorRawPeriodPrv()
Base implementation - Returns the previous time interval at which the raw sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:924
virtual void setSensorCurrentPeriodPrv(long period)
Sets a timestamp for when the current sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:886
long _PM25SensorPeriodPrv
The time when the pm25 sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1371
virtual bool getEventRaw(sensors_event_t *rawEvent)
Gets a sensor&#39;s Raw value.
Definition: WipperSnapper_I2C_Driver.h:946
virtual long sensorProximityPeriod()
Base implementation - Returns the proximity sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:1254
virtual bool getEventCurrent(sensors_event_t *currentEvent)
Base implementation - Reads a current sensor and converts the reading into the expected SI unit...
Definition: WipperSnapper_I2C_Driver.h:900
virtual void setSensorGasResistancePeriodPrv(long period)
Sets a timestamp for when the object gas resistance sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:1108
long _altitudeSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1352
virtual long getSensorVOCIndexPeriodPrv()
Base implementation - Returns the previous time interval at which the VOC Index sensor was queried la...
Definition: WipperSnapper_I2C_Driver.h:1199
long _NOxIndexPeriod
The time period between reading the NOx Index sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1412
virtual bool getEventVoltage(sensors_event_t *voltageEvent)
Base implementation - Reads a voltage sensor and converts the reading into the expected SI unit...
Definition: WipperSnapper_I2C_Driver.h:853
TwoWire * _i2c
Pointer to the I2C driver&#39;s Wire object.
Definition: WipperSnapper_I2C_Driver.h:1321
long _pressureSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1335
virtual long getSensorNOxIndexPeriod()
Base implementation - Returns the NOx Index sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:1138
virtual void setSensorLightPeriodPrv(long period)
Sets a timestamp for when the light sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:588
virtual void setSensorProximityPeriod(long period)
Set the proximity sensor&#39;s return frequency.
Definition: WipperSnapper_I2C_Driver.h:1264