Berry fix DAC support

This commit is contained in:
Stephan Hadinger 2022-01-11 18:40:47 +01:00
parent 6735c0c3fd
commit 0e78c0e41d
1 changed files with 8 additions and 8 deletions

View File

@ -62,8 +62,8 @@ extern "C" {
// DAC
#if defined(CONFIG_IDF_TARGET_ESP32)
if (25 == pin || 26 == pin) {
uint32_t channel = pin - 25 + 1; // 1 or 2
esp_err_t err = dac_output_enable((dac_channel_t) channel);
dac_channel_t channel = (25 == pin) ? DAC_CHANNEL_1 : DAC_CHANNEL_2;
esp_err_t err = dac_output_enable(channel);
if (err) {
be_raisef(vm, "value_error", "Error: dac_output_enable(%i) -> %i", channel, err);
}
@ -72,8 +72,8 @@ extern "C" {
}
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
if (17 == pin || 18 == pin) {
uint32_t channel = pin - 17 + 1; // 1 or 2
esp_err_t err = dac_output_enable((dac_channel_t) channel);
dac_channel_t channel = (17 == pin) ? DAC_CHANNEL_1 : DAC_CHANNEL_2;
esp_err_t err = dac_output_enable(channel);
if (err) {
be_raisef(vm, "value_error", "Error: dac_output_enable(%i) -> %i", channel, err);
}
@ -133,8 +133,8 @@ extern "C" {
uint32_t dac_value = changeUIntScale(mV, 0, 3300, 0, 255); // convert from 0..3300 ms to 0..255
#if defined(CONFIG_IDF_TARGET_ESP32)
if (25 == pin || 26 == pin) {
uint32_t channel = pin - 25 + 1; // 1 or 2
esp_err_t err = dac_output_voltage((dac_channel_t) channel, dac_value);
dac_channel_t channel = (25 == pin) ? DAC_CHANNEL_1 : DAC_CHANNEL_2;
esp_err_t err = dac_output_voltage(channel, dac_value);
if (err) {
be_raisef(vm, "internal_error", "Error: esp_err_tdac_output_voltage(%i, %i) -> %i", channel, dac_value, err);
}
@ -143,8 +143,8 @@ extern "C" {
}
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
if (17 == pin || 18 == pin) {
uint32_t channel = pin - 17 + 1; // 1 or 2
esp_err_t err = dac_output_voltage((dac_channel_t) channel, dac_value);
dac_channel_t channel = (17 == pin) ? DAC_CHANNEL_1 : DAC_CHANNEL_2;
esp_err_t err = dac_output_voltage(channel, dac_value);
if (err) {
be_raisef(vm, "internal_error", "Error: esp_err_tdac_output_voltage(%i, %i) -> %i", channel, dac_value, err);
}