You are reading a single comment by @radswid and its replies. Click here to read the full conversation.
  • Well, I went through the Bangle.JS First App and Clock Faces tutorials and spent some time reading code on github. But this was the first time I've done something without a tutorial and tried to get my ideas into codelines (the API Reference helped a ton and mozillas MDN JavaScript reference was very helpful too). It took me quite a while in the last two days to figure things out, but it's so satisfying if problems get solved :D

    It is working for me but... there are some things happening, I don't really understand.
    After loading the code into RAM, I twist to start counting -> Bangle beeps and starts counting my following twists confirming them with short vibrations and sends a BL command to my phone and beeps after 4s - that's what it should do. But on the second twist to start counting, it also vibrates and counts up one. Thats why I had to add a "reset counter" (line 20) function to be executed in line 24. If I hadn't done that, every counting would start with the counter set to 1 instead of 0.
    But what causes the +1 before the "real" countup starts?

    At first attempt I ran the code without Bangle.removeListener(). That caused added countup-functions everytime I started a new "start counting my twists"-twist. At this point I almost gave up until I discovered that you can "stop" Bangle.on('twist')-functions with those "removeListeners". Then I added Bangle.removeAllListeners(). which stopped those multiple countups at once, but also stopped the inital twist-listener for the "start counting my twists"-function after sending the commands first time. Then I tried "Bangle.removeListener('twist',countup)"­, which seems to have solved it.
    So it was a lot of try and error and looking up things. There's still a lot of syntax I don't understand.

    So the reasons why I'm asking are on the one hand the "problems" I mentioned above and on the other hand I want to improve it so one day it's fine enough to find it's way into the App Loader so others can use it too, if they want. :)

    I hope my text is kind of understandable

  • Tue 2021.05.18

    'I had some problems, which I solved very intricately (is this the right word?'

    intricately - 'in a very complicated or detailed manner'

    https://www.google.com/search?q=intricat­ely+definition&oq=intricately

    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'

    https://www.google.com/search?q=complexi­ty+definition&oq=complexity

    intuitive - 'what one feels to be true even without conscious reasoning'

    https://www.google.com/search?q=intuitiv­e+definition&oq=intuitive

    simply - 'in a straightforward or plain manner'

    https://www.google.com/search?q=simply+d­efinition&oq=simply+definition

     
    'Intuitive' seems to be the best fit.

    Enough of the nit-picky off topic stuff and on to what we all love to do!!


    'Is this the right place for this thread, or is "Projects" the better place?'

    Yes, as this is more of a coding issue, the 'Projects' area IMO was created for end users to demonstrate their completed works.



    'never wrote any code before, I hope it's not too "ugly"'

    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

    https://www.investopedia.com/terms/1/80-­20-rule.asp

    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.

    EDIT: counter=0 found L32 and later function L20 after post #3
    May I ask what the thinking was to embed the reset counter call within a timeout in L24? There likely was a valid reason, however as an observer, I'm not sure the delay is actually needed.

    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.

About

Avatar for radswid @radswid started