Handwriting pen handwriting generation method and electronic device

By incorporating accelerometer modules into electronic devices and styluses, and using acceleration information to determine the tilt angle, the problem of inaccurate handwriting generation at large tilt angles is solved, resulting in higher accuracy and a better user experience.

CN119739323BActive Publication Date: 2026-06-09HONOR DEVICE CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
HONOR DEVICE CO LTD
Filing Date
2025-01-27
Publication Date
2026-06-09

Smart Images

  • Figure CN119739323B_ABST
    Figure CN119739323B_ABST
Patent Text Reader

Abstract

This application provides a method for generating handwriting with a stylus and an electronic device, relating to the field of terminal technology. This method allows for precise execution of operations associated with the handwriting corresponding to the stylus based on an angle of inclination. Specifically, the electronic device receives first information sent by the stylus via a communication module. The first information includes acceleration information collected by a first accelerometer module in the stylus. The electronic device determines a first angle of inclination between the stylus and the electronic device. This first angle is determined by first and second information, where the second information includes acceleration information collected by a second accelerometer module on the electronic device, or angle information associated with the acceleration information. When the contact area between the stylus and the electronic device is less than or equal to a first threshold, the electronic device receives a first instruction from the stylus. The electronic device then responds to the first instruction by executing an operation associated with the handwriting corresponding to the stylus based on the first angle of inclination.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of terminal technology, and in particular to a method for generating handwriting with a stylus and an electronic device. Background Technology

[0002] With the development of technology, electronic devices can be equipped with styluses to enable more precise writing or touch control on the devices.

[0003] However, when the angle between the stylus and the electronic device is large, the electronic device cannot accurately determine the angle between the stylus and the electronic device, thus making it impossible for the electronic device to determine the handwriting corresponding to the stylus based on the angle. Summary of the Invention

[0004] This application provides a method for generating handwriting with a stylus and an electronic device that can accurately execute operations associated with the handwriting corresponding to the stylus based on the tilt angle.

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

[0006] In a first aspect, a method for generating handwriting with a stylus is provided, applied to an electronic device, the electronic device including a communication module and a second accelerometer sensor module. The electronic device receives first information transmitted by the stylus through the communication module, the first information including acceleration information collected by the first accelerometer sensor module in the stylus. The electronic device determines a first tilt angle between the stylus and the electronic device. The first tilt angle is determined by first information and second information, the second information including the acceleration information collected by the second accelerometer sensor module, or the second information including tilt angle information associated with the acceleration information collected by the second accelerometer sensor module. When the contact area between the stylus and the electronic device is less than or equal to a first threshold, the electronic device receives a first instruction from the stylus. The electronic device then responds to the first instruction and performs an operation associated with the handwriting corresponding to the stylus according to the first tilt angle.

[0007] In the above scheme, both the first and second information are determined based on the acceleration information collected by the accelerometer module. The acceleration information collected by the accelerometer module can accurately reflect the tilt of the device, and thus the tilt angle determined by the electronic device using the first and second information is also accurate. Even when the tilt angle between the stylus and the electronic device is large, i.e., when the contact area between the stylus and the electronic device is less than or equal to the first threshold, the electronic device can still accurately determine the tilt angle, and the electronic device can receive and respond to the stylus's instructions, accurately executing the operation associated with the handwriting corresponding to the stylus according to the first tilt angle.

[0008] In one possible implementation of the first aspect, the first tilt angle can range from 0 degrees to 360 degrees.

[0009] In the above scheme, both the first and second information are determined based on the acceleration information collected by the accelerometer module, which reflects the directional changes of the device where the accelerometer is located throughout the space. Therefore, the first tilt angle obtained by the electronic device based on the first and second information can range from 0 degrees to 360 degrees. That is, regardless of the posture of the electronic device and the stylus, the electronic device can determine the tilt angle between the electronic device and the stylus.

[0010] In another possible implementation of the first aspect, when the contact area between the stylus and the touchscreen is less than or equal to a first threshold, the electronic device receives a first instruction generated by the stylus contacting the touchscreen. In response to the first instruction, the electronic device performs a handwriting operation associated with the handwriting corresponding to the stylus, based on a first tilt angle.

[0011] In the above scheme, when the contact area between the stylus and the touch screen is less than or equal to the first threshold, the electronic device can also perform a handwriting operation associated with the handwriting corresponding to the stylus according to the first tilt angle after receiving the first instruction. That is, the electronic device can perform a handwriting operation even when the first tilt angle is large, so that the electronic device can better simulate the effect of the user writing with a real pen and improve the user experience.

[0012] In another possible implementation of the first aspect, in some embodiments, when the stylus is not in contact with the electronic device, the electronic device receives a first instruction sent by the stylus via a communication module. The first instruction is used to remotely control the electronic device to perform a first operation. In response to the first instruction, the electronic device performs a first operation associated with the handwriting corresponding to the stylus, based on a first tilt angle.

[0013] In the above solution, even when the stylus and the electronic device are not in contact, the electronic device can receive a first instruction, enabling the stylus to perform operations on the electronic device remotely. This operation allows users to interact without directly touching the electronic device, enhancing the user experience.

[0014] In another possible implementation of the first aspect, the first operation may be an operation performed on the game interface of the electronic device, the first operation may be an operation to determine the posture of the user holding the stylus, or the first operation may be an operation to determine the action key lock of the electronic device.

[0015] In the above solution, in this embodiment, the electronic device uses a first instruction to perform a first operation associated with the handwriting corresponding to the stylus according to a first tilt angle, thereby improving the user experience.

[0016] In another possible implementation of the first aspect, the electronic device determines the angle between the stylus in the axial direction and the electronic device in the normal direction based on the first and second information. The electronic device then determines the complementary angle corresponding to the included angle and uses the complementary angle as the first tilt angle.

[0017] In the above scheme, the electronic device accurately detects the angle between the stylus in the axial direction and the electronic device in the normal direction, and uses the corresponding complementary angle as the first tilt angle, thereby achieving accurate identification of the first tilt angle.

[0018] In another possible implementation of the first aspect, the electronic device determines a second tilt angle of the stylus in the first direction based on the first information. The electronic device then acquires second information collected by the second accelerometer module. Based on the second information, the electronic device determines a third tilt angle in the first direction. The electronic device then determines the included angle using the second and third tilt angles.

[0019] In the above scheme, the electronic device can accurately obtain the included angle through the second tilt angle and the third tilt angle, so that no matter what posture the electronic device and the stylus are in, the electronic device can accurately calculate the included angle between the normal direction of the electronic device and the axis direction of the stylus.

[0020] In another possible implementation of the first aspect, the stylus may further include a first gyroscope module. The electronic device acquires third information sent by the stylus through a communication module. The third information includes attitude information collected by the first gyroscope module in the stylus. The electronic device then corrects the first information based on the third information to obtain corrected fourth information. The electronic device then determines a first tilt angle between the stylus and the electronic device based on the second and fourth information.

[0021] In the above scheme, there may be errors in the process of the accelerometer sensor module collecting acceleration information. The electronic device can use the gyroscope information (or attitude information) on the stylus to correct the acceleration information collected by the accelerometer sensor module, so as to obtain more accurate acceleration information of the stylus. Furthermore, the electronic device can obtain the first tilt angle more accurately through the corrected acceleration information and the second information.

[0022] In a second aspect, this application provides an electronic device comprising: a memory and one or more processors, wherein when the processors execute one or more computer programs stored in the memory, the electronic device performs the method of the first aspect and any possible implementation thereof.

[0023] Thirdly, this application provides an electronic device comprising: a memory and one or more processors, the memory being coupled to the processors. The memory stores computer program code, which includes computer instructions. When the computer instructions are executed by the processor, the electronic device performs the method described in the first aspect and any of its possible implementations.

[0024] Fourthly, this application provides a chip system applied to an electronic device including a memory and a display screen. The chip system includes a processor that, when executing computer instructions stored in the memory, causes the chip system to perform the method of the first aspect and any possible implementation thereof.

[0025] Fifthly, embodiments of this application provide a computer-readable storage medium including computer instructions that, when executed on an electronic device, cause the electronic device to perform the method as described in the first aspect and any possible implementation thereof.

[0026] Sixthly, embodiments of this application provide a computer program product that, when run on a computer, causes the computer to perform the method as described in the first aspect and any possible implementation thereof. The computer may be an electronic device as described in the second aspect and any possible implementation thereof, an electronic device as described in the third aspect and any possible implementation thereof, or a chip system as described in the fourth aspect and any possible implementation thereof.

[0027] Understandably, the beneficial effects achieved by the electronic device of the second aspect, the electronic device of the third aspect, the chip system of the fourth aspect, the computer-readable storage medium of the fifth aspect, and the computer program product of the sixth aspect provided above can be referred to the beneficial effects in the method of the first aspect and any possible implementation thereof, which will not be repeated here. Attached Figure Description

[0028] Figure 1 A schematic diagram illustrating the interaction between a stylus and an electronic device, provided as an embodiment of this application;

[0029] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application;

[0030] Figure 3 A schematic diagram of the software system architecture of an electronic device provided in an embodiment of this application;

[0031] Figure 4 A flowchart illustrating a handwriting generation method provided in this application embodiment;

[0032] Figure 5A schematic diagram illustrating the principle of angle calculation provided in this application embodiment;

[0033] Figure 6 A flowchart illustrating another handwriting generation method provided in this application embodiment;

[0034] Figure 7 This is a timing diagram illustrating a handwriting generation method provided in an embodiment of this application. Detailed Implementation

[0035] Hereinafter, the terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Thus, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this embodiment, unless otherwise stated, "a plurality of" means two or more.

[0036] Electronic devices can be equipped with styluses to achieve more precise touch and writing. For example, an electronic device can receive touch input from a stylus and reproduce the effect of realistic pen strokes based on the touch input. Styluses can include, but are not limited to, capacitive styluses and electromagnetic styluses; capacitive styluses can further include active capacitive styluses.

[0037] In some embodiments, the electronic device can reproduce the actual strokes of the stylus based on the tilt angle between the electronic device and the stylus (referred to as the tilt angle) and the pressure received by the stylus tip. However, when the tilt angle between the electronic device and the stylus is large, due to the influence of the stylus tip contact structure, the electronic device may be unable to detect the contact point position and further determine the size of the tilt angle, thus preventing the electronic device from reproducing the actual strokes corresponding to the stylus. For example, with a large tilt angle, the electronic device cannot determine the tilt angle, and therefore cannot draw the strokes corresponding to the stylus.

[0038] The following section will explain in detail how a capacitive stylus determines the tilt angle.

[0039] Figure 1 This is a schematic diagram illustrating the interaction between a stylus and an electronic device, provided as an embodiment of this application. Figure 1 As shown in (a), the capacitive stylus has two electrodes. The first electrode 101 is disposed on the tip 102, and the second electrode 103 is disposed on the grip portion 104 of the capacitive stylus. The capacitive stylus can transmit electrical signals to the touch screen of the electronic device through the electrodes. For example, the electrical signal can be composed of high and low levels, and there is a preset transmission pattern in the transmission of high and low levels.

[0040] Combined Figure 1 In (a) and (b), the operating plane on the electronic device 200 receives electrical signals emitted by the two electrodes on the capacitive stylus to determine the first position 105 of the pen tip 102 corresponding to the first electrode 101 on the touch screen, and to determine the second position 106 of the grip portion 104 corresponding to the second electrode 103 vertically mapped on the touch screen.

[0041] The electronic device 200 then determines the first distance between the pen tip 102 and the grip 104, and the second distance between the first position 105 and the second position 106. The electronic device 200 then uses trigonometric functions to determine... The value of is then determined using inverse trigonometric functions in electronic device 200. The value of , where, The tilt angle between the electronic device 200 and the capacitive stylus.

[0042] However, as Figure 1 As shown in (b), since the second electrode 103 is disposed on the grip portion 104, and the grip portion 104 is annular, when the second electrode 103 transmits an electrical signal to the touch screen, a portion of the touch screen can receive the electrical signal, and the electronic device 200 determines the second position 106 within this portion of the touch screen. For example, when the tilt angle between the electronic device 200 and the stylus is small, the area on the electronic device 200 that can receive the electrical signal transmitted by the second electrode 103 is the first area 107, which has a small area, and the electronic device 200 then determines the second position 106 within the first area 107. As another example, when the tilt angle between the electronic device 200 and the stylus is large, the area on the electronic device 200 that can receive the electrical signal transmitted by the second electrode 103 is the second area 108, which has a large area, and the electronic device 200 then determines the second position 106 within the second area 108.

[0043] When the tilt angle between the electronic device 200 and the stylus is relatively large, and the electronic device 200 determines the second position 106 based on the second region 108, the second position 106 determined by the electronic device 200 based on the second region 108 may not be accurate enough due to the large area of ​​the second region 108. This will result in an error in the second distance obtained through the first position 105 and the second position 106, and consequently, an error in the tilt angle obtained through the second distance and the first distance, with the tilt angle error potentially around 5 degrees.

[0044] Furthermore, when the tilt angle between the stylus and the electronic device 200 is large, the electronic device 200 cannot detect the position of the pen tip contact due to the influence of the pen tip contact structure. That is, the electronic device 200 may not be able to determine the first position 105, and thus the electronic device 200 cannot determine the second distance through the first position 105 and the second position 106, and thus cannot determine the tilt angle through the second distance and the first distance. Consequently, the electronic device 200 cannot reconstruct the pen stroke corresponding to the stylus based on the tilt angle information.

[0045] Therefore, this application provides a method for generating handwriting with a stylus. The electronic device determines the tilt angle between the stylus and the electronic device using first acceleration information and second acceleration information. The first acceleration information is the acceleration information collected by a first acceleration sensor module on the stylus, and the second acceleration information is the acceleration information collected by a second acceleration sensor module on the electronic device. When the contact area between the stylus and the electronic device is less than or equal to a first threshold, the electronic device receives and responds to the stylus's instruction, performing an operation associated with the handwriting corresponding to the stylus according to the first tilt angle.

[0046] Understandably, in this embodiment, the acceleration information collected by the accelerometer module can accurately reflect the tilt of the device, and thus the tilt angle determined by the electronic device using the first and second acceleration information is also accurate. Even when the tilt angle between the stylus and the electronic device is large, i.e., when the contact area between the stylus and the electronic device is less than or equal to the first threshold, the electronic device can still accurately determine the tilt angle, and the electronic device can receive and respond to the stylus's instructions, executing operations associated with the handwriting corresponding to the stylus based on the first tilt angle. For example, the electronic device can generate and display the corresponding strokes based on the tilt angle.

[0047] For example, the aforementioned electronic device may be a mobile phone, tablet computer, smart remote control, wearable device (such as smart bracelet, smartwatch, or smart glasses), PDA, augmented reality (AR) / virtual reality (VR) device. Alternatively, the mobile phone 200 may also be a portable multimedia player (PMP), media player, or other types of electronic device. This application embodiment does not impose any limitations on the specific type of electronic device.

[0048] Figure 2 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0049] Electronic device 200 may include processor 210, external memory interface 220, internal memory 221, universal serial bus (USB) interface 230, charging management module 240, power management module 241, battery 242, antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, audio module 270, sensor module 280, cameras 1~N293, and displays 1~N294. The sensor module 280 may include touch sensor 280K, gyroscope sensor 280B, accelerometer sensor 280E, etc.

[0050] It is understood that the structures illustrated in the embodiments of this application do not constitute a specific limitation on the electronic device 200. In other embodiments of this application, the electronic device 200 may include more or fewer components than illustrated, or combine some components, or split some components, or have different component arrangements. The illustrated components may be implemented in hardware, software, or a combination of software and hardware.

[0051] Processor 210 may include one or more processing units, such as application processor (AP), modem processor, graphics processing unit (GPU), image signal processor (ISP), controller, memory, video codec, digital signal processor (DSP), baseband processor, and / or neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors.

[0052] The controller can be the nerve center and command center of the electronic device 200. The controller can generate operation control signals based on the instruction opcode and timing signals to control the fetching and execution of instructions.

[0053] The processor 210 may also include a memory for storing instructions and data. In some embodiments, the memory in the processor 210 is a cache memory. This memory can store instructions or data that the processor 210 has just used or that are used repeatedly. If the processor 210 needs to use the instruction or data again, it can retrieve it directly from the memory. This avoids repeated accesses, reduces the waiting time of the processor 210, and thus improves the efficiency of the system.

[0054] In some embodiments, the processor 210 may include one or more interfaces. 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, etc.

[0055] The I2C interface is a bidirectional synchronous serial bus, including a serial data line (SDA) and a serial clock line (SCL). In some embodiments, the processor 210 may include multiple I2C buses. The processor 210 can couple to the touch sensor 280K, charger, flash, camera 193, etc., through different I2C bus interfaces. For example, the processor 210 can couple to the touch sensor 280K through the I2C interface, enabling the processor 210 and the touch sensor 280K to communicate through the I2C bus interface, thereby realizing the touch function of the electronic device 200.

[0056] The wireless communication function of electronic device 200 can be implemented through antenna 1, antenna 2, mobile communication module 250, wireless communication module 260, modem processor, and baseband processor.

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

[0058] Display screen 294 is used to display images, videos, etc. Display screen 294 includes a display panel. The display panel may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a miniature LED, a microLED, a quantum dot light-emitting diode (QLED), etc. In some embodiments, electronic device 200 may include one or N displays 294, where N is a positive integer greater than 1.

[0059] Video codecs are used to compress or decompress digital video. Electronic device 200 may support one or more video codecs. Thus, electronic device 200 can play or record video in various encoding formats, such as Moving Picture Experts Group (MPEG) 1, MPEG2, MPEG3, MPEG4, etc.

[0060] An NPU (Neural Processing Unit) is a neural network (NN) computing processor that, by borrowing the structure of biological neural networks, such as the transmission patterns between neurons in the human brain, rapidly processes input information and can continuously learn on its own. NPUs enable intelligent cognitive applications in electronic devices, such as image recognition, facial recognition, speech recognition, and text understanding.

[0061] The external storage interface 220 can be used to connect an external memory card, such as a Micro SD card, to expand the storage capacity of the electronic device 200. The external memory card communicates with the processor 210 through the external storage interface 220 to perform data storage functions. For example, music, video, and other files can be saved on the external memory card.

[0062] Internal memory 221 can be used to store computer executable program code, which includes instructions. Processor 210 executes various functional applications and data processing of electronic device 200 by running the instructions stored in internal memory 221. Internal memory 221 may include a program storage area and a data storage area. The program storage area may store the operating system, at least one application program required for a function (such as sound playback, image playback, etc.), etc. The data storage area may store data created during the use of electronic device 200 (such as audio data, phonebook, etc.). Furthermore, internal memory 221 may include high-speed random access memory, and may also include non-volatile memory, such as at least one disk storage device, flash memory device, universal flash storage (UFS), etc.

[0063] Touch sensor 280K, also known as a "touch panel," can be located on display screen 294. The touch sensor 280K and display screen 294 together form a touchscreen, also known as a "touchscreen." Touch sensor 280K detects touch operations applied to or near it. The touch sensor can transmit the detected touch operation to the application processor to determine the type of touch event. Visual output related to the touch operation can be provided through display screen 294. In other embodiments, touch sensor 280K may also be located on the surface of electronic device 200, in a different position than display screen 294.

[0064] The gyroscope sensor 280B can be used to determine the motion attitude of the electronic device 200. In some embodiments, the gyroscope sensor 280B can determine the angular velocity of the electronic device 200 around three axes (i.e., the x, y, and z axes). The gyroscope sensor 280B can be used for image stabilization. For example, when the shutter is pressed, the gyroscope sensor 280B detects the angle of the electronic device 200's shake, calculates the distance that the lens module needs to compensate based on the angle, and allows the lens to counteract the shake of the electronic device 200 through reverse movement, thus achieving image stabilization. The gyroscope sensor 280B can also be used in navigation and motion-sensing game scenarios.

[0065] The accelerometer 280E can detect the magnitude of acceleration of electronic device 200 in various directions (typically three axes). When electronic device 200 is stationary, it can detect the magnitude and direction of gravity. It can also be used to identify the posture of electronic device, and can be applied to applications such as screen orientation switching and pedometers.

[0066] Figure 3 This is a schematic diagram of the software system architecture of an electronic device provided in an embodiment of this application.

[0067] The software system of an electronic device can adopt a layered architecture, event-driven architecture, microkernel architecture, microservice architecture, or cloud architecture. This embodiment of the invention uses the layered architecture Android system as an example to illustrate the software structure of an electronic device.

[0068] A layered architecture divides software into several layers, each with a clear role and function. Layers communicate with each other through software interfaces. In some embodiments, the Android system is divided into four layers, from top to bottom: the application layer, the application framework layer, the hardware abstraction layer, and the kernel layer.

[0069] The application layer can include a series of application packages.

[0070] like Figure 3 As shown, the application layer can include system applications, third-party applications, etc. It should be understood that system applications can include: drawing tablet, camera, gallery, calendar, call, map, navigation, WLAN, Bluetooth, music, video, SMS, and other applications, not all of which are shown in the diagram.

[0071] The application framework layer provides application programming interfaces (APIs) and a programming framework for applications in the application layer. The application framework layer includes a set of predefined functions.

[0072] like Figure 3 As shown, the application framework layer may include a stylus interface. The application framework layer may also include a window manager, content provider, view system, phone manager, resource manager, notification manager, etc., not all of which are shown in the diagram.

[0073] The stylus interface is used to provide applications in the application layer with information related to the current touch of the stylus. This information includes: the coordinate position information of the stylus, the pressure information of the stylus, and the tilt angle between the stylus and the electronic device.

[0074] The Hardware Abstraction Layer (HAL) is a layer located between the application framework layer and the kernel layer, and its purpose is to abstract the hardware. The HAL includes a tilt angle calculation module. This module reads first and second information from the kernel layer and calculates the tilt angle between the stylus and the electronic device based on this information.

[0075] The kernel layer is the layer between hardware and software. It includes Bluetooth drivers, sensor drivers, and more. The Bluetooth driver connects to other devices, enabling Bluetooth communication. For example, an electronic device can use the Bluetooth driver to receive initial information from a stylus pen via Bluetooth. The sensor driver reads sensor information and transmits it to the tilt calculation module. For instance, the sensor driver can acquire information from accelerometers and touch sensors.

[0076] The handwriting generation method of this application will be described in detail below with reference to the accompanying drawings.

[0077] Figure 4 This is a flowchart illustrating a handwriting generation method provided in an embodiment of this application. Figure 4 As shown, the specific implementation steps of the handwriting generation method of this application are as follows.

[0078] Step 401: The electronic device receives the first information sent by the stylus through the communication module. The first information includes the acceleration information collected by the first acceleration sensor module in the stylus.

[0079] The electronic device and the stylus may be equipped with a communication module, which may be a Bluetooth module, an infrared transmission module, a Wi-Fi transmission module, etc. The communication module enables communication between the electronic device and the stylus. This application embodiment does not limit the communication method; it can be Bluetooth communication, Wi-Fi communication, infrared communication, etc.

[0080] An accelerometer module can detect changes in an object's orientation in space, especially in terms of tilt angle. Acceleration information reflects changes in an object's acceleration along three axes (typically the X, Y, and Z axes), and the object's orientation in space is determined by these acceleration change data.

[0081] In this embodiment, after the electronic device and the stylus establish a communication connection, the stylus can send first information to the electronic device in real time to inform the electronic device of the acceleration information currently collected by the first acceleration sensor module in the stylus.

[0082] Step 402: The electronic device determines a first tilt angle between the stylus and the electronic device. The first tilt angle is determined by first information and second information, wherein the second information includes acceleration information collected by the second acceleration sensor module, or the second information includes tilt angle information associated with the acceleration information collected by the second acceleration sensor module.

[0083] In this embodiment, the electronic device is also equipped with an acceleration sensor module, which is used to collect the acceleration information of the electronic device and determine the changes of the electronic device in space through the acceleration information.

[0084] The electronic device can also obtain associated tilt information based on the acceleration information collected by the second acceleration sensor module. The tilt information can refer to the tilt angle information between the electronic device and the reference X-axis, Y-axis and Z-axis. For example, the electronic device can obtain pitch angle information relative to the reference X-axis, roll angle information relative to the Y-axis and yaw angle information relative to the Z-axis.

[0085] In some embodiments, when the second information is tilt information, the electronic device can also convert the acceleration information in the first information into associated tilt information, and then obtain the first tilt angle between the stylus and the electronic device based on the tilt information corresponding to the first information and the second information.

[0086] In some embodiments, when the second information is acceleration information, the electronic device can directly calculate the first tilt angle between the stylus and the electronic device based on the first and second information. Alternatively, the electronic device can convert the first information into associated first tilt angle information and the second information into associated second tilt angle information, and then obtain the first tilt angle between the stylus and the electronic device based on the first and second tilt angle information.

[0087] Step 403: When the contact area between the stylus and the electronic device is less than or equal to the first threshold, the electronic device receives the first instruction from the stylus.

[0088] In this embodiment, when the tilt angle between the electronic device and the stylus is large, the contact area between the stylus and the electronic device will be less than or equal to the first threshold.

[0089] The first instruction is used to cause the electronic device to perform an operation associated with the handwriting corresponding to the stylus according to the first tilt angle. For example, the first instruction can cause the electronic device to draw the handwriting corresponding to the stylus according to the first tilt angle, or the first instruction can cause the electronic device to perform certain operations without contact between the electronic device and the stylus, such as transferring a file on the electronic device to another electronic device via the stylus. In the embodiments of this application, the first instruction is not limited.

[0090] Step 404: The electronic device responds to the first instruction and performs an operation associated with the handwriting corresponding to the stylus according to the first tilt angle.

[0091] In this embodiment, the operations associated with the handwriting of the stylus can include handwriting operations, touch operations, etc. For example, when the electronic device responds to the first instruction and performs a handwriting operation corresponding to the stylus according to the first tilt angle, the electronic device can generate the handwriting corresponding to the stylus according to the first tilt angle and display it on the screen of the electronic device. For example, the electronic device responds to the first instruction, obtains the first tilt angle, and performs a touch operation corresponding to the stylus according to the first tilt angle, and the electronic device can respond to the touch operation.

[0092] Understandably, in this embodiment, both the first and second information are determined based on the acceleration information collected by the accelerometer module. The acceleration information collected by the accelerometer module can accurately reflect the tilt of the device, and thus the tilt angle determined by the electronic device using the first and second information is also accurate. Even when the tilt angle between the stylus and the electronic device is large, i.e., when the contact area between the stylus and the electronic device is less than or equal to the first threshold, the electronic device can still accurately determine the tilt angle, and the electronic device can receive and respond to the stylus's instructions, accurately executing the operation associated with the handwriting corresponding to the stylus according to the first tilt angle.

[0093] In some embodiments, the first tilt angle can range from 0 degrees to 360 degrees.

[0094] Understandably, both the first and second pieces of information are determined based on the acceleration information collected by the accelerometer module, which reflects the directional changes of the device containing the accelerometer throughout space. Therefore, the first tilt angle obtained by the electronic device based on the first and second information can range from 0 degrees to 360 degrees. That is, regardless of the posture of the electronic device and the stylus, the electronic device can determine the tilt angle between them.

[0095] In some embodiments, when the electronic device is a flat-screen device, the electronic device can detect an angle between the electronic device and the stylus ranging from 0 degrees to 360 degrees. In other embodiments, when the electronic device is a foldable-screen device, the electronic device can also detect an angle between the electronic device and the stylus ranging from 0 degrees to 360 degrees. That is, in the embodiments of this application, regardless of the type of electronic device, the angle between a certain operating plane on the electronic device and the stylus can be detected through the embodiments of this application.

[0096] Taking a flat-screen electronic device as an example, the electronic device may also include a touchscreen. When a stylus is in contact with the touchscreen, the electronic device can detect the tilt angle between the touchscreen and the stylus, which can range from 0 degrees to 180 degrees. For instance, when the electronic device receives a touch operation from the stylus on the touchscreen, it can detect the tilt angle between the stylus and the touchscreen, which can range from 0 degrees to 180 degrees, and generate the corresponding handwriting based on the tilt angle.

[0097] Taking a flat-screen electronic device as an example, with a touch screen on one side of the electronic device and a stylus on the side facing away from the touch screen, and the stylus not in contact with the touch screen, the electronic device can detect tilt angles ranging from 180 degrees to 360 degrees, and the electronic device can perform operations associated with the handwriting corresponding to the stylus according to the tilt angle.

[0098] Taking a foldable screen electronic device as an example, when the foldable screen electronic device is an outward foldable screen electronic device, no matter which side of the screen the stylus touches, the electronic device can detect the tilt angle between the stylus and the electronic device, and the tilt angle range is 0 degrees to 360 degrees.

[0099] After determining the first tilt angle, the electronic device can perform operations associated with the handwriting corresponding to the stylus. The following section explains in detail how the electronic device performs these operations based on the first tilt angle.

[0100] In some embodiments, when the contact area between the stylus and the touchscreen is less than or equal to a first threshold, the electronic device receives a first instruction generated by the stylus contacting the touchscreen. In response to the first instruction, the electronic device performs a handwriting operation associated with the handwriting corresponding to the stylus, based on a first tilt angle.

[0101] The following is a specific example illustrating how an electronic device performs handwriting operations.

[0102] After establishing a communication connection between the electronic device and the stylus, the electronic device will determine the stylus's current coordinate position, pressure, and tilt angle information in real time. The coordinate position information is determined by the touchscreen. The pressure and tilt angle information can be determined by the first information received by the communication module. Specifically, the first information may include acceleration information collected by the first sensor module, as well as the stylus's pressure information. The electronic device can determine the tilt angle information using the acceleration information collected by the first and second sensor modules.

[0103] After determining the coordinate position, pressure, and first tilt angle information of the stylus during touch, the electronic device receives and responds to the stylus's first command and executes a handwriting operation based on the first tilt angle. The handwriting operation refers to the process by which the electronic device generates and displays handwriting based on the stylus's movement and tilt angle changes when the stylus is used for handwriting or drawing on the electronic device. Furthermore, even if the first tilt angle is large, causing the contact area between the stylus and the touchscreen to be less than or equal to a first threshold, the electronic device can still generate corresponding handwriting based on the first tilt angle during the handwriting operation.

[0104] In some embodiments, the electronic device may also incorporate 0g ink dispensing technology, enabling the electronic device to generate corresponding handwriting even when the first tilt angle is large.

[0105] Specifically, when the initial tilt angle is large, the stylus tip may tilt upwards due to the influence of the pen tip contact structure, and the tip may not be able to contact the touchscreen. In this case, the stylus cannot obtain pressure information from the pen tip, making it impossible for the electronic device to generate and display the corresponding handwriting even at a large tilt angle.

[0106] In this embodiment, the electronic device uses zero-gram ink dispensing technology so that even when the stylus cannot obtain pressure information from the pen tip due to a large tilt angle, the electronic device can still generate and display the corresponding handwriting based on the change in capacitance.

[0107] Understandably, in this embodiment, when the contact area between the stylus and the touchscreen is less than or equal to the first threshold, the electronic device can also perform a handwriting operation associated with the handwriting corresponding to the stylus based on the first tilt angle after receiving the first instruction. That is, the electronic device can perform a handwriting operation even when the first tilt angle is large, so that the electronic device can better simulate the effect of the user writing with a real pen and improve the user experience.

[0108] In other embodiments, when the stylus is not in contact with the electronic device, the electronic device receives a first instruction sent by the stylus via a communication module. The first instruction is used to remotely control the electronic device to perform a first operation. In response to the first instruction, the electronic device performs a first operation associated with the handwriting corresponding to the stylus, based on a first tilt angle.

[0109] Understandably, in this embodiment, even when the stylus and the electronic device are not in contact, the electronic device can receive a first instruction to enable the stylus to perform operations on the electronic device remotely. This operation allows users to interact without directly touching the electronic device, enhancing the user experience.

[0110] In some embodiments, the first operation may be an operation performed on the game interface of the electronic device, the first operation may be an operation to determine the posture of the user holding the stylus, or the first operation may be an operation to determine the action key lock of the electronic device.

[0111] The first operation, which can be performed on the game interface of an electronic device, means that the electronic device can use a stylus as a joystick on the game interface. For example, after the electronic device detects the handwriting corresponding to the stylus, it can operate the game interface according to the handwriting.

[0112] The first operation can also be the operation of determining the posture of the user holding the stylus. This means that the electronic device can detect the corresponding handwriting during the movement of the stylus and determine the posture of the user holding the stylus based on the handwriting.

[0113] In some embodiments, after determining the posture of the user holding the stylus, the electronic device can determine the handwriting the user is currently writing in the air based on the user's posture, and the electronic device can generate a corresponding string based on the handwriting.

[0114] After determining the posture of the user holding the stylus, the electronic device can also simulate the sound of the user playing a musical instrument based on that posture.

[0115] Once the electronic device determines the posture of the user holding the stylus, it can perform corresponding operations based on the preset posture. For example, if the electronic device determines that the user's posture is posture 1, it can transfer data from its memory to other electronic devices.

[0116] No restrictions are placed on the operation of the electronic device after it determines the posture of the user holding the stylus.

[0117] The first step can also be to determine the action lock operation of the electronic device. This means that the electronic device can detect the dynamic information of the user's hand movements using a stylus. Since the user's dynamic information is difficult to imitate, the electronic device can use this dynamic information as an action lock. The electronic device can determine the currently detected action lock, and if the action lock is correct, the electronic device can be unlocked.

[0118] Understandably, in this embodiment, the electronic device uses a first instruction to perform a first operation associated with the handwriting corresponding to the stylus based on a first tilt angle, thereby improving the user experience.

[0119] In some embodiments, the electronic device determines the angle between the stylus in the axial direction and the electronic device in the normal direction based on first information and second information. The electronic device then determines the complementary angle corresponding to the included angle and uses the complementary angle as the first tilt angle.

[0120] Here, the axial direction refers to the direction in which the stylus extends, while the normal direction refers to the direction perpendicular to the screen or operating plane of the electronic device.

[0121] During the process of determining the included angle, the electronic device uses first and second information to determine the tilt angle of the stylus relative to the screen or plane of the electronic device. After determining the included angle, the electronic device then determines the complementary angle, and uses this complementary angle as the tilt angle between the electronic device and the stylus. For example, the electronic device can obtain the complementary angle by subtracting the determined included angle from 90 degrees.

[0122] Understandably, in this embodiment, the electronic device accurately identifies the first tilt angle by precisely detecting the angle between the stylus in the axial direction and the electronic device in the normal direction, and using the corresponding complementary angle as the first tilt angle.

[0123] The following section will provide a more detailed explanation of how to obtain the included angle based on the first and second pieces of information.

[0124] In some embodiments, the electronic device determines a second tilt angle of the stylus in a first direction based on first information. The electronic device then acquires second information collected by a second accelerometer module. Based on the second information, the electronic device determines a third tilt angle in the first direction. The electronic device then determines the included angle using the second and third tilt angles.

[0125] Figure 5 This is a schematic diagram illustrating the principle of angle calculation provided in an embodiment of this application. Figure 5 As shown, the electronic device 200 can establish a reference coordinate system, namely, a spatial coordinate system with X-axis, Y-axis, and Z-axis. The first direction can be the Z-axis direction, the second tilt angle can be the tilt angle between the axis direction of the stylus 100 and the Z-axis direction, and the third tilt angle can be the tilt angle between the normal direction of the electronic device 200 and the Z-axis direction. Based on the second and third tilt angles, the electronic device 200 then obtains the angle between the normal direction of the electronic device 200 and the axis direction of the stylus 100. In this embodiment, the first direction can also be the X-axis direction or the Y-axis direction; no limitation is made on the first direction in this application.

[0126] Specifically, the electronic device establishes a reference coordinate system, and the first direction can be... Figure 5 The electronic device acquires the acceleration information of the stylus collected by the first acceleration sensor module in the first information, and then converts the acceleration information into the tilt angle between the axis direction of the stylus and the X-axis, Y-axis and Z-axis directions.

[0127] The following example illustrates how an electronic device converts acceleration information into a second tilt angle between the axis of the stylus and the Z-axis.

[0128] The electronic device first converts the acceleration information of the stylus along the X-axis into pitch angle values, the acceleration information along the Y-axis into roll angle values, and the acceleration information along the Z-axis into yaw angle values. The converted angle values ​​can be represented by (f1, g1, p1), where f1 is the pitch angle, g1 is the roll angle, and p1 is the yaw angle. The acceleration values ​​can be represented by (x1, y1, z1), where x1 is the acceleration value along the X-axis, y1 is the acceleration value along the Y-axis, and z1 is the acceleration value along the Z-axis. The formula for converting (x1, y1, z1) to (f1, g1, p1) can be:

[0129] f1= ;

[0130] g1= ;

[0131] p1= .

[0132] The electronic device then uses the pitch, roll, and yaw angle values ​​to obtain the first spatial vector of the stylus in the reference coordinate system. The electronic device then calculates the component of this first spatial vector along the Z-axis, thus obtaining the second spatial vector. For example, the electronic device can multiply the inverse of the first spatial vector by (0, 0, 1) to obtain the second spatial vector. Since the electronic device is calculating the component along the Z-axis, the Z-axis value is 1, the X-axis value is 0, and the Y-axis value is 0. Its expression can be:

[0133] ;

[0134] in, Let be the first spatial vector. This is the second spatial vector.

[0135] After obtaining the second spatial vector, that is, after obtaining the component of the first spatial vector in the Z-axis direction, the electronic device then calculates the second tilt angle between the axis direction of the stylus and the Z-axis direction based on the second spatial vector.

[0136] Similarly, the electronic device acquires the acceleration information collected by the second acceleration sensor module in the second information. The electronic device first converts the acceleration information along the X-axis into a pitch angle value, the acceleration information along the Y-axis into a roll angle value, and the acceleration information along the Z-axis into a yaw angle value. Based on the pitch, roll, and yaw angle values, the electronic device then obtains a third spatial vector in the reference coordinate system. The electronic device then calculates the component of this third spatial vector along the Z-axis, thus obtaining a fourth spatial vector. After obtaining the fourth spatial vector—that is, after obtaining the component of the third spatial vector along the Z-axis—the electronic device calculates the third tilt angle between the normal direction and the Z-axis direction based on the fourth spatial vector.

[0137] After obtaining the third and second tilt angles, the electronic device can then determine the included angle based on these angles. In other words, the electronic device determines the angle between the normal direction of the electronic device and the axis direction of the stylus. For example, the electronic device can add the third and second tilt angles to obtain the included angle.

[0138] Alternatively, in other embodiments, after the electronic device obtains the fourth spatial vector and the second spatial vector, it can calculate the dot product between the fourth and second spatial vectors, calculate the magnitude of the fourth spatial vector, and calculate the magnitude of the second spatial vector. Then, it divides the dot product between the fourth and second spatial vectors by the magnitudes of the fourth and second spatial vectors to directly obtain the angle between the normal direction of the electronic device and the axis direction of the stylus. Its expression can be:

[0139] ,in, Angle For the second spatial vector, It is the fourth space vector.

[0140] Understandably, in this embodiment, the electronic device can accurately obtain the included angle through the second tilt angle and the third tilt angle, so that the electronic device can accurately calculate the included angle between the normal direction of the electronic device and the axial direction of the stylus regardless of the posture of the electronic device and the stylus.

[0141] In some embodiments, the stylus may further include a first gyroscope module. The electronic device acquires third information sent by the stylus through a communication module. The third information includes attitude information collected by the first gyroscope module in the stylus. The electronic device then corrects the first information based on the third information to obtain corrected fourth information. The electronic device then determines a first tilt angle between the stylus and the electronic device based on the second and fourth information.

[0142] Understandably, in this embodiment, there may be errors in the process of the accelerometer sensor module collecting acceleration information. The electronic device can use the gyroscope information (or attitude information) on the stylus to correct the acceleration information collected by the accelerometer sensor module, so as to obtain more accurate acceleration information of the stylus. Furthermore, the electronic device can obtain the first tilt angle more accurately through the corrected acceleration information and the second information.

[0143] The gyroscope module and the accelerometer module can be integrated on the same chip or on different chips, and the power supply module on the stylus can power the chips.

[0144] Next, let's combine... Figure 3 The software architecture described in the document will be explained in more detail with respect to specific embodiments of the handwriting generation method of this application. For example... Figure 6 As shown, Figure 6 The following is a flowchart illustrating another handwriting generation method provided in this application embodiment, with the specific steps as follows.

[0145] Step 601: The tilt angle calculation module in the hardware abstraction layer of the electronic device reads the first information and the second information, and calculates the first tilt angle based on the first information and the second information.

[0146] The first piece of information is obtained by receiving information sent by the stylus in real time through the Bluetooth driver in the kernel layer. The second piece of information is the acceleration information collected in real time by the second accelerometer module in the sensor driver in the kernel layer.

[0147] Step 602: The electronic device determines the pressure information of the stylus based on the first information received in real time by the Bluetooth driver.

[0148] Step 603: The electronic device acquires the information collected by the touch sensor through the sensor driver and determines the coordinate position information of the current touch of the stylus.

[0149] Step 604: The electronic device responds to the operation of opening the drawing board application. The drawing board application calls the stylus interface in the application framework layer to obtain the current touch coordinate position information, first tilt angle and pressure information of the stylus.

[0150] Step 605: The electronic device generates the handwriting corresponding to the stylus based on the information returned by the stylus interface, and displays the handwriting in the interface of the drawing board application.

[0151] In this embodiment, the execution order of the steps of calculating the first tilt angle, determining the coordinate position information, and determining the pressure information by the electronic device is not limited, and they can also be executed simultaneously.

[0152] The handwriting generation method of this application will be further explained below with reference to the timing diagram. For example... Figure 7 As shown, Figure 7 The following is a timing diagram illustrating a handwriting generation method provided in an embodiment of this application. The specific steps are as follows.

[0153] Step 701: The tilt angle calculation module reads the first information and the second information, and calculates the first tilt angle based on the first information and the second information.

[0154] Step 702: The tilt angle calculation module determines the coordinate position information and pressure information of the stylus's current touch.

[0155] Step 703: In response to the drawing board opening operation, the drawing board calls the stylus interface to obtain the current touch coordinate position information, first tilt angle and pressure information of the stylus.

[0156] Step 704: The stylus interface obtains the current touch coordinate position information, first tilt angle, and pressure information of the stylus from the tilt angle calculation module.

[0157] Step 705: The stylus interface returns the current touch coordinate position information, first tilt angle, and pressure information of the stylus to the drawing board.

[0158] Step 706: The drawing board generates the corresponding handwriting based on the coordinate position information, first tilt angle, and pressure information of the stylus returned by the stylus interface.

[0159] Understandably, in the embodiments of this application, during data transmission by the communication module on the electronic device, the transmission protocol can be analyzed to obtain the transmitted data. If it is determined that the data transmitted from the stylus to the electronic device is acceleration information or gyroscope data, then the solution of this application is used.

[0160] In summary, the handwriting generation method of this application enables the electronic device to accurately determine the tilt angle between the electronic device and the handwriting pen using the first and second information. Even when the tilt angle is large, the electronic device can still perform the handwriting-related operations based on the tilt angle, ensuring the normal operation of the handwriting pen on the electronic device and achieving accurate detection of large tilt angles.

[0161] Other embodiments of this application provide an electronic device that may include a memory and one or more processors. When the processors execute one or more computer programs stored in the memory, the electronic device performs the various functions or steps described in the method embodiments above. The structure of this electronic device can be referred to... Figure 2 and Figure 3 The structure of the electronic device 200 shown.

[0162] Other embodiments of this application provide an electronic device that may include a memory and one or more processors coupled together. The memory stores computer program code, which includes computer instructions. When the computer instructions are executed by the processor, the electronic device performs the various functions or steps described in the above method embodiments. The structure of this electronic device can be referred to... Figure 2 and Figure 3 The structure of the electronic device 200 shown.

[0163] Other embodiments of this application provide a chip system applied to an electronic device including a memory and a display screen. The chip system includes a processor. When the processor executes computer instructions stored in the memory, it causes the chip system to perform the various functions or steps described in the above method embodiments. The structure of the electronic device can be referred to... Figure 2 and Figure 3 The structure of the electronic device 200 shown.

[0164] This application also provides a computer storage medium that includes computer instructions. When the computer instructions are executed on the electronic device, the electronic device performs various functions or steps performed by the electronic device in the above method embodiments.

[0165] This application also provides a computer program product that, when run on a computer, causes the computer to perform various functions or steps performed by the electronic device in the above method embodiments.

[0166] Through the above description of the embodiments, those skilled in the art can clearly understand that, for the sake of convenience and brevity, only the division of the above functional modules is used as an example. In actual applications, the above 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.

[0167] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another apparatus, or some features may be ignored or not executed. Furthermore, the mutual coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.

[0168] The units described as separate components may or may not be physically separate. A component shown as a unit can be one or more physical units; that is, it can be located in one place or distributed in multiple different locations. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0169] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.

[0170] If the integrated unit is implemented as 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 solutions of the embodiments of this application, in essence, or the parts that contribute to the prior art, or all or part of the technical solutions, can be embodied in the form of a software product. This software product is stored in a storage medium and includes several instructions to cause a device (which may be a microcontroller, chip, etc.) or processor to execute all or part of the steps of the methods of the various embodiments of this application. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0171] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented in software, it can be implemented, in whole or in part, as a computer program product. A computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, all or part of the flow or function according to the embodiments of this application is generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., coaxial cable, fiber optic, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that integrates one or more available media. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state drive), etc.

[0172] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. This program can be stored in a computer-readable storage medium, and when executed, it can include the processes described in the above method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM or random access memory (RAM), magnetic disks, or optical disks.

[0173] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions within the technical scope disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

Claims

1. A method for generating handwriting with a stylus, applied to electronic devices, characterized in that, The electronic device includes a communication module and a second acceleration sensor module, and the method includes: The communication module receives first information sent by the stylus, the first information including acceleration information collected by the first acceleration sensor module in the stylus; The acceleration information in the first information is converted into a first angle value, which includes pitch angle, roll angle, and yaw angle values. Based on the first angle value, a first spatial vector of the stylus in the spatial coordinate system is determined. The inverse vector of the first spatial vector is multiplied by a unit vector in the first direction to obtain a second spatial vector, which is the component of the first spatial vector in the first direction. A second tilt angle of the stylus between the axial direction and the first direction is determined according to the second spatial vector. The axial direction refers to the extension direction of the stylus. The first direction includes the Z-axis direction. Obtain second information, which includes acceleration information collected by the second acceleration sensor module; The acceleration information in the second information is converted into a second angle value, which includes pitch angle, roll angle, and yaw angle values. Based on the second angle value, a third spatial vector of the electronic device in the spatial coordinate system is determined. The inverse vector of the third spatial vector is multiplied by the unit vector of the first direction to obtain a fourth spatial vector, which is the component of the third spatial vector in the first direction. A third tilt angle between the normal direction of the electronic device and the first direction is determined according to the fourth spatial vector. The normal direction refers to the direction perpendicular to the screen or operating plane of the electronic device. Add the second tilt angle and the third tilt angle to obtain the angle between the stylus in the axial direction and the electronic device in the normal direction, and take the complementary angle corresponding to the included angle as the first tilt angle between the stylus and the electronic device; When the contact area between the stylus and the electronic device is less than or equal to a first threshold, a first instruction from the stylus is received; in response to the first instruction, a handwriting operation associated with the handwriting corresponding to the stylus is executed according to the first tilt angle to restore the real handwriting; Before converting the acceleration information in the first information into a first angle value, the method further includes: The communication module obtains third information sent by the stylus, the third information including posture information collected by the first gyroscope module in the stylus; and the first information is corrected based on the third information.

2. The method according to claim 1, characterized in that, The first tilt angle ranges from 0 degrees to 360 degrees.

3. The method according to claim 1 or 2, characterized in that, The electronic device further includes: a touch screen; receiving a first instruction from the stylus, including: receiving the first instruction generated by the stylus contacting the touch screen when the contact area between the stylus and the touch screen is less than or equal to a first threshold; In response to the first instruction, performing an operation associated with the handwriting corresponding to the stylus according to the first tilt angle includes: in response to the first instruction, performing a handwriting operation associated with the handwriting corresponding to the stylus according to the first tilt angle.

4. The method according to claim 1 or 2, characterized in that, The method further includes: receiving a first instruction from the stylus, including: receiving the first instruction sent by the stylus through the communication module when the stylus is not in contact with the electronic device, wherein the first instruction is used to remotely control the electronic device to perform a first operation; In response to the first instruction, performing an operation associated with the handwriting corresponding to the stylus according to the first tilt angle includes: in response to the first instruction, performing a first operation associated with the handwriting corresponding to the stylus according to the first tilt angle.

5. The method according to claim 4, characterized in that, The first operation includes any one of the following: The first operation is performed on the game interface of the electronic device; The first operation is to determine the posture of the user holding the stylus; The first operation is to determine the action password lock operation of the electronic device.

6. An electronic device, characterized in that, The electronic device includes: one or more processors; when the processors execute one or more computer programs stored in a memory, the electronic device performs the method as described in any one of claims 1-5.

7. An electronic device, characterized in that, The electronic device includes: one or more processors; a memory; wherein the memory is coupled to the one or more processors, the memory is used to store computer program code, the computer program code including computer instructions, and the one or more processors call the computer instructions to cause the electronic device to perform the method as described in any one of claims 1-5.

8. A chip system, characterized in that, The chip system is applied to an electronic device including a memory and a display screen; the chip system includes a processor; when the processor executes computer instructions stored in the memory, the electronic device performs the method as described in any one of claims 1-5.

9. A computer-readable storage medium comprising instructions, characterized in that, When the instructions are executed on an electronic device, the electronic device causes the electronic device to perform the method as described in any one of claims 1-5.

10. A computer program product containing instructions, characterized in that, When the computer program product is run on an electronic device, it causes the electronic device to perform the method as described in any one of claims 1-5.