Function switching method and device, computer equipment and storage medium

By setting function selectors and function pins in the headphone box and using software programs to realize time-sharing control communication or charging logic, the existing TWS headphones have solved the problems of high hardware costs and long development time, and efficient charging and communication functions are achieved.

CN120034770APending Publication Date: 2025-05-23SHENZHEN 3NOD DIGITAL TECH
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311570382.7
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-11-21
Publication Date
2025-05-23

AI Technical Summary

Technical Problem

When implementing time-sharing control communication or charging logic, existing TWS headphones need to add a variety of hardware modules, resulting in high manufacturing costs. The conventional two-PIN pin communication method relies on proprietary chips, limiting the code porting and development time.

Method used

By setting the first function selector and the first function pin in the headphone box, the logic of time-sharing control communication or charging is realized using the software program. The specific steps include obtaining the switch box status of the headphone box and the headphone communication information of the TWS headphones, determining the control program based on the status and information, and switching the corresponding function of the control function pins.

Benefits of technology

It realizes charging control and communication functions through 2 pins, saves hardware costs, and supports internal program switching of headphone boxes, making it convenient to customize customer needs and functions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120034770A_ABST
    Figure CN120034770A_ABST
Patent Text Reader

Abstract

The embodiment of the invention belongs to the technical field of wireless earphones, and relates to a function switching method, which comprises the following steps: acquiring a switch box state of an earphone box and earphone communication information of a TWS earphone; if the earphone box is in an open box state, the first function selector enters a communication mode, and the first function pin and the TWS earphone are controlled to perform information interaction processing through a first control program; if the earphone box is in a closed state and the earphone communication information is charging information, the first function selector enters a discharging mode, and the first function pin is controlled through a first control program to charge the TWS earphone; if the earphone box is in a closed box state and the earphone communication information is upgrading information, the first function selector enters a communication mode, and the first function pin is controlled by the first control program to carry out background upgrading processing on the TWS earphone, so that the logic of communication or charging is controlled in a time-sharing manner through a software program, the hardware cost can be greatly saved, and the communication efficiency is improved. And customer requirements and functions can be customized conveniently.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the technical field of wireless headsets, and in particular to a function switching method, device, computer equipment and storage medium. Background Art

[0002] Currently, if TWS headphones want to implement time-sharing control communication or charging logic, they need to add multiple hardware modules. For example, the peripheral circuit of the main control module requires the cooperation of multiple modules to realize the function, which has high manufacturing costs.

[0003] The existing conventional two-PIN communication method uses a dedicated chip to control communication and charging through I2C reading and writing, such as SY8801 and SY5500. Due to certain limitations of the proprietary chip itself, the code cannot be transplanted according to the existing code, which increases the development time. Summary of the invention

[0004] The purpose of the embodiments of the present application is to propose a function switching method, device, computer equipment and storage medium, so as to achieve the logic of time-sharing control of communication or charging through software programs, thereby saving hardware costs.

[0005] In order to solve the above technical problems, an embodiment of the present application provides a function switching method, which is applied to an earphone box, characterized in that the earphone box is provided with a first function selector and a first function pin, the first function selector includes a first control program, and adopts the following technical solution:

[0006] When a TWS headset is placed in the headset box, a switch box state of the headset box and headset communication information of the TWS headset are obtained, wherein the headset communication information includes charging information and upgrade information, and the switch box state includes an open box state and a closed box state;

[0007] If the earphone box is in an open box state, the first function selector enters a communication mode, and the first function pin is controlled by the first control program to perform information interaction processing with the TWS earphone;

[0008] If the earphone box is in a closed box state and the earphone communication information is charging information, the first function selector enters a discharge mode, and the first function pin is controlled by the first control program to charge the TWS earphone;

[0009] If the earphone box is in a closed box state and the earphone communication information is upgrade information, the first function selector enters a communication mode, and controls the first function pin through the first control program to perform background upgrade processing on the TWS earphone.

[0010] Further, if the earphone box is in a closed box state and the earphone communication information is upgrade information, the first function selector enters a communication mode, and after the step of controlling the first function pin to perform background upgrade processing on the TWS earphone through the first control program, it also includes:

[0011] The TWS earphone is timed by the first functional pin to obtain the warehouse entry time of the TWS earphone, wherein the prerequisite for the warehouse entry time is that the earphone box is in a closed box state;

[0012] The entry time is compared with the preset timeout standby time. If the entry time is greater than or equal to the preset timeout standby time, the timing process is terminated and the TWS headset is charged through the first functional pin. If the entry time is less than the preset timeout standby time, the timing process is continued.

[0013] Further, if the earphone box is in an open box state, the first function selector enters a communication mode, and the step of controlling the first function pin to perform information interaction processing with the TWS earphone through the first control program specifically includes:

[0014] Determine the position of the TWS headset;

[0015] If the TWS earphone is in the earphone box, the foreground upgrade process is performed with the TWS earphone through the first function pin;

[0016] If the TWS earphone is not in the earphone box, the first function selector maintains the communication mode.

[0017] In order to solve the above technical problems, the embodiment of the present application further provides a function switching device, which is applied to an earphone box, characterized in that the earphone box is provided with a first function selector and a first function pin, and the first function selector includes a first control program, including:

[0018] A first acquisition module is used to acquire a switch box state and earphone communication information of the earphone box when a TWS earphone is placed in the earphone box, wherein the earphone communication information includes charging information and upgrade information, and the switch box state includes an open box state and a closed box state;

[0019] A first processing module, configured to, if the earphone box is in an open box state, enable the first function selector to enter a communication mode, and control the first function pin to perform information interaction processing with the TWS earphone through the first control program;

[0020] A second processing module is configured to, if the earphone box is in a closed box state and the earphone communication information is charging information, cause the first function selector to enter a discharge mode, and control the first function pin to charge the TWS earphone through the first control program;

[0021] The third processing module is used to, if the earphone box is in a closed box state and the earphone communication information is upgrade information, then the first function selector enters the communication mode, and controls the first function pin through the first control program to perform background upgrade processing on the TWS earphone.

[0022] In order to solve the above technical problems, an embodiment of the present application further provides a function switching device, which is applied to a TWS headset, characterized in that the TWS headset is provided with a second function selector, a voltage comparator and a second function pin, and the second function selector includes a second control program, including:

[0023] An initialization module, used for initializing and setting a level threshold of the voltage comparator, wherein the level threshold includes a high level threshold and a low level threshold;

[0024] A second acquisition module, used to acquire the voltage value of the second functional pin;

[0025] A determination module, configured to perform level determination on the voltage value of the second functional pin based on the level threshold of the voltage comparator to obtain a level result of the second functional pin;

[0026] A determination module, configured to determine a function mode of the second function selector based on a result of the level of the second function pin;

[0027] The fourth processing module is used to control the second control program to process the second function pin based on the functional mode to obtain earphone communication information.

[0028] In order to solve the above technical problems, the embodiment of the present application also provides a function switching method, which is applied to a TWS headset, characterized in that the TWS headset is provided with a second function selector, a voltage comparator and a second function pin, and the second function selector includes a second control program, and adopts the following technical solution:

[0029] Initializing and setting a level threshold of the voltage comparator, wherein the level threshold includes a high level threshold and a low level threshold;

[0030] Obtaining the voltage value of the second function pin;

[0031] Performing level discrimination on the voltage value of the second functional pin based on the level threshold of the voltage comparator to obtain a level result of the second functional pin;

[0032] a function mode of the second function selector determined based on the result of the level of the second function pin;

[0033] The second control program is controlled based on the functional mode to process the second functional pin to obtain earphone communication information.

[0034] Further, the second function pin level result includes a high level result and a low level result, the function mode of the second function selector includes a charging mode and a communication mode, and the step of determining the function mode of the second function selector based on the second function pin level result specifically includes:

[0035] If the second function pin level result is the high level result, the function mode of the second function selector is the charging mode;

[0036] If the second function pin level result is the high level result, the function mode of the second function selector is the communication mode.

[0037] Furthermore, the step of controlling the second control program to process the second function pin based on the functional mode to obtain the earphone communication information specifically includes:

[0038] If the functional mode is the charging mode, the second control program enters the charging setting program, and controls the second functional pin to send charging information based on the charging setting program;

[0039] If the functional mode is the communication mode, the second control program enters the serial port communication program, and controls the second functional pin to send upgrade information based on the serial port communication program.

[0040] In order to solve the above technical problems, the embodiment of the present application further provides a computer device, which adopts the following technical solution:

[0041] A computer device includes a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the function switching method for applying an earphone box and the steps of the function switching method for applying a TWS earphone are implemented.

[0042] In order to solve the above technical problems, the embodiment of the present application further provides a computer-readable storage medium, which adopts the following technical solution:

[0043] A computer-readable storage medium, characterized in that computer-readable instructions are stored on the computer-readable storage medium, and when the computer-readable instructions are executed by a processor, the steps of the function switching method using an earphone box and the steps of the function switching method applied to a TWS earphone are implemented.

[0044] Compared with the prior art, the embodiments of the present application have the following beneficial effects:

[0045] The present application obtains the switch box status of the earphone box and the earphone communication information of the TWS earphone, determines the first control program according to the above switch box status and earphone communication information, controls the first function selector and the first function pin to complete the corresponding function switching, and realizes the charging control and communication functions with 2 pins, and then supports the internal program switching of the earphone box, and controls the communication or charging logic in time-sharing through the software program, which can greatly save hardware costs and facilitate the customization of customer needs and functions.

[0046] The present application obtains the voltage value of the second function pin by initializing and setting the level threshold of the voltage comparator, performs level discrimination on the voltage value of the second function pin based on the level threshold of the voltage comparator, obtains the level result of the second function pin, determines the function mode of the second function selector based on the level result of the second function pin, controls the second control program to process the second function pin based on the function mode, obtains the earphone communication information, and realizes the charging control and communication functions by 2 pins, and then supports the internal program switching of the earphone, and controls the communication or charging logic through the software program in a time-sharing manner, which can greatly save the hardware cost and facilitate the customization of customer needs and functions. BRIEF DESCRIPTION OF THE DRAWINGS

[0047] In order to more clearly illustrate the scheme in the present application, a brief introduction is given below to the drawings required for use in the description of the embodiments of the present application. Obviously, the drawings described below are some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0048] Figure 1 is an exemplary system architecture diagram to which the present application may be applied;

[0049] Figure 2 A flow chart of an embodiment of a function switching method applied to an earphone box according to the present application;

[0050] Figure 3 A flowchart of an embodiment of a function switching method applied to a TWS headset according to the present application;

[0051] Figure 4 is a structural schematic diagram of an embodiment of a function switching device applied to an earphone box according to the present application;

[0052] Figure 5 is a structural schematic diagram of an embodiment of a function switching device applied to a TWS headset according to the present application;

[0053] Figure 6 It is a structural diagram of an embodiment of a computer device according to the present application. DETAILED DESCRIPTION

[0054] Unless otherwise defined, all technical and scientific terms used herein have the same meaning as those commonly understood by technicians in the technical field of the present application; the terms used in the specification of the application herein are only for the purpose of describing specific embodiments and are not intended to limit the present application; the terms "including" and "having" and any variations thereof in the specification and claims of the present application and the above-mentioned drawings are intended to cover non-exclusive inclusions. The terms "first", "second", etc. in the specification and claims of the present application or the above-mentioned drawings are used to distinguish different objects, not to describe a specific order.

[0055] Reference to "embodiments" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiments may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments.

[0056] In order to enable those skilled in the art to better understand the solution of the present application, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the accompanying drawings.

[0057] like Figure 1 As shown, the system architecture 100 may include terminal devices 101, 102, 103, a network 104 and a server 105. The network 104 is used to provide a medium for communication links between the terminal devices 101, 102, 103 and the server 105. The network 104 may include various connection types, such as wired, wireless communication links or optical fiber cables, etc.

[0058] Users can use terminal devices 101, 102, 103 to interact with server 105 through network 104 to receive or send messages, etc. Various communication client applications can be installed on terminal devices 101, 102, 103, such as web browser applications, shopping applications, search applications, instant messaging tools, email clients, social platform software, etc.

[0059] Terminal devices 101, 102, 103 can be various electronic devices with display screens and supporting web browsing, including but not limited to smart phones, tablet computers, e-book readers, MP3 players (Moving Picture Experts Group Audio Layer III), MP4 (Moving Picture Experts Group Audio Layer IV) players, laptop computers, desktop computers, etc.

[0060] The server 105 may be a server that provides various services, such as a background server that provides support for web pages displayed on the terminal devices 101 , 102 , and 103 .

[0061] It should be noted that the function switching method provided in the embodiment of the present application is generally executed by a server / terminal device, and accordingly, the function switching device is generally arranged in the server / terminal device.

[0062] It should be understood that Figure 1 The number of terminal devices, networks and servers in the embodiment is only for illustration. Any number of terminal devices, networks and servers may be provided according to implementation requirements.

[0063] Continue to refer Figure 2 , showing a flow chart of an embodiment of a function switching method applied to an earphone box according to the present application. The function switching method comprises the following steps:

[0064] Step S201, obtaining the switch box status of the earphone box and the earphone communication information of the TWS earphone.

[0065] In this embodiment, the function switching method is executed on the electronic device (eg Figure 1 The server / terminal device shown in the figure) can receive the function switching request through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.

[0066] In this embodiment, the above-mentioned function switching method can be applied to an earphone box. The above-mentioned earphone box can be a TWS earphone charging box, which can be used for storing, protecting, serial communication, upgrading and charging TWS earphones. A first function selector and a first function pin are set in the above-mentioned earphone box.

[0067] Specifically, the above-mentioned first function selector can be a discharge and communication selector, and the above-mentioned discharge and communication selector can control the above-mentioned earphone box to enter the communication mode or the discharge mode. The above-mentioned first function selector is provided with a first control program, and the above-mentioned first control program is used to control the above-mentioned first function selector to perform a mode switching function. The above-mentioned first control program may include program modes such as a charging setting program, a serial port access program and an infinite loop program. The specific functions of the above-mentioned program modes are as follows: the above-mentioned charging setting program can control the above-mentioned first function selector to switch the earphone box to the discharge mode; the above-mentioned serial port access program can control the above-mentioned first function selector to switch the earphone box to the communication mode; the above-mentioned infinite loop program can control the above-mentioned first function selector to keep the current state unchanged until the next program controls the above-mentioned first function selector.

[0068] Specifically, the first function pin can be a pin pin. The earphone box has two pin pins, namely the GND pin and the first function pin. The GND pin represents the abbreviation of Ground. In the circuit, GND is a reference point or potential, which is usually defined as the zero voltage point in the circuit. The first function pin can be used for single-line serial communication and as a charging VCC pin. The first control program can control the first function pin to realize different functions. For example, when the first control program is the serial port communication program, the first function pin can communicate with the TWS earphone through single-line serial communication.

[0069] In this embodiment, the switch box state of the earphone box may include the open box state of the earphone box and the closed box state of the earphone box, and the earphone communication information may include charging information and upgrade information. Specifically, the switch box state of the earphone box may be obtained by embedding a magnetic sensor in the earphone box and detecting the power state of the earphone box through a switch detection chip. The magnetic sensor may be connected to the earphone box power supply through electromagnetic induction, and the earphone box power supply is connected to the switch detection chip. When the box lid is opened, the magnetic sensor will detect that the earphone box is opened, thereby triggering the earphone box power to turn on, and when the lid is closed, the magnetic sensor will detect that the earphone box is closed, thereby triggering the earphone box power to turn off. The switch detection chip in the earphone box can judge the switch box state of the earphone box by turning the earphone box power on and off; the earphone communication information may be when a TWS earphone is placed in the earphone box, a serial port communication is established with the TWS earphone through the first function pin in the earphone box, and the charging information and the upgrade information transmitted by the TWS earphone are received. The earphone communication information may be used to control the first function selector to switch functions.

[0070] Step S202, if the earphone box is in an open box state, the first function selector enters a communication mode, and controls the first function pin to perform information interaction processing with the TWS earphone through the first control program.

[0071] In this embodiment, if the switch detection chip detects that the earphone box is in an open box state, and the TWS earphone bound to the earphone box is in the earphone box, the first control program in the first function selector directly enters the serial port access program, and the first function selector is controlled by the serial port access program to switch the earphone box to the communication mode. The earphone box can control the first function pin to execute the single-line serial port communication function through the serial port access program to communicate with the TWS earphone to realize information interaction processing.

[0072] In a possible embodiment, after the above-mentioned earphone box enters the communication mode, and the TWS earphone bound to the above-mentioned earphone box is not in the earphone box, the above-mentioned TWS earphone also needs to enter the corresponding communication mode, and the above-mentioned information interaction processing can be through the wireless communication module built into the earphone box, such as a Bluetooth module, to receive the above-mentioned charging information or the above-mentioned upgrade information transmitted by the above-mentioned TWS earphone via Bluetooth signals.

[0073] Step S203, if the earphone box is in a closed box state and the earphone communication information is charging information, the first function selector enters a discharge mode, and controls the first function pin to charge the TWS earphone through the first control program.

[0074] In this embodiment, if the switch detection chip detects that the earphone box is in a closed box state, and the TWS earphone bound to the earphone box is in the earphone box, and the earphone box receives the charging information sent by the TWS earphone through the first function pin, the first control program in the first function selector directly enters the charging setting program, and controls the first function selector to switch the earphone box to the discharge mode through the charging setting program. The earphone box can control the first function pin to execute the charging function of the VCC pin through the charging setting program to charge the TWS earphone.

[0075] In a possible embodiment, if the switch detection chip detects that the earphone box is in a closed box state, and the TWS earphone bound to the earphone box is not in the earphone box, then even if the earphone communication information is charging information, the first control program in the first function selector will directly enter the infinite loop program, and control the first function selector to maintain the current state without changing.

[0076] Step S204, if the earphone box is in a closed box state and the earphone communication information is upgrade information, the first function selector enters the communication mode, and controls the first function pin through the first control program to perform background upgrade processing on the TWS earphone.

[0077] In this embodiment, if the switch detection chip detects that the earphone box is in a closed box state, and the TWS earphone bound to the earphone box is in the earphone box, and the earphone box receives the upgrade information sent by the TWS earphone through the first function pin, the first control program in the first function selector directly enters the serial port access program, and controls the first function selector through the serial port access program to switch the earphone box to the communication mode. The earphone box can control the first function pin through the serial port access program to perform the single-line serial communication function to communicate with the TWS earphone and perform background upgrade processing. Specifically, the background upgrade processing can be to execute the software and hardware upgrade package preset in the earphone box to upgrade the TWS earphone, and the upgrade processing can be automatic upgrade without manual intervention.

[0078] In a possible embodiment, if the switch detection chip detects that the earphone box is in a closed box state, and the TWS earphone bound to the earphone box is not in the earphone box, then even if the earphone communication information is an upgrade information, the first control program in the first function selector will directly enter the infinite loop program, and control the first function selector to maintain the current state without changing.

[0079] The present application obtains the switch box status of the earphone box and the earphone communication information of the TWS earphone, determines the first control program according to the above switch box status and earphone communication information, controls the first function selector and the first function pin to complete the corresponding function switching, and realizes the charging control and communication functions with 2 pins, and then supports the internal program switching of the earphone box, and controls the communication or charging logic in time-sharing through the software program, which can greatly save hardware costs and facilitate the customization of customer needs and functions.

[0080] In some optional implementations of this embodiment, after step S204, the electronic device may further perform the following steps:

[0081] The TWS earphone is timed through the first function pin to obtain the entry time of the TWS earphone;

[0082] The entry time is compared with the preset timeout standby time. If the entry time is greater than or equal to the preset timeout standby time, the timing process is terminated and the TWS headset is charged through the first function pin. If the entry time is less than the preset timeout standby time, the timing process continues.

[0083] In this embodiment, the prerequisite for the above-mentioned entry time is that the above-mentioned earphone box is in a closed box state; the above-mentioned timing processing may be that after the above-mentioned earphone box controls the above-mentioned first function pin to perform background upgrade processing on the TWS earphone through the above-mentioned first control program, the time of the above-mentioned TWS earphone in the above-mentioned earphone box is calculated; the above-mentioned preset timeout standby time may be the time set when the above-mentioned earphone box leaves the factory, or it may be the time set for the above-mentioned earphone box through the matching software in the mobile phone after the user matches the above-mentioned earphone box with Bluetooth through the mobile phone, such as 10 seconds, 15 seconds, 20 seconds, etc. Specifically, after the background upgrade process of the above-mentioned earphone box is completed, the above-mentioned first control program enters the above-mentioned infinite loop program, and detects whether the above-mentioned TWS earphone is in the earphone box through the above-mentioned first function pin. If the above-mentioned TWS earphone is in the earphone box, the contact time between the above-mentioned first function pin and the TWS earphone is calculated through the above-mentioned first control program, and the above-mentioned contact time is used as the above-mentioned entry time. Every five seconds, the above-mentioned first function pin is used to detect whether the above-mentioned TWS earphone is in the earphone box. At the same time, the above-mentioned entry time is compared with the preset timeout standby time. If the entry time is greater than or equal to the preset timeout standby time, the timing process is terminated, and the above-mentioned TWS earphone is charged through the above-mentioned first function pin. If the above-mentioned entry time is less than the above-mentioned preset timeout standby time, the timing process continues.

[0084] In a possible embodiment, if during the timing process, the switch box state of the earphone box changes to the open box state, the timing process is directly canceled.

[0085] This application uses the first function pin to perform timing processing on the TWS headset, and compares the entry time with the preset timeout standby time, thereby improving the user-friendliness of the TWS headset and saving battery life.

[0086] In some optional implementations, step S202 includes the following steps:

[0087] Determine the location of the TWS earphones;

[0088] If the TWS earphone is in the earphone box, the front-end upgrade process is performed with the TWS earphone through the first function pin;

[0089] If the TWS earphone is not in the earphone box, the first function selector maintains the communication mode. In the present embodiment, the position of the TWS earphone may include being in the earphone box and the earphone box state is a closed box state, being in the earphone box and the earphone box state is an open box state, being not in the earphone box and not being worn, and being not in the earphone box and being worn. Specifically, the position of the TWS earphone can be determined by the first function pin, and the specific determination method can be as follows: the earphone box is in an open box state, the first control program is switched to the serial port access program, and the first function selector is controlled by the serial port access program to switch the earphone box to the communication mode. The earphone box can control the first function pin to perform the single-line serial communication function through the serial port access program to communicate with the TWS earphone via the serial port communication function, or communicate wirelessly with the TWS earphone through the function of the wireless communication module built into the earphone box, and obtain the position and wearing status of the TWS earphone.

[0090] In this embodiment, if the TWS earphone is in the earphone box and the earbox is in the open box state, the earphone box enters the communication mode and the foreground upgrade process can be performed. Specifically, the foreground upgrade process can be an OTA foreground upgrade or an earphone box burning process. OTA (Over-The-Air) foreground upgrade refers to upgrading or updating the device through the Internet or other wireless communication methods. When the earphone box is started for the first time after the foreground upgrade process, the earphone box needs to be initialized. The initialization process can be to set the earphone box to the discharge mode to activate the TWS earphone and prevent the TWS earphone from being in an abnormal state or shut down.

[0091] In a possible embodiment, if the TWS earphones are not in the earphone box, the first control program in the first function selector will directly enter the infinite loop program to control the first function selector to maintain the current state (ie, communication mode) without changing.

[0092] The present application improves the upgrade reliability of the TWS earphone box by determining the position of the TWS earphone and determining the function of the current earphone box based on the position of the TWS earphone.

[0093] Continue to refer Figure 3 , showing a flow chart of an embodiment of a function switching method applied to a TWS headset according to the present application. The function switching method comprises the following steps:

[0094] Step S301, initializing and setting the level threshold of the voltage comparator.

[0095] In this embodiment, the function switching method is executed on the electronic device (eg Figure 1The server / terminal device shown in the figure) can receive the function switching request through a wired connection or a wireless connection. It should be noted that the above wireless connection method may include but is not limited to 3G / 4G / 5G connection, WiFi connection, Bluetooth connection, WiMAX connection, Zigbee connection, UWB (ultra wideband) connection, and other wireless connection methods currently known or to be developed in the future.

[0096] In this embodiment, the function switching method can be applied to a TWS headset, which is a wireless headset that does not require a traditional headphone cable to connect the left and right earphones, nor does it require a cable connected to a mobile device to transmit audio signals. The TWS headset is provided with a second function selector, a voltage comparator, and a second function pin.

[0097] Specifically, the second function selector may be a charging and communication selector, which may control the TWS headset to enter a communication mode or a charging mode. A second control program may be provided in the second function selector, and the second control program may include program modes such as a charging setting program, a serial communication program, and an infinite loop program. The voltage comparator may be an electronic component such as LM741, LM339, and LM393, which may be used to detect the voltage signal of the second function pin.

[0098] Specifically, the second function pin can be a pin pin. The TWS headset has 2 pin pins, namely the GND pin and the second function pin. The GND pin represents the abbreviation of Ground. In the circuit, GND is a reference point or potential, which is usually defined as the zero voltage point in the circuit. The second function pin can be used for single-line serial communication and as a charging VCC pin. The second control program can control the second function pin to realize different functions. For example, when the second control program is the serial port communication program, the second function pin can communicate with the earphone box through single-line serial communication.

[0099] In this embodiment, the level threshold includes a high level threshold and a low level threshold, and the initialization setting can be to set the interrupt rising edge and interrupt falling edge triggering mode of the GPIO port of the voltage comparator. Specifically, the interrupt rising edge refers to an interrupt or operation triggered when the signal changes from a low level to a high level, and the interrupt falling edge refers to an interrupt or operation triggered when the signal changes from a high level to a low level. The high level threshold is set to 5V and the low level threshold is set to 3.3V. When the voltage is greater than or equal to 5V, it is determined that the voltage is a high level voltage, and when the voltage is less than 3.3V, it is determined that the voltage is a low level voltage.

[0100] Step S302, obtaining the voltage value of the second functional pin;

[0101] Step S303, performing level determination on the voltage value of the second function pin based on the level threshold of the voltage comparator to obtain a level result of the second function pin.

[0102] In this embodiment, the second function pin can be connected to the GPIO port of the voltage comparator to obtain the voltage value of the second function pin. The level judgment can be to compare the voltage value of the second function pin with the level threshold. If the voltage value of the second function pin is greater than or equal to 5V, the level result of the second function pin is determined to be a high level result. When the voltage value of the second function pin is less than 3.3V, the level result of the second function pin is determined to be a low level result.

[0103] Step S304, determining the function mode of the second function selector based on the result of the second function pin level.

[0104] In this embodiment, the functional mode of the above-mentioned second function selector includes a charging mode and a communication mode. If the second function pin level result is the above-mentioned high level result, the functional mode of the second function selector is the charging mode. If the second function pin level result is the above-mentioned high level result, the functional mode of the second function selector is the communication mode.

[0105] Step S305, controlling the second control program to process the second function pin based on the function mode to obtain earphone communication information.

[0106] In this embodiment, the above-mentioned earphone communication information may include charging information and upgrade information. Specifically, the above-mentioned charging information can be used to allow the above-mentioned earphone box to enter the discharge mode, and the above-mentioned upgrade information can be used for the above-mentioned TWS to perform OTA background upgrade or the above-mentioned OTA foreground upgrade; the above-mentioned processing of the second function pin can be that the above-mentioned second control program controls the above-mentioned second function pin to perform charging processing or to perform communication processing on the above-mentioned earphone box.

[0107] The present application obtains the voltage value of the second function pin by initializing and setting the level threshold of the voltage comparator, performs level discrimination on the voltage value of the second function pin based on the level threshold of the voltage comparator, obtains the level result of the second function pin, determines the function mode of the second function selector based on the level result of the second function pin, controls the second control program to process the second function pin based on the function mode, obtains the earphone communication information, and realizes the charging control and communication functions by 2 pins, and then supports the internal program switching of the earphone, and controls the communication or charging logic through the software program in a time-sharing manner, which can greatly save the hardware cost and facilitate the customization of customer needs and functions.

[0108] In some optional implementations, step S304 includes the following steps:

[0109] If the second function pin level result is a high level result, the function mode of the second function selector is a charging mode;

[0110] If the level result of the second function pin is a high level result, the function mode of the second function selector is the communication mode.

[0111] In the embodiment of the present invention, the function mode of the second function selector is determined by the second function pin level result, so as to improve the flexibility and functionality of the device and switch according to different needs to meet the requirements of charging or communication.

[0112] In some optional implementations, step S305 includes the following steps:

[0113] If the function mode is the charging mode, the second control program enters the charging setting program, and controls the second function pin to send charging information based on the charging setting program;

[0114] If the function mode is the communication mode, the second control program enters the serial port communication program, and controls the second function pin to send the upgrade information based on the serial port communication program.

[0115] In an embodiment of the present invention, the charging information and upgrade information sent by the second function pin can be transmitted through a wireless communication module built into the TWS headset, such as a Bluetooth module, by sending a Bluetooth signal to transmit the charging information or the upgrade information. If the TWS headset is in the earphone box, the second function pin can be used to perform serial port communication with the first function pin of the earphone box to send the charging information or the upgrade information.

[0116] In an embodiment of the present invention, the accuracy of information sent by the TWS headset can be improved by controlling the second control program to operate the second function pin through the function mode.

[0117] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiments can be implemented by instructing the relevant hardware through computer-readable instructions, and the computer-readable instructions can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, the aforementioned storage medium can be a non-volatile storage medium such as a disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).

[0118] It should be understood that, although the steps in the flowchart of the accompanying drawings are displayed in sequence as indicated by the arrows, these steps are not necessarily executed in sequence in the order indicated by the arrows. Unless otherwise specified herein, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least a part of the steps in the flowchart of the accompanying drawings may include multiple sub-steps or multiple stages, and these sub-steps or stages are not necessarily executed at the same time, but can be executed at different times, and their execution order is not necessarily sequential, but can be executed in turn or alternately with other steps or at least a part of the sub-steps or stages of other steps.

[0119] Further references Figure 4 , as a response to the above Figure 2 The present application provides an embodiment of a function switching device applied to an earphone box, and the device embodiment is similar to Figure 2 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0120] like Figure 4 As shown, the function switching device 400 described in this embodiment includes: a first acquisition module 401, a first processing module 402, a second processing module 403 and a third processing module 404. Among them:

[0121] A first acquisition module 401 is used to acquire a switch box state of the earphone box and earphone communication information of the TWS earphone when a TWS earphone is placed in the earphone box, wherein the earphone communication information includes charging information and upgrade information, and the switch box state includes an open box state and a closed box state;

[0122] The first processing module 402 is used for, if the earphone box is in an open box state, causing the first function selector to enter a communication mode, and controlling the first function pin to perform information interaction processing with the TWS earphone through the first control program;

[0123] The second processing module 403 is used for, if the earphone box is in a closed box state and the earphone communication information is charging information, the first function selector enters a discharge mode, and controls the first function pin to charge the TWS earphone through the first control program;

[0124] The third processing module 404 is used to, if the earphone box is in a closed box state and the earphone communication information is upgrade information, then the first function selector enters the communication mode, and controls the first function pin through the first control program to perform background upgrade processing on the TWS earphone.

[0125] In this embodiment, by obtaining the switch box status of the earphone box and the earphone communication information of the TWS earphone, the first control program is judged according to the above switch box status and earphone communication information, and the first function selector and the first function pin are controlled to complete the corresponding function switching, so that the charging control and communication functions can be realized by 2 pin pins, and then the internal program switching of the earphone box is supported. The communication or charging logic is controlled in time-sharing through the software program, which can greatly save hardware costs and facilitate customization of customer needs and functions.

[0126] In some optional implementations of this embodiment, after the third processing module 404, a timing module and a comparison module are included, wherein:

[0127] a timing module, configured to perform timing processing on the TWS earphone through the first functional pin to obtain a storage time of the TWS earphone, wherein a prerequisite for the storage time is that the earphone box is in a closed box state;

[0128] The comparison module is used to compare the entry time with the preset timeout standby time. If the entry time is greater than or equal to the preset timeout standby time, the timing process is terminated and the TWS headset is charged through the first functional pin. If the entry time is less than the preset timeout standby time, the timing process is continued.

[0129] In this embodiment, the TWS headset is timed by the first functional pin, and the entry time is compared with the preset timeout standby time, which improves the user-friendliness of the TWS headset and saves battery life.

[0130] In some optional implementations of this embodiment, the third processing module 402 includes: a positioning unit, a first processing unit, and a second processing unit, wherein:

[0131] A positioning unit, used to determine the position of the TWS headset;

[0132] A first processing unit, configured to perform a foreground upgrade process with the TWS earphone through the first function pin if the TWS earphone is in the earphone box;

[0133] The second processing unit is configured to enable the first function selector to maintain the communication mode if the TWS earphone is not in the earphone box.

[0134] The present application improves the upgrade reliability of the TWS earphone box by determining the position of the TWS earphone and determining the function of the current earphone box based on the position of the TWS earphone.

[0135] See also Figure 5 , as a response to the above Figure 3The present application provides an embodiment of a function switching device for TWS earphones. Figure 3 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0136] like Figure 5 As shown, the function switching device 500 described in this embodiment includes: an initialization module 501, a second acquisition module 502, a determination module 503, a determination module 504 and a fourth processing module 505. Among them:

[0137] An initialization module 501 is used to initialize and set a level threshold of the voltage comparator, wherein the level threshold includes a high level threshold and a low level threshold;

[0138] A second acquisition module 502, used to acquire the voltage value of the second functional pin;

[0139] A determination module 503, configured to perform level determination on the voltage value of the second functional pin based on the level threshold of the voltage comparator to obtain a level result of the second functional pin;

[0140] A determination module 504, configured to determine a function mode of the second function selector based on the result of the second function pin level;

[0141] The fourth processing module 505 is used to control the second control program to process the second function pin based on the functional mode to obtain earphone communication information.

[0142] The method obtains the voltage value of the second function pin by initializing and setting the level threshold of the voltage comparator, performs level discrimination on the voltage value of the second function pin based on the level threshold of the voltage comparator, obtains the level result of the second function pin, determines the function mode of the second function selector based on the level result of the second function pin, controls the second control program to process the second function pin based on the function mode, obtains the earphone communication information, and realizes the charging control and communication functions by 2 pins, and then supports the internal program switching of the earphone, and controls the communication or charging logic in time-sharing through the software program, which can greatly save the hardware cost and facilitate the customization of customer needs and functions.

[0143] In some optional implementations of this embodiment, the determination module 504 includes: a first comparison unit and a second comparison unit, wherein:

[0144] A first comparison unit, configured to: if the second function pin level result is the high level result, the function mode of the second function selector is the charging mode;

[0145] The second comparing unit is used for, if the level result of the second function pin is the high level result, then the function mode of the second function selector is the communication mode.

[0146] In the embodiment of the present invention, the function mode of the second function selector is determined by the second function pin level result, so as to improve the flexibility and functionality of the device and switch according to different needs to meet the requirements of charging or communication.

[0147] In some optional implementations of this embodiment, the fourth processing module 505 includes: a first control unit and a second control unit, wherein:

[0148] a first control unit, configured to, if the function mode is the charging mode, cause the second control program to enter a charging setting program, and control the second function pin to send charging information based on the charging setting program;

[0149] The first control unit is used for, if the functional mode is the communication mode, causing the second control program to enter the serial port communication program, and controlling the second functional pin to send upgrade information based on the serial port communication program.

[0150] In an embodiment of the present invention, the accuracy of information sent by the TWS headset can be improved by controlling the second control program to operate the second function pin through the function mode.

[0151] To solve the above technical problems, the present application also provides a computer device. Figure 6 , Figure 6 This is a basic structural block diagram of the computer device in this embodiment.

[0152] The computer device 6 includes a memory 61, a processor 62, and a network interface 63 that are interconnected through a system bus. It should be noted that the figure only shows a computer device 6 with components 61-63, but it should be understood that it is not required to implement all the components shown, and more or fewer components can be implemented instead. Among them, those skilled in the art can understand that the computer device here is a device that can automatically perform numerical calculations and / or information processing according to pre-set or stored instructions, and its hardware includes but is not limited to microprocessors, application specific integrated circuits (Application Specific Integrated Circuit, ASIC), programmable gate arrays (Field-Programmable Gate Array, FPGA), digital processors (Digital Signal Processor, DSP), embedded devices, etc.

[0153] The computer device may be a computing device such as a desktop computer, a notebook, a PDA, a cloud server, etc. The computer device may interact with a user through a keyboard, a mouse, a remote controller, a touch pad, or a voice control device.

[0154] The memory 61 includes at least one type of readable storage medium, and the readable storage medium includes flash memory, hard disk, multimedia card, card-type memory (for example, SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, disk, optical disk, etc. In some embodiments, the memory 61 can be an internal storage unit of the computer device 6, such as a hard disk or memory of the computer device 6. In other embodiments, the memory 61 can also be an external storage device of the computer device 6, such as a plug-in hard disk equipped on the computer device 6, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (FlashCard), etc. Of course, the memory 61 can also include both the internal storage unit of the computer device 6 and its external storage device. In this embodiment, the memory 61 is generally used to store the operating system and various application software installed on the computer device 6, such as computer-readable instructions of the function switching method, etc. In addition, the memory 61 can also be used to temporarily store various types of data that have been output or are to be output.

[0155] The processor 62 may be a central processing unit (CPU), a controller, a microcontroller, a microprocessor, or other data processing chip in some embodiments. The processor 62 is generally used to control the overall operation of the computer device 6. In this embodiment, the processor 62 is used to run computer-readable instructions or process data stored in the memory 61, such as computer-readable instructions for running the function switching method.

[0156] The network interface 63 may include a wireless network interface or a wired network interface. The network interface 63 is generally used to establish a communication connection between the computer device 6 and other electronic devices.

[0157] The present application provides a computer device, which obtains the switch box status of the earphone box and the earphone communication information of the TWS earphone, determines the first control program according to the above-mentioned switch box status and earphone communication information, controls the first function selector and the first function pin to complete the corresponding function switching, and realizes the charging control and communication functions by 2 pin pins, and then supports the internal program switching of the earphone box, and controls the communication or charging logic in time-sharing through the software program, which can greatly save hardware costs and facilitate customization of customer needs and functions.

[0158] The present application provides a computer device, which obtains the voltage value of the second function pin by initializing and setting the level threshold of the voltage comparator, performs level discrimination on the voltage value of the second function pin based on the level threshold of the voltage comparator, obtains the level result of the second function pin, determines the function mode of the second function selector based on the level result of the second function pin, controls the second control program to process the second function pin based on the function mode, obtains the earphone communication information, realizes the charging control and communication functions by 2 pins, and then supports the internal program switching of the earphone, and controls the communication or charging logic by time-sharing through the software program, which can greatly save the hardware cost and facilitate the customization of customer needs and functions.

[0159] The present application also provides another implementation, namely, providing a computer-readable storage medium, wherein the computer-readable storage medium stores computer-readable instructions, and the computer-readable instructions can be executed by at least one processor to enable the at least one processor to perform the steps of the function switching method as described above.

[0160] The present application provides a computer-readable storage medium, which obtains the switch box status of the earphone box and the earphone communication information of the TWS earphone, determines the first control program according to the above-mentioned switch box status and earphone communication information, controls the first function selector and the first function pin to complete the corresponding function switching, and realizes the charging control and communication functions by 2 pin pins, and then supports the internal program switching of the earphone box, and controls the communication or charging logic in time-sharing through the software program, which can greatly save hardware costs and facilitate customization of customer needs and functions.

[0161] Optionally, the computer-readable storage medium can also obtain the voltage value of the second function pin by initializing the level threshold of the voltage comparator, perform level judgment on the voltage value of the second function pin based on the level threshold of the voltage comparator, obtain the level result of the second function pin, determine the function mode of the second function selector based on the level result of the second function pin, control the second control program to process the second function pin based on the function mode, obtain the earphone communication information, and realize the charging control and communication functions by 2 pins, and then support the internal program switching of the earphone, and use the software program to control the communication or charging logic in time-sharing, which can greatly save hardware costs and facilitate the customization of customer needs and functions.

[0162] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus a necessary general hardware platform, and of course by hardware, but in many cases the former is a better implementation method. Based on such an understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for a terminal device (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0163] Obviously, the embodiments described above are only some embodiments of the present application, rather than all embodiments. The preferred embodiments of the present application are given in the accompanying drawings, but they do not limit the patent scope of the present application. The present application can be implemented in many different forms. On the contrary, the purpose of providing these embodiments is to make the understanding of the disclosure of the present application more thorough and comprehensive. Although the present application is described in detail with reference to the aforementioned embodiments, for those skilled in the art, it is still possible to modify the technical solutions recorded in the aforementioned specific implementation methods, or to perform equivalent replacement of some of the technical features therein. Any equivalent structure made using the contents of the specification and drawings of this application, directly or indirectly used in other related technical fields, is similarly within the scope of patent protection of this application.

Claims

1. A function switching method, applied to an earphone box, It is characterized in that The earphone box is provided with a first function selector and a first function pin, the first function selector includes a first control program, and the method includes the following steps: When a TWS headset is placed in the headset box, a switch box state of the headset box and headset communication information of the TWS headset are obtained, wherein the headset communication information includes charging information and upgrade information, and the switch box state includes an open box state and a closed box state; If the earphone box is in an open box state, the first function selector enters a communication mode, and the first function pin is controlled by the first control program to perform information interaction processing with the TWS earphone; If the earphone box is in a closed box state and the earphone communication information is charging information, the first function selector enters a discharge mode, and the first function pin is controlled by the first control program to charge the TWS earphone; If the earphone box is in a closed box state and the earphone communication information is upgrade information, the first function selector enters a communication mode, and controls the first function pin through the first control program to perform background upgrade processing on the TWS earphone.

2. The function switching method according to claim 1, It is characterized in that If the earphone box is in a closed box state and the earphone communication information is upgrade information, the first function selector enters a communication mode, and after the step of controlling the first function pin to perform background upgrade processing on the TWS earphone through the first control program, the method further includes: The TWS earphone is timed by the first functional pin to obtain the warehouse entry time of the TWS earphone, wherein the prerequisite for the warehouse entry time is that the earphone box is in a closed box state; The entry time is compared with the preset timeout standby time. If the entry time is greater than or equal to the preset timeout standby time, the timing process is terminated and the TWS headset is charged through the first functional pin. If the entry time is less than the preset timeout standby time, the timing process is continued.

3. The function switching method according to claim 1, It is characterized in that If the earphone box is in an open box state, the first function selector enters a communication mode, and the first control program controls the first function pin to perform information interaction processing with the TWS earphone, specifically including: Determine the position of the TWS headset; If the TWS earphone is in the earphone box, the foreground upgrade process is performed with the TWS earphone through the first function pin; If the TWS earphone is not in the earphone box, the first function selector maintains the communication mode.

4. A function switching method, applied to TWS headphones, It is characterized in that The TWS headset is provided with a second function selector, a voltage comparator and a second function pin, the second function selector includes a second control program, and the method includes the following steps: Initializing and setting a level threshold of the voltage comparator, wherein the level threshold includes a high level threshold and a low level threshold; Obtaining the voltage value of the second function pin; Performing level discrimination on the voltage value of the second functional pin based on the level threshold of the voltage comparator to obtain a level result of the second functional pin; a function mode of the second function selector determined based on the result of the level of the second function pin; The second control program is controlled based on the functional mode to process the second functional pin to obtain earphone communication information.

5. The function switching method according to claim 4, It is characterized in that The second function pin level result includes a high level result and a low level result, the function mode of the second function selector includes a charging mode and a communication mode, and the step of determining the function mode of the second function selector based on the second function pin level result specifically includes: If the second function pin level result is the high level result, the function mode of the second function selector is the charging mode; If the second function pin level result is the high level result, the function mode of the second function selector is the communication mode.

6. The function switching method according to claim 5, It is characterized in that The step of controlling the second control program to process the second function pin based on the functional mode to obtain the earphone communication information specifically includes: If the functional mode is the charging mode, the second control program enters the charging setting program, and controls the second functional pin to send charging information based on the charging setting program; If the functional mode is the communication mode, the second control program enters the serial port communication program, and controls the second functional pin to send upgrade information based on the serial port communication program.

7. A function switching device, applied to an earphone box, It is characterized in that The earphone box is provided with a first function selector and a first function pin, and the first function selector includes a first control program, including: A first acquisition module is used to acquire a switch box state and earphone communication information of the earphone box when a TWS earphone is placed in the earphone box, wherein the earphone communication information includes charging information and upgrade information, and the switch box state includes an open box state and a closed box state; A first processing module, configured to, if the earphone box is in an open box state, enable the first function selector to enter a communication mode, and control the first function pin to perform information interaction processing with the TWS earphone through the first control program; A second processing module is configured to, if the earphone box is in a closed box state and the earphone communication information is charging information, cause the first function selector to enter a discharge mode, and control the first function pin to charge the TWS earphone through the first control program; The third processing module is used to, if the earphone box is in a closed box state and the earphone communication information is upgrade information, then the first function selector enters the communication mode, and controls the first function pin through the first control program to perform background upgrade processing on the TWS earphone.

8. A function switching device, applied to TWS earphones, It is characterized in that The TWS headset is provided with a second function selector, a voltage comparator and a second function pin, and the second function selector includes a second control program, including: An initialization module, used for initializing and setting a level threshold of the voltage comparator, wherein the level threshold includes a high level threshold and a low level threshold; A second acquisition module, used to acquire the voltage value of the second functional pin; A determination module, configured to perform level determination on the voltage value of the second functional pin based on the level threshold of the voltage comparator to obtain a level result of the second functional pin; A determination module, configured to determine a function mode of the second function selector based on a result of the level of the second function pin; The fourth processing module is used to control the second control program to process the second function pin based on the functional mode to obtain earphone communication information.

9. A computer device, comprising a memory and a processor, wherein the memory stores computer-readable instructions, and when the processor executes the computer-readable instructions, the steps of the function switching method as described in any one of claims 1 to 3 and the steps of the function switching method as described in any one of claims 4 to 6 are implemented.

10. A computer-readable storage medium, It is characterized in that The computer-readable storage medium stores computer-readable instructions, which, when executed by a processor, implement the steps of the function switching method according to any one of claims 1 to 3 and the steps of the function switching method according to any one of claims 4 to 6.