|
|
@ -220,7 +220,6 @@ void _sensorInit() { |
|
|
|
{ |
|
|
|
DallasSensor * sensor = new DallasSensor(); |
|
|
|
sensor->setGPIO(DALLAS_PIN); |
|
|
|
sensor->setPullUp(DALLAS_PULLUP); |
|
|
|
_sensorRegister(sensor); |
|
|
|
} |
|
|
|
#endif
|
|
|
@ -320,46 +319,14 @@ void _sensorInit() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Values
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
unsigned char sensorCount() { |
|
|
|
return _sensors.size(); |
|
|
|
} |
|
|
|
|
|
|
|
unsigned char magnitudeCount() { |
|
|
|
return _magnitudes.size(); |
|
|
|
} |
|
|
|
|
|
|
|
String magnitudeName(unsigned char index) { |
|
|
|
if (index < _magnitudes.size()) { |
|
|
|
sensor_magnitude_t magnitude = _magnitudes[index]; |
|
|
|
return magnitude.sensor->slot(magnitude.local); |
|
|
|
} |
|
|
|
return String(); |
|
|
|
} |
|
|
|
void _magnitudesInit() { |
|
|
|
|
|
|
|
unsigned char magnitudeType(unsigned char index) { |
|
|
|
if (index < _magnitudes.size()) { |
|
|
|
return int(_magnitudes[index].type); |
|
|
|
} |
|
|
|
return MAGNITUDE_NONE; |
|
|
|
} |
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void sensorSetup() { |
|
|
|
|
|
|
|
// Load sensors
|
|
|
|
_sensorInit(); |
|
|
|
|
|
|
|
// Load magnitudes
|
|
|
|
for (unsigned char i=0; i<_sensors.size(); i++) { |
|
|
|
|
|
|
|
BaseSensor * sensor = _sensors[i]; |
|
|
|
|
|
|
|
DEBUG_MSG("[SENSOR] %s\n", sensor->name().c_str()); |
|
|
|
if (sensor->count() == 0) DEBUG_MSG("[SENSOR] -> NOTHING FOUND\n"); |
|
|
|
if (sensor->error() != 0) DEBUG_MSG("[SENSOR] -> ERROR %d\n", sensor->error()); |
|
|
|
|
|
|
|
for (unsigned char k=0; k<sensor->count(); k++) { |
|
|
|
|
|
|
@ -391,6 +358,45 @@ void sensorSetup() { |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
// Public
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
unsigned char sensorCount() { |
|
|
|
return _sensors.size(); |
|
|
|
} |
|
|
|
|
|
|
|
unsigned char magnitudeCount() { |
|
|
|
return _magnitudes.size(); |
|
|
|
} |
|
|
|
|
|
|
|
String magnitudeName(unsigned char index) { |
|
|
|
if (index < _magnitudes.size()) { |
|
|
|
sensor_magnitude_t magnitude = _magnitudes[index]; |
|
|
|
return magnitude.sensor->slot(magnitude.local); |
|
|
|
} |
|
|
|
return String(); |
|
|
|
} |
|
|
|
|
|
|
|
unsigned char magnitudeType(unsigned char index) { |
|
|
|
if (index < _magnitudes.size()) { |
|
|
|
return int(_magnitudes[index].type); |
|
|
|
} |
|
|
|
return MAGNITUDE_NONE; |
|
|
|
} |
|
|
|
|
|
|
|
// -----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
void sensorSetup() { |
|
|
|
|
|
|
|
// Load sensors
|
|
|
|
_sensorInit(); |
|
|
|
|
|
|
|
// Load magnitudes
|
|
|
|
_magnitudesInit(); |
|
|
|
|
|
|
|
#if WEB_SUPPORT
|
|
|
|
|
|
|
|
// Websockets
|
|
|
|