Jak skonfigurować buttony i virtualrelay

User avatar
Duch__
Posts: 2199
Joined: Wed Aug 24, 2016 7:26 pm
Location: Opole
Been thanked: 6 times

Post

Hej.

Męczę się. Mam 4 przyciski:

GPIO0 Przycisk 1
GPIO9 Przycisk 2
GPIO10 Przycisk 3
GPIO14 Przycisk 4

i 4 wirtualne przekaźniki:

vrelay_1
vrelay_2
vrelay_3
vrelay_4

Jak skonfigurować żeby przycisk 1 sterował TOGGLE vrelay_1 przy krótkim naciśnięciu, a przy przytrzymaniu włączył tryb konfiguracji, a pozostałe przyciski działały na zasadzie tylko TOGGLE tj. przycisk 2 steruje vrelay_2, przycisk 3 steruje vrelay_3 i przycisk 4 steruje vrelay_4?
User avatar
veeroos
Posts: 1080
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

Code: Select all

button->addAction(Supla::TOGGLE, vrelay_1, Supla::ON_CLICK_1);

Code: Select all

button->addAction(Supla::ENTER_CONFIG_MODE_OR_RESET_TO_FACTORY, SuplaDevice, Supla::ON_HOLD, true);
Sprawdź proszę to

Edit. Jeszcze dobrze by było zrobić wyjście z trybu konfiguracji pojedynczym kliknięciem, na przykład tak

Code: Select all

button->addAction(Supla::LEAVE_CONFIG_MODE_AND_RESET, SuplaDevice, Supla::ON_CLICK_1, true);
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
Duch__
Posts: 2199
Joined: Wed Aug 24, 2016 7:26 pm
Location: Opole
Been thanked: 6 times

Post

Mam to umieścić w przed void setup czy w nim?
User avatar
veeroos
Posts: 1080
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

Duch__ wrote: Sat Aug 24, 2024 11:35 am Mam to umieścić w przed void setup czy w nim?
W setupie
Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005
User avatar
Duch__
Posts: 2199
Joined: Wed Aug 24, 2016 7:26 pm
Location: Opole
Been thanked: 6 times

Post

Otrzymuje:

Code: Select all

base operand of '->' has non-pointer type 'Supla::Control::Button'
[email protected]
Posts: 1584
Joined: Mon Feb 06, 2023 8:56 am
Has thanked: 18 times
Been thanked: 26 times

Post

Duch__ wrote: Sat Aug 24, 2024 12:00 pm Otrzymuje:

Code: Select all

base operand of '->' has non-pointer type 'Supla::Control::Button'
A zadeklarowales twój button jako wskaźnik ?
User avatar
Duch__
Posts: 2199
Joined: Wed Aug 24, 2016 7:26 pm
Location: Opole
Been thanked: 6 times

Post

Od czasu jak zostały wprowadzone wskaźniki, klasy to nic z tego programowanie nie rozumiem. Jak to zrobić?
[email protected]
Posts: 1584
Joined: Mon Feb 06, 2023 8:56 am
Has thanked: 18 times
Been thanked: 26 times

Post

Duch__ wrote: Sat Aug 24, 2024 12:06 pm Od czasu jak zostały wprowadzone wskaźniki, klasy to nic z tego programowanie nie rozumiem. Jak to zrobić?
Supla::Control::Button *button= new Supla::Control ::Button( i tu parametry jakie przyjmuje )
User avatar
veeroos
Posts: 1080
Joined: Sun Mar 20, 2022 9:30 am
Location: Głogów
Has thanked: 1 time
Been thanked: 9 times

Post

biblioteki:

Code: Select all

#include <supla/control/virtual_relay.h>
#include <supla/control/button.h>
w setupie:

Code: Select all

auto vrelay_1 = new Supla::Control::VirtualRelay();
auto vrelay_2 = new Supla::Control::VirtualRelay();
auto vrelay_3 = new Supla::Control::VirtualRelay();
auto vrelay_4 = new Supla::Control::VirtualRelay();
auto button_1 = new Supla::Control::Button(0, true, true);
auto button_2 = new Supla::Control::Button(9, true, true);
auto button_3 = new Supla::Control::Button(10, true, true);
auto button_4 = new Supla::Control::Button(14, true, true);
button_1->addAction(Supla::TOGGLE, vrelay_1, Supla::ON_CLICK_1);
button_2->addAction(Supla::TOGGLE, vrelay_2, Supla::ON_CLICK_1);
button_3->addAction(Supla::TOGGLE, vrelay_3, Supla::ON_CLICK_1);
button_4->addAction(Supla::TOGGLE, vrelay_4, Supla::ON_CLICK_1);
button_1->addAction(Supla::ENTER_CONFIG_MODE_OR_RESET_TO_FACTORY, SuplaDevice, Supla::ON_HOLD, true);
button_1->addAction(Supla::LEAVE_CONFIG_MODE_AND_RESET, SuplaDevice, Supla::ON_CLICK_1, true);

Zamel Mew-01, Zamel PEW-01, Zamel SBW-01, Zamel THW-01, Zamel SRW-01, Zamel mSLW-02, Auraton BOX + Indor Sensor, Airly Gate By Veeroos, Zigbee to Supla Gateway + sensors, Zamel SGW-01 and more

https://github.com/v33r005

Return to “Ogólna dyskusja”