How to develop a Stopwatch for Lite Wearable in Harmony OS

Mehmet Yozgatlı
Jan 21 · 2 min read
Huawei Watch GT2 Pro

Introduction

In this article, I have explained how to develop a stopwatch application for Huawei Lite Wearable Device.

Huawei Lite Wearable watch application development supports JS language with the support of HTML tags and CSS for styling layouts.

Requirements

  • Dev Eco Studio IDE

New Project For Lite Wearable

You can create a new project for Lite Wearable in 3 steps as follows.

  • Step -1
Page-1
  • Step-2
Page-2
  • Step-3
Page-3

Implementation

  • UI Design :
UI Design

I used 2 basic components for the application. I used a text for the duration and 3 images to start, pause and finish the time.

index.hml:

index.hml

index.css:

index.css
  • Code Part :

setInterval function sets a repeating timer for the system to repeatedly execute a function at a fixed interval. In the remaining part, I calculated using the starting time and the elapsed time. I converted this time into hours, minutes, seconds and milliseconds and transferred it to the text.

index.js:

index.js

Output

App Screen Record

Conclusion

If you are going to make an application related to the stopwatch, you can simply use it this way. In this article, we learned how to develop applications for Harmony OS using Dev Eco Studio.

References

Huawei Developers

Huawei Developers