-
• #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 :)
-
• #40
I have finally designed the new case for my modification and 3D printed and assembled the watch. It has a piezo buzzer, the same motor (moved to the right side wall), USB type C charging port, 350mAh battery and 4 additional switches. attached is a picture of the assembled modified watch. I will show some more pictures later.
As I explained before, the HRM module was removed and 3 pins (D32, D24, D22) from the header was used to get 4 switch inputs.
Everything works as I expected, but the accelerometer stopped working. I have checked the components (the accelerometer chip and caps and resistors around the chip) visually (with a magnifying glass) but couldn't find anything wrong.
I wonder if the power for the accelerometer chip is through the HRM header. Is there anything I can check? Below is the reading of the accelerometer.
Bangle.getAccel() ={ x: 0.00012207031, y: -0.00012207031, z: 0.00012207031, mag: 0.00021143198, diff: 0 }
These values don't change when I move the watch. So the question is whether removing the HRM module can affect to the accelerometer. Any thoughts?
2 Attachments
-
• #41
Wow, that's very impressive!
The accelerometer is on the PCB and it has its own I2C lines, so I wouldn't have thought that anything you do with the HRM would affect it. You could check with
Bangle.accelRd
and see if you can communicate with it at all? It's possible that you got a solder splash or something on a wire which shorted one of the data connections to it out? -
• #42
Hi Gordon,
Bangle.accelRd()
returns 255. Does this mean it's communicating or not?
Thanks. -
• #43
Well, if you try reading a bunch of registers with it (
Bangle.accelRd(1)
/2/etc) and they all ready 255 then it's not communicating. 255 is the default state (with the data pin stuck high) -
• #44
It needs some parameters https://www.espruino.com/Reference#l_Bangle_accelRd
Bangle.accelRd(0x0f,1) =new Uint8Array([20]) >
this reads WHOAMI register at 0x0f address and value 20=0x14 is KX022 (as per https://www.mouser.com/datasheet/2/348/KX022_1020_Specifications_Rev_12_0-1101230.pdf#page=36 )
-
• #45
@Gordon and @fanoush, thank you for your responses and suggestions. I tried your suggested tests and all returned 255.
I searched and found this link that shows exactly same readings fromBangle.getAccel()
orBangle.accelRd(0x0F)
.
I have checked the PCB closely and couldn't find any solder that might short any connections. My guess is when I replaced the battery, somehow the accelerometer got messed up internally. The link above says it was fixed after draining the battery, so I would try that.
Thank you. -
• #46
I flattened the battery and waited for about an hour and tried to turn on and it did. So, I waited overnight to make sure the battery's fully discharged (it may not be fully discharged, but just below the voltage threshold of the FET) so that the accelerometer is not powered (hopefully).
This morning, I started charging the watch and after a few minutes, I tried the codeBangle.accelRd(0x0F)
and hoped to get21
as a return value, but it still returned255
. Too bad. :-(
I'm thinking to discharge it again and leave it for longer period of time, say a couple of days over the weekend. -
• #47
I'm thinking to discharge it again and leave it for longer period of time, say a couple of days over the weekend.
since you have made a new case, don't you have access to the battery terminals? You can short them for half a second, the BMS on the battery will turn off, and turn on again once you plug in the charger.
-
• #49
do not take "for a second" literally, whole second is far too much, just a brief moment - the fastest you can make it, or you may damage the battery
-
• #50
yes sorry, not a full second, just a touch will do.
D43 and D42 work as either digital I/O or analog output, not for input.