Merge pull request from s-hadinger/berry_dac_fix

Berry fix DAC
This commit is contained in:
s-hadinger 2021-10-03 10:42:14 +02:00 committed by GitHub
commit 54359e5aa7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -50,7 +50,7 @@ extern "C" {
// DAC
#if defined(CONFIG_IDF_TARGET_ESP32)
if (25 == pin || 26 == pin) {
uint32_t channel = pin - 25; // 1 or 2
uint32_t channel = pin - 25 + 1; // 1 or 2
esp_err_t err = dac_output_enable((dac_channel_t) channel);
if (err) {
be_raisef(vm, "value_error", "Error: dac_output_enable(%i) -> %i", channel, err);
@ -60,7 +60,7 @@ extern "C" {
}
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
if (17 == pin || 18 == pin) {
uint32_t channel = pin - 17; // 1 or 2
uint32_t channel = pin - 17 + 1; // 1 or 2
esp_err_t err = dac_output_enable((dac_channel_t) channel);
if (err) {
be_raisef(vm, "value_error", "Error: dac_output_enable(%i) -> %i", channel, err);
@ -121,7 +121,7 @@ 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 or 2
uint32_t channel = pin - 25 + 1; // 1 or 2
esp_err_t err = dac_output_voltage((dac_channel_t) channel, dac_value);
if (err) {
be_raisef(vm, "internal_error", "Error: esp_err_tdac_output_voltage(%i, %i) -> %i", channel, dac_value, err);
@ -131,7 +131,7 @@ extern "C" {
}
#elif defined(CONFIG_IDF_TARGET_ESP32S2)
if (17 == pin || 18 == pin) {
uint32_t channel = pin - 17; // 1 or 2
uint32_t channel = pin - 17 + 1; // 1 or 2
esp_err_t err = dac_output_voltage((dac_channel_t) channel, dac_value);
if (err) {
be_raisef(vm, "internal_error", "Error: esp_err_tdac_output_voltage(%i, %i) -> %i", channel, dac_value, err);