Maintainers
Pricing
Enterprise
More
More
Documentation
Try Live
Rankings
Install
Blog
Docs7
Ask
New
Add Docs
Zepp OS
https://github.com/zepp-health/zeppos-docs
Admin
https://docs.zepp.com/
Tokens:
702,350
Snippets:
6,298
Trust Score:
7.1
License:
Apache-2.0
Update:
4 weeks ago
Context
Chat
Benchmark
69.01
Latest
Show doc for...
Code
Info
Show Results
Tokens:
Raw
Copy
Link
Tokens:
Raw
Copy
Link
### SystemSounds usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/sensor/SystemSounds.mdx Example showing how to import SystemSounds, create an instance, get the ALARM type, check if enabled, and start playing. ```js import { SystemSounds } from '@zos/sensor' const systemSounds = new SystemSounds() const alarmType = systemSounds.getSourceType().ALARM if (systemSounds.getEnabled()) { systemSounds.start(alarmType) } ``` -------------------------------- ### Create player and recorder example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/media/create.mdx Example usage of create to instantiate a player and a recorder from '@zos/media'. Sets source and format, then prepares and starts playback/recording. ```js import { codec, create, id } from '@zos/media' const player = create(id.PLAYER) player.setSource(player.source.FILE, { file: 'data://music.opus' }) player.prepare() const recorder = create(id.RECORDER) recorder.setFormat(codec.OPUS, { target_file: 'data://record.opus' }) recorder.start() recorder.stop() ``` -------------------------------- ### Recorder usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/media/Recorder.mdx JavaScript example showing how to create a recorder, listen for start and stop events, set the format to OPUS with a target file, start recording, check status, and stop. ```js import { codec, create, id } from '@zos/media' const recorder = create(id.RECORDER) recorder.addEventListener(recorder.event.START, (result) => { if (result) console.log('recording started') }) recorder.addEventListener(recorder.event.STOP, () => { console.log('recording stopped') }) recorder.setFormat(codec.OPUS, { target_file: 'data://record.opus', }) recorder.start() recorder.getStatus() recorder.stop() ``` -------------------------------- ### Compass usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/sensor/Compass.mdx Example showing how to import the Compass class, create an instance, register a callback, start listening, and stop when not needed. The callback checks calibration status before logging direction and angle. ```js import { Compass } from '@zos/sensor' const compass = new Compass() const callback = () => { if (compass.getStatus()) { console.log(compass.getDirection()) console.log(compass.getDirectionAngle()) } } compass.onChange(callback) compass.start() // When not needed for use compass.offChange() compass.stop() ``` -------------------------------- ### mstBuildProfile Example Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms/@zos-ble.md Shows the import of mstBuildProfile and a placeholder. Starts from API_LEVEL 3.0. ```JavaScript import { mstBuildProfile } from '@zos/ble' // ... ``` -------------------------------- ### Vibrator.start Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt Starts vibration with optional mode or scene array. ```APIDOC ## Vibrator.start ### Description Starts vibration. The optional `option` parameter only takes effect for this vibration. Starting from API_LEVEL 3.6, an array of `Action` objects can be passed to support vibration scenes. ### Method start ### Signature ```ts start(option?: Option | Array<Action>): void ``` ### Parameters #### Option - **mode** (number) - Optional - Vibration mode. Refer to Vibration motor mode constants. Default: `VIBRATOR_SCENE_SHORT_MIDDLE`. API_LEVEL: 2.0 #### Action - **type** (number) - Required - Vibration Scene Type. API_LEVEL: 3.6 - **duration** (number) - Optional - Duration of vibration. API_LEVEL: 3.6 ### Constants #### Vibration motor mode constants - `VIBRATOR_SCENE_SHORT_LIGHT` - Light vibration intensity and short time (20ms). API_LEVEL: 2.0 - `VIBRATOR_SCENE_SHORT_MIDDLE` - Medium vibration intensity, short time (20ms). API_LEVEL: 2.0 - `VIBRATOR_SCENE_SHORT_STRONG` - High vibration intensity and short time (20ms). API_LEVEL: 2.0 - `VIBRATOR_SCENE_DURATION` - High vibration intensity, lasting 600ms. API_LEVEL: 2.0 - `VIBRATOR_SCENE_DURATION_LONG` - High vibration intensity, lasting 1000ms. API_LEVEL: 2.0 - `VIBRATOR_SCENE_STRONG_REMINDER` - High vibration intensity, four vibrations in 1200ms, can be used for stronger reminders. API_LEVEL: 2.0 - `VIBRATOR_SCENE_NOTIFICATION` - Two short, continuous vibrations, consistent with the watch message notification vibration feedback. API_LEVEL: 2.0 - `VIBRATOR_SCENE_CALL` - High vibration intensity, single vibration twice in 500ms, continuous vibration, need to manually `stop`, consistent with the watch call vibration feedback. API_LEVEL: 2.0 - `VIBRATOR_SCENE_TIMER` - High vibration intensity, single long vibration 500ms, continuous vibration, need to manually `stop`, consistent with the watch alarm clock, countdown vibration feedback. API_LEVEL: 2.0 ### Example ```js import { Vibrator, VIBRATOR_SCENE_DURATION } from '@zos/sensor' const vibrator = new Vibrator() vibrator.start() // set scene vibrator.setMode(VIBRATOR_SCENE_DURATION) vibrator.start() ``` ``` -------------------------------- ### JavaScript example: using openInspector().draw() Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt Example of using openInspector().draw() inside a Page's build() method to draw boundary rectangles for all layout widgets. The draw() call is wrapped in a setTimeout() to delay execution by 100ms, and uses options for line color (red), line width (1), and border mode (inward). ```js Page({ build() { // Create layout... // Draw boundary rectangles for all widgets participating in layout setTimeout(() => { openInspector().draw({ line_color: 0xff0000, // Red line_width: 1, // Line width of 1 border_mode: 1 // Draw border inward }) }, 100) } }) ``` -------------------------------- ### Workout Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt Documentation for the Workout sensor class from the @zos/sensor module, including its methods and usage example. ```APIDOC ## Workout ### Description Workout Sensor. Provides access to workout status, history, user heart rate zone settings, and workout track navigation information. ### Import ```js import { Workout } from '@zos/sensor' ``` ### Constructor `new Workout()` ### Methods #### `getStatus()` Returns the current workout status. #### `getHistory()` Returns the workout history. #### `getUserHrZoneSettings()` Returns the user's heart rate zone settings. Example output: ```json {"type":0,"rest":83,"range":[129,138,147,157,166,175]} {"type":1,"rest":70,"range":[90,108,126,144,162,181]} ``` #### `getWorkoutTrackNavInfo()` Returns workout track navigation information. ### Example ```js import { Workout } from '@zos/sensor' const workout = new Workout() const status = workout.getStatus() const history = workout.getHistory() const hrZoneSettings = workout.getUserHrZoneSettings() // {"type":0,"rest":83,"range":[129,138,147,157,166,175]} // {"type":1,"rest":70,"range":[90,108,126,144,162,181]} const trackNavInfo = workout.getWorkoutTrackNavInfo() ``` ### Permissions - `data:user.hd.workout` ### API Level - 3.0 ``` -------------------------------- ### Weather Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt Documentation for the Weather class, including its getForecast method and usage example. ```APIDOC ## Weather ### Description Provides weather forecast and tide data. ### Constructor `new Weather()` ### Methods #### `getForecast()` Returns an object containing `forecastData`, `tideData`, and `cityName`. ### Example ```js const weather = new Weather() const { forecastData, tideData, cityName } = weather.getForecast() console.log(cityName) for (let i = 0; i < forecastData.count; i++) { const element = forecastData.data[i] console.log('Index' + element.index) console.log('Highest temperature' + element.high) console.log('Lowest temperature' + element.low) } for (let i = 0; i < tideData.count; i++) { const element = tideData.data[i] console.log('Sunrise' + element.sunrise.hour + element.sunrise.minute) console.log('Sunset' + element.sunset.hour + element.sunset.minute) } ``` ``` -------------------------------- ### Create Checkbox Group with State Buttons Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt Example of creating a checkbox group with three state buttons and setting initial and checked properties. Uses image resources referenced from the design resources. ```js Page({ build() { const checkbox_group = createWidget(widget.CHECKBOX_GROUP, { x: 0, y: 0, w: 480, h: 64, select_src: 'selected.png', unselect_src: 'unselected.png', check_func: (group, index, checked) => { console.log('index', index) console.log('checked', checked) } }) const button1 = checkbox_group.createWidget(widget.STATE_BUTTON, { x: 40, y: 200, w: 64, h: 64 }) const button2 = checkbox_group.createWidget(widget.STATE_BUTTON, { x: 190, y: 200, w: 64, h: 64 }) const button3 = checkbox_group.createWidget(widget.STATE_BUTTON, { x: 340, y: 200, w: 64, h: 64 }) checkbox_group.setProperty(prop.INIT, button2) checkbox_group.setProperty(prop.CHECKED, button3) } }) ``` -------------------------------- ### Geolocation Sensor Usage Example Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms/@zos-sensor.md Example of using the Geolocation sensor to get latitude and longitude. It creates a Geolocation instance, defines a callback that checks the status and logs coordinates, then starts the sensor and registers the callback. The example also shows how to stop listening and stop the sensor when no longer needed. ```javascript const geolocation = new Geolocation() const callback = () => { if (geolocation.getStatus() === 'A') { console.log(geolocation.getLatitude()) console.log(geolocation.getLongitude()) } } geolocation.start() geolocation.onChange(callback) // When not needed for use geolocation.offChange(callback) geolocation.stop() ``` -------------------------------- ### Buzzer usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/sensor/Buzzer.mdx Complete example showing how to use the Buzzer API in a Zepp OS widget. It creates a text widget and a button, and on button click, checks if the buzzer is enabled, gets the source type for the current scene, starts the buzzer, and cycles through the scene list. ```js import { createWidget, widget, prop, align, text_style } from '@zos/ui' import { Buzzer } from '@zos/sensor' import { px } from '@zos/utils' const sceneList = ['ALARM', 'REMIND_1', 'REMIND_2', 'OPERATE', 'SUCCESS', 'FAILURE'] Page({ state: { pageName: 'BUZZER', currentIndex: 0, }, build() { const buzzer = new Buzzer() const sceneText = createWidget(widget.TEXT, { x: px(0), y: px(120), w: px(480), h: px(46), color: 0xffffff, text_size: px(20), align_h: align.CENTER_H, align_v: align.CENTER_V, text_style: text_style.NONE, text: `${sceneList[this.state.currentIndex]}`, }) const startBuzzer = () => { const alarmType = buzzer.getSourceType()[sceneList[this.state.currentIndex]] if (buzzer.isEnabled()) { buzzer.start(alarmType) } this.state.currentIndex = (this.state.currentIndex + 1) % sceneList.length sceneText.setProperty(prop.MORE, { text: `BUZZER: ${sceneList[this.state.currentIndex]}`, }) } createWidget(widget.BUTTON, { x: px(80), y: px(300), w: px(300), h: px(60), radius: px(12), normal_color: 0xfc6950, press_color: 0xfeb4a8, text: 'START BUZZER', click_func: startBuzzer, }) }, }) ``` -------------------------------- ### Complete MUSIC sensor example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/watchface/api/hmSensor/sensorId/MUSIC.mdx Complete example showing sensor creation, initialization, playback controls, and logging artist and title properties. ```js const music = hmSensor.createSensor(hmSensor.id.MUSIC) music.audInit() music.audPlay() music.audPause() music.audPrev() music.audNext() console.log('The artist of song: ' + music.artist) console.log('The name of song: ' + music.title) ``` -------------------------------- ### Get weight target example without import Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms/@zos-settings.md Gets the weight target and logs it. This example omits the import statement. ```js const weightTarget = getWeightTarget() console.log(weightTarget) ``` -------------------------------- ### start(): void Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/media/Recorder.mdx Starts the recording process. ```APIDOC ## start ### Description Starts the recording process. ### Method start ### Signature ```ts start(): void ``` ### Parameters None ### Returns void ``` -------------------------------- ### RadioGroup Component Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt Documentation for the RadioGroup widget component, including its initialization parameters, callback function, state button properties, and prop properties for setting and getting checked states. ```APIDOC ## RadioGroup Component ### Description RadioGroup is a widget that allows users to select one option from a group of options. It is initialized with a `radioGroupParam` object and supports setting and getting the checked state of child widgets. ### Properties #### radioGroupParam: object | Properties | Description | Required | Type | API_LEVEL | | ------------ | ----------------------------------------- | -------- | ----------- | --------- | | x | The x-coordinate of the widget | YES | `number` | 2.0 | | y | The y-coordinate of the widget | YES | `number` | 2.0 | | w | Width of the widget | YES | `number` | 2.0 | | h | Height of the widget | YES | `number` | 2.0 | | select_src | Image displayed when widget is selected | YES | `string` | 2.0 | | unselect_src | Image displayed when widget is unselected | YES | `string` | 2.0 | | check_func | Callback when button state changes | NO | `CheckFunc` | 2.0 | | use_color | Whether to display widget using colors | NO | `boolean` | 4.0 | #### CheckFunc: function ```js (radioGroup: RadioGroup, index: number, checked: boolean) => void ``` | Parameters | Description | Type | | ---------- | --------------------------- | ------------ | | radioGroup | The radioGroup instance | `RadioGroup` | | index | Index of the option | `number` | | checked | Whether selected | `boolean` | #### StateButton: object | Properties | Description | Required | Type | API_LEVEL | | -------------- | ------------------------------------------------------------ | -------- | -------- | --------- | | x | The x-coordinate relative to radioGroup | YES | `number` | 2.0 | | y | The y-coordinate relative to radioGroup | YES | `number` | 2.0 | | w | Width of the widget | YES | `number` | 2.0 | | h | Height of the widget | YES | `number` | 2.0 | | select_color | Color when selected | NO | `number` | 4.0 | | unselect_color | Color when unselected | NO | `number` | 4.0 | | fill_width | Button color display area width | NO | `number` | 4.0 | | fill_height | Button color display area height | NO | `number` | 4.0 | ### Prop Properties | Properties | Support get/set | Type | Notes | | ---------------- | -------------- | -------- | ---------------------------------------------------------------------------------------------------------------------------------------- | | `prop.INIT` | set | `object` | Initialize the component and set the default selected item | | `prop.CHECKED` | set/get | `object` | Set the selected child widget to selected state, or get the selected state of the child widget, the value type is `boolean` | | `prop.UNCHECKED` | get | `object` | Set the selected child widget to unselected state, or get the selected state of the child widget, the value type is `boolean` | ### Usage > **⚠️ Caution** > > The widget must be initialized once with `prop.INIT` to render the view ``` -------------------------------- ### canvas.addEventListener interaction event example Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt Listens for the CLICK_UP event on the canvas. The callback receives an info object with x and y coordinates, which are logged to the console. ```js canvas.addEventListener(event.CLICK_UP, function cb(info) { console.log(info.x) console.log(info.y) }) ``` -------------------------------- ### Wear Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt The Wear class provides methods to get the current wearing status and to register/unregister callbacks for wear status change events. ```APIDOC ## Wear ### Import ```js import { Wear } from '@zos/sensor' ``` ### Description Wearing status sensor. ### Methods #### getStatus Get the current device wearing status, `0`: not wearing, `1`: wearing, `2`: in motion, `3`: not sure ```ts getStatus(): number ``` #### onChange Register the device wear status change event listening callback function ```ts onChange(callback: () => void): void ``` #### offChange Cancel the device wear status change event listening callback function ```ts offChange(callback: () => void): void ``` ### Example ```js const wear = new Wear() const status = wear.getStatus() const callback = () => { console.log(wear.getStatus()) } wear.onChange(callback) // When not needed for use wear.offChange(callback) ``` ``` -------------------------------- ### getSystemMode Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt Gets the current system mode state, including DND, sleep, theater, system lock, low temperature, power saving, ultra power saving, button, and accessible switch modes. ```APIDOC ## getSystemMode ### Description Gets the current system mode state. ### Method function ### Signature `function getSystemMode(): Result` ### Parameters None. ### Return Value Returns a `Result` object with the following boolean properties: | Property | Type | Description | API_LEVEL | | ---------------- | ------- | ----------------------------- | --------- | | DND | boolean | State of Do Not Disturb Mode | 3.0 | | sleep | boolean | State of Sleep Mode | 3.0 | | theater | boolean | State of Sleep Mode | 3.0 | | systemLock | boolean | State of Screen Lock Mode | 3.0 | | lowTemperature | boolean | State of Low Temperature Mode | 3.0 | | powerSaving | boolean | State of Power Saving Mode | 3.0 | | ultraPowerSaving | boolean | State of Clock Mode | 3.0 | | button | boolean | State of Button Mode | 3.0 | | accessibleSwitch | boolean | State of Accessible | 3.0 | ### Example ```js const mode = getSystemMode() console.log(mode) ``` ``` -------------------------------- ### Preview project in default language (en) Source: https://github.com/zepp-health/zeppos-docs/blob/main/README.md Use this command to start the local development server and preview the documentation in the default 'en' language. The 'npm start' command uses npm, while 'yarn start' is for yarn. ```sh npm start // or yarn start ``` -------------------------------- ### getPerformance usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/app/getPerformance.mdx Example usage of getPerformance. Import from '@zos/app', then call with 'memory' to get memory statistics, or with both 'memory' and 'perf' to get memory and performance statistics. ```js import { getPerformance } from '@zos/app' // Get memory info only const memoryProfile = getPerformance('memory') // Get both memory and performance info const fullProfile = getPerformance('memory', 'perf') ``` -------------------------------- ### Update container layout style with updateLayoutStyle Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt Updates the layout style of a widget node. The style parameter is a LayoutStyle object containing layout properties. The example sets display to flex, flex-direction to row, justify-content to space-between, align-items to center, width to 100%, and height to 200px. ```js const container = createWidget(widget.VIRTUAL_CONTAINER) // Update container layout style container.updateLayoutStyle({ display: 'flex', 'flex-direction': 'row', 'justify-content': 'space-between', 'align-items': 'center', width: '100%', height: '200px' }) ``` -------------------------------- ### Weather Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt The Weather class provides a method to get weather forecast data, including forecast and tide information. ```APIDOC ## Weather ### Import ```js import { Weather } from '@zos/sensor' ``` ### Description Weather Forecasts sensor. ### Methods #### getForecastWeather Get weather forecast data ```ts getForecastWeather(): Weather.getForecastWeather.ForecastWeather ``` > **⚠️ Warning** > > This interface has been deprecated, please refer to https://github.com/orgs/zepp-health/discussions/83 ### Example ```js const weather = new Weather() const { forecastData, tideData, cityName } = weather.getForecast() console.log(cityName) for (let i = 0; i < forecastData.count; i++) { const element = forecastData.data[i] console.log('Index' + element.index) console.log('Highest temperature' + element.high) console.log('Lowest temperature' + element.low) } for (let i = 0; i < tideData.count; i++) { const element = tideData.data[i] console.log('Sunrise' + element.sunrise.hour + element.sunrise.minute) console.log('Sunset' + element.sunset.hour + element.sunset.minute) } ``` ``` -------------------------------- ### start Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/media/Player.mdx Starts playback of the prepared media file. ```APIDOC ## start ### Description Start playback ### Method start ### Signature ```ts start(): void ``` ### Parameters None. ### Return Value - **void** - This method does not return a value. ``` -------------------------------- ### SessionStorage usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/storage/sessionStorage.mdx Example usage of SessionStorage: create an instance, set a value, get it, get a default value for a missing key, remove an item, and clear all data. ```js import { SessionStorage } from '@zos/storage' const sessionStorage = new SessionStorage() sessionStorage.setItem('test', 'test value') const val = sessionStorage.getItem('test') const defaultValue = sessionStorage.getItem('none_key', 'defaultValue') sessionStorage.removeItem('test') sessionStorage.clear() ``` -------------------------------- ### WorldClock Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt World Clock Sensor API for Zepp OS. Provides methods to get the number of configured world clocks and retrieve their information. ```APIDOC ## WorldClock ### Description World Clock Sensor. Provides access to configured world clocks. ### Import ```js import { WorldClock } from '@zos/sensor' ``` ### Methods #### getCount Get the number of configured world clocks. ```ts getCount(): number ``` #### getInfo Get the configured world clock information according to the index. ```ts getInfo(index: number): WorldClockInfo ``` ##### WorldClockInfo | Property | Type | Description | API_LEVEL | | -------------- | -------- | ----------------------------------- | --------- | | city | string | City Name | 3.0 | | cityCode | string | City code, e.g. San Francisco `SFO` | 3.0 | | hour | number | Hour | 3.0 | | minute | number | Minute | 3.0 | | timeZoneHour | number | Time Zone hours | 3.0 | | timeZoneMinute | number | Time zone minutes | 3.0 | ### Example ```js import { WorldClock } from '@zos/sensor' const worldClock = new WorldClock() const worldClockCount = worldClock.getCount() for (let i = 0; i < worldClockCount; i++) { const worldClockInfo = worldClock.getInfo(i) console.log(worldClockInfo.city) console.log(worldClockInfo.cityCode) console.log(worldClockInfo.hour) console.log(worldClockInfo.minute) console.log(worldClockInfo.timeZoneHour) console.log(worldClockInfo.timeZoneMinute) } // When not needed for use worldClock.destroy() ``` ``` -------------------------------- ### getTimeFormat Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt Gets the hour format set by the user. Returns a number corresponding to the hour format constants. ```APIDOC ## getTimeFormat ### Description Gets the hour format set by the user. ### Import ```js import { getTimeFormat } from '@zos/settings' ``` ### Type ```ts function getTimeFormat(): Result ``` ### Parameters #### Result - **number** - Hour format, value refer to hour format constants ### Constants #### Hour format constants - `TIME_FORMAT_12` - 12-hour format (API_LEVEL 2.1) - `TIME_FORMAT_24` - 24-hour format (API_LEVEL 2.1) ### Example ```js const timeFormat = getTimeFormat() if (timeFormat === TIME_FORMAT_24) { console.log('time format is 24-hour format') } ``` ``` -------------------------------- ### getApp usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/global/getApp.mdx Example showing how to define an app with globalData and lifecycle callbacks, then retrieve the app instance with getApp() and access its globalData via _options. ```js App({ globalData: { text: 'Hello Zepp OS', }, onCreate() { console.log('onCreate') console.log(this.globalData.text) }, onDestroy() { console.log('onDestroy') }, }) const app = getApp() console.log(app._options.globalData.text) ``` -------------------------------- ### Get and process basic sleep info Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/watchface/api/hmSensor/sensorId/SLEEP.mdx Retrieves basic sleep info and logs score, deepMin, startTime, and endTime. Includes commented-out total time calculation and example logic for converting start and end times to hours and minutes, handling day wrap-around with SLEEP_REFERENCE_ZERO. ```js const basicInfo = sleep.getBasicInfo() console.log('basicInfo score=' + basicInfo.score) //sleep score console.log('basicInfo deepMin=' + basicInfo.deepMin) //deep sleep time unit score console.log('basicInfo startTime=' + basicInfo.startTime) // sleep start time, based on the number of minutes at 0:00 of the day console.log('basicInfo endTime=' + basicInfo.endTime) // sleep end time, minutes from the same base as the start time // sleep totalTime = endTime - startTime + 1; let start = basicInfo.startTime if (start >= SLEEP_REFERENCE_ZERO) { // SLEEP_REFERENCE_ZERO is the number of minutes in a day, i.e. 24*60 start -= SLEEP_REFERENCE_ZERO } hour = start / 60 minute = start % 60 const end = basicInfo.endTime + 1 // if it is aligned with the secondary screen, the end time should be added by 1 if (end >= SLEEP_REFERENCE_ZERO) { end -= SLEEP_REFERENCE_ZERO } hour = end / 60 minute = end % 60 ``` -------------------------------- ### JavaScript import and usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/ble/addListener.mdx Example showing how to import addListener from '@zos/ble'. ```js import { addListener } from '@zos/ble' // ... ``` -------------------------------- ### start() Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/sensor/Accelerometer.mdx Starts listening to accelerometer data. ```APIDOC ## start() ### Description Starts listening to accelerometer data. ### Method start ### Signature ts start(): void ### Parameters None ### Returns void ``` -------------------------------- ### Vibrator Example Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms/@zos-sensor.md Creates a Vibrator instance, starts vibration, then sets the scene to duration mode and starts again. ```javascript const vibrator = new Vibrator() vibrator.start() // set scene vibrator.setMode(VIBRATOR_SCENE_DURATION) vibrator.start() ``` -------------------------------- ### mstOnPrepare Usage Example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/ble/mstOnPrepare.mdx Example of importing mstOnPrepare from '@zos/ble'. ```js import { mstOnPrepare } from '@zos/ble' // ... ``` -------------------------------- ### Example: using getSwiperIndex Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms/@zos-page.md Shows a minimal usage example: get the scroll top of the current page. ```javascript const top = getScrollTop() console.log(top) ``` -------------------------------- ### statAssetsSync usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/fs/statAssetsSync.mdx Example of importing and using `statAssetsSync` to get file information and log its size. ```js import { statAssetsSync } from '@zos/fs' const result = statAssetsSync({ path: 'test.txt', }) if (result) { const { size } = result console.log(size) } ``` -------------------------------- ### home usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/router/home.mdx JavaScript example importing `home` from `@zos/router` and calling it to exit the Mini Program. ```js import { home } from '@zos/router' home() ``` -------------------------------- ### Buzzer Example: Page with Scene List and Start Button Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms/@zos-sensor.md Full Page example that cycles through alarm types (ALARM, REMIND_1, etc.) and starts the buzzer if enabled. It creates a text widget to show the current scene and a button to trigger the buzzer. The example uses the Buzzer API from @zos/sensor. ```javascript const sceneList = ['ALARM', 'REMIND_1', 'REMIND_2', 'OPERATE', 'SUCCESS', 'FAILURE'] Page({ state: { pageName: 'BUZZER', currentIndex: 0, }, build() { const buzzer = new Buzzer() const sceneText = createWidget(widget.TEXT, { x: px(0), y: px(120), w: px(480), h: px(46), color: 0xffffff, text_size: px(20), align_h: align.CENTER_H, align_v: align.CENTER_V, text_style: text_style.NONE, text: `${sceneList[this.state.currentIndex]}`, }) const startBuzzer = () => { const alarmType = buzzer.getSourceType()[sceneList[this.state.currentIndex]] if (buzzer.isEnabled()) { buzzer.start(alarmType) } this.state.currentIndex = (this.state.currentIndex + 1) % sceneList.length sceneText.setProperty(prop.MORE, { text: `BUZZER: ${sceneList[this.state.currentIndex]}`, }) } createWidget(widget.BUTTON, { x: px(80), y: px(300), w: px(300), h: px(60), radius: px(12), normal_color: 0xfc6950, press_color: 0xfeb4a8, text: 'START BUZZER', click_func: startBuzzer, }) }, }) ``` -------------------------------- ### mkdirSync Example (Repeated) Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms/@zos-fs.md Synchronously creates a directory in the /data directory of the Mini Program. The function returns 0 on success, and the example logs a success message when the result is 0. ```js const result = mkdirSync({ path: 'content', }) if (result === 0) { console.log('mkdirSync success') } ``` -------------------------------- ### Example usage of getSettings Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/display/getSettings.mdx Example usage of getSettings, importing it from '@zos/display' and logging the result to the console. ```js import { getSettings } from '@zos/display' console.log(getSettings()) ``` -------------------------------- ### Get language code with getLanguage (no import) Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms/@zos-settings.md Example showing how to get the language code and log it, without the import statement. ```javascript const languageCode = getLanguage() console.log(languageCode) ``` -------------------------------- ### Buzzer: Full example with UI and start() Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms/@zos-sensor.md Complete Buzzer example that creates a text widget and a button. Pressing the button starts the buzzer with the current scene type if enabled, then cycles to the next scene. Requires API_LEVEL 3.6 or higher. ```js import { createWidget, widget, prop, align, text_style } from "@zos/ui"; import { Buzzer } from "@zos/sensor"; import { px } from "@zos/utils"; const sceneList = ['ALARM', 'REMIND_1', 'REMIND_2', 'OPERATE', 'SUCCESS', 'FAILURE'] Page({ state: { pageName: "BUZZER", currentIndex: 0 }, build() { const buzzer = new Buzzer(); const sceneText = createWidget(widget.TEXT, { x: px(0), y: px(120), w: px(480), h: px(46), color: 0xffffff, text_size: px(20), align_h: align.CENTER_H, align_v: align.CENTER_V, text_style: text_style.NONE, text: `${sceneList[this.state.currentIndex]}`, }); const startBuzzer = () => { const alarmType = buzzer.getSourceType()[sceneList[this.state.currentIndex]]; if (buzzer.isEnabled()) { buzzer.start(alarmType); } this.state.currentIndex = (this.state.currentIndex + 1) % sceneList.length sceneText.setProperty(prop.MORE, { text: `BUZZER: ${sceneList[this.state.currentIndex]}`, }); }; createWidget(widget.BUTTON, { x: px(80), y: px(300), w: px(300), h: px(60), radius: px(12), normal_color: 0xfc6950, press_color: 0xfeb4a8, text: "START BUZZER", click_func: startBuzzer, }); }, }); ``` -------------------------------- ### getSystemInfo Usage Example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/settings/getSystemInfo.mdx JavaScript example showing how to import getSystemInfo from '@zos/settings' and log the minAPI value. ```js import { getSystemInfo } from '@zos/settings' const { minAPI } = getSystemInfo() console.log(minAPI) ``` -------------------------------- ### Complete VIBRATE usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/watchface/api/hmSensor/sensorId/VIBRATE.mdx Complete example showing creation, setting scene to 25, starting vibration, and stopping on page destroy. ```javascript const vibrate = hmSensor.createSensor(hmSensor.id.VIBRATE) function click() { vibrate.stop() vibrate.scene = 25 vibrate.start() } click() Page({ onDestroy() { vibrate && vibrate.stop() } }) ``` -------------------------------- ### TypedStorage usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/storage/TypedStorage.mdx Shows how to import TypedStorage, create an instance, and use put/get methods. ```js import { TypedStorage } from '@zos/storage' const storage = new TypedStorage() storage.putBool('enabled', true) storage.putInt('count', 1) const enabled = storage.getBool('enabled', false) const count = storage.getInt('count', 0) ``` -------------------------------- ### Example: updateLayoutStyle() with Flex layout Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/ui/updateLayoutStyle.mdx JavaScript example showing how to import createWidget and widget from @zos/ui, create a virtual container, and update its layout style with flex properties such as display, flex-direction, justify-content, align-items, width, and height. ```js import { createWidget, widget } from '@zos/ui' const container = createWidget(widget.VIRTUAL_CONTAINER) // Update container layout style container.updateLayoutStyle({ display: 'flex', 'flex-direction': 'row', 'justify-content': 'space-between', 'align-items': 'center', width: '100%', height: '200px' }) ``` -------------------------------- ### Vibrator usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/sensor/Vibrator.mdx Creates a Vibrator instance, starts it, sets the scene mode to VIBRATOR_SCENE_DURATION, and starts again. Requires importing Vibrator and VIBRATOR_SCENE_DURATION from '@zos/sensor'. ```js import { Vibrator, VIBRATOR_SCENE_DURATION } from '@zos/sensor' const vibrator = new Vibrator() vibrator.start() // set scene vibrator.setMode(VIBRATOR_SCENE_DURATION) vibrator.start() ``` -------------------------------- ### clearLaunchAppTimeout usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/router/clearLaunchAppTimeout.mdx Example showing how to set a launch app timeout and then cancel it using clearLaunchAppTimeout. ```js import { setLaunchAppTimeout, clearLaunchAppTimeout } from '@zos/router' const timeoutId = setLaunchAppTimeout({ url: 'pages/js_widget_sample', appId: 1000001, delay: 10000, }) clearLaunchAppTimeout({ timeoutId, }) ``` -------------------------------- ### Accelerometer usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/sensor/Accelerometer.mdx Example of using the Accelerometer API: import, create instance, register callback, set frequency mode, start, and stop. ```js import { Accelerometer, FREQ_MODE_NORMAL } from '@zos/sensor' const accelerometer = new Accelerometer() const callback = () => { console.log(accelerometer.getCurrent()) } accelerometer.onChange(callback) accelerometer.setFreqMode(FREQ_MODE_NORMAL) accelerometer.start() // When not needed for use accelerometer.offChange() accelerometer.stop() ``` -------------------------------- ### Create a project with Zeus CLI Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/guides/quick-start/create.mdx Creates a new Mini Program project template named hello-world using the Zeus CLI. Follow the command line prompts shown in the animation. After successful execution, a new directory named /hello-world is created. ```sh zeus create hello-world ``` -------------------------------- ### showToast usage example Source: https://github.com/zepp-health/zeppos-docs/blob/main/docs/reference/device-app-api/newAPI/interaction/showToast.mdx Example of importing and calling showToast with a content option to display 'hello world'. ```js import { showToast } from '@zos/interaction' showToast({ content: 'hello world', }) ``` -------------------------------- ### SystemSounds Source: https://github.com/zepp-health/zeppos-docs/blob/main/static/llms-full.txt Documentation for the SystemSounds class from the @zos/sensor module, including methods to get enabled status, get source types, start and stop playback. ```APIDOC ## SystemSounds ### Import ```js import { SystemSounds } from '@zos/sensor' ``` ### Typings - Description: System Sounds - API_LEVEL: 3.6 - Example: ```js import { SystemSounds } from '@zos/sensor' const systemSounds = new SystemSounds() const alarmType = systemSounds.getSourceType().ALARM if (systemSounds.getEnabled()) { systemSounds.start(alarmType) } ``` > Start from API_LEVEL `3.6` . Please refer to [API_LEVEL](https://docs.zepp.com/docs/guides/framework/device/compatibility). System Sounds. ### Methods #### getEnabled Get whether the system ringtone function is turned on, and it can only be played after it is turned on ```ts getEnabled(): boolean ``` #### getSourceType Get built-in system ringtone type ```ts getSourceType(): Type ``` ##### Type | Property | Type | Required | DefaultValue | Description | API_LEVEL | | -------- | ------------------- | -------- | ------------ | --------------------------------------------------------- | --------- | | ALARM | `number` | Y | - | Alarm clock reminder | 3.6 | | MESSAGE | `number` | Y | - | Notification sound when receiving text messages or emails | 3.6 | | REGULAR | `number` | Y | - | TingTing sound | 3.6 | | ACHIEVE | `number` | Y | - | Goals achieved | 3.6 | | CAMERA | `number` | Y | - | Camera shutter | 3.6 | | ABN_HIGH | `number` | Y | - | Health data measurement abnormalities (high values) | 3.6 | | ABN_LOW | `number` | Y | - | Health data measurement abnormalities (low values) | 3.6 | | SOS | `number` | Y | - | SOS for help | 3.6 | #### start Start playing the sound, you can pass in `type` to specify the ringtone type, `repeatCount` is the number of audio repetitions, default is `0`, do not repeat playback ```ts start(sourceType: number, repeatCount: 0): void ``` #### stop Stop sound playback ```ts stop(): void ``` ```