reading of events on gpio pins for switch

Moderators: grovkillen, Stuntteam, TD-er

Post Reply
Message
Author
android12
New user
Posts: 5
Joined: 20 Aug 2018, 16:43

reading of events on gpio pins for switch

#1 Post by android12 » 26 Sep 2018, 22:37

Hello,

I was searching in source code of ESPEasy in branch "mega" for a place, when interrupt (irq / external even listener / isr ... however you call it) is configured on GPIO, if such GPIO is configured for switch.
However i didn't find any. I only found a piece of code, which is called 10x per second and reading value.
Did I overlook it, or is there really no interrupt registered and only relying on fact, that one of these reads will detect pressed state (specially if i have push button)? Cannot it then happen, that button press was in between of two checks and hence not detected at all?

thank you
best regards
jano

User avatar
enesbcs
Normal user
Posts: 587
Joined: 18 Jun 2017, 11:02
Location: Békéscsaba, Hungary
Contact:

Re: reading of events on gpio pins for switch

#2 Post by enesbcs » 27 Sep 2018, 19:53

android12 wrote: 26 Sep 2018, 22:37 Hello,

I was searching in source code of ESPEasy in branch "mega" for a place, when interrupt (irq / external even listener / isr ... however you call it) is configured on GPIO, if such GPIO is configured for switch.
However i didn't find any. I only found a piece of code, which is called 10x per second and reading value.
Did I overlook it, or is there really no interrupt registered and only relying on fact, that one of these reads will detect pressed state (specially if i have push button)? Cannot it then happen, that button press was in between of two checks and hence not detected at all?

thank you
best regards
jano
attachInterrupt() is what you looking for. You can see a usage example in my Pushbutton plugin. Also you can use it, if it's functionality is enough for you. There are some serious requirements against event handler, such as being static and being global.

https://github.com/enesbcs/ESPEasyPlugi ... button.ino

android12
New user
Posts: 5
Joined: 20 Aug 2018, 16:43

Re: reading of events on gpio pins for switch

#3 Post by android12 » 27 Sep 2018, 20:46

Hi,

thanks for plugin. I'll consider it, if i'm forced to do build for myself.

I was asking about official "standard" builds, as we these it's not a problem for me to do such a short button press, that it's not detected at all. Also in real life, it happens to me like each 20-50th click is not recognized by easyesp.

And from source analysis it looks to me, it's loosing events just becase there is only poller user, but no attachInterrupts and ISR.

I was already thinking to switch to uPY, but there i also cannot find it in sources.

So if i got it confirmed, that there are no interrupts used in standard builds,then i can move on, and look for solution like custom build, or own script instead of easyESP etc.

thank you
best regards
jano

User avatar
grovkillen
Core team member
Posts: 3621
Joined: 19 Jan 2017, 12:56
Location: Hudiksvall, Sweden
Contact:

Re: reading of events on gpio pins for switch

#4 Post by grovkillen » 27 Sep 2018, 20:56

I suggest you look into the message delay in advanced settings. It should be 100mSec not 1000mSec.
ESP Easy Flasher [flash tool and wifi setup at flash time]
ESP Easy Webdumper [easy screendumping of your units]
ESP Easy Netscan [find units]
Official shop: https://firstbyte.shop/
Sponsor ESP Easy, we need you :idea: :idea: :idea:

android12
New user
Posts: 5
Joined: 20 Aug 2018, 16:43

Re: reading of events on gpio pins for switch

#5 Post by android12 » 29 Sep 2018, 23:23

Hi,

delays in unchanged (0) but i don't use any controllers. I send UDP message from rule instead. But even without that, only when counting events in rules, i see there are lost ones.
IMHO due to fact, that it's not using interrupts to read GPIO changes.

thank you
best regards
jano

TD-er
Core team member
Posts: 8749
Joined: 01 Sep 2017, 22:13
Location: the Netherlands
Contact:

Re: reading of events on gpio pins for switch

#6 Post by TD-er » 29 Sep 2018, 23:49

The pulsecounter plugin can use interrupts to read GPIO pins.
But only for the first 4 plugin positions in the list on the Devices tab.

Post Reply

Who is online

Users browsing this forum: No registered users and 34 guests