I'm coding a clock face app. Here's the code:
import clock from "clock";
import document from "document";
import { preferences } from "user-settings";
import * as util from "../common/utils";
import { today } from "user-activity";
import { HeartRateSensor } from "heart-rate";
let heartRate = document.getElementById("heartRate");
heartRate.text = "-";
var hrm = new HeartRateSensor();
hrm.onreading = function() {
// Peek the current sensor values
heartRate.text = hrm.heartRate;
console.log("Current heart rate: " + hrm.heartRate);
hrm.stop()
hrm.start()
// Update the clock every minute
clock.granularity = "seconds";
let txtSteps = document.getElementById("txtSteps");
// inside the clock tick handler
txtSteps.text = today.adjusted.steps || 5;
// Get a handle on the <text> element
const myLabel = document.getElementById("myLabel");
// Update the <text> element every tick with the current time
clock.ontick = (evt) => {
let today = evt.date;
let hours = today.getHours();
if (preferences.clockDisplay === "12h") {
// 12h format
hours = hours % 12 || 12;
} else {
// 24h format
hours = util.zeroPad(hours);
}
let mins = util.zeroPad(today.getMinutes());
myLabel.text = `${hours}:${mins}`;
}
It comes out with this:
I have a } at the end, like it wants me to have.
I'm new to this, please help!
Answered! Go to the Best Answer.
For the heart rate sensor, you have the function on reading hrm with an open bracket -
@FunGamer wrote:var hrm = new HeartRateSensor();
hrm.onreading = function() {
but haven't given the closing brackets } for this function.
Best AnswerThe SDK Developer Board is a place to more likely get help with this.
Best AnswerFor the heart rate sensor, you have the function on reading hrm with an open bracket -
@FunGamer wrote:var hrm = new HeartRateSensor();
hrm.onreading = function() {
but haven't given the closing brackets } for this function.
Best Answer