Skip to content

Commit

Permalink
Merge pull request #20 from kike-canaries/refactor_enum_generic_#16
Browse files Browse the repository at this point in the history
Refactor enum generic #16
  • Loading branch information
hpsaturn authored Nov 8, 2020
2 parents 1aec8bf + c1e9a54 commit d48e6c0
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 20 deletions.
6 changes: 3 additions & 3 deletions Sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ bool Sensors::pmSensirionRead() {
*/
bool Sensors::pmSensorRead() {
switch (device_type) {
case Honeywell:
case Auto:
return pmGenericRead();
break;

Expand Down Expand Up @@ -361,8 +361,8 @@ bool Sensors::pmSensorAutoDetect(int pms_type) {
} else {
DEBUG("-->[PMSENSOR] detecting Honeywell/Plantower sensor..");
if (pmGenericRead()) {
device_selected = "HONEYWELL";
device_type = Honeywell;
device_selected = "GENERIC";
device_type = Auto;
return true;
}
DEBUG("-->[PMSENSOR] detecting Panasonic sensor..");
Expand Down
4 changes: 2 additions & 2 deletions Sensors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ class Sensors {

public:

/// Supported devices. Honeywell and Plantower sensors are similars
enum SENSOR_TYPE { Honeywell, Panasonic, Sensirion };
/// Supported devices. Auto is for Honeywell and Plantower sensors and similars
enum SENSOR_TYPE { Auto, Panasonic, Sensirion };

/// SPS30 values. Only for Sensirion SPS30 sensor.
struct sps_values val;
Expand Down
12 changes: 7 additions & 5 deletions examples/basic/basic.ino
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ void setup() {
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
sensors.setOnErrorCallBack(&onSensorDataError); // [optional] error callback
sensors.setDebugMode(false); // [optional] debug mode
sensors.init(sensors.Sensirion); // force sensor detection for Sensirion SPS30

// You also can try init() with:
// sensors.init() => auto detection PM sensors (Honeywell, Plantower or Panasonic)
// sensors.init(sensors.Sensirion) => only auto detection for Sensirion
// sensors.init(sensors.Honeywell,21,22) => force RX,TX pines
// sensors.init(); // Auto detection of PM sensors (Honeywell, Plantower)
// sensors.init(sensors.Auto); // Auto detection of PM sensors (Honeywell, Plantower)
// sensors.init(sensors.Panasonic); // Force detection to Panasonic sensor
// sensors.init(sensors.Sensirion); // Force detection to Sensirion sensor
// sensors.init(sensors.Auto,mRX,mTX); // Auto detection and custom RX, TX pines

sensors.init(sensors.Sensirion); // Force detection to Sensirion sensor

if(sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
Expand Down
4 changes: 2 additions & 2 deletions examples/platformio/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ framework = arduino
upload_speed = 1500000
monitor_speed = 115200
build_flags =
-D SRC_REV=072
-D SRC_REV=079
; -D CORE_DEBUG_LEVEL=0
lib_deps =
hpsaturn/CanAirIO Air Quality Sensors Library @ ^0.1.1
hpsaturn/CanAirIO Air Quality Sensors Library

# variant for official guide:
# TTGO T7 v1.3 mini board (d1mini v2) and Panasonic sensor
Expand Down
12 changes: 8 additions & 4 deletions examples/platformio/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,14 @@ void setup() {
sensors.setOnDataCallBack(&onSensorDataOk); // all data read callback
sensors.setOnErrorCallBack(&onSensorDataError); // [optional] error callback
sensors.setDebugMode(false); // [optional] debug mode
sensors.init(); // start all sensors and
// force to try autodetection,
// you can try to select one:
// sensors.init(sensors.Sensirion);

// sensors.init(); // Auto detection of PM sensors (Honeywell, Plantower)
// sensors.init(sensors.Auto); // Auto detection of PM sensors (Honeywell, Plantower)
// sensors.init(sensors.Panasonic); // Force detection to Panasonic sensor
// sensors.init(sensors.Sensirion); // Force detection to Sensirion sensor
// sensors.init(sensors.Auto,mRX,mTX); // Auto detection and custom RX, TX pines

sensors.init(sensors.Sensirion); // Force detection to Sensirion sensor

if(sensors.isPmSensorConfigured())
Serial.println("-->[SETUP] Sensor configured: " + sensors.getPmDeviceSelected());
Expand Down
6 changes: 3 additions & 3 deletions library.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "CanAirIO Air Quality Sensors Library",
"version": "0.1.2",
"maintainer":"[email protected]",
"homepage":"https://canair.io",
"keywords":
[
Expand Down Expand Up @@ -47,8 +46,9 @@
"authors":
[
{
"name": "Antonio Vanegas",
"url": "https://hpsaturn.com"
"name": "@hpsaturn",
"url": "https://hpsaturn.com",
"maintainer": true
},
{
"name": "CanAirIO Project",
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name=CanAirIO Air Quality Sensors Library
version=0.1.2
author=Antonio Vanegas @hpsaturn, CanAirIO project <[email protected]>
author=@hpsaturn, CanAirIO project <[email protected]>
maintainer=Antonio Vanegas <[email protected]>
url=https://github.com/kike-canaries/canairio_sensorlib
sentence=Air quality particle meter sensors manager for multiple sensors.
Expand Down

0 comments on commit d48e6c0

Please sign in to comment.