mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
Merge pull request #2202 from MichaelDvP/dev
fix analog input pullup and counter on gpio 25/26, dac values on web #2201
This commit is contained in:
@@ -23,5 +23,6 @@ For more details go to [www.emsesp.org](https://www.emsesp.org/).
|
|||||||
- lastCode character check [#2189](https://github.com/emsesp/EMS-ESP32/issues/2189)
|
- lastCode character check [#2189](https://github.com/emsesp/EMS-ESP32/issues/2189)
|
||||||
- reading too many telegram parts
|
- reading too many telegram parts
|
||||||
- heatpump cost UOMs [#2188](https://github.com/emsesp/EMS-ESP32/issues/2188)
|
- heatpump cost UOMs [#2188](https://github.com/emsesp/EMS-ESP32/issues/2188)
|
||||||
|
- analog dac output and inputs on dac pins [#2201](https://github.com/emsesp/EMS-ESP32/discussions/2201)
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
|
|||||||
@@ -438,7 +438,8 @@ const Sensors = () => {
|
|||||||
<Cell stiff>{a.g}</Cell>
|
<Cell stiff>{a.g}</Cell>
|
||||||
<Cell>{a.n}</Cell>
|
<Cell>{a.n}</Cell>
|
||||||
<Cell stiff>{AnalogTypeNames[a.t]} </Cell>
|
<Cell stiff>{AnalogTypeNames[a.t]} </Cell>
|
||||||
{a.t === AnalogType.DIGITAL_OUT || a.t === AnalogType.DIGITAL_IN ? (
|
{(a.t === AnalogType.DIGITAL_OUT && a.g !== 25 && a.g !== 26) ||
|
||||||
|
a.t === AnalogType.DIGITAL_IN ? (
|
||||||
<Cell stiff>{a.v ? LL.ON() : LL.OFF()}</Cell>
|
<Cell stiff>{a.v ? LL.ON() : LL.OFF()}</Cell>
|
||||||
) : (
|
) : (
|
||||||
<Cell stiff>{a.t ? formatValue(a.v, a.u) : ''}</Cell>
|
<Cell stiff>{a.t ? formatValue(a.v, a.u) : ''}</Cell>
|
||||||
|
|||||||
@@ -138,6 +138,20 @@ void AnalogSensor::reload(bool get_nvs) {
|
|||||||
continue; // skip this loop pass
|
continue; // skip this loop pass
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((sensor.gpio() == 25 || sensor.gpio() == 26)
|
||||||
|
&& (sensor.type() == AnalogType::COUNTER || sensor.type() == AnalogType::DIGITAL_IN || sensor.type() == AnalogType::RATE
|
||||||
|
|| sensor.type() == AnalogType::TIMER)) {
|
||||||
|
// pullup is mapped to DAC, so set to 3.3V
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
|
if (sensor.gpio() == 25 || sensor.gpio() == 26) {
|
||||||
|
dacWrite(sensor.gpio(), 255);
|
||||||
|
}
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
if (sensor.gpio() == 17 || sensor.gpio() == 18) {
|
||||||
|
dacWrite(sensor.gpio(), 255);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
if (sensor.type() == AnalogType::ADC) {
|
if (sensor.type() == AnalogType::ADC) {
|
||||||
LOG_DEBUG("ADC Sensor on GPIO %02d", sensor.gpio());
|
LOG_DEBUG("ADC Sensor on GPIO %02d", sensor.gpio());
|
||||||
// analogSetPinAttenuation does not work with analogReadMilliVolts
|
// analogSetPinAttenuation does not work with analogReadMilliVolts
|
||||||
@@ -146,15 +160,6 @@ void AnalogSensor::reload(bool get_nvs) {
|
|||||||
} else if (sensor.type() == AnalogType::COUNTER) {
|
} else if (sensor.type() == AnalogType::COUNTER) {
|
||||||
LOG_DEBUG("I/O Counter on GPIO %02d", sensor.gpio());
|
LOG_DEBUG("I/O Counter on GPIO %02d", sensor.gpio());
|
||||||
pinMode(sensor.gpio(), INPUT_PULLUP);
|
pinMode(sensor.gpio(), INPUT_PULLUP);
|
||||||
#if CONFIG_IDF_TARGET_ESP32
|
|
||||||
if (sensor.gpio() == 25 || sensor.gpio() == 26) {
|
|
||||||
dacWrite(sensor.gpio(), 255);
|
|
||||||
}
|
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
|
||||||
if (sensor.gpio() == 23 || sensor.gpio() == 24) {
|
|
||||||
dacWrite(sensor.gpio(), 255);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
sensor.polltime_ = 0;
|
sensor.polltime_ = 0;
|
||||||
sensor.poll_ = digitalRead(sensor.gpio());
|
sensor.poll_ = digitalRead(sensor.gpio());
|
||||||
if (double_t val = EMSESP::nvs_.getDouble(sensor.name().c_str(), 0)) {
|
if (double_t val = EMSESP::nvs_.getDouble(sensor.name().c_str(), 0)) {
|
||||||
@@ -192,7 +197,7 @@ void AnalogSensor::reload(bool get_nvs) {
|
|||||||
sensor.set_value(sensor.offset());
|
sensor.set_value(sensor.offset());
|
||||||
} else
|
} else
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||||
if (sensor.gpio() == 23 || sensor.gpio() == 24) {
|
if (sensor.gpio() == 17 || sensor.gpio() == 18) {
|
||||||
if (sensor.offset() > 255) {
|
if (sensor.offset() > 255) {
|
||||||
sensor.set_offset(255);
|
sensor.set_offset(255);
|
||||||
} else if (sensor.offset() < 0) {
|
} else if (sensor.offset() < 0) {
|
||||||
@@ -745,7 +750,7 @@ bool AnalogSensor::command_setvalue(const char * value, const int8_t gpio) {
|
|||||||
dacWrite(sensor.gpio(), sensor.offset());
|
dacWrite(sensor.gpio(), sensor.offset());
|
||||||
} else
|
} else
|
||||||
#elif CONFIG_IDF_TARGET_ESP32S2
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||||
if ((sensor.gpio() == 23 || sensor.gpio() == 24) && v <= 255) {
|
if ((sensor.gpio() == 17 || sensor.gpio() == 18) && v <= 255) {
|
||||||
sensor.set_offset(v);
|
sensor.set_offset(v);
|
||||||
sensor.set_value(v);
|
sensor.set_value(v);
|
||||||
pinMode(sensor.gpio(), OUTPUT);
|
pinMode(sensor.gpio(), OUTPUT);
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
#define EMSESP_APP_VERSION "3.7.1-dev.6"
|
#define EMSESP_APP_VERSION "3.7.1-dev.7"
|
||||||
@@ -415,6 +415,15 @@ void WebDataService::dashboard_data(AsyncWebServerRequest * request) {
|
|||||||
|
|
||||||
JsonObject dv = node["dv"].to<JsonObject>();
|
JsonObject dv = node["dv"].to<JsonObject>();
|
||||||
dv["id"] = "00" + sensor.name();
|
dv["id"] = "00" + sensor.name();
|
||||||
|
#if CONFIG_IDF_TARGET_ESP32
|
||||||
|
if (sensor.type() == AnalogSensor::AnalogType::DIGITAL_OUT && (sensor.gpio() == 25 || sensor.gpio() == 26)) {
|
||||||
|
obj["v"] = Helpers::transformNumFloat(sensor.value(), 0);
|
||||||
|
} else
|
||||||
|
#elif CONFIG_IDF_TARGET_ESP32S2
|
||||||
|
if (sensor.type() == AnalogSensor::AnalogType::DIGITAL_OUT && (sensor.gpio() == 17 || sensor.gpio() == 18)) {
|
||||||
|
obj["v"] = Helpers::transformNumFloat(sensor.value(), 0);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
if (sensor.type() == AnalogSensor::AnalogType::DIGITAL_OUT || sensor.type() == AnalogSensor::AnalogType::DIGITAL_IN) {
|
if (sensor.type() == AnalogSensor::AnalogType::DIGITAL_OUT || sensor.type() == AnalogSensor::AnalogType::DIGITAL_IN) {
|
||||||
char s[12];
|
char s[12];
|
||||||
dv["v"] = Helpers::render_boolean(s, sensor.value() != 0, true);
|
dv["v"] = Helpers::render_boolean(s, sensor.value() != 0, true);
|
||||||
|
|||||||
Reference in New Issue
Block a user