Cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Steps not counting

ANSWERED

Hello,

 

I copied a basic watch face to start on and the step counter worked. Now it just stays on 0.

It is counting them because it shows on the app but the watch face counter doesn't change from 0.

 

Thanks in advance!

Best Answer
0 Votes
1 BEST ANSWER

Accepted Solutions

Where in your code are you updating the displayed value? The display won't change unless you tell it to. Maybe paste the relevant bit of code.

Peter McLennan
Gondwana Software

View best answer in original post

Best Answer
0 Votes
11 REPLIES 11

Where in your code are you updating the displayed value? The display won't change unless you tell it to. Maybe paste the relevant bit of code.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Ok cool. Any idea what that might look like? 

Best Answer
0 Votes

ontick listener is a common choice.

Peter McLennan
Gondwana Software
Best Answer

Cracked it thank you. There was an erroneous space in the original, turns out the one I copied would never have worked.

Best Answer

Good debugging! 👍

Peter McLennan
Gondwana Software
Best Answer

Hi @Gondwana I saw that you helped Jamesismagic with his code.  My Versa2 clock face has a similar problem.  I initially get the correct number of steps on the clock face, but after a few seconds (probably one second) it changes to zero.  Sometimes it changes to undefined if I don't have the || 0 on the stepsValue assignment

excerpts of my code:

import clock from "clock";
import * as document from "document";
import { today } from "user-activity";
import { battery } from "power";

...

let stepsHandle = document.getElementById("stepsLabel");            //tried both let and const initialization
const batteryHandle = document.getElementById("batteryLabel");

...

function updateClock() {

...

// Activity Values: adjusted type
let stepsValue = (today.adjusted.steps || 0);         // without || 0, steps displays and then changes to undefined
stepsHandle.text = `${stepsValue}`;               //  also tried   = stepsValue instead of literal

// Battery Measurement
let batteryValue = battery.chargeLevel;

// Assignment value battery
batteryHandle.text = `${batteryValue} %`;           //  battery level works correctly on clock face
...

}

clock.ontick = () => updateClock();

FROM INDEX.GUI

<svg viewport-fill="black">

...

<text id="stepsLabel" x="80%" y="82%"
fill="red" font-size="40" font-family="System-Regular"
text-anchor="middle" text-length="10">--</text>
<text id="batteryLabel" x="10%" y="7%"
fill="lime" font-size="30" font-family="System-Regular"
text-anchor="middle" text-length="6">00</text>
</svg>

Parts of the code I don't show here that are inside the function updateClock work correctly, as does batterylevel.  Just steps goes to zero.  Any help that you can suggest to a novice code-writer is appreciated.

Best Answer
0 Votes

At a quick glance, I can't see what's wrong with that. Consider putting a console.log line below the stepsValue calculation, displaying stepsValue, to verify that its value is wrong. You might also be able to verify that the function is being called only once per second.

As an aside, I'm not a fan of ||0 . If the steps value can't be read, it doesn't mean that the user hasn't taken any steps during the day. They almost certainly have, so displaying 0 is fibbing.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

Thanks for taking a look, Peter

Unfortunately I can't side-load apps or clock faces now.  my versa 2 never connects to the Developer Bridge.  I'm loading and testing thru GAM.  I don't know of a way to see the console.log.  I also cant get the simulator to work either.

I'm not a fan of ||0 either.  However, looking at 0 is better than undefined on my watch face.   Maybe I'll make it ||10000 so it looks like I'm being active. 🙂

Best Answer
0 Votes

That's a painful way to debug. The simulator really should work for things like this. Perhaps an account issue.

Make sure that no other code is setting stepsHandle.text (which can happen if you copy-and-paste and forget to change).

Instead of a number, I make invalid fields display — or ?.

Peter McLennan
Gondwana Software
Best Answer
0 Votes

I'll have to read up on the simulator again.  its been a while since I tried it.

Thanks

Best Answer
0 Votes

Hi @RustyKeyboard - also possibly check your code in case you assign something to a today variable or definition.

Author | ch, passion for improvement.

Best Answer
0 Votes