onUpdate() event

Former Member
Former Member

Hello, 

guys anyone know how to make the onUpdate() event run every second?? 

I try to create my own watch face for vivoactive 3 and i create getHeartRate() function and its work very well when i look at the screen and the screen light turn on and when its off 

the heart rate text is stack on the last heart rate,

this is the code: 

function getHeartRate(){
var heartRateText = "";
var currentHeartRate = Activity.getActivityInfo().currentHeartRate;
if(currentHeartRate != null){
heartRateText = currentHeartRate.toString();
}else{
var heartRateHistory = ActivityMonitor.getHeartRateHistory(1, true);
var heartRateSample = heartRateHistory.next();
var heartRate = heartRateSample.heartRate;
if(heartRateSample == ActivityMonitor.INVALID_HR_SAMPLE){
heartRateText = "";
}else{
heartRateText = heartRate;
}
}
var heartRateDisplay = View.findDrawableById("HeartRateDisplay");
heartRateDisplay.setText(heartRateText.toString());
}

and i call this event in my onUpdate() event. 

Ty

  • Former Member
    0 Former Member in reply to jim_m_58

    Hi, I understand but I use eclipse because idk how to development monkey c in vsCode and I search for videos and find nothing can you share me a video about monkey c in vsCode and after this I can do what you say 

  • You can use eclipse.  Just import the project, and run it.  There's a sticky in this forum about switching to money C, and here's a blog post:

    https://forums.garmin.com/developer/connect-iq/b/news-announcements/posts/moving-from-eclipse-to-visual-studio-code

  • Former Member
    0 Former Member in reply to jim_m_58

    Hello, 

    i switch to vsCode

    and its work very good in my watch the seconds its good but i can do that in the heartRate to? 

    and yes i'm a kid xD 12 years old and i know java,javascript,c#,c,html

  • Yes.  The thread I pointed at talks about also doing HR.  You only want to update it if it changes when you use onPartialUpdate.

  • Former Member
    0 Former Member in reply to jim_m_58

    i understand nothing with the code that you send me i just have to find tutorial because i create beautiful watch face in the monkey c: new project but now i dont understand what is all this code like onPartialUpdate and can1Hz and more things in the project that you give me like where is the layout.xml file and why you do dc.drawText if you can create label in the layout.xml and just setText in the onUpdate() function like this: look at the getDate function i just setText on the label i create, and now i need to do alot of things like dc.drawText(x,y....) and where i should do it in onUpdate or in onPartialUpdate??????? 

  • The code in the 1hz thread is really basic, and you need to understand it  If you look at how seconds are done, HR would be done much the same way

  • Former Member
    0 Former Member in reply to jim_m_58

    this is my problem how you start to lern monkey c garmin development because im 12 years old and its very difficult to me to understand it do you have time to explain this to me ??? like give me project with the HR and i can understand how all this system work, i done before watch face with steps count steps goal and seconds(with the bug onUpdate(); ) and the HR too, the HR stack on the last HR after i stop looking the watch and when i back to look its immediately update the text to my current HR 

    But ty for the help 

  • Start by looking at the samples in the SDK.  There are simple examples of lots of things there.

  • Former Member
    0 Former Member in reply to jim_m_58

    wdym smaples in the sdk ??? where can i fount it??