Btn.addButton() with interrupt

Discussion about Z-Uno product. Visit http://z-uno.z-wave.me for more details.
Post Reply
KGBEl
Posts: 47
Joined: 21 Feb 2023 00:37

Btn.addButton() with interrupt

Post by KGBEl »

Hi out there.

I have copied the example from https://z-uno.z-wave.me/Reference/ZUNO_ ... addButton/
and it works well.
In the text there is a hint of BtnButtonModeExtInt wich you can use instead of BtnButtonModeTimer
in the example.

My question is, how do I set up an ISR and let the interrupt find its way to that ISR.

I found out that attachInterrupt() is not working in this case.

Z-Uno v2, 3.0.10, Razberry 7 Pro, RaspBerry 4
SDK Version: 7.15.00
Serial API Version: 07.05

Very thankful in advance.
amatilda
Posts: 68
Joined: 26 Sep 2021 22:09

Re: Btn.addButton() with interrupt

Post by amatilda »

KGBEl wrote:
29 Feb 2024 12:00
Hi out there.

I have copied the example from https://z-uno.z-wave.me/Reference/ZUNO_ ... addButton/
and it works well.
In the text there is a hint of BtnButtonModeExtInt wich you can use instead of BtnButtonModeTimer
in the example.

My question is, how do I set up an ISR and let the interrupt find its way to that ISR.

I found out that attachInterrupt() is not working in this case.

Z-Uno v2, 3.0.10, Razberry 7 Pro, RaspBerry 4
SDK Version: 7.15.00
Serial API Version: 07.05

Very thankful in advance.
Hello.
Replace

Code: Select all

init.mode = BtnButtonModeTimer;
on

Code: Select all

init.mode = BtnButtonModeExtInt;
KGBEl
Posts: 47
Joined: 21 Feb 2023 00:37

Re: Btn.addButton() with interrupt

Post by KGBEl »

Thank you for answering, I did that but I haven't found out how to catch the button press.

How do I set up an isr so I can catch the interrupt?
amatilda
Posts: 68
Joined: 26 Sep 2021 22:09

Re: Btn.addButton() with interrupt

Post by amatilda »

KGBEl wrote:
14 Mar 2024 21:11
Thank you for answering, I did that but I haven't found out how to catch the button press.

How do I set up an isr so I can catch the interrupt?
If you check button presses, then as in the example:

Code: Select all

void process_buttons() {
	if(Btn.isSingleClick(BUTTON)) {
		Serial0.println("isSingleClick");
		if (dimmerValue == 5)
			dimmerValue = 100;
		else
			dimmerValue = 5;
	}
	if(Btn.isTripleClick(BUTTON)) {
		Serial0.println("isTripleClick");
		if (dimmerValue == 5)
			dimmerValue = 100;
		else
			dimmerValue = 5;
	}
	if(Btn.isLongClick(BUTTON)) {
		Serial0.println("isLongClick");
		if (dimmerValue == 5)
			dimmerValue = 100;
		else
			dimmerValue = 5;
	}
	if(Btn.isDoubleClick(BUTTON)) {
		Serial0.println("isDoubleClick");
		if (dimmerValue == 5)
			dimmerValue = 100;
		else
			dimmerValue = 5;
	}
}
If you need an interrupt callback, this class does not currently provide this.
You need to use attachInterrupt https://z-uno.z-wave.me/Reference/Inter ... Interrupt/ instead of this class.
KGBEl
Posts: 47
Joined: 21 Feb 2023 00:37

Re: Btn.addButton() with interrupt

Post by KGBEl »

Thank you for answering.

If I understand you right, there is no way to use BtnButtonModeExtInt and get an
answer to pushed button without polling the Btn.xxxx for events.

Best is to use attachInterrupt() an work around?
KGBEl
Posts: 47
Joined: 21 Feb 2023 00:37

Re: Btn.addButton() with interrupt

Post by KGBEl »

One more question, is there a plan for getting an callback on BtnButtonModeExtInt?
amatilda
Posts: 68
Joined: 26 Sep 2021 22:09

Re: Btn.addButton() with interrupt

Post by amatilda »

KGBEl wrote:
15 Mar 2024 19:07
If I understand you right, there is no way to use BtnButtonModeExtInt and get an
answer to pushed button without polling the Btn.xxxx for events.

Best is to use attachInterrupt() an work around?
Yes that's right.
amatilda
Posts: 68
Joined: 26 Sep 2021 22:09

Re: Btn.addButton() with interrupt

Post by amatilda »

KGBEl wrote:
15 Mar 2024 19:09
One more question, is there a plan for getting an callback on BtnButtonModeExtInt?
At the moment there are no plans for this.
KGBEl
Posts: 47
Joined: 21 Feb 2023 00:37

Re: Btn.addButton() with interrupt

Post by KGBEl »

Thank you very much for your answers, appreciated.
Post Reply