• Amministratore
  •  
    Support Ukraine
    If you experience any problems with the forum (it is not visible, there is no way to post messages, or some functionality does not work), please let us know. If you have problems with registration or you did not receive confirmation letter, let us know and we will activate your account manually.
    If you get an "The submitted form was invalid. Try submitting again" error, delete cookies, then try again.
     

How to change watch display with js (Active 2)

Topics related to the creation, development, and designing of the watch faces.

Moderatori: asoo, Watchmens

Regole del forum
When adding a new topic, use the template: Topic title [device name]
For example: How to create watch face [Falcon]
All communication in this branch should only be in English.
Rispondi
zankezaa
Messaggi: 8
Iscritto il: 10 mar 2025, 12:02
Località: Indonesia
Contatta:

How to change watch display with js (Active 2)

Messaggio da zankezaa »

After i make this watchface there known issue is when on altimeter and barometer the world time is not showing, but if on compass section the world time is showing. Is there any error in my script?
Here i attached my projects.
Allegati
compass_Active_2_073910.zip
(263.57 KiB) Scaricato 39 volte
Avatar utente
asoo
Messaggi: 2108
Iscritto il: 03 gen 2019, 01:48
Località: ͼͽ Thailand ͼͽ
Has thanked: 404 times
Been thanked: 2022 times

Messaggio da asoo »

zankezaa ha scritto: 13 nov 2025, 00:46
After i make this watchface there known issue is when on altimeter and barometer the world time is not showing, but if on compass section the world time is showing. Is there any error in my script?
Here i attached my projects.
Explanation
The code above will always hide normal_time_gmt_text from the start (hmUI.prop.VISIBLE, false).

Then, in the click_CONTENT() function you used to change element_index,
you call it again for each value (1–4):

normal_time_gmt_text.setProperty(hmUI.prop.VISIBLE, element_index == 2);
normal_time_gmt_text.setProperty(hmUI.prop.VISIBLE, element_index == 3);
normal_time_gmt_text.setProperty(hmUI.prop.VISIBLE, element_index == 4);

This means:

If element_index == 2 → the first line will be set to true,
but the second and third lines will be set to false again (because 2 ≠ 3 and 2 ≠ 4).

The final result is that VISIBLE becomes false again.

That is, the "true value" is overwritten by the "false value" from the following lines.

💡 Summary of results
Element_index value, working line, final result
1 (no visible set for text) ❌ Not displayed
2 True then false then false ❌ Not displayed
3 False then true then false ❌ Not displayed
4 False then false then true ✅ Displayed

I think you don't understand the logic, which is why you're getting an unintended logic error. If I were to suggest using
.setProperty(hmUI.prop.VISIBLE, false);
.setProperty(hmUI.prop.VISIBLE, true);
to implement the function, it will help you understand it better.


If you want to use logic ( true false ), here's how to fix it:
✅ Solution

Leave only one line to control. normal_time_gmt_text
By adjusting in click_CONTENT() like this:

Codice: Seleziona tutto

function click_CONTENT() { 
element_index++; 
if (element_index > element_count) element_index = 1; 

normal_digital_clock_img_time.setProperty(hmUI.prop.VISIBLE, element_index == 1); 
normal_digital_clock_hour_separator_img.setProperty(hmUI.prop.VISIBLE, element_index == 1); 
normal_step_current_text_font.setProperty(hmUI.prop.VISIBLE, element_index == 1); 
normal_heart_rate_text_font.setProperty(hmUI.prop.VISIBLE, element_index == 1); 

normal_altitude_target_text_img.setProperty(hmUI.prop.VISIBLE, element_index == 2); 
normal_altitude_target_separator_img.setProperty(hmUI.prop.VISIBLE, element_index == 2); 

normal_altimeter_text_text_img.setProperty(hmUI.prop.VISIBLE, element_index == 3); 
normal_altimeter_text_separator_img.setProperty(hmUI.prop.VISIBLE, element_index == 3); 

normal_compass_text_img.setProperty(hmUI.prop.VISIBLE, element_index == 4); 
normal_compass_separator_img.setProperty(hmUI.prop.VISIBLE, element_index == 4); 

//  Make it show all pages (2, 3, 4) 
normal_time_gmt_text.setProperty( 
hmUI.prop.VISIBLE, 
element_index == 2 || element_index == 3 || element_index == 4 
); 

if (element_index == 1) hmUI.showToast({ text: 'DIGITAL TIME' }); 
if (element_index == 2) hmUI.showToast({ text: 'ALTIMETER' }); 
if (element_index == 3) hmUI.showToast({ text: 'BAROMETER' }); 
if (element_index == 4) hmUI.showToast({ text: 'COMPASS' });
}
compass_Active_2_fix_switch.zip
(263.48 KiB) Scaricato 34 volte
ͼͽ To request please use the interrelated forum in action ͼͽ
Please do not PM to me for requests ported watchface.
zankezaa
Messaggi: 8
Iscritto il: 10 mar 2025, 12:02
Località: Indonesia
Contatta:

Messaggio da zankezaa »

thankyou asoo, now i understand the logic :D

the watchface was work very nice
Rispondi

Torna a “Watchfaces discussion”

Chi c’è in linea

Visitano il forum: Nessuno e 1 ospite