jimibamper ha scritto: 27 mar 2026, 06:23
Hi everyone! I'm working on a watch face for the T-Rex 3 and I'm facing a battery drain issue because the compass is constantly active.
Is there a way to implement a 'tap-to-toggle' feature to turn the compass (magnetometer) on/off? Or perhaps a way to set its update interval to save battery life? If anyone has experience with this in Zepp OS, I would appreciate any tips or code snippets. Thanks!
I'm not sure how you scripted the compass to run constantly, but if you're using Sasha's editor, I don't think the power consumption to much is due to the compass itself.
Because the editor already has this script to control on/off widget compass
Codice: Seleziona tutto
pause_call: (function () {
console.log('pause_call()');
if (compass) compass.stop();
}),
resume_call: (function () {
console.log('resume_call()');
if (compass && screenType == hmSetting.screen_type.WATCHFACE) compass.start();
}),
This means that when your screen is off or you're not on the main screen, the compass will stop working immediately and will resume when the screen is on again or you return to the main screen.
I think the high power consumption might be due to other widgets, or you might be using many widgets on your watchface, or in the AOD you might be calling seconds. I can only speculate because you haven't provided a project for further investigation.
Or, if you're sure the problem is actually with the compass, you could create buttons to disable or enable the functions:
compass.stop()
compass.start()
yourself, without having to use them through:
pause_call:
resume_call:
Examples of using the compass on/off button :
If you are using Sasha's editor to create a compass widget and want to switch to a direct compass on/off control button,
remember to remove the controls in resume_call and pause_call
Codice: Seleziona tutto
-------------------------------- resume and pause in index.js --------------------------------------------
resume_call: (function () {
console.log('resume_call()');
// if (compass && screenType == hmSetting.screen_type.WATCHFACE) compass.start(); // remove this line
}),
pause_call: (function () {
console.log('pause_call()');
// if (compass) compass.stop(); // remove this line
}),
However, in my testing, even though the power button can be used to turn it off compass, after the screen is off for a while and then turns back on, sometime the compass will turn on . I'm not sure what causes it, but this happens rarely.
Therefore, I think "resume_call" and "pause_call" are the most appropriate solutions.