-
Hey Robin, thanks a lot for your detailed answer!
The counter call within a timeout in L24 is caused by the different timeouts on lines 56 & 57. If it would be reset before sendCmd is executed, sendCmd would always have counter=0 and therefore never send any commands to my phone, was my line of thought.The only thing I consider to be the possible problem is in L39 "Bangle.removeListener('twist',countup);". Maybe I don't get this function right. I wanted to remove the listener that looks for twists and executes "countup" then. Is line39 removing the listener and also executing countup once?
EDIT: just tested to change the L39 into "Bangle.removeListener('twist');", which causes errors and breaks the functionality. So I guess, it was right in first place?(regarding the "nit-picky" off topic stuff: "tackling sth in a roundabout way" may be what I wanted to say. I guess one could write this "functionality" with less functions, so it preserves RAM and battery. So I was also looking for hints to do so ;-) )
Tue 2021.05.18
intricately - 'in a very complicated or detailed manner'
While I'll agree the English language, at times can be quite complicated, I'm trying to find a more correct word, but finding it difficult to truly understand what means were used for the 'which I solved' statement based on the perceived 'problems'.
these also come to mind
complexity - 'a factor involved in a complicated process or situation'
intuitive - 'what one feels to be true even without conscious reasoning'
simply - 'in a straightforward or plain manner'
'Intuitive' seems to be the best fit.
Enough of the nit-picky off topic stuff and on to what we all love to do!!
Yes, as this is more of a coding issue, the 'Projects' area IMO was created for end users to demonstrate their completed works.
I too agree with Gordon here, @radswid as you are demonstrating key techniques early on, such as: naming order; variable definitons before function definitions, short declaritive naming convention, (which BTW I also prefer the obj-action or obj-state manner such as 'volup' 'voldn') command of the language statements, with both syntax and usage, and are now at a wall with command of the 'run-time' error's or in this case more of a run-time anomaly where actual functionality just isn't quite what is envisioned. And, those are the toughest to resolve, I'm afraid.
You strike me as more of a solution oriented problem solver where you would garner more satisfaction learning to solve the issue yourself, and that is how I prefer to present possibilities, rather than provide the solution.
The 80-20 Pareto axiom
For software development, I find it is closer to 60-40 or 70-30 for me, where 40% of my efforts (time) get's me to 60% of a solution (completion). You are on the right track to your solution, so let's put a bit of polish on it while learning through experience, shall we?
While I haven't installed your snippet, no Bangle to test on, I believe I have detected an area that needs a bit of attention. The twist event L63 fires function twistctrl(). L52 responds to that event, firstly checking the state of the twist state variable 'tstate'. But what happens should another twist event occur, and the state of 'tstate' is actually 'true'? Ans: as you will astutely observe - nothing
So this is where I believe the thinking path was to then toy with listeners.
I also don't see where variable 'counter' is ever reset. This likely is also contributory.
Hint: test for both conditions in this one function for starters
Moving forward, a bit of re-thinking will be needed. Would you prefer to further your knowledge by tackling on your own as my assessment suggests, or are you at a point where total frustration has now set in and moving forward is just too painful?
I know others are dying to jump in with their solution, however, there will be more joy and satisfaction solving this on your own as you have made tremendous strides in a near complete solution to start with.