Page 1 of 1

Heart rate how to graph -GTR 3 PRO

Posted: 15 Aug 2023, 21:16
by vojta_1
Zdravím
Dělám ciferník pro GTR 3 PRO, který má graf pro srdeční tep, něco jsem tu na forech našel , ale moc to nefunguje,
V souboru index.js je update pro graf - min - max , jak to nahraji do hodinek tak ciferník nejde vidět, ale
když ze souboru index.js vymažu update pro graf - min - max a znova to nahraji do hodinek tak ciferník najede, sice graf se zastaví , min- max jede, nevím kde je problém, muže mi někdo poradit ......
Spoiler
Image
soubor index.js

Code: Select all

    /*
    ** Watch_Face_Editor tool
    ** watchface js version v2.1.1
    ** Copyright © SashaCX75. All Rights Reserved
    */
   
    try {
    (() => {
        //start of ignored block
        const __$$app$$__ = __$$hmAppManager$$__.currentApp;
        function getApp() {
            return __$$app$$__.app;
        }
        function getCurrentPage() {
            return __$$app$$__.current && __$$app$$__.current.module;
        }
        const __$$module$$__ = __$$app$$__.current;
        const h = new DeviceRuntimeCore.WidgetFactory(new DeviceRuntimeCore.HmDomApi(__$$app$$__, __$$module$$__));
        const {px} = __$$app$$__.__globals__;
        const logger = Logger.getLogger('watchface_SashaCX75');
        //end of ignored block

        //dynamic modify start

        let normal_background_bg_img = ''
        let normal_g_heart = ''
        let normal_system_disconnect_img = ''
        let normal_system_clock_img = ''
        let normal_spo2_text_text_img = ''
        let normal_date_img_date_month_img = ''
        let normal_date_img_date_day = ''
        let normal_city_name_text = ''
        let normal_temperature_current_text_img = ''
        let normal_weather_image_progress_img_level = ''
        let normal_calorie_TextRotate = new Array(4);
        let normal_calorie_TextRotate_ASCIIARRAY = new Array(10);
        let normal_calorie_TextRotate_img_width = 21;
        let normal_step_current_text_img = ''
        let normal_step_image_progress_img_level = ''
        let normal_digital_clock_img_time = ''
        let normal_digital_clock_hour_separator_img = ''
        let normal_alarm_jumpable_img_click = ''


        //dynamic modify end

        __$$module$$__.module = DeviceRuntimeCore.WatchFace({
            init_view() {
                //dynamic modify start
                    
                
            normal_background_bg_img = hmUI.createWidget(hmUI.widget.IMG, {
              x: 0,
              y: 0,
              w: 480,
              h: 480,
              src: 'main.png',
              show_level: hmUI.show_level.ONLY_NORMAL,
            });
              
              /////////////////////  Show graph heart rate  /////////////////////
              
             
              normal_g_heart=hmUI.createWidget(hmUI.widget.GRADKIENT_POLYLINE,{
                              x: 65,
                              y: 100,
                              w: 350,
                              h: 100,
                              line_color:0xFF6600,
                              line_width:2,
                              type:hmUI.data_type.HEART,
                              show_level:hmUI.show_level.ONLY_NORMAL
                             });

                              let heartArr = hmSensor.createSensor(hmSensor.id.HEART).today;
                              let min_heart = Math.min(...heartArr)
                              let max_heart = Math.max(...heartArr)
               
            ///////////////////////  show value  main , max , min /////////////////////////
                
               let heart_num = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
                                x: 260,
                                y: 58,
                                type: hmUI.data_type.HEART,
                                font_array: ["34.png","35.png","36.png","37.png","38.png","39.png","40.png","41.png","42.png","43.png"],
                                h_space: 0,
                                align_h: hmUI.align.RIGHT,
                                padding: false,
                                isCharacter: true,
                                invalid_image: "34.png",
                                isCharacter: true,
                                unit_sc: "bpm.png",
                                unit_tc: "bpm.png",
                                unit_en: "bpm.png",
                           }); 

                let maxText = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
                                x: 341,
                                y: 93,
                                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: 341,
                                y: 128,
                                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,
                           });

                   ////////////////// End /////////////////////////
                
                   ////////////////////  update ////////////////////

       
                           const widgetDelegate = hmUI.createWidget(hmUI.widget.WIDGET_DELEGATE, {
                              
                                   resume_call: (function () {


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

                                    heart_num.setProperty(hmUI.prop.MORE, {
                                        x: 171,
                                        y: 60,
                                        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",
                                unit_sc:"bpm.png",
                                unit_tc: "bpm.png",
                                unit_en: "bpm.png",
                                    });


                                    maxText.setProperty(hmUI.prop.MORE, {
                                        x: 333,
                                        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,
                                    });

                                    minText.setProperty(hmUI.prop.MORE, {
                                        x: 333,
                                        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,
                                    });

                                }),
                                pause_call: (function () {
                                   console.log('ui pause');
                              }),
                            });         

             


                //dynamic modify end
            },
            onInit() {
                logger.log('index page.js on init invoke');
            },
            build() {
                this.init_view();
                logger.log('index page.js on ready invoke');
            },
            onDestroy() {
                logger.log('index page.js on destroy invoke');
            }
        });
        ;
    })();
} catch (e) {
    console.log('Mini Program Error', e);
    e && e.stack && e.stack.split(/\n/).forEach(i => console.log('error stack', i));
    ;
}
///////////////////////////////////////////////////////////////////////////////////////
           normal_system_disconnect_img = hmUI.createWidget(hmUI.widget.IMG_STATUS, {
              x: 79,
              y: 364,
              src: '56.png',
              type: hmUI.system_status.DISCONNECT,
              show_level: hmUI.show_level.ONLY_NORMAL,
            });

            normal_system_clock_img = hmUI.createWidget(hmUI.widget.IMG_STATUS, {
              x: 0,
              y: 0,
              src: '57.png',
              type: hmUI.system_status.CLOCK,
              show_level: hmUI.show_level.ONLY_NORMAL,
            });

            normal_spo2_text_text_img = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
              x: 341,
              y: 162,
              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"],
              padding: false,
              h_space: 0,
              align_h: hmUI.align.RIGHT,
              type: hmUI.data_type.SPO2,
              show_level: hmUI.show_level.ONLY_NORMAL,
            });

            normal_date_img_date_month_img = hmUI.createWidget(hmUI.widget.IMG_DATE, {
              month_startX: 203,
              month_startY: 404,
              month_sc_array: ["22.png","23.png","24.png","25.png","26.png","27.png","28.png","29.png","30.png","31.png","32.png","33.png"],
              month_tc_array: ["22.png","23.png","24.png","25.png","26.png","27.png","28.png","29.png","30.png","31.png","32.png","33.png"],
              month_en_array: ["22.png","23.png","24.png","25.png","26.png","27.png","28.png","29.png","30.png","31.png","32.png","33.png"],
              month_is_character: true ,
              show_level: hmUI.show_level.ONLY_NORMAL,
            });

            normal_date_img_date_day = hmUI.createWidget(hmUI.widget.IMG_DATE, {
              day_startX: 202,
              day_startY: 321,
              day_sc_array: ["46.png","47.png","48.png","49.png","50.png","51.png","52.png","53.png","54.png","55.png"],
              day_tc_array: ["46.png","47.png","48.png","49.png","50.png","51.png","52.png","53.png","54.png","55.png"],
              day_en_array: ["46.png","47.png","48.png","49.png","50.png","51.png","52.png","53.png","54.png","55.png"],
              day_zero: 0,
              day_space: 0,
              day_align: hmUI.align.CENTER_H,
              day_is_character: false,
              show_level: hmUI.show_level.ONLY_NORMAL,
            });

            normal_city_name_text = hmUI.createWidget(hmUI.widget.TEXT, {
              x: 188,
              y: 33,
              w: 150,
              h: 30,
              text_size: 22,
              char_space: 0,
              line_space: 0,
              color: 0xFFFFCF95,
              align_h: hmUI.align.LEFT,
              align_v: hmUI.align.TOP,
              text_style: hmUI.text_style.ELLIPSIS,
              show_level: hmUI.show_level.ONLY_NORMAL,
            });

            normal_temperature_current_text_img = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
              x: 103,
              y: 398,
              font_array: ["34.png","35.png","36.png","37.png","38.png","39.png","40.png","41.png","42.png","43.png"],
              padding: false,
              h_space: 0,
              unit_sc: '45.png',
              unit_tc: '45.png',
              unit_en: '45.png',
              negative_image: '44.png',
              invalid_image: '44.png',
              align_h: hmUI.align.RIGHT,
              type: hmUI.data_type.WEATHER_CURRENT,
              show_level: hmUI.show_level.ONLY_NORMAL,
            });

            normal_weather_image_progress_img_level = hmUI.createWidget(hmUI.widget.IMG_LEVEL, {
              x: 136,
              y: 355,
              image_array: ["Weather_01.png","Weather_02.png","Weather_03.png","Weather_04.png","Weather_05.png","Weather_06.png","Weather_07.png","Weather_08.png","Weather_09.png","Weather_10.png","Weather_11.png","Weather_12.png","Weather_13.png","Weather_14.png","Weather_15.png","Weather_16.png","Weather_17.png","Weather_18.png","Weather_19.png","Weather_20.png","Weather_21.png","Weather_22.png","Weather_23.png","Weather_24.png","Weather_25.png","Weather_26.png","Weather_27.png","Weather_28.png","Weather_29.png"],
              image_length: 29,
              type: hmUI.data_type.WEATHER_CURRENT,
              show_level: hmUI.show_level.ONLY_NORMAL,
            });

            // normal_calorie_text_rotate_img = hmUI.createWidget(hmUI.widget.Text_Rotate, {
              // x: 351,
              // y: 354,
              // font_array: ["34.png","35.png","36.png","37.png","38.png","39.png","40.png","41.png","42.png","43.png"],
              // zero: true,
              // unit_in_alignment: false,
              // h_space: 0,
              // angle: 89,
              // align_h: hmUI.align.LEFT,
              // type: hmUI.data_type.CAL,
              // show_level: hmUI.show_level.ONLY_NORMAL,
            // });

            normal_calorie_TextRotate_ASCIIARRAY[0] = '34.png';  // set of images with numbers
            normal_calorie_TextRotate_ASCIIARRAY[1] = '35.png';  // set of images with numbers
            normal_calorie_TextRotate_ASCIIARRAY[2] = '36.png';  // set of images with numbers
            normal_calorie_TextRotate_ASCIIARRAY[3] = '37.png';  // set of images with numbers
            normal_calorie_TextRotate_ASCIIARRAY[4] = '38.png';  // set of images with numbers
            normal_calorie_TextRotate_ASCIIARRAY[5] = '39.png';  // set of images with numbers
            normal_calorie_TextRotate_ASCIIARRAY[6] = '40.png';  // set of images with numbers
            normal_calorie_TextRotate_ASCIIARRAY[7] = '41.png';  // set of images with numbers
            normal_calorie_TextRotate_ASCIIARRAY[8] = '42.png';  // set of images with numbers
            normal_calorie_TextRotate_ASCIIARRAY[9] = '43.png';  // set of images with numbers

            //start of ignored block
            for (let i = 0; i < 4; i++) {
              normal_calorie_TextRotate[i] = hmUI.createWidget(hmUI.widget.IMG, {
                x: 0,
                y: 0,
                w: 480,
                h: 480,
                center_x: 351,
                center_y: 354,
                pos_x: 351,
                pos_y: 354,
                angle: 89,
                src: '34.png',
                show_level: hmUI.show_level.ONLY_NORMAL,
              });
              normal_calorie_TextRotate[i].setProperty(hmUI.prop.VISIBLE, false);
            };
            //end of ignored block
            
            const calorie = hmSensor.createSensor(hmSensor.id.CALORIE);
            calorie.addEventListener(hmSensor.event.CHANGE, function() {
              text_update();
            });

            normal_step_current_text_img = hmUI.createWidget(hmUI.widget.TEXT_IMG, {
              x: 340,
              y: 292,
              font_array: ["34.png","35.png","36.png","37.png","38.png","39.png","40.png","41.png","42.png","43.png"],
              padding: true,
              h_space: 0,
              align_h: hmUI.align.RIGHT,
              type: hmUI.data_type.STEP,
              show_level: hmUI.show_level.ONLY_NORMAL,
            });

            normal_step_image_progress_img_level = hmUI.createWidget(hmUI.widget.IMG_LEVEL, {
              x: 333,
              y: 246,
              image_array: ["146.png","147.png","148.png","149.png","150.png","151.png","152.png","153.png","154.png","155.png","156.png","157.png","158.png","159.png","160.png","161.png","162.png","163.png","164.png","165.png","166.png","167.png","168.png","169.png","170.png"],
              image_length: 25,
              type: hmUI.data_type.STEP,
              show_level: hmUI.show_level.ONLY_NORMAL,
            });

              normal_digital_clock_img_time = hmUI.createWidget(hmUI.widget.IMG_TIME, {
              hour_startX: 27,
              hour_startY: 203,
              hour_array: ["1.png","2.png","3.png","4.png","5.png","6.png","7.png","8.png","9.png","10.png"],
              hour_zero: 1,
              hour_space: 0,
              hour_angle: 0,
              hour_align: hmUI.align.RIGHT,

              minute_startX: 171,
              minute_startY: 203,
              minute_array: ["1.png","2.png","3.png","4.png","5.png","6.png","7.png","8.png","9.png","10.png"],
              minute_zero: 1,
              minute_space: 0,
              minute_angle: 0,
              minute_follow: 0,
              minute_align: hmUI.align.RIGHT,

              show_level: hmUI.show_level.ONLY_NORMAL,
            });

            normal_digital_clock_hour_separator_img = hmUI.createWidget(hmUI.widget.IMG, {
              x: 151,
              y: 213,
              src: '11.png',
              show_level: hmUI.show_level.ONLY_NORMAL,
            });



            normal_alarm_jumpable_img_click = hmUI.createWidget(hmUI.widget.IMG_CLICK, {
              x: 400,
              y: 191,
              w: 100,
              h: 100,
              src: 'shortcut.png',
              type: hmUI.data_type.ALARM_CLOCK,
              show_level: hmUI.show_level.ONLY_NORMAL,
            });

            let screenType = hmSetting.getScreenType();
            function text_update() {

              console.log('update text rotate calorie_CALORIE');
              let valueCalories = calorie.current;
              let normal_calorie_rotate_string = parseInt(valueCalories).toString();
              normal_calorie_rotate_string = normal_calorie_rotate_string.padStart(4, '0');

              if (screenType != hmSetting.screen_type.AOD) {
                for (var i = 1; i < 4; i++) {  // hide all symbols
                  normal_calorie_TextRotate[i].setProperty(hmUI.prop.VISIBLE, false);
                };
                if (valueCalories != null && valueCalories != undefined && isFinite(valueCalories) && normal_calorie_rotate_string.length > 0 && normal_calorie_rotate_string.length < 6) {  // display data if it was possible to get it
                  let img_offset = 0;
                  
                  let index = 0;
                  for (let char of normal_calorie_rotate_string) {
                    let charCode = char.charCodeAt()-48;
                    if (index >= 4) break;
                    if (charCode >= 0 && charCode < 10) { 
                      normal_calorie_TextRotate[index].setProperty(hmUI.prop.POS_X, 351 + img_offset);
                      normal_calorie_TextRotate[index].setProperty(hmUI.prop.SRC, normal_calorie_TextRotate_ASCIIARRAY[charCode]);
                      normal_calorie_TextRotate[index].setProperty(hmUI.prop.VISIBLE, true);
                      img_offset += normal_calorie_TextRotate_img_width;
                      index++;
                    };  // end if digit
                  };  // end char of string
                }  // end isFinite

              };

            };

            function scale_call() {

              console.log('Weather city name');
              const weatherSensor = hmSensor.createSensor(hmSensor.id.WEATHER);
              const weatherData = weatherSensor.getForecastWeather();
              normal_city_name_text.setProperty(hmUI.prop.TEXT, weatherData.cityName);

            };

            const widgetDelegate = hmUI.createWidget(hmUI.widget.WIDGET_DELEGATE, {
              resume_call: (function () {
                scale_call();
                text_update();
              }),
            });

                //dynamic modify end
            },
            onInit() {
                logger.log('index page.js on init invoke');
            },
            build() {
                this.init_view();
                logger.log('index page.js on ready invoke');
            },
            onDestroy() {
                logger.log('index page.js on destroy invoke');
            }
        });
        ;
    })();
} catch (e) {
    console.log('Mini Program Error', e);
    e && e.stack && e.stack.split(/\n/).forEach(i => console.log('error stack', i));
    ;
}

Re: Heart rate how to graph -GTR 3 PRO

Posted: 15 Aug 2023, 22:49
by asoo
vojta_1 wrote: 15 Aug 2023, 21:16
Zdravím
Dělám ciferník pro GTR 3 PRO, který má graf pro srdeční tep, něco jsem tu na forech našel , ale moc to nefunguje,
V souboru index.js je update pro graf - min - max , jak to nahraji do hodinek tak ciferník nejde vidět, ale
když ze souboru index.js vymažu update pro graf - min - max a znova to nahraji do hodinek tak ciferník najede, sice graf se zastaví , min- max jede, nevím kde je problém, muže mi někdo poradit ......
Because you don't use English to ask.
I use google to translate as far as I understand.
Your index has a problem when updating.

The problem is most likely caused by your resume_call.
You should include your resume_call in one footer.
To prevent the program from doing resume_call incorrectly and causing the program to stop.

because you didn't send The whole set of dials came to inspect. I can only try to fix
By including your resume_call in one footer. However, I'm not sure. Will it work? Because I don't have all resources to test.
new 2.txt
(22 KiB) Downloaded 104 times

As for the graph that sometimes stops working, it can happen.
But I'm not sure of the cause either.
If the graph stops working Lets you choose another watch face. Then go back to select the original dial, the graph will return to display again.

Re: Heart rate how to graph -GTR 3 PRO

Posted: 16 Aug 2023, 06:37
by vojta_1
Hello asoo ....
I don't use a translator because I don't know how it would turn out, your Czech is good after the translation, but with your file......, after inserting and uploading it to the watch, the watch face does not appear, I tried the reset to put a different watch face, etc., I will attach the watch face file it will be better

Re: Heart rate how to graph -GTR 3 PRO

Posted: 16 Aug 2023, 19:13
by asoo
vojta_1 wrote: 16 Aug 2023, 06:37
Hello asoo ....
I don't use a translator because I don't know how it would turn out, your Czech is good after the translation, but with your file......, after inserting and uploading it to the watch, the watch face does not appear, I tried the reset to put a different watch face, etc., I will attach the watch face file it will be better
Looking at the file you sent, it looks like you don't understand how to write a set of instructions. If you want to edit it yourself, I recommend you to learn more about the basic requirements for writing java script.

I've edited it to display (but not including the problem that The graph sometimes stops working. Because that seems to be a firmware problem, Then I can't fix it)
VT057_FIXED.zip
(282.04 KiB) Downloaded 142 times
This file I have tested on simulation program only.
Not tested on real devices because I don't have it.

Re: Heart rate how to graph -GTR 3 PRO

Posted: 16 Aug 2023, 20:27
by vojta_1
Hello, thank you very much and I appreciate it, I have already made a lot of dials, but I wanted to create something extra, there are not many people here who play with this theme, the only thing I did not understand was the update and finally the processing of the entire script.
They will upload it to the watch and then I will report.....
Thanks for now

Re: Heart rate how to graph -GTR 3 PRO

Posted: 25 Aug 2023, 21:03
by vojta_1
Hello, I want to ask, is there a program or simulation where I could test the heartbeat (graph) ....

Re: Heart rate how to graph -GTR 3 PRO

Posted: 26 Aug 2023, 02:35
by asoo
vojta_1 wrote: 25 Aug 2023, 21:03
Hello, I want to ask, is there a program or simulation where I could test the heartbeat (graph) ....
I'm not sure if the official Simulator will be able to do that. because I've never used it. and not sure can direct with the dial or not or have to do through https://watchface.zepp.com/create only

If you're interested, read more here.
https://docs.zepp.com/docs/guides/tools/simulator/