-
• #27
ah good point. got my numbers wrong! doh. 🤦♂️
-
• #28
Here is my solution with diodes. See attached animated gif.
Three digital input (input_pullup, no additional 100k resistors in the image are needed) pins with 3 diodes will be used. As mentioned before, only 2 pins can be watched by setWatch with interrupts, so I will set two pins (D32 and D24) for setWatch and the third pin, D42, can be combined in the code to watch. In other words, no matter which button is pressed, always one or both of D32 and D24 will be triggered. This way, with only 2 interrupts, 4 pins can be monitored. Actually, there is one more combination, D24 and D42, is available for another switch if needed.
I saved one pin, D43, for an analog output for the buzzer.
1 Attachment
-
• #29
As mentioned before, only 2 pins can be watched by setWatch with interrupts
can you verify this? Maybe you have 4 watches already running, and you are hitting a limit of 6. I have seen this limit in the past, on the Rock watch, with fanoush's firmware I could not enable a watch for the second button, with jefmer's it was ok, I think the bangle2 firmware has the same limit.
Maybe run this on the console to check how many you have running.
global["\xFF"].watches -
• #30
I just tested setWatch with 3 pins (D32, D24 and D22 (found this pin additionally)) and confirmed only the first 2 pins with setWatch work. I don't know how many GPIOTE handlers are available in nRF, but it seems only two channels are available for users.
-
• #31
but it seems only two channels are available for users.
I am not sure this is an nRF restriction, this is why I am posting, so that Gordon and Fanoush will correct me :)
In any case, please run this to verify how many watches are running when you get the mesage that no more watches are available. Maybe some app is using a watch etc.
global["\xFF"].watches -
• #32
>global["\xFF"].watches =[ undefined, { pin: D17, recur: true, debounce: 26214, edge: -1, cb: function () { ... }, state: false } ]
I'm not sure what this command does, but D17 is the BTN1 for Bangle.js 2.
-
• #33
I'm not sure what this command does
It just lists the watches that are currently running. So you only have the BTN watch, and you can only enable two more, a total of three?
-
• #34
After I tried to set pins with setWatch for the 3 pins, I ran your command again. Here is the result.
>global["\xFF"].watches =[ undefined, { pin: D32, recur: true, edge: -1, cb: function () { ... }, state: false }, { pin: D24, recur: true, edge: -1, cb: function () { ... }, state: false }, { pin: D22, recur: true, edge: -1, cb: function () { ... }, state: true }, { pin: D24, recur: true, edge: -1, cb: function () { ... }, state: false } ]
-
• #35
After I tried to set pins with setWatch for the 3 pins
a bit strange, I guess you run the setwatch command two times for pin D24, but where is the D17, the BTN1?
Maybe try assigning the watch number to a variable, so that you can then clear them and do your test better, like so?
testD22=setWatch(function(e) { console.log("testD22"); }, D22, {
repeat:true, edge:'both' });clearWatch(testD22)
-
• #36
D17 is not listed because I ran the code in the RAM only setting 3 pins with setWatch. If I added the code to my clock app, D17 is also listed. Still no clue for the D24 appears again at the end of the list. It's nothing to do with the hardware, so you can try with your own watch, I guess.
I don't really care about more interrupt pins anymore because I can use my solution (#28) with diodes. I already tried this solution and it works fine as expected. -
• #37
I don't really care about more interrupt pins anymore because I can use my solution (#28) with diodes. I already tried this solution and it works fine as expected.
nice, thanks for your time, I was just curious because on some older firmwares there was no limit on the number of watches I think. But yes, it is not important, thanks.
-
• #38
I didn't mean to be rude. I just realized my previous reply might have sounded not very nice. My apologies. I'm also curious about the limits, but I just wanted to say I found a solution and I was fine without more interrupts. Thank you.
-
• #39
I didn't mean to be rude
you were not, I was a bit, it was clear that you had it solved, yet I was returning to the watches limit thing. Sorry, all is ok :)
D43 and D42 work as either digital I/O or analog output, not for input.