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?
Jak skonfigurować buttony i virtualrelay
-
veeroos
- Posts: 1080
- Joined: Sun Mar 20, 2022 9:30 am
- Location: Głogów
- Has thanked: 1 time
- Been thanked: 9 times
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);
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
https://github.com/v33r005
-
veeroos
- Posts: 1080
- Joined: Sun Mar 20, 2022 9:30 am
- Location: Głogów
- Has thanked: 1 time
- Been thanked: 9 times
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
https://github.com/v33r005
-
Duch__
- Posts: 2199
- Joined: Wed Aug 24, 2016 7:26 pm
- Location: Opole
- Been thanked: 6 times
-
[email protected]
- Posts: 1584
- Joined: Mon Feb 06, 2023 8:56 am
- Has thanked: 18 times
- Been thanked: 26 times
A zadeklarowales twój button jako wskaźnik ?Duch__ wrote: Sat Aug 24, 2024 12:00 pm 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
Supla::Control::Button *button= new Supla::Control ::Button( i tu parametry jakie przyjmuje )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ć?
-
veeroos
- Posts: 1080
- Joined: Sun Mar 20, 2022 9:30 am
- Location: Głogów
- Has thanked: 1 time
- Been thanked: 9 times
biblioteki:
w setupie:
Code: Select all
#include <supla/control/virtual_relay.h>
#include <supla/control/button.h>
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
https://github.com/v33r005
