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 "wippersnapper/i2c/v1/i2c.pb.h"
20 #include <Adafruit_Sensor.h>
21 #include <Arduino.h>
22 #include <Wire.h>
23 
24 #define PERIOD_24HRS_AGO_MILLIS (millis() - (24 * 60 * 60 * 1000))
25 
27 /**************************************************************************/
31 /**************************************************************************/
33 
34 public:
35  /*******************************************************************************/
43  /*******************************************************************************/
44  WipperSnapper_I2C_Driver(TwoWire *i2c, uint16_t sensorAddress) {
45  _i2c = i2c;
46  _sensorAddress = sensorAddress;
47  }
48 
49  /*******************************************************************************/
53  /*******************************************************************************/
55 
56  /*******************************************************************************/
61  /*******************************************************************************/
62  bool begin() { return false; }
63 
64  /*******************************************************************************/
72  /*******************************************************************************/
73  void setSensorPeriod(float period,
74  wippersnapper_i2c_v1_SensorType sensorType) {
75  long sensorPeriod = (long)period * 1000;
76 
77  switch (sensorType) {
78  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE:
79  _tempSensorPeriod = sensorPeriod;
80  break;
81  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_RELATIVE_HUMIDITY:
82  _humidSensorPeriod = sensorPeriod;
83  break;
84  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PRESSURE:
85  _pressureSensorPeriod = sensorPeriod;
86  break;
87  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_CO2:
88  _CO2SensorPeriod = sensorPeriod;
89  break;
90  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_ECO2:
91  _ECO2SensorPeriod = sensorPeriod;
92  break;
93  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_TVOC:
94  _TVOCSensorPeriod = sensorPeriod;
95  break;
96  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_ALTITUDE:
97  _altitudeSensorPeriod = sensorPeriod;
98  break;
99  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE:
100  _objectTempSensorPeriod = sensorPeriod;
101  break;
102  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_LIGHT:
103  _lightSensorPeriod = sensorPeriod;
104  break;
105  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PM10_STD:
106  _PM10SensorPeriod = sensorPeriod;
107  break;
108  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PM25_STD:
109  _PM25SensorPeriod = sensorPeriod;
110  break;
111  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PM100_STD:
112  _PM100SensorPeriod = sensorPeriod;
113  break;
114  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_UNITLESS_PERCENT:
115  _unitlessPercentPeriod = sensorPeriod;
116  break;
117  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_VOLTAGE:
118  _voltagePeriod = sensorPeriod;
119  break;
120  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_CURRENT:
121  _currentPeriod = sensorPeriod;
122  break;
123  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_PROXIMITY:
124  _proximitySensorPeriod = sensorPeriod;
125  break;
126  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_RAW:
127  _rawSensorPeriod = sensorPeriod;
128  break;
129  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_AMBIENT_TEMPERATURE_FAHRENHEIT:
130  _ambientTempFPeriod = sensorPeriod;
131  break;
132  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_OBJECT_TEMPERATURE_FAHRENHEIT:
133  _objectTempFPeriod = sensorPeriod;
134  break;
135  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_GAS_RESISTANCE:
136  _gasResistancePeriod = sensorPeriod;
137  break;
138  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_NOX_INDEX:
139  _NOxIndexPeriod = sensorPeriod;
140  break;
141  case wippersnapper_i2c_v1_SensorType_SENSOR_TYPE_VOC_INDEX:
142  _VOCIndexPeriod = sensorPeriod;
143  break;
144  default:
145  break;
146  }
147  }
148 
149  /*******************************************************************************/
156  /*******************************************************************************/
157  void
158  configureDriver(wippersnapper_i2c_v1_I2CDeviceInitRequest *msgDeviceInitReq) {
159  int propertyIdx = 0; // contains the amount of i2c sensors in the
160  // msgDeviceInitReq to configure
161  while (propertyIdx < msgDeviceInitReq->i2c_device_properties_count) {
163  msgDeviceInitReq->i2c_device_properties[propertyIdx].sensor_period,
164  msgDeviceInitReq->i2c_device_properties[propertyIdx].sensor_type);
165  ++propertyIdx;
166  }
167  }
168 
169  /*******************************************************************************/
174  /*******************************************************************************/
175  uint16_t getI2CAddress() { return _sensorAddress; }
176 
177  /****************************** SENSOR_TYPE: CO2
178  * *******************************/
179  /*********************************************************************************/
185  /*********************************************************************************/
186  virtual long getSensorCO2Period() { return _CO2SensorPeriod; }
187 
188  /*********************************************************************************/
194  /*********************************************************************************/
195  virtual long getSensorCO2PeriodPrv() { return _CO2SensorPeriodPrv; }
196 
197  /*******************************************************************************/
203  /*******************************************************************************/
204  virtual void setSensorCO2PeriodPrv(long period) {
205  _CO2SensorPeriodPrv = period;
206  }
207 
208  /*******************************************************************************/
216  /*******************************************************************************/
217  virtual bool getEventCO2(sensors_event_t *co2Event) {
218  (void)
219  co2Event; // Parameter is intentionally unused in this virtual function.
220  return false;
221  }
222 
223  /****************************** SENSOR_TYPE: ECO2
224  * *******************************/
225  /*********************************************************************************/
231  /*********************************************************************************/
232  virtual long getSensorECO2Period() { return _ECO2SensorPeriod; }
233 
234  /*********************************************************************************/
240  /*********************************************************************************/
241  virtual long getSensorECO2PeriodPrv() { return _ECO2SensorPeriodPrv; }
242 
243  /*******************************************************************************/
249  /*******************************************************************************/
250  virtual void setSensorECO2PeriodPrv(long period) {
251  _ECO2SensorPeriodPrv = period;
252  }
253 
254  /*******************************************************************************/
262  /*******************************************************************************/
263  virtual bool getEventECO2(sensors_event_t *eco2Event) {
264  (void)eco2Event; // Parameter is intentionally unused in this virtual
265  // function.
266  return false;
267  }
268 
269  /****************************** SENSOR_TYPE: TVOC
270  * *******************************/
271  /*********************************************************************************/
277  /*********************************************************************************/
278  virtual long getSensorTVOCPeriod() { return _TVOCSensorPeriod; }
279 
280  /*********************************************************************************/
286  /*********************************************************************************/
287  virtual long getSensorTVOCPeriodPrv() { return _TVOCSensorPeriodPrv; }
288 
289  /*******************************************************************************/
295  /*******************************************************************************/
296  virtual void setSensorTVOCPeriodPrv(long period) {
297  _TVOCSensorPeriodPrv = period;
298  }
299 
300  /*******************************************************************************/
308  /*******************************************************************************/
309  virtual bool getEventTVOC(sensors_event_t *tvocEvent) {
310  (void)tvocEvent; // Parameter is intentionally unused in this virtual
311  // function.
312  return false;
313  }
314 
315  /********************** SENSOR_TYPE: AMBIENT TEMPERATURE (°C)
316  * ***********************/
317  /*********************************************************************************/
323  /*********************************************************************************/
325 
326  /*********************************************************************************/
333  /*********************************************************************************/
335 
336  /*******************************************************************************/
344  /*******************************************************************************/
345  virtual void setSensorAmbientTempPeriodPrv(long periodPrv) {
346  _tempSensorPeriodPrv = periodPrv;
347  }
348 
349  /*******************************************************************************/
358  /*******************************************************************************/
359  virtual bool getEventAmbientTemp(sensors_event_t *tempEvent) {
360  (void)tempEvent; // Parameter is intentionally unused in this virtual
361  // function.
362  return false;
363  }
364 
365  /************************* SENSOR_TYPE: RELATIVE_HUMIDITY
366  * ***********************/
367  /*********************************************************************************/
373  /*********************************************************************************/
375 
376  /*********************************************************************************/
382  /*********************************************************************************/
384  return _humidSensorPeriodPrv;
385  }
386 
387  /*******************************************************************************/
393  /*******************************************************************************/
394  virtual void setSensorRelativeHumidityPeriodPrv(long periodPrv) {
395  _humidSensorPeriodPrv = periodPrv;
396  }
397 
398  /*******************************************************************************/
407  /*******************************************************************************/
408  virtual bool getEventRelativeHumidity(sensors_event_t *humidEvent) {
409  (void)humidEvent; // Parameter is intentionally unused in this virtual
410  // function.
411  return false;
412  }
413 
414  /**************************** SENSOR_TYPE: PRESSURE
415  * ****************************/
416  /*********************************************************************************/
422  /*********************************************************************************/
424 
425  /*********************************************************************************/
431  /*********************************************************************************/
433 
434  /*******************************************************************************/
440  /*******************************************************************************/
441  virtual void setSensorPressurePeriodPrv(long period) {
442  _pressureSensorPeriodPrv = period;
443  }
444 
445  /*******************************************************************************/
454  /*******************************************************************************/
455  virtual bool getEventPressure(sensors_event_t *pressureEvent) {
456  (void)pressureEvent; // Parameter is intentionally unused in this virtual
457  // function.
458  return false;
459  }
460 
461  /**************************** SENSOR_TYPE: Altitude
462  * ****************************/
463  /*********************************************************************************/
469  /*********************************************************************************/
471 
472  /*********************************************************************************/
478  /*********************************************************************************/
480 
481  /*******************************************************************************/
487  /*******************************************************************************/
488  virtual void setSensorAltitudePeriodPrv(long period) {
489  _altitudeSensorPeriodPrv = period;
490  }
491 
492  /*******************************************************************************/
501  /*******************************************************************************/
502  virtual bool getEventAltitude(sensors_event_t *altitudeEvent) {
503  (void)altitudeEvent; // Parameter is intentionally unused in this virtual
504  // function.
505  return false;
506  }
507 
508  /**************************** SENSOR_TYPE: Object_Temperature
509  * ****************************/
510  /*********************************************************************************/
517  /*********************************************************************************/
519 
520  /*********************************************************************************/
527  /*********************************************************************************/
530  }
531 
532  /*******************************************************************************/
539  /*******************************************************************************/
540  virtual void setSensorObjectTempPeriodPrv(long period) {
542  }
543 
544  /*******************************************************************************/
553  /*******************************************************************************/
554  virtual bool getEventObjectTemp(sensors_event_t *objectTempEvent) {
555  (void)objectTempEvent; // Parameter is intentionally unused in this virtual
556  // function.
557  return false;
558  }
559 
560  /**************************** SENSOR_TYPE: LIGHT
561  * ****************************/
562  /*********************************************************************************/
569  /*********************************************************************************/
570  virtual long getSensorLightPeriod() { return _lightSensorPeriod; }
571 
572  /*********************************************************************************/
579  /*********************************************************************************/
581 
582  /*******************************************************************************/
589  /*******************************************************************************/
590  virtual void setSensorLightPeriodPrv(long period) {
591  _lightSensorPeriodPrv = period;
592  }
593 
594  /*******************************************************************************/
603  /*******************************************************************************/
604  virtual bool getEventLight(sensors_event_t *lightEvent) {
605  (void)lightEvent; // Parameter is intentionally unused in this virtual
606  // function.
607  return false;
608  }
609 
610  /**************************** SENSOR_TYPE: PM10_STD
611  * ****************************/
612  /*********************************************************************************/
619  /*********************************************************************************/
620  virtual long getSensorPM10_STDPeriod() { return _PM10SensorPeriod; }
621 
622  /*********************************************************************************/
629  /*********************************************************************************/
631 
632  /*******************************************************************************/
639  /*******************************************************************************/
640  virtual void setSensorPM10_STDPeriodPrv(long period) {
641  _PM10SensorPeriodPrv = period;
642  }
643 
644  /*******************************************************************************/
653  /*******************************************************************************/
654  virtual bool getEventPM10_STD(sensors_event_t *pm10StdEvent) {
655  (void)pm10StdEvent; // Parameter is intentionally unused in this virtual
656  // function.
657  return false;
658  }
659 
660  /**************************** SENSOR_TYPE: PM25_STD
661  * ****************************/
662  /*********************************************************************************/
669  /*********************************************************************************/
670  virtual long getSensorPM25_STDPeriod() { return _PM25SensorPeriod; }
671 
672  /*********************************************************************************/
679  /*********************************************************************************/
681 
682  /*******************************************************************************/
689  /*******************************************************************************/
690  virtual void setSensorPM25_STDPeriodPrv(long period) {
691  _PM25SensorPeriodPrv = period;
692  }
693 
694  /*******************************************************************************/
703  /*******************************************************************************/
704  virtual bool getEventPM25_STD(sensors_event_t *pm25StdEvent) {
705  (void)pm25StdEvent; // Parameter is intentionally unused in this virtual
706  // function.
707  return false;
708  }
709 
710  /**************************** SENSOR_TYPE: PM100_STD
711  * ****************************/
712  /*********************************************************************************/
719  /*********************************************************************************/
720  virtual long getSensorPM100_STDPeriod() { return _PM100SensorPeriod; }
721 
722  /*********************************************************************************/
729  /*********************************************************************************/
731 
732  /*******************************************************************************/
739  /*******************************************************************************/
740  virtual void setSensorPM100_STDPeriodPrv(long period) {
741  _PM100SensorPeriodPrv = period;
742  }
743 
744  /*******************************************************************************/
753  /*******************************************************************************/
754  virtual bool getEventPM100_STD(sensors_event_t *pm100StdEvent) {
755  (void)pm100StdEvent; // Parameter is intentionally unused in this virtual
756  // function.
757  return false;
758  }
759 
760  /**************************** SENSOR_TYPE: UNITLESS_PERCENT
761  * ****************************/
762  /*********************************************************************************/
769  /*********************************************************************************/
771  return _unitlessPercentPeriod;
772  }
773 
774  /*********************************************************************************/
781  /*********************************************************************************/
784  }
785 
786  /*******************************************************************************/
793  /*******************************************************************************/
794  virtual void setSensorUnitlessPercentPeriodPrv(long period) {
795  _unitlessPercentPeriodPrv = period;
796  }
797 
798  /*******************************************************************************/
807  /*******************************************************************************/
808  virtual bool getEventUnitlessPercent(sensors_event_t *unitlessPercentEvent) {
809  (void)unitlessPercentEvent; // Parameter is intentionally unused in this
810  // virtual function.
811  return false;
812  }
813 
814  /**************************** SENSOR_TYPE: VOLTAGE
815  * ****************************/
816  /*********************************************************************************/
822  /*********************************************************************************/
823  virtual long getSensorVoltagePeriod() { return _voltagePeriod; }
824 
825  /*********************************************************************************/
831  /*********************************************************************************/
832  virtual long getSensorVoltagePeriodPrv() { return _voltagePeriodPrv; }
833 
834  /*******************************************************************************/
840  /*******************************************************************************/
841  virtual void setSensorVoltagePeriodPrv(long period) {
842  _voltagePeriodPrv = period;
843  }
844 
845  /*******************************************************************************/
854  /*******************************************************************************/
855  virtual bool getEventVoltage(sensors_event_t *voltageEvent) {
856  (void)voltageEvent; // Parameter is intentionally unused in this virtual
857  // function.
858  return false;
859  }
860 
861  /**************************** SENSOR_TYPE: CURRENT
862  * ****************************/
863  /*********************************************************************************/
869  /*********************************************************************************/
870  virtual long getSensorCurrentPeriod() { return _currentPeriod; }
871 
872  /*********************************************************************************/
878  /*********************************************************************************/
879  virtual long getSensorCurrentPeriodPrv() { return _currentPeriodPrv; }
880 
881  /*******************************************************************************/
887  /*******************************************************************************/
888  virtual void setSensorCurrentPeriodPrv(long period) {
889  _currentPeriodPrv = period;
890  }
891 
892  /*******************************************************************************/
901  /*******************************************************************************/
902  virtual bool getEventCurrent(sensors_event_t *currentEvent) {
903  (void)currentEvent; // Parameter is intentionally unused in this virtual
904  // function.
905  return false;
906  }
907 
908  /****************************** SENSOR_TYPE: Raw
909  * *******************************/
910  /*********************************************************************************/
916  /*********************************************************************************/
917  virtual long getSensorRawPeriod() { return _rawSensorPeriod; }
918 
919  /*********************************************************************************/
925  /*********************************************************************************/
926  virtual long getSensorRawPeriodPrv() { return _rawSensorPeriodPrv; }
927 
928  /*******************************************************************************/
934  /*******************************************************************************/
935  virtual void setSensorRawPeriodPrv(long period) {
936  _rawSensorPeriodPrv = period;
937  }
938 
939  /*******************************************************************************/
947  /*******************************************************************************/
948  virtual bool getEventRaw(sensors_event_t *rawEvent) {
949  (void)
950  rawEvent; // Parameter is intentionally unused in this virtual function.
951  return false;
952  }
953 
954  /****************************** SENSOR_TYPE: Ambient Temp (°F)
955  * *******************************/
956 
957  /*******************************************************************************/
962  /*******************************************************************************/
963  virtual void disableAmbientTempF() { _ambientTempFPeriod = 0.0L; }
964 
965  /*********************************************************************************/
972  /*********************************************************************************/
974 
975  /*********************************************************************************/
982  /*********************************************************************************/
984  return _ambientTempFPeriodPrv;
985  }
986 
987  /*******************************************************************************/
995  /*******************************************************************************/
996  virtual void setSensorAmbientTempFPeriodPrv(long period) {
997  _ambientTempFPeriodPrv = period;
998  }
999 
1000  /*******************************************************************************/
1010  /*******************************************************************************/
1011  virtual bool getEventAmbientTempF(sensors_event_t *AmbientTempFEvent) {
1012  // obtain ambient temp. in °C
1013  if (!getEventAmbientTemp(AmbientTempFEvent))
1014  return false;
1015  // convert event from °C to °F
1016  AmbientTempFEvent->temperature =
1017  (AmbientTempFEvent->temperature * 9.0) / 5.0 + 32;
1018  return true;
1019  }
1020 
1021  /****************************** SENSOR_TYPE: Object Temp (°F)
1022  * *******************************/
1023  /*********************************************************************************/
1030  /*********************************************************************************/
1032 
1033  /*********************************************************************************/
1040  /*********************************************************************************/
1042 
1043  /*******************************************************************************/
1051  /*******************************************************************************/
1052  virtual void setSensorObjectTempFPeriodPrv(long period) {
1053  _objectTempFPeriodPrv = period;
1054  }
1055 
1056  /*******************************************************************************/
1066  /*******************************************************************************/
1067  virtual bool getEventObjectTempF(sensors_event_t *objectTempFEvent) {
1068  // obtain ambient temp. in °C
1069  if (!getEventObjectTemp(objectTempFEvent))
1070  return false;
1071  // convert event from °C to °F
1072  objectTempFEvent->temperature =
1073  (objectTempFEvent->temperature * 9.0) / 5.0 + 32.0;
1074  return true;
1075  }
1076 
1077  /****************************** SENSOR_TYPE: Gas Resistance (ohms)
1078  * *******************************/
1079  /*********************************************************************************/
1086  /*********************************************************************************/
1088 
1089  /*********************************************************************************/
1096  /*********************************************************************************/
1098  return _gasResistancePeriodPrv;
1099  }
1100 
1101  /*******************************************************************************/
1109  /*******************************************************************************/
1110  virtual void setSensorGasResistancePeriodPrv(long period) {
1111  _gasResistancePeriodPrv = period;
1112  }
1113 
1114  /*******************************************************************************/
1123  /*******************************************************************************/
1124  virtual bool getEventGasResistance(sensors_event_t *gasEvent) {
1125  (void)
1126  gasEvent; // Parameter is intentionally unused in this virtual function.
1127  return false;
1128  }
1129 
1130  /****************************** SENSOR_TYPE: NOx Index (index)
1131  * *******************************/
1132  /*********************************************************************************/
1139  /*********************************************************************************/
1140  virtual long getSensorNOxIndexPeriod() { return _NOxIndexPeriod; }
1141 
1142  /*********************************************************************************/
1149  /*********************************************************************************/
1151 
1152  /*******************************************************************************/
1160  /*******************************************************************************/
1161  virtual void setSensorNOxIndexPeriodPrv(long period) {
1162  _NOxIndexPeriodPrv = period;
1163  }
1164 
1165  /*******************************************************************************/
1174  /*******************************************************************************/
1175  virtual bool getEventNOxIndex(sensors_event_t *gasEvent) {
1176  (void)
1177  gasEvent; // Parameter is intentionally unused in this virtual function.
1178  return false;
1179  }
1180 
1181  /****************************** SENSOR_TYPE: VOC Index (index)
1182  * *******************************/
1183  /*********************************************************************************/
1190  /*********************************************************************************/
1191  virtual long getSensorVOCIndexPeriod() { return _VOCIndexPeriod; }
1192 
1193  /*********************************************************************************/
1200  /*********************************************************************************/
1202 
1203  /*******************************************************************************/
1211  /*******************************************************************************/
1212  virtual void setSensorVOCIndexPeriodPrv(long period) {
1213  _VOCIndexPeriodPrv = period;
1214  }
1215 
1216  /*******************************************************************************/
1225  /*******************************************************************************/
1226  virtual bool getEventVOCIndex(sensors_event_t *gasEvent) {
1227  (void)
1228  gasEvent; // Parameter is intentionally unused in this virtual function.
1229  return false;
1230  }
1231 
1232  /**************************** SENSOR_TYPE: PROXIMITY
1233  * ****************************/
1234  /*******************************************************************************/
1238  /*******************************************************************************/
1239  virtual void enableSensorProximity() {};
1240 
1241  /*******************************************************************************/
1245  /*******************************************************************************/
1247 
1248  /*********************************************************************************/
1255  /*********************************************************************************/
1257 
1258  /*******************************************************************************/
1265  /*******************************************************************************/
1266  virtual void setSensorProximityPeriod(long period) {
1267  if (period == 0)
1269  _proximitySensorPeriod = period;
1270  }
1271 
1272  /*********************************************************************************/
1279  /*********************************************************************************/
1281 
1282  /*******************************************************************************/
1289  /*******************************************************************************/
1290  virtual void setSensorProximityPeriodPrv(long period) {
1291  _proximitySensorPeriodPrv = period;
1292  }
1293 
1294  /*******************************************************************************/
1303  /*******************************************************************************/
1304  virtual bool getEventProximity(sensors_event_t *proximityEvent) {
1305  (void)proximityEvent; // Parameter is intentionally unused in this virtual
1306  // function.
1307  return false;
1308  }
1309 
1310  /*******************************************************************************/
1317  /*******************************************************************************/
1318  virtual void updateSensorProximity(float period) {
1319  setSensorProximityPeriod(period);
1320  }
1321 
1322 protected:
1323  TwoWire *_i2c;
1324  uint16_t _sensorAddress;
1326  0L;
1329  long _humidSensorPeriod =
1331  0L;
1334  long _pressureSensorPeriod =
1336  0L;
1339  long _CO2SensorPeriod =
1341  0L;
1345  0L;
1349  0L;
1353  0L;
1356  long _objectTempSensorPeriod = 0L;
1361  long _lightSensorPeriod =
1363  0L;
1366  long _PM10SensorPeriod =
1368  0L;
1372  0L;
1376  0L;
1379  long _unitlessPercentPeriod =
1381  0L;
1384  long _voltagePeriod =
1386  0L;
1389  long _currentPeriod =
1391  0L;
1394  long _rawSensorPeriod =
1396  0L;
1400  long _ambientTempFPeriodPrv =
1403  long _objectTempFPeriod = 0L;
1405  long _objectTempFPeriodPrv =
1408  long _gasResistancePeriod = 0L;
1413  long _NOxIndexPeriod =
1415  0L;
1418  long _VOCIndexPeriod =
1420  0L;
1423  long _proximitySensorPeriod =
1425  0L;
1428 };
1430 
1431 #endif // WipperSnapper_I2C_Driver_H
long _unitlessPercentPeriod
The time period between reading the unitless % sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1380
virtual long getSensorUnitlessPercentPeriodPrv()
Base implementation - Returns the previous time interval at which the unitless % sensor was queried l...
Definition: WipperSnapper_I2C_Driver.h:782
virtual long getSensorLightPeriodPrv()
Base implementation - Returns the previous time interval at which the light sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:580
virtual long getSensorObjectTempPeriodPrv()
Base implementation - Returns the previous time interval at which the object temperature sensor was q...
Definition: WipperSnapper_I2C_Driver.h:528
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:654
virtual void updateSensorProximity(float period)
Updates the properties of a proximity sensor.
Definition: WipperSnapper_I2C_Driver.h:1318
long _PM10SensorPeriod
The time period between reading the pm25 sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1367
uint16_t getI2CAddress()
Gets the I2C device&#39;s address.
Definition: WipperSnapper_I2C_Driver.h:175
virtual long getSensorPM25_STDPeriod()
Base implementation - Returns the object pm25 standard sensors&#39; period, if set.
Definition: WipperSnapper_I2C_Driver.h:670
virtual void setSensorObjectTempFPeriodPrv(long period)
Sets a timestamp for when the object temperature sensor (°F) was queried.
Definition: WipperSnapper_I2C_Driver.h:1052
long _PM100SensorPeriod
The time period between reading the pm100_std sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1375
#define PERIOD_24HRS_AGO_MILLIS
Used for last sensor read time, initially set 24hrs ago (max period)
Definition: WipperSnapper_I2C_Driver.h:24
virtual void setSensorVOCIndexPeriodPrv(long period)
Sets a timestamp for when the object VOC Index sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:1212
long _currentPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1392
virtual long getSensorPressurePeriod()
Base implementation - Returns the pressure sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:423
virtual long getSensorTVOCPeriodPrv()
Base implementation - Returns the previous time interval at which the TVOC sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:287
virtual void setSensorAmbientTempFPeriodPrv(long period)
Sets a timestamp for when the ambient temperature sensor (°F) was queried.
Definition: WipperSnapper_I2C_Driver.h:996
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:754
virtual long getSensorCurrentPeriod()
Base implementation - Returns the current sensor&#39;s period.
Definition: WipperSnapper_I2C_Driver.h:870
virtual long getSensorRelativeHumidityPeriodPrv()
Base implementation - Returns the previous time interval at which the humidity sensor was queried las...
Definition: WipperSnapper_I2C_Driver.h:383
long _altitudeSensorPeriod
The time period between reading the altitude sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1352
virtual long getSensorVOCIndexPeriod()
Base implementation - Returns the VOC Index sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:1191
virtual long getSensorTVOCPeriod()
Base implementation - Returns the TVOC sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:278
virtual void setSensorProximityPeriodPrv(long period)
Sets a timestamp for when the proximity sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:1290
virtual bool getEventCO2(sensors_event_t *co2Event)
Gets a sensor&#39;s CO2 value.
Definition: WipperSnapper_I2C_Driver.h:217
virtual long getSensorAmbientTempPeriod()
Base implementation - Returns the ambient temperature (°C) sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:324
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:730
virtual long getSensorAmbientTempPeriodPrv()
Base implementation - Returns the previous time interval at which the ambient temperature sensor (°C)...
Definition: WipperSnapper_I2C_Driver.h:334
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:704
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:1175
virtual long getSensorECO2PeriodPrv()
Base implementation - Returns the previous time interval at which the eCO2 sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:241
long _currentPeriod
The time period between reading the current sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1390
long _NOxIndexPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1416
long _objectTempSensorPeriod
Definition: WipperSnapper_I2C_Driver.h:1357
long _TVOCSensorPeriod
The time period between reading the TVOC sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1348
long _ambientTempFPeriod
Definition: WipperSnapper_I2C_Driver.h:1399
virtual long getSensorUnitlessPercentPeriod()
Base implementation - Returns the object unitless % sensor period, if set.
Definition: WipperSnapper_I2C_Driver.h:770
virtual long getSensorCO2Period()
Base implementation - Returns the co2 sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:186
virtual void setSensorTVOCPeriodPrv(long period)
Sets a timestamp for when the TVOC sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:296
long _VOCIndexPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1421
virtual void setSensorVoltagePeriodPrv(long period)
Sets a timestamp for when the voltage sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:841
virtual void setSensorAltitudePeriodPrv(long period)
Sets a timestamp for when the Altitude sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:488
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:1304
long _tempSensorPeriod
The time period between reading the temperature sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1325
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:408
virtual void setSensorNOxIndexPeriodPrv(long period)
Sets a timestamp for when the object NOx Index sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:1161
virtual ~WipperSnapper_I2C_Driver()
Destructor for an I2C sensor.
Definition: WipperSnapper_I2C_Driver.h:54
long _unitlessPercentPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1382
virtual long getSensorAmbientTempFPeriodPrv()
Base implementation - Returns the previous time interval at which the ambient temperature sensor (°F)...
Definition: WipperSnapper_I2C_Driver.h:983
long _voltagePeriod
The time period between reading the voltage sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1385
bool begin()
Initializes the I2C sensor and begins I2C.
Definition: WipperSnapper_I2C_Driver.h:62
virtual long getSensorAmbientTempFPeriod()
Base implementation - Returns the ambient temperature (°F) sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:973
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:1011
long _TVOCSensorPeriodPrv
The time when the TVOC sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1350
WipperSnapper_I2C_Driver(TwoWire *i2c, uint16_t sensorAddress)
Instanciates an I2C sensor.
Definition: WipperSnapper_I2C_Driver.h:44
virtual void disableAmbientTempF()
Disables the device&#39;s ambient temperature (°F) sensor, if it exists.
Definition: WipperSnapper_I2C_Driver.h:963
Base class for I2C Drivers.
Definition: WipperSnapper_I2C_Driver.h:32
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:502
long _pressureSensorPeriod
The time period between reading the pressure sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1335
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:1226
long _objectTempFPeriod
Definition: WipperSnapper_I2C_Driver.h:1404
long _ambientTempFPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1401
long _ECO2SensorPeriodPrv
The time when the eCO2 sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1346
long _gasResistancePeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1411
long _humidSensorPeriod
The time period between reading the humidity sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1330
virtual void setSensorPM100_STDPeriodPrv(long period)
Sets a timestamp for when the light sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:740
virtual long getSensorLightPeriod()
Base implementation - Returns the object light sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:570
long _PM100SensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1377
virtual long getSensorRelativeHumidityPeriod()
Base implementation - Returns the humidity sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:374
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:808
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:680
virtual bool getEventTVOC(sensors_event_t *tvocEvent)
Gets a sensor&#39;s TVOC value.
Definition: WipperSnapper_I2C_Driver.h:309
uint16_t _sensorAddress
The I2C driver&#39;s unique I2C address.
Definition: WipperSnapper_I2C_Driver.h:1324
virtual long getSensorAltitudePeriodPrv()
Base implementation - Returns the previous time interval at which the Altitude sensor was queried las...
Definition: WipperSnapper_I2C_Driver.h:479
virtual void setSensorECO2PeriodPrv(long period)
Sets a timestamp for when the eCO2 sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:250
virtual long getSensorGasResistancePeriodPrv()
Base implementation - Returns the previous time interval at which the gas resistance sensor (ohms) wa...
Definition: WipperSnapper_I2C_Driver.h:1097
long _gasResistancePeriod
Definition: WipperSnapper_I2C_Driver.h:1409
virtual long SensorProximityPeriodPrv()
Base implementation - Returns the previous time interval at which the proximity sensor was queried la...
Definition: WipperSnapper_I2C_Driver.h:1280
virtual long getSensorPM100_STDPeriod()
Base implementation - Returns the object pm100 standard sensors&#39; period, if set.
Definition: WipperSnapper_I2C_Driver.h:720
long _humidSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1332
virtual long getSensorVoltagePeriod()
Base implementation - Returns the voltage sensor&#39;s period.
Definition: WipperSnapper_I2C_Driver.h:823
virtual void setSensorPM10_STDPeriodPrv(long period)
Sets a timestamp for when the light sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:640
long _objectTempSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1359
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:630
long _objectTempFPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1406
long _lightSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1364
virtual bool getEventECO2(sensors_event_t *eco2Event)
Gets a sensor&#39;s eCO2 value.
Definition: WipperSnapper_I2C_Driver.h:263
virtual void setSensorPM25_STDPeriodPrv(long period)
Sets a timestamp for when the light sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:690
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:73
virtual void setSensorObjectTempPeriodPrv(long period)
Sets a timestamp for when the object temperature sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:540
virtual long getSensorPressurePeriodPrv()
Base implementation - Returns the previous time interval at which the pressure sensor was queried las...
Definition: WipperSnapper_I2C_Driver.h:432
virtual void setSensorPressurePeriodPrv(long period)
Sets a timestamp for when the pressure sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:441
virtual void setSensorRelativeHumidityPeriodPrv(long periodPrv)
Sets a timestamp for when the temperature sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:394
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:455
virtual long getSensorCurrentPeriodPrv()
Base implementation - Returns the previous time interval at which the current sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:879
virtual long getSensorGasResistancePeriod()
Base implementation - Returns the gas resistance (ohms) sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:1087
virtual long getSensorAltitudePeriod()
Base implementation - Returns the Altitude sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:470
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:604
long _VOCIndexPeriod
The time period between reading the VOC Index sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1419
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:1124
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:359
virtual long getSensorObjectTempFPeriod()
Base implementation - Returns the object temperature (°F) sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:1031
long _CO2SensorPeriodPrv
The time when the CO2 sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1342
long _lightSensorPeriod
The time period between reading the light sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1362
void configureDriver(wippersnapper_i2c_v1_I2CDeviceInitRequest *msgDeviceInitReq)
Uses an I2CDeviceInitRequest message to configure the sensors belonging to the driver.
Definition: WipperSnapper_I2C_Driver.h:158
virtual void enableSensorProximity()
Enables the device&#39;s proximity sensor, if it exists.
Definition: WipperSnapper_I2C_Driver.h:1239
virtual long getSensorNOxIndexPeriodPrv()
Base implementation - Returns the previous time interval at which the NOx Index sensor was queried la...
Definition: WipperSnapper_I2C_Driver.h:1150
virtual void setSensorUnitlessPercentPeriodPrv(long period)
Sets a timestamp for when the unitless % sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:794
virtual void setSensorCO2PeriodPrv(long period)
Sets a timestamp for when the co2 sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:204
virtual long getSensorRawPeriod()
Base implementation - Returns the raw sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:917
virtual void setSensorRawPeriodPrv(long period)
Sets a timestamp for when the raw sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:935
virtual long getSensorObjectTempPeriod()
Base implementation - Returns the object temperature sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:518
virtual void setSensorAmbientTempPeriodPrv(long periodPrv)
Sets a timestamp for when the ambient temperature sensor (°C) was queried.
Definition: WipperSnapper_I2C_Driver.h:345
long _voltagePeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1387
long _rawSensorPeriod
The time period between reading the Raw sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1395
virtual long getSensorCO2PeriodPrv()
Base implementation - Returns the previous time interval at which the co2 sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:195
virtual long getSensorECO2Period()
Base implementation - Returns the eCO2 sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:232
virtual void disableSensorProximity()
Disables the device&#39;s object proximity sensor, if it exists.
Definition: WipperSnapper_I2C_Driver.h:1246
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:1067
long _rawSensorPeriodPrv
The time when the Raw sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1397
long _PM25SensorPeriod
The time period between reading the pm25 sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1371
long _tempSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1327
long _PM10SensorPeriodPrv
The time when the pm25 sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1369
long _CO2SensorPeriod
The time period between reading the CO2 sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1340
virtual long getSensorPM10_STDPeriod()
Base implementation - Returns the object pm10 standard sensors&#39; period, if set.
Definition: WipperSnapper_I2C_Driver.h:620
virtual long getSensorObjectTempFPeriodPrv()
Base implementation - Returns the previous time interval at which the object temperature sensor (°F) ...
Definition: WipperSnapper_I2C_Driver.h:1041
long _proximitySensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1426
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:554
virtual long getSensorVoltagePeriodPrv()
Base implementation - Returns the previous time interval at which the voltage sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:832
long _ECO2SensorPeriod
The time period between reading the eCO2 sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1344
long _proximitySensorPeriod
The time period between reading the proximity sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1424
virtual long getSensorRawPeriodPrv()
Base implementation - Returns the previous time interval at which the raw sensor was queried last...
Definition: WipperSnapper_I2C_Driver.h:926
virtual void setSensorCurrentPeriodPrv(long period)
Sets a timestamp for when the current sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:888
long _PM25SensorPeriodPrv
The time when the pm25 sensor was last read.
Definition: WipperSnapper_I2C_Driver.h:1373
virtual bool getEventRaw(sensors_event_t *rawEvent)
Gets a sensor&#39;s Raw value.
Definition: WipperSnapper_I2C_Driver.h:948
virtual long sensorProximityPeriod()
Base implementation - Returns the proximity sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:1256
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:902
virtual void setSensorGasResistancePeriodPrv(long period)
Sets a timestamp for when the object gas resistance sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:1110
long _altitudeSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1354
virtual long getSensorVOCIndexPeriodPrv()
Base implementation - Returns the previous time interval at which the VOC Index sensor was queried la...
Definition: WipperSnapper_I2C_Driver.h:1201
long _NOxIndexPeriod
The time period between reading the NOx Index sensor&#39;s value.
Definition: WipperSnapper_I2C_Driver.h:1414
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:855
TwoWire * _i2c
Pointer to the I2C driver&#39;s Wire object.
Definition: WipperSnapper_I2C_Driver.h:1323
long _pressureSensorPeriodPrv
Definition: WipperSnapper_I2C_Driver.h:1337
virtual long getSensorNOxIndexPeriod()
Base implementation - Returns the NOx Index sensor&#39;s period, if set.
Definition: WipperSnapper_I2C_Driver.h:1140
virtual void setSensorLightPeriodPrv(long period)
Sets a timestamp for when the light sensor was queried.
Definition: WipperSnapper_I2C_Driver.h:590
virtual void setSensorProximityPeriod(long period)
Set the proximity sensor&#39;s return frequency.
Definition: WipperSnapper_I2C_Driver.h:1266