Motor driving method and terminal equipment

CN119769017APending Publication Date: 2025-04-04HONOR DEVICE CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202380061463.6
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Priority Date
2022-11-22
Filing Date
2023-09-08
Publication Date
2025-04-04

AI Technical Summary

Technical Problem

In the prior art, the linear motor does not reach the maximum vibration in a short time, resulting in the user not being able to perceive the vibration and affecting the user experience.

Method used

By controlling the voltage waveform output by the vibration chip, the linear motor can quickly reach the maximum amplitude in a short time and maintain the maximum value at an appropriate voltage, ensuring that the user perceives vibration.

Benefits of technology

It improves the amplitude and user experience of the linear motor in a short time, ensures that users can clearly perceive vibration, and improves the user experience of terminal equipment.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119769017A_ABST
    Figure CN119769017A_ABST
Patent Text Reader

Abstract

The invention provides a motor driving method and terminal equipment, and relates to the technical field of motor driving. According to the method, the amplitude of the linear motor can be increased to the maximum value from 0 in a short time, so that a user can clearly feel vibration. The method comprises the following steps: receiving a first vibration event, wherein the first vibration event is used for triggering motor vibration; in response to the first vibration event, controlling the vibration chip to output a first voltage to the motor within a first duration so as to enable the amplitude of the motor to reach a maximum value at the end of the first duration, and controlling the vibration chip to start to output a second voltage to the motor from the end of the first duration so as to enable the amplitude of the motor to be kept at the maximum value; wherein the first voltage and the second voltage are in the same direction, and the absolute value of the first voltage is larger than that of the second voltage.
Need to check novelty before this filing date? Find Prior Art

Description

A method for driving a motor and a terminal device

[0001] This application claims priority to the Chinese patent application filed with the State Intellectual Property Office on November 22, 2022, with application number 202211466439.4 and invention name “A method and terminal device for driving a motor”, the entire contents of which are incorporated by reference into this application. Technical Field

[0002] The present application relates to the field of motor drive technology, and in particular to a method and terminal device for driving a motor. Background Art

[0003] At present, in order to improve the user experience when using terminal devices, when the user performs certain operations on the terminal, the terminal can prompt the user by vibration. For example, when the user is playing games on the terminal, the terminal can vibrate when the user performs preset operations to give the user tactile feedback and an immersive experience. The vibration of the terminal is achieved by the vibration of a motor installed in the terminal. Motors can be divided into nonlinear motors and linear motors. Compared with nonlinear motors that are controlled by on-off power and have only two modes of start and stop, linear motors can be driven by pulse voltage signals, and according to the period, amplitude, and frequency of the pulse voltage signal, linear motors can vibrate in different ways and intensities, giving users a rich vibration experience.

[0004] In the prior art, considering the compatibility of nonlinear motors and linear motors, when some third-party applications have vibration requirements, they can call the universal vibration interface provided by the operating system to send a vibration request to the motor driver, so that the motor driver outputs a driving voltage with the rated frequency and rated voltage to continuously drive the motor to vibrate. Under the action of the driving voltage, the vibration intensity of the linear motor gradually increases over time to the maximum intensity and maintains the maximum intensity for continuous vibration. For some extremely short vibrations, the vibration intensity of the linear motor needs to stop before it reaches the maximum, which results in a weak vibration intensity and the user may not feel the vibration.

[0005] Summary of the Invention

[0006] The embodiments of the present application provide a method and a terminal device for driving a motor, which can increase the amplitude of a linear motor in a short period of time.

[0007] To achieve the above objectives, the embodiments of the present application adopt the following technical solutions:

[0008] In a first aspect, a method for driving a motor is provided, which is applied to a terminal device. The terminal device includes a vibration chip and a linear motor. The method comprises: receiving a first vibration event for triggering vibration of the motor, wherein the first vibration event may include any one of receiving an operation by a user to unlock the terminal device, receiving an operation by a user to make an online payment, receiving an operation by a user to enter a face, receiving an operation by a user to release a skill, receiving an incoming call request, or the current time matching a preset time. In response to the first vibration event, the vibration chip is controlled to output a first voltage to the motor for a first duration so that the motor's amplitude reaches a maximum value at the end of the first duration, and the vibration chip is controlled to output a second voltage to the motor starting at the end of the first duration so that the motor's amplitude remains at the maximum value. The first voltage and the second voltage are in the same direction, and the absolute value of the first voltage is greater than the absolute value of the second voltage. In this manner, the motor's amplitude rapidly reaches its maximum value under the action of the first voltage and then remains at its maximum value under the action of the second voltage. In other words, the motor's amplitude can reach its maximum value even when the vibration duration is very short, providing a noticeable vibration sensation to the user and improving the user experience.

[0009] In one embodiment provided in the first aspect, in response to a first vibration event, controlling the vibration chip to output a first voltage to the motor within a first duration so that the motor's amplitude reaches a maximum value at the end of the first duration, and controlling the vibration chip to output a second voltage to the motor starting from the end of the first duration so that the motor's amplitude remains at the maximum value, further comprising: obtaining vibration parameters of the motor in response to the first vibration event; if the vibration parameters do not include the vibration duration, controlling the vibration chip to output the first voltage to the motor within the first duration so that the motor's amplitude reaches a maximum value at the end of the first duration, and controlling the vibration chip to output the second voltage to the motor starting from the end of the first duration so that the motor's amplitude remains at the maximum value. It is understood that, depending on the actual settings of the application, the vibration parameters may include or exclude the vibration duration. If the vibration parameters do not include the vibration duration, the terminal device may first control the motor to start quickly and then control the motor to stop vibrating later.

[0010] In one embodiment provided in the first aspect, the method further includes: controlling the vibration chip to output a third voltage to the motor when a preset time period has elapsed since the start of a first vibration event received from the terminal device, so as to reduce the amplitude of the motor from a maximum value to zero within a second time period; wherein the third voltage is opposite to the second voltage, and the absolute value of the third voltage is greater than the absolute value of the second voltage, and the preset time period is greater than the first time period. Typically, each vibration event may correspond to a theoretical vibration time period. For example, the theoretical vibration time period corresponding to the first vibration event is a preset time period, meaning that the terminal device needs to control the motor to stop vibrating after receiving the preset time period from the start of the first vibration event. Therefore, controlling the vibration chip to output the third voltage to the motor when the preset time period from the start of the first vibration event received from the terminal device has elapsed, so as to stop the motor from vibrating. For example, if the terminal device receives a first vibration event at 10:00, and the first vibration event requires the motor to stop vibrating after 1 minute, the terminal device may output the third voltage to the motor at 10:01 to control the motor to stop vibrating. At the same time, compared with the method of stopping the output voltage to stop the motor from vibrating, this embodiment can quickly stop the motor from vibrating and reduce vibration tailing by outputting a third voltage that is opposite to the second voltage and larger than the second voltage.

[0011] In one embodiment provided in the first aspect, the method further includes: controlling the vibration chip to output a third voltage to the motor when the actual vibration duration of the motor reaches a first value, so that the amplitude of the motor is reduced from a maximum value to 0 within a second duration; wherein the third voltage is opposite to the second voltage, and the absolute value of the third voltage is greater than the absolute value of the second voltage. In other words, the terminal device can obtain the actual vibration duration of the motor in real time, and when the actual vibration duration reaches the first value, output a third voltage to the motor to stop the motor from vibrating, so as to reduce the situation where the actual vibration duration of the motor is too short and the user cannot perceive the vibration. In addition, the first value can be the theoretical vibration duration corresponding to the first vibration event (i.e., the aforementioned preset duration), or the first value can be other parameters. For details, see below and are not described here. At the same time, compared to the method of stopping the output voltage to stop the motor from vibrating, this embodiment can quickly stop the motor from vibrating and reduce vibration tailing by outputting a third voltage that is opposite to the second voltage and greater than the second voltage.

[0012] In an embodiment provided in the first aspect, in response to a first vibration event, the vibration chip is controlled to output a first voltage to the motor within a first time period so that the amplitude of the motor reaches a maximum value at the end of the first time period, and the vibration chip is controlled to output a second voltage to the motor starting from the end of the first time period so that the amplitude of the motor is maintained at a maximum value, further comprising: in response to the first vibration event, obtaining the vibration parameters of the motor; when the vibration parameters include the vibration time period, the vibration chip is controlled to output the first voltage to the motor within the first time period so that the amplitude of the motor reaches a maximum value at the end of the first time period, and the vibration chip is controlled to output the second voltage to the motor within the vibration time period starting from the end of the first time period so that the amplitude of the motor is maintained at a maximum value, and the vibration chip is controlled to output a third voltage to the motor starting from the end of the vibration time period so that the amplitude of the motor is reduced from the maximum value to 0 within the second time period; wherein the third voltage is opposite to the second voltage, and the absolute value of the third voltage is greater than the absolute value of the second voltage. It can be understood that when the vibration parameters include vibration duration, the terminal device is clear about the duration for which the motor needs to vibrate, and therefore can output a second voltage to the motor within the vibration duration starting from the end of the first duration, so that the actual vibration duration of the motor can reach the vibration duration included in the vibration parameters.

[0013] In an embodiment provided in the first aspect, the vibration chip is controlled to output a first voltage to the motor within a first duration so that the amplitude of the motor reaches a maximum value at the end of the first duration, and the vibration chip is controlled to output a second voltage to the motor within the vibration duration from the end of the first duration so that the amplitude of the motor is maintained at the maximum value, and the vibration chip is controlled to output a third voltage to the motor from the end of the vibration duration so that the amplitude of the motor is reduced from the maximum value to 0 within the second duration, further comprising: if the vibration duration is less than a second value, the vibration chip is controlled to output the first voltage to the motor within the first duration so that the amplitude of the motor reaches a maximum value at the end of the first duration, and the vibration chip is controlled to output the second voltage to the motor within the vibration duration from the end of the first duration so that the amplitude of the motor is maintained at the maximum value, and the vibration chip is controlled to output the third voltage to the motor from the end of the vibration duration so that the amplitude of the motor is reduced from the maximum value to 0 within the second duration. In this way, for vibration events with a vibration duration greater than or equal to the second value and vibration events with a vibration duration less than the second value, the terminal device can use different driving methods to control the motor vibration. Among them, for vibration events with a vibration duration greater than or equal to the second value, the amplitude of the motor is less affected by the vibration duration, so the conventional method can be used to drive the motor to vibrate; for vibration events with a vibration duration less than the second value, the amplitude of the motor is more affected by the vibration duration, and the shorter the vibration duration, the smaller the amplitude of the motor, that is, the user is not easy to perceive the vibration, so the amplitude of the motor can be quickly made to reach the maximum value to reduce the impact of the vibration duration on the amplitude and give the user a clear vibration feeling.

[0014] In one embodiment provided in the first aspect, the first vibration event includes one of the following: receiving an operation of the user unlocking the terminal device, receiving an operation of the user making an online payment, receiving an operation of the user entering a face, receiving an operation of the user releasing a skill, receiving an incoming call request, or the current time matches the preset time.

[0015] In an embodiment provided in the first aspect, a terminal device includes a first application, a vibration service, a vibration hardware abstraction layer HAL and a vibration driver; wherein the vibration HAL includes a type judgment module, a first interface and a second interface, and in response to a first vibration event, controls the vibration chip to output a first voltage to the motor within a first time period so that the amplitude of the motor reaches a maximum value at the end of the first time period, and controls the vibration chip to output a second voltage to the motor starting from the end of the first time period so that the amplitude of the motor is maintained at a maximum value, further comprising: in response to the first vibration event, the first application sends a vibration request to the vibration service; the vibration service sends a vibration request to the type judgment module, the vibration request including vibration parameters; the type judgment module determines whether the motor is a linear motor; in the vibration parameters When the type of number indicates that the vibration interface is the first interface, the type judgment module sends a vibration request and a message indicating that the motor is a linear motor to the first interface; the first interface sends a vibration request to the second interface; the second interface updates the vibration parameter based on the first parameter, and the first parameter is used to describe the vibration waveform generated by the motor vibrating for a first time under the action of a first voltage; the second interface sends the first vibration parameter to the vibration driver, and the first vibration parameter is the vibration parameter updated based on the first parameter; the vibration driver writes the first vibration parameter into the vibration chip; the vibration chip outputs a first voltage to the motor within the first time so that the amplitude of the motor reaches the maximum value at the end of the first time, and starts to output a second voltage to the motor from the end of the first time so that the amplitude of the motor remains at the maximum value.

[0016] In an implementation manner provided by the first aspect, updating the vibration parameter based on the first parameter by the second interface further includes: when the vibration parameter does not include vibration duration, the second interface updates the vibration parameter based on the first parameter.

[0017] In an embodiment provided in the first aspect, the method also includes: the first application sends a request to stop vibration to the vibration service at the end of a preset time period starting from receiving the first vibration event; the vibration service sends a request to stop vibration to the first interface; the first interface sends a second parameter to the vibration driver, and the second parameter is used to describe the vibration waveform generated by the motor vibrating for a second time period under the action of a third voltage; the vibration driver writes the second parameter into the vibration chip; and the vibration chip outputs a third voltage to the motor to reduce the amplitude of the motor from a maximum value to 0 within the second time period.

[0018] In an embodiment provided in the first aspect, the method also includes: in response to receiving a vibration request, the second interface starts a first timer to obtain a third duration; in response to receiving a request to stop vibration, the first interface starts a second timer to obtain a fourth duration; the first interface sends a second parameter to the vibration driver, further including: when the actual vibration duration of the motor reaches a first value, the first interface sends a second parameter to the vibration driver, and the first value is the difference between the third duration and the fourth duration.

[0019] In one embodiment provided in the first aspect, the method also includes: when the vibration parameters include vibration duration, the second interface updates the vibration parameters based on the first parameters and the second parameters, the second parameter being used to describe the vibration waveform generated by the motor vibrating for a second duration under the action of a third voltage; the second interface sends the second vibration parameters to the vibration driver, the second vibration parameters being the updated vibration parameters based on the first parameters and the second parameters; the vibration driver writes the second vibration parameters into the vibration chip; the vibration chip outputs a first voltage to the motor within the first duration so that the amplitude of the motor reaches a maximum value at the end of the first duration, and outputs a second voltage to the motor from the end of the first duration within the vibration duration so that the amplitude of the motor remains at the maximum value, and outputs a third voltage to the motor from the end of the vibration duration so that the amplitude of the motor decreases from the maximum value to 0 within the second duration; wherein the third voltage is opposite to the second voltage, and the absolute value of the third voltage is greater than the absolute value of the second voltage.

[0020] In an embodiment provided in the first aspect, when the vibration parameters include vibration duration, the second interface updates the vibration parameters based on the first parameters and the second parameters, further including: when the vibration parameters include vibration duration and the vibration duration is less than the second value, the second interface updates the vibration parameters based on the first parameters and the second parameters.

[0021] In an embodiment provided in the first aspect, the method also includes: the first interface determines whether the vibration duration is less than a second value; the first interface sends a vibration request to the second interface, further including: if the vibration duration is less than the second value, the first interface sends a vibration request to the second interface.

[0022] In an embodiment provided in the first aspect, in response to a first vibration event, a first application sends a vibration request to a vibration service, including: in response to the first vibration event, the first application sends a request to the vibration service to turn on the motor; the vibration service detects whether a motor exists and sends a detection result to the first application; if the detection result indicates that a motor exists, the first application sends a vibration request to the vibration service.

[0023] In a second aspect, the present application provides a chip system comprising one or more interface circuits and one or more processors. The interface circuit and the processor are interconnected via a circuit. The chip system can be applied to an electronic device comprising a communication module and a memory. The interface circuit is configured to receive a signal from the memory of the electronic device and send the received signal to the processor, the signal comprising a computer instruction stored in the memory. When the processor executes the computer instruction, the electronic device can execute the method described in the first aspect and any possible design thereof.

[0024] In a third aspect, the present application provides a computer-readable storage medium comprising computer instructions. When the computer instructions are executed on a terminal device (such as a mobile phone), the terminal device executes the method described in the first aspect and any possible design thereof.

[0025] In a fourth aspect, the present application provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute the method described in the first aspect and any possible design thereof.

[0026] In a fifth aspect, the present application provides a terminal device, comprising: a memory and one or more processors; the memory is coupled to the processor; wherein the memory is used to store computer program code, and the computer program code includes computer instructions; when the computer instructions are executed by the processor, the terminal device executes the method described in the first aspect and any possible design method thereof.

[0027] Among them, the technical effects brought about by any design method in the fourth to fifth aspects can refer to the technical effects brought about by different design methods in the first aspect, and will not be repeated here. BRIEF DESCRIPTION OF THE DRAWINGS

[0028] FIG1 is a waveform diagram of a driving voltage signal S1 and a vibration acceleration signal S2 of a linear motor;

[0029] FIG2 is a waveform diagram of a driving voltage signal S3 and a vibration acceleration signal S4 of a linear motor;

[0030] FIG3 is a schematic structural diagram of a terminal device provided in an embodiment of the present application;

[0031] FIG4 is a schematic diagram of a software module architecture of a terminal device provided in an embodiment of the present application;

[0032] FIG5 is a schematic diagram of interaction between software modules provided in an embodiment of the present application;

[0033] FIG6 is a first flow chart of a method for driving a motor provided in an embodiment of the present application;

[0034] FIG7 is a waveform diagram of a driving voltage signal S5 and a vibration acceleration signal S6 provided in an embodiment of the present application;

[0035] FIG8 is a second flow chart of a method for driving a motor provided in an embodiment of the present application;

[0036] FIG9 is a third flow chart of a method for driving a motor provided in an embodiment of the present application;

[0037] FIG10 is a time node diagram of a motor vibration process according to an embodiment of the present application;

[0038] FIG11 is a fourth flow chart of a method for driving a motor provided in an embodiment of the present application;

[0039] FIG12 is a time node diagram of another motor vibration process provided in an embodiment of the present application. DETAILED DESCRIPTION

[0040] The following description of exemplary embodiments of the present application is made in conjunction with the accompanying drawings, including various details of the embodiments of the present application to facilitate understanding, which should be considered as merely exemplary. Therefore, those skilled in the art will recognize that various changes and modifications may be made to the embodiments described herein without departing from the scope and spirit of the present application. Similarly, for the sake of clarity and conciseness, descriptions of well-known functions and structures are omitted in the following description.

[0041] In order to make the description of the following embodiments clear and concise, a brief introduction to the relevant technology is first given.

[0042] Nonlinear motors, also known as rotor motors, can include iron core motors and flat motors. They generate vibrations by rotating the eccentric mass (also called the rotor) on the shaft when the shaft is powered.

[0043] A linear motor uses a pulsed voltage signal to generate a varying electromagnetic field, which in turn drives a magnet to drive a mass in periodic motion. Varying the frequency and amplitude of the pulsed voltage signal results in varying vibration intensities in the linear motor.

[0044] The resonant frequency, also known as the natural frequency, is the frequency at which a linear motor resonates. When the drive voltage is at this resonant frequency, the linear motor vibrates at the resonant frequency with maximum amplitude, meaning maximum vibration intensity.

[0045] Currently, in addition to providing user prompts through sound, terminals can also provide user prompts through vibration to enhance the user experience. For example, in a conference scenario, when a user performs certain operations on their phone, the phone can vibrate to prevent the phone's prompt sound from interfering with other users in the meeting. Another example is when a phone receives an incoming call, the phone can simultaneously ring and vibrate to prompt the user to respond promptly. In particular, when a user performs certain operations on the terminal, to enhance the user experience, the terminal can provide timely vibration feedback upon detecting the user's operation. In some scenarios, the terminal vibrates for a short period of time, meaning that the terminal is vibrating briefly. In this case, the terminal's vibration should not be too long to avoid affecting the user experience. This requires the linear motor in the terminal to be able to start and stop quickly.

[0046] However, given the ability to adapt to both nonlinear motors and linear motors, some third-party applications with vibration requirements can use the universal vibration interface provided by the operating system to transmit vibration parameters, so that the vibration chip outputs a drive voltage with the rated frequency and rated voltage to drive the motor to vibrate. Figure 1 shows a waveform diagram of a drive voltage signal S1 and a vibration acceleration signal S2 for a linear motor. Drive voltage signal S1 is the drive voltage output by the vibration chip to the linear motor, with a duration of 0 to 500 ms. Vibration acceleration signal S2 indicates the vibration acceleration generated by the linear motor under the action of drive voltage signal S1. Furthermore, the frequency of drive voltage signal S1 is the resonant frequency f0 of the linear motor, and accordingly, the frequency of vibration acceleration signal S2 is also the resonant frequency f0 of the linear motor. As shown in Figure 1, under the action of drive voltage signal S1, the vibration process of the linear motor from start to stop can include three stages: start-up stage P1, steady-state stage P2, and braking stage P3. During start-up stage P1 and steady-state stage P2, the vibration chip stably outputs drive voltage signal S1. After stopping the output of the drive voltage signal S1, the braking phase P3 begins. During the startup phase P1 (0-80 ms), the amplitude of the vibration acceleration signal S2 increases from 0 to a maximum value (e.g., 0.65 V), indicating that the linear motor's startup amplitude gradually increases. During the steady-state phase P2 (80-500 ms), the amplitude of the vibration acceleration signal S6 remains at its maximum value, indicating that the linear motor's amplitude remains at its maximum value. During the braking phase P3 (500-710 ms), the amplitude of the vibration acceleration signal S2 gradually decreases from its maximum value to 0, indicating that the linear motor is damping vibration until it stops.

[0047] It can be seen that under the action of the driving voltage, the amplitude of the linear motor (also known as the vibration intensity) gradually increases to a maximum value over time and remains at the maximum value; after not receiving the driving voltage, the linear motor ends the vibration with damped oscillation. This is for scenarios where the linear motor needs to start and stop quickly, and the vibration intensity of the linear motor needs to stop before it reaches the maximum. For example, Figure 2 shows a waveform diagram of a driving voltage signal S3 and a vibration acceleration signal S4 of a linear motor. Among them, the driving voltage signal S3 is the driving voltage output by the vibration chip to the linear motor, and its duration is 0 to 50ms. The vibration acceleration signal S4 is used to indicate the vibration acceleration generated by the linear motor under the action of the driving voltage signal S3. According to Figure 2, the vibration chip outputs the driving voltage signal S3 to the linear motor from the 0th second and stops outputting the driving voltage signal S3 at the 50th ms. At the same time, the amplitude of the vibration acceleration signal S4 increases gradually during the period from 0 to 50ms, and gradually decreases to 0 starting at the 50th ms. Comparing Figures 1 and 2, we can see that the linear motor first enters the starting phase P1 (0-50ms) under the action of drive voltage signal S3, and then directly enters the braking phase P3 (50-189ms) due to the disappearance of drive voltage signal S3. In other words, the vibration amplitude of the linear motor begins to decrease before reaching its maximum value.

[0048] It can be seen that in scenarios where the linear motor needs to start and stop quickly, the existing technology has a problem that the user cannot perceive the vibration due to the small amplitude during the rapid start and stop of the linear motor, and the user cannot be reminded by vibration.

[0049] In light of this, the present application provides a motor driving method for use in a terminal device including a linear motor. The terminal device can provide a first voltage to the linear motor upon startup, causing the linear motor's amplitude to quickly reach a maximum value under the influence of the first voltage. This allows the linear motor to vibrate at its maximum amplitude, making the vibration more easily perceptible to the user, effectively alerting the user and improving the user experience.

[0050] It should be noted that the terminal device described in this embodiment may be a mobile phone, a tablet computer, a personal communication service (PCS) phone, a virtual reality (VR) terminal device, an augmented reality (AR) terminal device, a wireless terminal in industrial control, a wireless terminal in self-driving, a wireless terminal in remote medical surgery, a wireless terminal in a smart grid, a wireless terminal in transportation safety, a wireless terminal in a smart city, a wireless terminal in a smart home, etc., and no specific limitation is made here.

[0051] Figure 3 is a schematic diagram of the structure of a terminal device provided in an embodiment of the present application. As shown in Figure 3, the terminal device may include: a processor 210, an external memory interface 220, an internal memory 221, a universal serial bus (USB) interface 230, a charging management module 240, a power management module 241, a battery 242, an antenna 1, an antenna 2, a mobile communication module 250, a wireless communication module 260, an audio module 270, a speaker 270A, a receiver 270B, a microphone 270C, an earphone interface 270D, a sensor module 280, a button 290, a motor 291, an indicator 292, a camera 293, a display 294, and a subscriber identification module (SIM) card interface 295, etc.

[0052] The processor 210 may include one or more processing units, for example, the processor 210 may include an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a memory, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural-network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors. The processor 210 may be the nerve center and command center of the terminal device. The processor 210 may generate an operation control signal based on the instruction opcode and timing signal to complete the control of instruction fetching and execution.

[0053] Processor 210 may also include a memory for storing instructions and data. In some embodiments, the memory in processor 210 is a cache memory. This memory can store instructions or data that have just been used or are being recycled by processor 210. If processor 210 needs to use the same instruction or data again, it can directly access the memory. This avoids duplicate accesses, reduces processor 210 latency, and thus improves system efficiency.

[0054] In some embodiments, the processor 210 may include one or more interfaces. The interfaces may include an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a subscriber identity module (SIM) interface, and / or a universal serial bus (USB) interface.

[0055] The external memory interface 220 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the terminal device. The external memory card communicates with the processor 210 via the external memory interface 220 to implement data storage functions. For example, files such as music and videos can be stored on the external memory card.

[0056] The internal memory 221 can be used to store computer executable program code, which includes instructions. The processor 210 executes various functional applications and data processing of the terminal device by running the instructions stored in the internal memory 221. For example, in an embodiment of the present application, the processor 210 can execute instructions stored in the internal memory 221, and the internal memory 221 can include a program storage area and a data storage area.

[0057] The program storage area can store an operating system, at least one application required for a function (such as a sound playback function, an image playback function, etc.), a configuration file for the motor 291, etc. The data storage area can store data created during the use of the terminal device (such as audio data, a phone book, etc.). In addition, the internal memory 221 can include high-speed random access memory and non-volatile memory, such as at least one disk storage device, a flash memory device, or a universal flash storage (UFS).

[0058] The charging management module 240 is used to receive charging input from a charger. The charger can be a wireless charger or a wired charger. While charging the battery 242, the charging management module 240 can also power the terminal device through the power management module 241.

[0059] The power management module 241 is used to connect the battery 242, the charging management module 240, and the processor 210. The power management module 241 receives input from the battery 242 and / or the charging management module 240 and provides power to the processor 210, the internal memory 221, the external memory, the display 294, the camera 293, and the wireless communication module 260. In some embodiments, the power management module 241 and the charging management module 240 can also be provided in the same device.

[0060] The wireless communication function of the terminal device can be implemented through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor, and baseband processor. In some embodiments, antenna 1 and mobile communication module 250 of the terminal device are coupled, and antenna 2 and wireless communication module 260 are coupled, so that the terminal device can communicate with the network and other devices through wireless communication technology.

[0061] Antenna 1 and Antenna 2 are used to transmit and receive electromagnetic wave signals. Each antenna in the terminal device can be used to cover a single or multiple communication frequency bands. Different antennas can also be reused to improve antenna utilization. For example, antenna 1 can be reused as a diversity antenna for a wireless local area network. In other embodiments, the antennas can be used in conjunction with a tuning switch.

[0062] Mobile communication module 250 can provide wireless communication solutions for terminal devices, including 2G / 3G / 4G / 5G. It can include at least one filter, switch, power amplifier, and low-noise amplifier (LNA). Mobile communication module 250 receives electromagnetic waves from antenna 1, filters and amplifies the received electromagnetic waves, and transmits them to the modem processor for demodulation.

[0063] The mobile communication module 250 can also amplify the signal modulated by the modem processor and convert it into electromagnetic waves for radiation via the antenna 1. In some embodiments, at least some functional modules of the mobile communication module 250 can be set in the processor 210. In some embodiments, at least some functional modules of the mobile communication module 250 can be set in the same device as at least some modules of the processor 210.

[0064] The wireless communication module 260 can provide wireless communication solutions applied to terminal devices, including WLAN (such as wireless fidelity, Wi-Fi network), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication technology (NFC), infrared technology (IR), etc.

[0065] Wireless communication module 260 can be one or more devices that integrate at least one communication processing module. Wireless communication module 260 receives electromagnetic waves via antenna 2, frequency-modulates and filters the electromagnetic wave signals, and transmits the processed signals to processor 210. Wireless communication module 260 can also receive signals to be transmitted from processor 210, frequency-modulate and amplify them, and then convert them into electromagnetic waves for radiation via antenna 2.

[0066] The terminal device can implement audio functions such as music playback and recording through the audio module 270, the speaker 270A, the receiver 270B, the microphone 270C, the headphone jack 270D, and the application processor.

[0067] The sensor module 280 may include a pressure sensor, a gyroscope sensor, an air pressure sensor, a magnetic sensor, an acceleration sensor, a distance sensor, a proximity light sensor, a fingerprint sensor, a temperature sensor, a touch sensor, an ambient light sensor, a bone conduction sensor, and other sensors. The terminal device may collect various data through the sensor module 280.

[0068] The terminal device implements display functionality through a GPU, display screen 294, and an application processor. The GPU is a microprocessor for image processing that connects the display screen 294 and the application processor. The GPU is used to perform mathematical and geometric calculations for graphics rendering. The processor 210 may include one or more GPUs that execute program instructions to generate or modify display information.

[0069] The display screen 294 is used to display images, videos, etc. The display screen 294 includes a display panel.

[0070] The terminal device can implement a camera function through an ISP, a camera 293, a video codec, a GPU, a display 294, and an application processor. The ISP is responsible for processing data fed back by the camera 293. The camera 293 is responsible for capturing still images or videos. In some embodiments, the terminal device may include one or N cameras 293, where N is a positive integer greater than one.

[0071] The buttons 290 include a power button, a volume button, etc. The button 290 can be a mechanical button. It can also be a touch button. The motor 291 can generate a vibration prompt. The motor 291 can be used for an incoming call vibration prompt, or for touch vibration feedback. The indicator 292 can be an indicator light, which can be used to indicate the charging status, power changes, messages, missed calls, notifications, etc. The SIM card interface 295 is used to connect the SIM card. The SIM card can be inserted into the SIM card interface 295, or pulled out from the SIM card interface 295 to achieve contact and separation with the terminal device. The terminal device can support 1 or N SIM card interfaces, where N is a positive integer greater than 1. The SIM card interface 295 can support Nano SIM cards, Micro SIM cards, SIM cards, etc.

[0072] It should be understood that the interface connection relationships between the modules illustrated in this embodiment are merely illustrative and do not constitute a structural limitation on the terminal device. In other embodiments, the terminal device may include more or fewer modules than those provided in the above embodiment, and the modules may also adopt different interface connection methods than those in the above embodiment, or a combination of multiple interface connection methods.

[0073] The software system of the terminal device can adopt a layered architecture, an event-driven architecture, a micro-kernel architecture, a micro-service architecture, or a cloud architecture. The embodiment of the present invention takes the layered architecture of the Android system as an example to exemplify the software structure of the terminal device.

[0074] The layered architecture divides the software into several layers, each with a clear role and division of labor. The layers communicate with each other through interfaces. In some embodiments, the Android system may include an application layer, an application framework layer, an Android runtime (Android runtime) and a system library, a hardware abstraction layer (HAL) and a kernel layer. It should be noted that the embodiments of the present application are illustrated by taking the Android system as an example. In other operating systems (such as Hongmeng system, IOS system, etc.), as long as the functions implemented by each functional module are similar to those of the embodiments of the present application, the solutions of the present application can also be implemented.

[0075] The application layer can include a series of application packages. As shown in Figure 4, the application package can include applications such as camera application, gallery, calendar, call, map, navigation, WLAN, settings, music, lock screen application, short message, etc. Of course, the application layer can also include other application packages, such as payment applications, shopping applications, banking applications, chat applications, financial management applications, and other third-party applications, which are not limited in this application.

[0076] The application framework layer provides an application programming interface (API) and programming framework for applications in the application layer. The application framework layer includes some predefined functions. For example, it may include an activity manager, a window manager, a content provider, a view system, a resource manager, a notification manager, a vibration service, etc., which are not limited in this embodiment of the application. The vibration service is used to provide vibration-related support services.

[0077] The system library can include multiple functional modules, such as the surface manager, media libraries, OpenGL ES, and SGL.

[0078] The surface manager is used to manage the display subsystem and provide fusion of 2D and 3D layers for multiple applications.

[0079] The media library supports playback and recording of a variety of common audio and video formats, as well as static image files. The media library can support a variety of audio and video encoding formats, such as MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, etc.

[0080] OpenGL ES is used to implement 3D graphics drawing, image rendering, compositing, and layer processing.

[0081] SGL is a graphics engine for 2D graphics.

[0082] The Android runtime consists of core libraries and a virtual machine (VM). The Android runtime is responsible for scheduling and management of the Android system. The core libraries consist of two parts: one for Java-based functions and the other for the Android core library. The application layer and application framework layer run in the VM. The VM executes Java files from the application and framework layers as binary files. The VM is responsible for managing object lifecycles, stack management, thread management, security and exception management, and garbage collection.

[0083] The HAL layer is an encapsulation of the Linux kernel driver, providing an interface to the upper layer and shielding the implementation details of the underlying hardware.

[0084] The HAL layer may include a vibration HAL (vibrator HAL), a camera HAL (camera HAL), and the like.

[0085] The vibration HAL may include a type determination module, a general vibration interface, a self-developed vibration interface, and a 4D vibration interface. The type determination module can determine whether a motor is a linear motor or a nonlinear motor by reading the motor's configuration file.

[0086] The universal vibration interface, the self-developed vibration interface, and the 4D vibration interface can all interact with the vibration driver of the core layer. The difference is that the three vibration interfaces can process different vibration parameters. For the specific vibration parameters processed by the three vibration interfaces, please refer to S604 and related descriptions, which will not be repeated here.

[0087] The kernel layer is the layer between hardware and software. It includes at least the display driver, audio driver, camera driver, and vibration driver. The vibration driver is a program that allows high-level computer software to interact with the hardware, essentially driving the motors.

[0088] The hardware layer includes memory, a vibration chip, and a motor. The vibration chip outputs a driving voltage to the motor, driving it to vibrate. The motor vibrates to create a vibration sensation for the user.

[0089] The following describes the interaction between the software modules and modules involved in the method for driving a motor provided in an embodiment of the present application. As shown in Figure 5, the first application in the application layer can interact with the vibration service in the application framework layer by calling a preset application programming interface (API) interface, and the vibration service can interact with the vibration HAL in the HAL layer. The vibration HAL may include a type judgment module, a universal vibration interface, a self-developed vibration interface, and a 4D vibration interface. The type judgment module can read the configuration information of the motor to determine the motor type (including linear motors and nonlinear motors). When the type judgment module determines that the motor type is a linear motor, it can interact with the vibration drive of the kernel layer through the universal vibration interface, the self-developed vibration interface, or directly interact with the vibration drive of the kernel layer through the self-developed vibration interface or the 4D vibration interface. When the type judgment module determines that the motor type is a nonlinear motor, it can directly interact with the vibration drive of the kernel layer through the universal vibration interface. The vibration drive can configure the vibration chip in the hardware layer so that the vibration chip outputs a driving voltage to drive the motor to vibrate.

[0090] The method for driving a motor provided by the present application will be described below with reference to the accompanying drawings.

[0091] In an optional embodiment, the terminal device receives a first vibration event, and the first vibration event is used to trigger the motor vibration. The first vibration event includes receiving an operation of unlocking the terminal device by a user, receiving an operation of making an online payment by a user, receiving an operation of entering a face, receiving an operation of releasing a skill by a user, receiving an incoming call request, or the current time matching a preset time.

[0092] In response to a first vibration event, the vibration chip is controlled to output a first voltage to the motor within a first duration so that the amplitude of the motor reaches a maximum value at the end of the first duration; and the vibration chip is controlled to output a second voltage to the motor starting from the end of the first duration so that the amplitude of the motor remains at the maximum value, the first voltage and the second voltage being in the same direction, and the absolute value of the first voltage being greater than the absolute value of the second voltage. The first voltage and the second voltage are both alternating currents, and the absolute value of the first voltage being greater than the absolute value of the second voltage can refer to the amplitude of the first voltage being greater than the amplitude of the second voltage. The first voltage and the second voltage being in the same direction can refer to the current direction of the first voltage and the second voltage being the same at the end of the first duration.

[0093] In this way, the motor's amplitude can quickly reach its maximum value under the action of the first voltage and then remain at its maximum value under the action of the second voltage. In other words, the motor's amplitude can reach its maximum value even when the vibration duration is very short, giving the user a noticeable vibration feeling and improving the user experience.

[0094] In this embodiment, in response to the first vibration event, the terminal device may obtain vibration parameters of the motor. The vibration parameters are used to indicate the vibration mode of the motor. Depending on whether the vibration parameters include the vibration duration or not, the present application may provide different methods for driving the motor to vibrate.

[0095] In an optional embodiment, when the vibration parameter includes vibration duration, the terminal device may control the vibration chip to output a first voltage to the motor during the first duration so that the motor's amplitude reaches a maximum value at the end of the first duration. The terminal device may also control the vibration chip to output a second voltage to the motor starting at the end of the first duration to maintain the motor's amplitude at the maximum value, and control the vibration chip to output a third voltage to the motor starting at the end of the vibration duration to reduce the motor's amplitude from the maximum value to zero within the second duration. The third voltage is opposite to the second voltage, and its absolute value is greater than the absolute value of the second voltage. It is understood that the third voltage is also alternating current, and the fact that the third voltage is opposite to the second voltage means that the current direction of the third voltage is the same as that of the second voltage at the end of the vibration duration. The fact that the absolute value of the third voltage is greater than the absolute value of the second voltage means that the amplitude of the third voltage is greater than that of the second voltage.

[0096] When the vibration parameters do not include the vibration duration, the terminal device can control the vibration chip to output a first voltage to the motor within a first duration so that the amplitude of the motor reaches a maximum value at the end of the first duration; and control the vibration chip to output a second voltage to the motor starting from the end of the first duration so that the amplitude of the motor is maintained at the maximum value.

[0097] It is understandable that when the vibration parameters include the vibration duration, the terminal device is clear about the duration for which the motor needs to vibrate. Therefore, the vibration chip can be controlled to output a second voltage to the motor within the vibration duration starting from the end of the first duration, so that the actual vibration duration of the motor can reach the vibration duration included in the vibration parameters. When the vibration parameters do not include the vibration duration, the terminal device is not clear about the duration for which the motor needs to vibrate, and can first control the motor to start quickly, and then control the motor to stop vibrating later.

[0098] In order to implement the method of driving a motor provided by the present application, the present application provides a method of driving a motor, which is used to illustrate the process of controlling the vibration of a motor by a terminal device when the vibration parameters include the vibration duration. As shown in Figure 6, Figure 6 is a flow chart of a method of driving a motor provided by the present application, which includes the following steps:

[0099] S601 : In response to receiving a first vibration event, the first application sends a request to the vibration service to turn on a motor.

[0100] The first application can receive the first vibration event and send a request to the vibration service to turn on the motor after receiving the first vibration event. Depending on the actual application scenario, the first vibration event may be different. For example, when the first application is a lock screen application, the first vibration event may be receiving an operation of the user unlocking the terminal device through a virtual button. For another example, when the first application is a game application, the first vibration event may be receiving an operation of the user releasing a game skill. For another example, if the first application is a call application, the first vibration event may be receiving an incoming call request. For another example, if the first application is an alarm clock application, the first vibration event may be that the current time is consistent with the preset time set by the user.

[0101] The first application may call a preset API interface to send a request to the vibration service to turn on the motor.

[0102] S602: The vibration service detects whether a motor exists.

[0103] Optionally, the vibration service can detect whether the terminal device has a motor through the vibrator.hasVibrator() function.

[0104] It is understandable that the first application is not aware of whether the terminal device includes a motor. Therefore, it is necessary to determine whether the terminal device includes a motor before sending a vibration request.

[0105] S603: The vibration service sends the detection result to the first application.

[0106] The detection result may be true or false. If the detection result is false, the vibration service notifies the first application that the terminal device does not have a motor. If the detection result is true, the vibration service notifies the first application that the terminal device does have a motor, and S604 and subsequent steps may be executed.

[0107] Optionally, the vibration service can also detect whether the motor is in an idle state. The detection result also includes information about whether the motor is in an idle state or not. If the detection result indicates that the terminal device has a motor and the motor is in an idle state, the first application can execute S604 and subsequent steps. If the detection result indicates that the terminal device does not have a motor or the motor is in a non-idle state, the first application can determine that the motor is unavailable.

[0108] S604: The first application sends a vibration request to the vibration service.

[0109] The vibration request carries a vibration parameter. The vibration parameter is used to indicate the vibration mode required by the first application. In this embodiment, the content included in the vibration parameter may be different depending on the vibration interface called by the first application. The vibration interface called by the first application may include: a universal vibration interface (also referred to as a first interface), a native vibration interface (also referred to as a second interface), and a 4D vibration interface.

[0110] The Universal Vibration Interface, also known as the Google Vibration Interface, enables control of linear and nonlinear motors through vibration drivers. Applications that call the Universal Vibration Interface send vibration parameters that can be used by both linear and nonlinear motors, including vibration type, vibration duration, and sleep duration. The sleep duration can refer to the time interval between two vibrations.

[0111] The native vibration interface is a vibration interface developed by the device manufacturer itself, which can control the linear motor through vibration drive. For applications that call the native vibration interface, the vibration parameters sent may include information such as the name of the vibration waveform and the sleep duration. Among them, the terminal device stores description files of multiple vibration waveforms pre-designed by developers, each of which has a different name. The native vibration interface can find the corresponding description file based on the name of the received vibration waveform and parse the description file to obtain the vibration waveform data. This vibration waveform data is used to describe the vibration waveform. This vibration method is relatively complex and cannot be implemented by nonlinear motors.

[0112] A 4D vibration interface, developed jointly by the device manufacturer and a third party, allows control of linear motors through vibration drive. Applications invoking the 4D vibration interface send vibration parameters including a waveform ID and waveform file data. The waveform file data indicates the storage address of the description file. Similar to native vibration interfaces, the vibration methods implemented by the 4D vibration interface are more complex and unsuitable for nonlinear motors.

[0113] The first application may call a preset API interface to send a vibration request to the vibration service.

[0114] S605: The vibration service sends a vibration request to the type determination module.

[0115] For the description of the vibration request, please refer to the relevant content of S604 and will not be repeated here.

[0116] S606: The type determination module obtains motor type information.

[0117] In this embodiment, the type determination module can read a configuration file from a preset storage address. The configuration file includes motor configuration information, which may include information such as the motor type and the motor's resonant frequency. Motor types may include linear motors (e.g., labeled 1) and nonlinear motors (e.g., labeled 2).

[0118] S607: The type determination module determines whether the motor is a linear motor.

[0119] For example, if the motor type information is 1, the type determination module may determine that the motor is a linear motor; if the motor type information is 2, the type determination module may determine that the motor is a nonlinear motor.

[0120] The following description takes the example of the type determination module determining that the motor is a linear motor. After S607, the following steps are also included: S608 to S615:

[0121] S608: The type determination module determines the vibration interface according to the vibration parameters.

[0122] Specifically, the type determination module can determine the vibration interface based on the type of vibration parameters. For example, if the vibration parameters include vibration duration and sleep duration, the vibration interface can be determined to be a universal vibration interface. If the vibration parameters include the name of the vibration waveform and the sleep duration, the vibration interface can be determined to be a native vibration interface. If the vibration parameters include the waveform ID and waveform file data, the vibration interface can be determined to be a 4D vibration interface.

[0123] The following description is made by taking the case where the type determination module determines that the vibration interface is a universal vibration interface as an example.

[0124] S609 , the type determination module sends a vibration request and a message indicating that the motor is a linear motor to the universal vibration interface.

[0125] S610: The universal vibration interface determines whether the vibration duration is less than a second value.

[0126] The second value may be the time required for the linear motor to change from an amplitude of 0 to a maximum value under the action of the rated voltage, determined based on multiple tests. For example, the second value may be 100 milliseconds.

[0127] In this embodiment, if the universal vibration interface determines that the vibration duration is less than the second value, S611 may be executed. If the universal vibration interface determines that the vibration duration is greater than or equal to the second value, the universal vibration interface may directly send the vibration request to the vibration driver, which then controls the motor to vibrate. For example, after receiving the vibration request, the vibration driver may directly control the vibration chip to output the second voltage to the motor, causing the motor to vibrate according to the waveform diagram of vibration acceleration signal S2 in FIG1 .

[0128] S611: The general vibration interface sends a vibration request to the self-developed vibration interface.

[0129] S612: The self-developed vibration interface updates the vibration parameters based on the first parameter and the second parameter.

[0130] Among them, the first parameter is used to describe the vibration waveform generated by the linear motor vibrating for a first time period under the action of a first voltage, and the first voltage is used to increase the amplitude of the motor from 0 to a maximum value within the first time period. The second parameter is used to describe the vibration waveform generated by the linear motor vibrating for a second time period under the drive of a third voltage, and the third voltage is used to reduce the amplitude of the motor from a maximum value to 0 within the second time period. Optionally, the first time period and the second time period can be 1 to 1.5 (including 1 and 1.5) times the resonance period. The first time period and the second time period can be the same or different, and there is no specific limitation here. The resonance period is the inverse of the natural frequency of the linear motor. The first voltage can be a voltage value obtained based on multiple tests that can make the linear motor vibrate to the maximum amplitude within the first time period. The third voltage can be a voltage value obtained based on multiple tests that can make the vibration amplitude of the linear motor change from the maximum value to 0 (causing the linear motor to stop vibrating quickly) within the second time period.

[0131] S613: The self-developed vibration interface sends the updated vibration parameters (also referred to as second vibration parameters) to the vibration driver.

[0132] S614 , the vibration driver writes the updated vibration parameters into the vibration chip.

[0133] S615, the vibration chip outputs a first voltage to the motor within the first time period so that the amplitude of the motor reaches a maximum value at the end of the first time period, and outputs a second voltage to the motor within the vibration time period starting from the end of the first time period so that the amplitude of the motor is maintained at the maximum value, and outputs a third voltage to the motor starting from the end of the vibration time period so that the amplitude of the motor is reduced from the maximum value to 0 within the second time period.

[0134] The absolute value of the first voltage is greater than the absolute value of the second voltage, the absolute value of the third voltage is greater than the absolute value of the second voltage, the first voltage and the second voltage have the same direction, and the third voltage and the second voltage have an opposite direction. That is, the vibration chip first outputs the first voltage for a first duration, then outputs the second voltage for a vibration duration, and finally outputs the third voltage for a second duration.

[0135] Figure 7 shows a waveform diagram of a drive voltage signal S5 and a vibration acceleration signal S6. The drive voltage signal S5 is the drive voltage output by the vibration chip, and the vibration acceleration signal S6 is the vibration acceleration generated by the linear motor under the action of the drive voltage signal S1. As shown in Figure 7, the first duration can be 10 milliseconds, the vibration duration can be 26 milliseconds, and the third duration can be 9 milliseconds. The drive voltage signal S5 outputs a first voltage during period T1, a second voltage during period T2, and a third voltage during period T3. Under the action of the first voltage, the amplitude of the vibration acceleration signal S6 reaches a maximum value in a very short time (e.g., 10 milliseconds), indicating that the amplitude of the linear motor reaches its maximum value from 0 within 10 milliseconds. Under the action of the second voltage, the amplitude of the vibration acceleration signal S6 continues to maintain its maximum value, indicating that the amplitude of the motor remains at its maximum value. Under the action of the third voltage, the amplitude of the vibration acceleration signal S6 decreases from its maximum value to 0 in a very short time (e.g., 9 milliseconds), indicating that the motor quickly stops vibrating.

[0136] As can be seen, when the vibration parameter includes vibration duration, the terminal device can first determine whether the vibration duration is less than a second value. If the vibration duration is less than the second value, the vibration chip is controlled to output a first voltage to the motor within the first duration so that the motor's amplitude reaches a maximum value at the end of the first duration, and the vibration chip is controlled to output a second voltage to the motor from the end of the first duration to maintain the motor's amplitude at the maximum value. The vibration chip is also controlled to output a third voltage to the motor from the end of the vibration duration so that the motor's amplitude decreases from the maximum value to zero within the second duration. In this way, the linear motor's amplitude can quickly reach its maximum value under the action of the first voltage and maintain its maximum value under the action of the second voltage, making it easier for the user to perceive the vibration, improving the user experience, and avoiding the problem of the motor's amplitude being small due to a short vibration duration, which in turn makes the user unable to perceive the vibration. In addition, after the actual vibration duration of the motor reaches the vibration duration required by the first application, the terminal device can output a high voltage (i.e., a third voltage) that is opposite to the original driving voltage (i.e., the second voltage) to quickly stop the motor from vibrating, reducing vibration tailing and avoiding the discomfort caused by the lingering vibration.

[0137] In an optional embodiment, the terminal device may not need to determine whether the vibration duration is less than the second value. Instead, after receiving the first vibration event, the vibration chip is directly controlled to output the first voltage to the motor within the first duration, so that the amplitude of the motor reaches the maximum value at the end of the first duration, and the vibration chip is controlled to output the second voltage to the motor within the vibration duration from the end of the first duration, so that the amplitude of the motor is maintained at the maximum value, and the third voltage is output to the motor from the end of the vibration duration, so that the amplitude of the motor is reduced from the maximum value to 0 within the second duration. In this case, the flowchart shown in Figure 6 may not include S610. That is, after the universal vibration interface receives the vibration request sent by the type judgment module, it may not determine whether the vibration duration is less than the second value, but directly send a vibration request to the self-developed vibration interface, and execute S612 and subsequent steps. Among them, S610 is used to determine whether the vibration duration is less than the second value. It can be distinguished in advance whether the terminal device may have the problem of unclear vibration due to insufficient vibration duration. If the terminal device determines that the vibration duration is less than the second value, it indicates that there is a problem that the vibration is not obvious due to the short vibration duration. Therefore, the first voltage can be output to increase the amplitude of the motor from 0 to the maximum value in a short time (for example, the first duration). If the terminal device determines that the vibration duration is greater than or equal to the second value, it indicates that the vibration duration may be sufficient for the user to perceive the vibration, and there is no need to make the motor reach the maximum amplitude quickly. This method can not only enable the user to clearly feel the vibration, but also reduce the waste of resources caused by unnecessary processes.

[0138] It should be noted that if, in S608, the type determination module determines that the vibration interface is a native vibration interface or a 4D vibration interface, the type determination module may send a vibration request to the corresponding vibration interface. Upon receiving the vibration request, the corresponding vibration interface may directly transmit the vibration parameters to the vibration driver. The vibration driver then writes the vibration parameters to the vibration chip, causing the vibration chip to output a voltage according to the configuration of the vibration parameters, thereby achieving motor vibration.

[0139] In an optional embodiment, the motor may also be a nonlinear motor. The following description uses FIG8 as an example, using the case where the type determination module determines that the motor is a nonlinear motor. FIG8 is a second flow chart of a method for driving a motor provided in this application. As shown in FIG8 , after S607 , the method for driving a motor further includes S616 to S620 .

[0140] S616 , the type determination module sends a vibration request and a message indicating that the motor is a nonlinear motor to the universal vibration interface.

[0141] For the description of the vibration request, please refer to the relevant content of S604 and will not be repeated here.

[0142] S617: The general vibration interface extracts usable parameters from the vibration parameters.

[0143] The available parameters may include parameters applicable to nonlinear motors, such as vibration duration, sleep duration, etc. Specifically, the universal vibration interface may remove parameters not applicable to nonlinear motors from the vibration parameters, retaining parameters applicable to nonlinear motors, to achieve control of the nonlinear motor. It should be noted that parameters applicable to nonlinear motors refer to parameters that can be used to control nonlinear motors, while parameters not applicable to nonlinear motors refer to parameters that cannot be used to control nonlinear motors, such as the parameters related to the vibration waveform in S604.

[0144] For example, if the vibration parameters sent by the first application include the name of the vibration waveform and the sleep duration, the universal vibration interface may remove the name of the vibration waveform and retain the sleep duration as an available parameter.

[0145] S618: The universal vibration interface sends available parameters to the vibration driver.

[0146] S619, the vibration driver writes the available parameters into the vibration chip.

[0147] S620: The universal vibration interface outputs a second voltage to the motor.

[0148] In this embodiment, if the terminal device determines that the motor is a nonlinear motor, the terminal device no longer needs to determine the vibration interface based on the type of vibration parameters. Instead, the terminal device can directly extract the parameters that are adaptable to the nonlinear motor (i.e., usable parameters) from the vibration parameters. Based on these usable parameters, the vibration chip is configured to output a driving voltage (i.e., a second voltage) to vibrate the nonlinear motor. As can be understood, nonlinear motors do not support a rich vibration experience due to their inherent physical characteristics. By extracting the applicable parameters from the vibration parameters, the problem of the nonlinear motor not being able to vibrate due to the incompatibility of the vibration parameters with the nonlinear motor can be avoided, thereby achieving efficient and stable control of the motor.

[0149] As mentioned above, when the vibration parameters do not include the vibration duration, the terminal device can control the vibration chip to output a first voltage to the motor within a first duration so that the amplitude of the motor reaches a maximum value at the end of the first duration, and output a second voltage to the motor starting from the end of the first duration to keep the amplitude of the motor at the maximum value.

[0150] Optionally, the terminal device may further control the vibration chip to output a third voltage to the motor when the preset time duration from the start of the first vibration event received by the terminal device ends, so as to reduce the amplitude of the motor from a maximum value to 0 within the second time duration. Typically, each vibration event may be pre-set with a theoretical vibration duration, for example, the theoretical vibration duration corresponding to the first vibration event is a preset duration. For example, if the terminal device receives a first vibration event at 10:00, and the first vibration event requires the motor to stop vibrating after 1 minute, the terminal device may output a third voltage to the motor at 10:01 to control the motor to stop vibrating.

[0151] FIG9 is a third flow chart of a method for driving a motor provided in this application, illustrating the process of controlling the motor to vibrate and stop vibrating when the vibration duration does not include vibration parameters. As shown in FIG9 , the method for driving a motor provided in this embodiment includes: S901 to S919.

[0152] S901 : In response to receiving a first vibration event, the first application sends a request to the vibration service to turn on a motor.

[0153] S902, the vibration service detects whether a motor exists.

[0154] S903: The vibration service sends the detection result to the first application.

[0155] S904: The first application sends a vibration request to the vibration service.

[0156] S905: The vibration service sends a vibration request to the type determination module.

[0157] S906: The type determination module obtains motor type information.

[0158] S907: The type determination module determines whether the motor is a linear motor.

[0159] S908: The type determination module determines the vibration interface according to the vibration parameters.

[0160] S909 , the type determination module sends a vibration request and a message indicating that the motor is a linear motor to the universal vibration interface.

[0161] S910: The general vibration interface sends a vibration request to the self-developed vibration interface.

[0162] Compared to the process shown in FIG6 , in this embodiment, the vibration parameters do not include the vibration duration. Therefore, upon receiving the vibration request, the universal vibration interface does not need to determine whether the vibration duration is less than the second value. If the motor is determined to be a linear motor, the universal vibration interface can directly send the vibration request to the self-developed vibration interface upon receiving the vibration request, thereby enabling the motor to vibrate quickly at maximum amplitude through the self-developed vibration interface.

[0163] S911: The self-developed vibration interface updates the vibration parameter based on the first parameter.

[0164] According to S612, the first parameter is used to control the amplitude of the linear motor to reach a maximum value from 0 within a first duration, and the second parameter is used to change the amplitude of the linear motor from a maximum value to 0 within a second duration. Because the vibration parameters do not include the vibration duration, the terminal device does not know when to control the motor to stop vibrating. Therefore, the self-developed vibration interface does not need to update the vibration parameters based on the second parameter, but only updates the vibration parameters based on the first parameter to enable the motor to vibrate quickly at the maximum amplitude.

[0165] S912: The self-developed vibration interface sends updated vibration parameters (also referred to as first vibration parameters) to the vibration driver.

[0166] S913: The vibration driver writes the updated vibration parameters into the vibration chip.

[0167] S914, the vibration chip outputs a first voltage to the motor within a first time period so that the amplitude of the motor reaches a maximum value at the end of the first time period, and outputs a second voltage to the motor starting from the end of the first time period so that the amplitude of the motor is maintained at the maximum value.

[0168] Thus, under the action of the first voltage, the amplitude of the motor quickly reaches a maximum value from 0; under the action of the second voltage, the amplitude of the motor remains at the maximum value.

[0169] S915: The first application sends a request to the vibration service to stop vibration.

[0170] Specifically, the first application may send a stop vibration request to the vibration service at the end of the preset time from the start of the vibration request. For example, if the first application sends a vibration request to the vibration service at 9:10 and the preset time is 2 minutes, the first application will send a stop vibration request to the vibration service at 9:12. This stop vibration request is used to trigger the motor to stop vibrating.

[0171] S916: The vibration service sends a request to stop vibration to the universal vibration interface.

[0172] S917: The universal vibration interface sends the second parameter to the vibration driver.

[0173] For the description of the second parameter, please refer to S612 and will not be repeated here.

[0174] S918: The vibration driver writes the second parameter into the vibration chip.

[0175] S919: The vibration chip outputs a third voltage to the motor.

[0176] A simple comparison of Figures 6 and 9 shows that the method for driving the motor shown in Figure 6 is similar to the method for driving the motor shown in Figure 9. The difference between the two is that Figure 6 controls the motor to stop vibrating by setting the vibration duration, while Figure 9 controls the motor to stop vibrating by requesting to stop vibration. For the common parts between the two, please refer to Figure 6 and the related description, and will not be repeated here.

[0177] Figure 10 shows a time node diagram of the process of the terminal device driving the motor vibration according to the process shown in Figure 9. Among them, t1 is the moment when the first application sends a request to turn on the motor (i.e., the moment corresponding to S901), t2 is the moment when the first application sends a request to stop vibration (i.e., the moment corresponding to S915), t3 is the moment when the vibration chip outputs a first voltage to control the vibration of the motor (i.e., the moment corresponding to S914), and t4 is the moment when the vibration chip outputs a third voltage to control the motor to stop vibration (i.e., the moment corresponding to S919). Among them, the time difference between moment t3 and moment t1 is ΔT1, and ΔT1 is used to represent the time used to control the vibration of the motor. The time difference between moment t4 and moment t2 is ΔT2, and ΔT2 is used to represent the time used to control the vibration of the motor. The time difference between moment t2 and moment t1 is ΔT3, and ΔT3 is used to represent the vibration duration requested by the first application. The time difference between moment t4 and moment t3 is ΔT4, and ΔT4 is used to represent the actual vibration duration of the motor.

[0178] It can be seen that the terminal device needs to perform more operations from the time the first application sends a request to turn on the motor to the time the vibration chip outputs voltage to drive the motor to vibrate (i.e., from S901 to S914); the terminal device only needs to perform fewer operations from the time the first application sends a request to stop vibration to the time the vibration chip outputs voltage to drive the motor to stop vibration (i.e., from S915 to S919), that is, ΔT1 is greater than ΔT2. This will cause ΔT4 to be less than ΔT3, that is, the actual vibration duration of the motor (i.e., ΔT4) is less than the vibration duration requested by the first application (i.e., ΔT3). If the actual vibration duration of the motor is too short, it may make it difficult for the user to perceive the vibration, affecting the user experience.

[0179] In an optional embodiment, in order to avoid the actual vibration duration of the motor (i.e., the actual vibration duration of the motor) being too short, the terminal device can control the vibration chip to output a third voltage to the motor when the actual vibration duration of the motor reaches a first value, so that the amplitude of the motor is reduced from a maximum value to 0 within a second duration. Optionally, the first value can be the time difference between the moment when the terminal device generates a vibration request and the moment when it generates a request to stop vibration. Alternatively, the first value can be other parameters. The following is another embodiment of the terminal device controlling the vibration chip to output a third voltage to the motor when the actual vibration duration of the motor is greater than the first value.

[0180] Based on the flowchart shown in Figure 9, this embodiment provides another method for driving a motor. Figure 11 is a fourth flow chart of a method for driving a motor provided by this application.

[0181] Comparing FIG11 with FIG9 , it can be seen that the method for driving a motor provided in FIG11 is similar to the method for driving a motor provided in FIG9 , except that the method for driving a motor provided in FIG11 further includes S1101, S1102, and S1103. S1101, S1102, and S1103 will be described in detail below. For the common contents between the two embodiments, please refer to FIG9 and the related description, which will not be repeated here.

[0182] S1101: The self-developed vibration interface starts a first timer to obtain a third duration.

[0183] It should be noted that S1101 may be executed earlier than S911 or simultaneously with S911, and no specific limitation is made here.

[0184] It can be understood that after the self-developed vibration interface starts the first timer, the third duration increases in real time from 0.

[0185] After the vibration service sends a request to stop vibration to the universal vibration interface, the universal vibration interface may further execute S1102 and S1103 .

[0186] S1102: The universal vibration interface starts a second timer to obtain a fourth duration.

[0187] Similarly, after the universal vibration interface starts the second timer, the fourth duration increases in real time starting from 0.

[0188] S1103: The universal vibration interface determines whether the actual vibration duration is greater than or equal to the difference between the third duration and the fourth duration.

[0189] If the universal vibration interface determines that the actual vibration duration is greater than or equal to the difference between the third duration and the fourth duration, S917 may be executed (i.e., the second parameter is sent to the vibration driver); if the universal vibration interface determines that the actual vibration duration is less than the difference between the third duration and the fourth duration, the second timer may continue to count and S1103 may be re-executed until the actual vibration duration is greater than or equal to the difference between the third duration and the fourth duration. It will be understood that in this embodiment, the first value is the difference between the third duration and the fourth duration.

[0190] (a) and (b) in Figure 12 respectively show the time node diagrams of the terminal device driving the motor vibration process according to the process shown in Figure 9 and Figure 10. Among them, t3 is the moment when the vibration chip outputs the first voltage to control the vibration of the motor (that is, the moment corresponding to S914), t4 is the moment when the vibration chip in Figure 9 outputs the third voltage to control the motor to stop vibrating (that is, the moment corresponding to S919 in Figure 9), t5 is the moment when the self-developed vibration interface receives the vibration request, t6 is the moment when the universal vibration interface receives the request to stop vibration, and t7 is the moment when the vibration chip in Figure 11 outputs the third voltage to control the motor to stop vibrating (that is, the moment corresponding to S919 in Figure 11). Δt5 is the third duration obtained by the first timer, and Δt6 is the fourth duration obtained by the second timer. The time difference between moment t4 and moment t3 is Δt4, and Δt4 is used to characterize the actual vibration duration of the motor when the motor vibration is controlled by the flowchart shown in Figure 9. The time difference between moment t7 and moment t3 is Δt4', and Δt4' is used to characterize the actual vibration duration of the motor when the motor vibration is controlled by the flowchart shown in Figure 11.

[0191] By comparing (a) and (b) in Figure 12, it can be seen that by judging whether the actual vibration duration is greater than or equal to the difference between the third duration and the fourth duration, and only continuing to execute S917 when the actual vibration duration is greater than or equal to the difference between the third duration and the fourth duration, so as to control the motor to stop vibrating, the actual vibration duration of the motor can be changed from Δt4 to Δt4', which increases the actual vibration duration of the motor, so as to bring a clear vibration feeling to the user and improve the user experience.

[0192] Some embodiments of the present application provide a terminal device, which may include a memory and one or more processors. The memory and processors are coupled. The memory is configured to store computer program code, which includes computer instructions. When the processor executes the computer instructions, the terminal device may perform the functions or steps described in the method embodiments described above. The structure of the terminal device may refer to the structure of the terminal device shown in FIG3 .

[0193] An embodiment of the present application also provides a motor, which can be used to realize vibration waveforms under various configuration parameters in the above embodiments, etc. The terminal device equipped with the motor can execute the various functions or steps executed by the terminal device in the above method embodiments.

[0194] An embodiment of the present application also provides a computer-readable storage medium, which includes computer instructions. When the computer instructions are executed on the above-mentioned terminal device, the terminal device executes each function or step executed by the terminal device in the above-mentioned method embodiment.

[0195] An embodiment of the present application further provides a computer program product, which, when executed on a terminal device, enables the terminal device to execute each function or step executed by the terminal device in the above method embodiment.

[0196] Through the description of the above implementation methods, technical personnel in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional modules is used as an example. In actual applications, the above-mentioned functions can be assigned to different functional modules as needed, that is, the internal structure of the device can be divided into different functional modules to complete all or part of the functions described above.

[0197] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the modules or units is merely a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another device, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0198] The units described as separate components may or may not be physically separate, and the components shown as units may be one physical unit or multiple physical units, that is, they may be located in one place or distributed in multiple places. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0199] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.

[0200] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a readable storage medium. Based on this understanding, the technical solution of the embodiment of the present application is essentially or the part that contributes to the prior art or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for enabling a device (which can be a single-chip microcomputer, chip, etc.) or a processor (processor) to execute all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: various media that can store program codes, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0201] The above content is only a specific embodiment of this application, but the scope of protection of this application is not limited to this. Any changes or replacements within the technical scope disclosed in this application should be included in the scope of protection of this application. Therefore, the scope of protection of this application should be based on the scope of protection of the claims.

Claims

1. A method for driving a motor, characterized in that: Applied to a terminal device, the terminal device includes a vibration chip and a motor, the motor is a linear motor, and the method includes: receiving a first vibration event for triggering vibration of the motor; In response to the first vibration event, controlling the vibration chip to output a first voltage to the motor within a first duration, so that the amplitude of the motor reaches a maximum value at the end of the first duration; and Controlling the vibration chip to output a second voltage to the motor starting from the end of the first time period so that the amplitude of the motor is maintained at the maximum value; wherein, The first voltage and the second voltage have the same direction, and the absolute value of the first voltage is greater than the absolute value of the second voltage.

2. The method according to claim 1, characterized in that In response to the first vibration event, controlling the vibration chip to output a first voltage to the motor within a first duration so that the amplitude of the motor reaches a maximum value at the end of the first duration, and controlling the vibration chip to output a second voltage to the motor starting from the end of the first duration so that the amplitude of the motor is maintained at the maximum value, further comprising: acquiring a vibration parameter of the motor in response to the first vibration event; When the vibration parameters do not include the vibration duration, the vibration chip is controlled to output the first voltage to the motor within the first duration so that the amplitude of the motor reaches the maximum value at the end of the first duration, and the vibration chip is controlled to output the second voltage to the motor starting from the end of the first duration so that the amplitude of the motor is maintained at the maximum value.

3. The method according to claim 2, characterized in that The method further comprises: Controlling the vibration chip to output a third voltage to the motor when the preset time period starting from the first vibration event received from the terminal device ends, so that the amplitude of the motor decreases from the maximum value to 0 within a second time period; wherein, The third voltage is opposite to the second voltage, and an absolute value of the third voltage is greater than an absolute value of the second voltage; and The preset duration is greater than the first duration.

4. The method according to claim 2, characterized in that The method further comprises: controlling the vibration chip to output a third voltage to the motor when the actual vibration duration of the motor reaches a first value, so that the amplitude of the motor decreases from the maximum value to 0 within a second duration; The third voltage is opposite to the second voltage, and an absolute value of the third voltage is greater than an absolute value of the second voltage.

5. The method according to claim 1, wherein In response to the first vibration event, controlling the vibration chip to output a first voltage to the motor within a first duration so that the amplitude of the motor reaches a maximum value at the end of the first duration, and controlling the vibration chip to output a second voltage to the motor starting from the end of the first duration so that the amplitude of the motor is maintained at the maximum value, further comprising: acquiring a vibration parameter of the motor in response to the first vibration event; In a case where the vibration parameter includes the vibration duration, controlling the vibration chip to output a first voltage to the motor during the first duration so that the amplitude of the motor reaches the maximum value at the end of the first duration; and controlling the vibration chip to output a second voltage to the motor during the vibration duration starting from the end of the first duration, so that the amplitude of the motor is maintained at the maximum value; and controlling the vibration chip to output a third voltage to the motor starting from the end of the vibration duration, so that the amplitude of the motor decreases from the maximum value to 0 within a second duration; The third voltage is opposite to the second voltage, and the absolute value of the third voltage is greater than the absolute value of the second voltage.

6. The method according to claim 5, characterized in that The step of controlling the vibration chip to output a first voltage to the motor during the first duration so that the amplitude of the motor reaches the maximum value at the end of the first duration, controlling the vibration chip to output a second voltage to the motor during the vibration duration starting from the end of the first duration so that the amplitude of the motor is maintained at the maximum value, and controlling the vibration chip to output a third voltage to the motor starting from the end of the vibration duration so that the amplitude of the motor decreases from the maximum value to 0 during the second duration, further comprising: If the vibration duration is less than a second value, the vibration chip is controlled to output a first voltage to the motor within the first duration so that the amplitude of the motor reaches the maximum value at the end of the first duration, and the vibration chip is controlled to output a second voltage to the motor within the vibration duration starting from the end of the first duration so that the amplitude of the motor is maintained at the maximum value, and the vibration chip is controlled to output a third voltage to the motor starting from the end of the vibration duration so that the amplitude of the motor is reduced from the maximum value to 0 within the second duration.

7. The method according to any one of claims 1 to 6, characterized in that The first vibration event includes one of the following: receiving an operation of the user unlocking the terminal device, receiving an operation of the user making an online payment, receiving an operation of the user entering a face, receiving an operation of the user releasing a skill, receiving an incoming call request, or the current time matches the preset time.

8. The method according to any one of claims 1 to 6, characterized in that The terminal device includes a first application, a vibration service, a vibration hardware abstraction layer (HAL), and a vibration driver; wherein the vibration HAL includes a type determination module, a first interface, and a second interface; and in response to the first vibration event, controlling the vibration chip to output a first voltage to the motor within a first duration so that the amplitude of the motor reaches a maximum value at the end of the first duration, and controlling the vibration chip to output a second voltage to the motor starting from the end of the first duration so that the amplitude of the motor is maintained at the maximum value, further comprising: In response to the first vibration event, the first application sends a vibration request to the vibration service; The vibration service sends the vibration request to the type determination module, where the vibration request includes vibration parameters; The type determination module determines whether the motor is a linear motor; When the type of the vibration parameter indicates that the vibration interface is the first interface, the type determination module sends the vibration request and a message indicating that the motor is a linear motor to the first interface; The first interface sends the vibration request to the second interface; The second interface updates the vibration parameter based on a first parameter, where the first parameter is used to describe a vibration waveform generated when the motor vibrates for the first duration under the action of the first voltage; The second interface sends a first vibration parameter to the vibration driver, where the first vibration parameter is a vibration parameter updated based on the first parameter; The vibration driver writes the first vibration parameter into the vibration chip; and The vibration chip outputs a first voltage to the motor during the first time period so that the amplitude of the motor reaches a maximum value at the end of the first time period, and outputs a second voltage to the motor starting from the end of the first time period so that the amplitude of the motor is maintained at the maximum value.

9. The method according to claim 8, characterized in that The second interface updates the vibration parameter based on the first parameter, further comprising: In a case where the vibration parameter does not include vibration duration, the second interface updates the vibration parameter based on the first parameter.

10. The method according to claim 9, characterized in that The method further comprises: The first application sends a request to the vibration service to stop vibration when a preset time period starting from receiving the first vibration event ends; The vibration service sends the request to stop vibration to the first interface; The first interface sends a second parameter to the vibration driver, where the second parameter is used to describe a vibration waveform generated by the motor vibrating for a second time period under the action of a third voltage; The vibration driver writes the second parameter into the vibration chip; and The vibration chip outputs the third voltage to the motor so that the amplitude of the motor decreases from the maximum value to 0 within the second time period.

11. The method according to claim 10, characterized in that The method further comprises: In response to receiving the vibration request, the second interface starts a first timer to obtain a third duration; In response to receiving the request to stop vibration, the first interface starts a second timer to obtain a fourth duration; The first interface sending the second parameter to the vibration driver further includes: When the actual vibration duration of the motor reaches a first value, the first interface sends the second parameter to the vibration driver, where the first value is the difference between the third duration and the fourth duration.

12. The method according to claim 9, characterized in that The method further comprises: When the vibration parameter includes the vibration duration, the second interface updates the vibration parameter based on the first parameter and a second parameter, the second parameter being used to describe a vibration waveform generated by the motor vibrating for a second duration under the action of a third voltage; The second interface sends a second vibration parameter to the vibration driver, where the second vibration parameter is a vibration parameter updated based on the first parameter and the second parameter; The vibration driver writes the second vibration parameter into the vibration chip; The vibration chip outputs a first voltage to the motor during the first duration so that the amplitude of the motor reaches the maximum value at the end of the first duration, and outputs a second voltage to the motor from the end of the first duration during the vibration duration so that the amplitude of the motor is maintained at the maximum value, and outputs a third voltage to the motor from the end of the vibration duration so that the amplitude of the motor decreases from the maximum value to zero within the second duration; The third voltage is opposite to the second voltage, and an absolute value of the third voltage is greater than an absolute value of the second voltage.

13. The method according to claim 12, characterized in that When the vibration parameter includes the vibration duration, the second interface updates the vibration parameter based on the first parameter and the second parameter, further comprising: In a case where the vibration parameter includes the vibration duration and the vibration duration is less than a second value, the second interface updates the vibration parameter based on the first parameter and the second parameter.

14. The method according to claim 13, characterized in that The method further comprises: The first interface determines whether the vibration duration is less than a second value; The first interface sending the vibration request to the second interface further includes: If the vibration duration is less than the second value, the first interface sends the vibration request to the second interface.

15. The method according to any one of claims 8 to 14, characterized in that In response to the first vibration event, the first application sending a vibration request to the vibration service further includes: In response to the first vibration event, the first application sends a request to the vibration service to turn on a motor; The vibration service detects whether a motor exists and sends a detection result to the first application; If the detection result indicates that a motor is present, the first application sends the vibration request to the vibration service.

16. A terminal device, characterized in that: The terminal device includes: a memory and one or more processors; the memory is coupled to the processor; The memory is used to store computer program code, and the computer program code includes computer instructions; when the computer instructions are executed by the processor, the terminal device executes the method according to any one of claims 1 to 15.

17. A computer-readable storage medium, characterized in that including computer instructions; When the computer instructions are executed on a terminal device, the terminal device is caused to execute the method according to any one of claims 1 to 15.