mirror of
https://github.com/meshtastic/firmware.git
synced 2025-06-19 19:42:32 +00:00
commit
6ca3186bff
@ -44,9 +44,6 @@ shift "$((OPTIND-1))"
|
|||||||
shift
|
shift
|
||||||
}
|
}
|
||||||
|
|
||||||
# check that esptool is installed
|
|
||||||
"$PYTHON" -m esptool -h >/dev/null 2>&1 || echo "Error: esptool was not found."; exit 1
|
|
||||||
|
|
||||||
if [ -f "${FILENAME}" ]; then
|
if [ -f "${FILENAME}" ]; then
|
||||||
echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
|
echo "Trying to flash ${FILENAME}, but first erasing and writing system information"
|
||||||
"$PYTHON" -m esptool erase_flash
|
"$PYTHON" -m esptool erase_flash
|
||||||
|
@ -92,7 +92,10 @@ typedef enum _InputEventChar {
|
|||||||
|
|
||||||
typedef enum _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType {
|
typedef enum _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType {
|
||||||
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 = 0,
|
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11 = 0,
|
||||||
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20 = 1
|
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20 = 1,
|
||||||
|
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12 = 2,
|
||||||
|
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21 = 3,
|
||||||
|
RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22 = 4
|
||||||
} RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType;
|
} RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType;
|
||||||
|
|
||||||
/* Struct definitions */
|
/* Struct definitions */
|
||||||
@ -217,8 +220,8 @@ typedef struct _RadioConfig {
|
|||||||
#define _InputEventChar_ARRAYSIZE ((InputEventChar)(InputEventChar_BACK+1))
|
#define _InputEventChar_ARRAYSIZE ((InputEventChar)(InputEventChar_BACK+1))
|
||||||
|
|
||||||
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11
|
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MIN RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11
|
||||||
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20
|
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_MAX RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22
|
||||||
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20+1))
|
#define _RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_ARRAYSIZE ((RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType)(RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22+1))
|
||||||
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
@ -70,11 +70,13 @@ int32_t EnvironmentalMeasurementPlugin::runOnce()
|
|||||||
// it's possible to have this plugin enabled, only for displaying values on the screen.
|
// it's possible to have this plugin enabled, only for displaying values on the screen.
|
||||||
// therefore, we should only enable the sensor loop if measurement is also enabled
|
// therefore, we should only enable the sensor loop if measurement is also enabled
|
||||||
switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) {
|
switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) {
|
||||||
|
|
||||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
||||||
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12:
|
||||||
dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT11);
|
dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT11);
|
||||||
this->dht->begin();
|
this->dht->begin();
|
||||||
this->dht->read();
|
this->dht->read();
|
||||||
DEBUG_MSG("EnvironmentalMeasurement: Opened DHT11 on pin: %d\n",
|
DEBUG_MSG("EnvironmentalMeasurement: Opened DHT11/DHT12 on pin: %d\n",
|
||||||
radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
||||||
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20:
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20:
|
||||||
@ -86,6 +88,14 @@ int32_t EnvironmentalMeasurementPlugin::runOnce()
|
|||||||
DEBUG_MSG("EnvironmentalMeasurement: Opened DS18B20 on pin: %d\n",
|
DEBUG_MSG("EnvironmentalMeasurement: Opened DS18B20 on pin: %d\n",
|
||||||
radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
||||||
return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||||
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21:
|
||||||
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22:
|
||||||
|
dht = new DHT(radioConfig.preferences.environmental_measurement_plugin_sensor_pin, DHT22);
|
||||||
|
this->dht->begin();
|
||||||
|
this->dht->read();
|
||||||
|
DEBUG_MSG("EnvironmentalMeasurement: Opened DHT21/DHT22 on pin: %d\n",
|
||||||
|
radioConfig.preferences.environmental_measurement_plugin_sensor_pin);
|
||||||
|
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||||
default:
|
default:
|
||||||
DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin");
|
DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin");
|
||||||
return (INT32_MAX);
|
return (INT32_MAX);
|
||||||
@ -129,9 +139,13 @@ int32_t EnvironmentalMeasurementPlugin::runOnce()
|
|||||||
|
|
||||||
switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) {
|
switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) {
|
||||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
||||||
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12:
|
||||||
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20:
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DS18B20:
|
||||||
return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
return (DS18B20_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||||
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21:
|
||||||
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22:
|
||||||
|
return (DHT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||||
default:
|
default:
|
||||||
return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
return (DEFAULT_SENSOR_MINIMUM_WAIT_TIME_BETWEEN_READS);
|
||||||
}
|
}
|
||||||
@ -245,6 +259,7 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des
|
|||||||
|
|
||||||
switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) {
|
switch (radioConfig.preferences.environmental_measurement_plugin_sensor_type) {
|
||||||
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT11:
|
||||||
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT12:
|
||||||
if (!this->dht->read(true)) {
|
if (!this->dht->read(true)) {
|
||||||
sensor_read_error_count++;
|
sensor_read_error_count++;
|
||||||
DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n");
|
DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n");
|
||||||
@ -264,6 +279,16 @@ bool EnvironmentalMeasurementPlugin::sendOurEnvironmentalMeasurement(NodeNum des
|
|||||||
DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n");
|
DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT21:
|
||||||
|
case RadioConfig_UserPreferences_EnvironmentalMeasurementSensorType_DHT22:
|
||||||
|
if (!this->dht->read(true)) {
|
||||||
|
sensor_read_error_count++;
|
||||||
|
DEBUG_MSG("EnvironmentalMeasurement: FAILED TO READ DATA\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
m.relative_humidity = this->dht->readHumidity();
|
||||||
|
m.temperature = this->dht->readTemperature();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin");
|
DEBUG_MSG("EnvironmentalMeasurement: Invalid sensor type selected; Disabling plugin");
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user