Page 1 of 1

heart rate graph WF for GTR4

Posted: 18 Jul 2023, 19:06
by Wahwah
Hi everyone i’m fairly new to the amazfit community and i have been enjoying all the work and comments everyone making. i have a request i noticed there is not too many watchfaces that has heartrate graph for GTR4 like the one built in the watch i was wondering if someone can make one especially for the heartrate graph plus basic data like time, steps maybe weather temperature. i have been looking there is very nice one made by asoo for gtr3 but it has some reseting problems maybe because i’m using it on my gtr4. any watchface that helps me will be appreciate it. thanks everyone

Re: heart rate graph WF for GTR4

Posted: 18 Jul 2023, 20:46
by asoo
Wahwah wrote: 18 Jul 2023, 19:06
Spoiler
Hi everyone i’m fairly new to the amazfit community and i have been enjoying all the work and comments everyone making. i have a request i noticed there is not too many watchfaces that has heartrate graph for GTR4 like the one built in the watch i was wondering if someone can make one especially for the heartrate graph plus basic data like time, steps maybe weather temperature. i have been looking there is very nice one made by asoo for gtr3 but it has some reseting problems maybe because i’m using it on my gtr4. any watchface that helps me will be appreciate it. thanks everyone
It has a problem with GTR3 as well. I think it's FW issue because I tried it. official watch face Also had the same problem with the watch face I created (I use the same commands as the official watch face). I tried troubleshooting for a few days and couldn't fix it. The symptom on the GTR3 is that when used for a few days, the Graph will stop working, need to select another watch face Then came back to select the same watch face, the Graph will be work again, So I didn't continue it.
As for GTR4, I'm not sure what the problem is.

This is the code used to display the graph.

Code: Select all

let normal_g_heart = ''
normal_g_heart=hmUI.createWidget(hmUI.widget.GRADKIENT_POLYLINE,{
x: 50,
y: 100,
w: 350,
h: 100,
line_color:0xFF6600,
line_width:2,
type:hmUI.data_type.HEART,
show_level:hmUI.show_level.ONLY_NORMAL
});
This is the code for used to display the last check, min, max, pulse.

Code: Select all

            let heart_num = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
                                        x: 198,
                                        y: 410,
                                 type: hmUI.data_type.HEART,
                                font_array:["Act_font_0.png","Act_font_1.png","Act_font_2.png","Act_font_3.png","Act_font_4.png","Act_font_5.png","Act_font_6.png","Act_font_7.png","Act_font_8.png","Act_font_9.png"],
                                h_space: 2,
                                align_h: hmUI.align.CENTER_H,
                                padding: false,
                                isCharacter: true,
                                invalid_image: "Act_font_0.png",
                                isCharacter: true,
                                unit_sc:"bpm.png",
                                unit_tc: "bpm.png",
                                unit_en: "bpm.png",
});


///////////////////////  show value  max , min /////////////////////////

                                    let heartArr = hmSensor.createSensor(hmSensor.id.HEART).today;
                                    let min_heart = Math.min(...heartArr)
                                    let max_heart = Math.max(...heartArr)


                         let maxText = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
                                        x: 300,
                                        y: 100,
                                text: max_heart,
                                type: hmUI.data_type.HEART,
                                font_array:["Act_font_0.png","Act_font_1.png","Act_font_2.png","Act_font_3.png","Act_font_4.png","Act_font_5.png","Act_font_6.png","Act_font_7.png","Act_font_8.png","Act_font_9.png"],
                                h_space: 2,
                                align_h: hmUI.align.RIGHT,
                                padding: false,
                                isCharacter: true,
                            });


                            let minText = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
                                        x: 300,
                                        y: 170,
                                text: min_heart,
                                type: hmUI.data_type.HEART,
                                font_array:["Act_font_0.png","Act_font_1.png","Act_font_2.png","Act_font_3.png","Act_font_4.png","Act_font_5.png","Act_font_6.png","Act_font_7.png","Act_font_8.png","Act_font_9.png"],
                                h_space: 2,
                                align_h: hmUI.align.RIGHT,
                                padding: false,
                                isCharacter: true,
  });



////////////////////  Update  min max /////////////////////////

let intervalId;


function updateDataHeart() {

                                    let heart = hmSensor.createSensor(hmSensor.id.HEART);
                                    let heartArr = heart.today
                                    let min_heart = Math.min(...heartArr)
                                    let max_heart = Math.max(...heartArr)


normal_heart_rate_text_text_max_img.setProperty(hmUI.prop.MORE, {
        x: 330,
        y: 100,
        text: max_heart,
        type: hmUI.data_type.HEART,
        font_array: ["Act_font_0.png", "Act_font_1.png", "Act_font_2.png", "Act_font_3.png", "Act_font_4.png", "Act_font_5.png", "Act_font_6.png", "Act_font_7.png", "Act_font_8.png", "Act_font_9.png"],
        h_space: 2,
        align_h: hmUI.align.RIGHT,
        padding: false,
        isCharacter: true,
show_level: hmUI.show_level.ONLY_NORMAL,
    });

normal_heart_rate_text_text_min_img.setProperty(hmUI.prop.MORE, {
        x: 330,
        y: 170,
        text: min_heart,
        type: hmUI.data_type.HEART,
        font_array: ["Act_font_0.png", "Act_font_1.png", "Act_font_2.png", "Act_font_3.png", "Act_font_4.png", "Act_font_5.png", "Act_font_6.png", "Act_font_7.png", "Act_font_8.png", "Act_font_9.png"],
        h_space: 2,
        align_h: hmUI.align.RIGHT,
        padding: false,
        isCharacter: true,
show_level: hmUI.show_level.ONLY_NORMAL,
    });
}

intervalId = setInterval(updateDataHeart, 1000);
     //dynamic modify end
Anyone interested can test it.

Re: heart rate graph WF for GTR4

Posted: 18 Jul 2023, 20:59
by Wahwah
yeah man i really enjoyed this watchface and i was annoyed that it never reset after mid night 🙁 but i still appreciate you trying fixing it. i’m sure someone will help us figure this out 🙂