This API is called using wx.startGyroscope(Object object).
Property | Type | Default value | Required | Description |
interval | string | normal | False | The execution frequency of the callback function that listens for gyroscope data. |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
Value | Description |
game | Callback frequency suitable for game updates, about 20 ms/time. |
ui | Callback frequency suitable for UI updates, about 60 ms/time. |
normal | Normal callback frequency, about 200 ms/time. |
This API is called using wx.stopGyroscope(Object object).
Property | Type | Default value | Required | Description |
success | function | - | False | Callback function for successful API calls. |
fail | function | - | False | Callback function for failed API calls. |
complete | function | - | False | Callback function executed after API call ends (regardless of success or failure). |
This API is called using wx.onGyroscopeChange(function listener).
Property | Type | Description |
x | number | The angular velocity around the x-axis. |
y | number | The angular velocity around the y-axis. |
z | number | The angular velocity around the z-axis. |
This API is called using wx.offGyroscopeChange(function listener).
const listener = function (res) { console.log(res) }wx.onGyroscopeChange(listener)wx.offGyroscopeChange(listener) // Must pass the same function object used in onGyroscopeChange