From e9a3a7e22d311791055c3210ab05d871a37d1b65 Mon Sep 17 00:00:00 2001 From: Markus Kirberg Date: Mon, 20 May 2024 19:32:34 +0200 Subject: [PATCH] fix power measuring; fix swapping of output pins --- src/ShellyPlus2PM/shelly_init.cpp | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/ShellyPlus2PM/shelly_init.cpp b/src/ShellyPlus2PM/shelly_init.cpp index 05d46347..c46b8056 100644 --- a/src/ShellyPlus2PM/shelly_init.cpp +++ b/src/ShellyPlus2PM/shelly_init.cpp @@ -58,11 +58,7 @@ static Status PowerMeterInit(std::vector> *pms) { }; int reset_pin = 33; - mgos_gpio_set_mode(reset_pin, MGOS_GPIO_MODE_OUTPUT); - mgos_gpio_write(reset_pin, 0); - mgos_msleep(100); - mgos_gpio_write(reset_pin, 1); - mgos_gpio_set_mode(reset_pin, MGOS_GPIO_MODE_INPUT); + mgos_gpio_setup_output(reset_pin, 1); s_ade7953 = mgos_ade7953_create(mgos_i2c_get_global(), &ade7953_cfg); @@ -72,9 +68,9 @@ static Status PowerMeterInit(std::vector> *pms) { } Status st; - std::unique_ptr pm1(new ADE7953PowerMeter(1, s_ade7953, 1)); + std::unique_ptr pm1(new ADE7953PowerMeter(1, s_ade7953, 0)); if (!(st = pm1->Init()).ok()) return st; - std::unique_ptr pm2(new ADE7953PowerMeter(2, s_ade7953, 0)); + std::unique_ptr pm2(new ADE7953PowerMeter(2, s_ade7953, 1)); if (!(st = pm2->Init()).ok()) return st; pms->emplace_back(std::move(pm1)); @@ -87,8 +83,8 @@ void CreatePeripherals(std::vector> *inputs, std::vector> *outputs, std::vector> *pms, std::unique_ptr *sys_temp) { - outputs->emplace_back(new OutputPin(1, 12, 1)); - outputs->emplace_back(new OutputPin(2, 13, 1)); + outputs->emplace_back(new OutputPin(1, 13, 1)); + outputs->emplace_back(new OutputPin(2, 12, 1)); auto *in1 = new InputPin(1, 5, 1, MGOS_GPIO_PULL_NONE, true); in1->AddHandler(std::bind(&HandleInputResetSequence, in1, 4, _1, _2)); in1->Init();