Indicator lamp control method and device, electronic equipment and storage medium

By using a target linked list to manage LED control logic in embedded devices, independent of business logic, the problem of tight coupling between LED control and business logic is solved, enabling flexible LED indicator control and a simplified configuration process.

CN120897294APending Publication Date: 2025-11-04SHENZHEN SIYUAN ELECTRONICS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510818647.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-06-18
Publication Date
2025-11-04

AI Technical Summary

Technical Problem

In embedded device development, LED control logic is tightly coupled with business logic, and the lack of a flexible configuration mechanism means that a lot of code needs to be modified when adjusting the LED indicator logic.

Method used

By acquiring the target linked list, detecting the device status, and writing event information into the target linked list to indicate the LED lighting mode and control logic, the LED control logic can be managed independently, reducing coupling with business logic.

Benefits of technology

It improves the flexibility of LED indicator control and the ease of configuration, while reducing the workload of code modification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120897294A_ABST
    Figure CN120897294A_ABST
Patent Text Reader

Abstract

The invention discloses an indicator light control method and device, electronic equipment and a storage medium, and relates to the technical field of intelligent control, a target linked list is obtained, and the target linked list is used for indicating the lighting mode of each indicator light of the electronic equipment; detecting the state of the electronic equipment to obtain the current first state of the electronic equipment; acquiring event information corresponding to a first state of the electronic equipment, wherein the event information corresponding to the first state is used for indicating a first indicating lamp needing to be controlled and a control logic of the first indicating lamp; and writing the event information corresponding to the first state into the target linked list, so as to control the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light indicated by the target linked list in which the event information corresponding to the first state is written and the control logic of the first indicator light. The coupling between the control logic and the service logic of the LED indicating lamp can be reduced, so that the configuration flexibility is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of intelligent control technology, and more specifically, to a control method, device, electronic device, and storage medium for an indicator light. Background Technology

[0002] In current embedded device development, light-emitting diode (LED) indicators are widely used as important human-computer interaction display tools in scenarios such as device status indication.

[0003] In related technologies, LED control logic is tightly coupled with business logic, lacking a flexible configuration mechanism. Summary of the Invention

[0004] In view of the above problems, this application proposes a method, device, electronic device and storage medium for controlling indicator lights, so as to solve the control problem of indicator lights in related technologies.

[0005] In a first aspect, this embodiment provides a method for controlling an indicator light, comprising: acquiring a target linked list, the target linked list being used to indicate the lighting mode of each indicator light of an electronic device; detecting the state of the electronic device to obtain the current first state of the electronic device; acquiring event information corresponding to the first state of the electronic device, the event information corresponding to the first state being used to indicate the first indicator light to be controlled and the control logic of the first indicator light; writing the event information corresponding to the first state into the target linked list, so as to control the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light indicated by the target linked list containing the event information corresponding to the first state and the control logic of the first indicator light.

[0006] In one possible implementation, obtaining the target linked list includes: in response to the power-on of the electronic device, obtaining the polarity of the interface to which each indicator light of the electronic device is connected, wherein the polarity of the interface is used to indicate whether the interface controls the indicator light connected to the interface to turn on when a first level is detected or when a second level is detected, wherein the first level is greater than the second level; registering the polarity of the interface to which each indicator light is connected to obtain the target linked list.

[0007] In a possible implementation, the event information includes indicator light state information, flash light frequency information, control duration information, and a callback function to be executed after the control duration arrives, the indicator light state information is used to indicate a light-on, light-off, or flash light, and the callback function is used to indicate an action to be executed; the first indicator light is controlled based on the light-on mode of the first indicator light indicated by the target linked list to which the event information corresponding to the first state is written and the control logic of the first indicator light, including: the first indicator light indicated by the target linked list is controlled based on the light-on mode of the first indicator light indicated by the target linked list and the indicator light state information, the flash light frequency information, and the control duration information in the first indicator light; and the method further includes: if the callback function is not empty, after the control duration indicated by the control duration information arrives, controlling the electronic device to execute the action indicated by the callback function.

[0008] In a possible implementation, the method further includes: in response to the electronic device switching from the first state to a second state, obtaining event information corresponding to the second state, the event information corresponding to the second state being used to indicate a second indicator light to be controlled and a control logic of the second indicator light, where the first indicator light and the second indicator light are different, the indicator light state corresponding to the first indicator light is different from the indicator light state corresponding to the second indicator light, the flash light frequency corresponding to the first indicator light is different from the flash light frequency corresponding to the second indicator light, the control duration corresponding to the first indicator light is different from the control duration corresponding to the second indicator light, and / or the callback function corresponding to the first indicator light is different from the callback function corresponding to the second indicator light; and writing the event information corresponding to the second state into the target linked list, to control the second indicator light indicated by the target linked list based on the light-on mode of the second indicator light indicated by the target linked list to which the event information corresponding to the second state is written and the control logic of the second indicator light.

[0009] In a possible implementation, the method further includes: deleting the event information corresponding to the first state in the target linked list; or, retaining the event information corresponding to the first state in the target linked list, to control the first indicator light indicated by the target linked list based on the light-on mode of the first indicator light indicated by the target linked list to which the event information corresponding to the first state is written and the control logic of the first indicator light, in a case where the electronic device recovers from the second state to the first state.

[0010] In a possible implementation, the method further includes: creating threads corresponding to the indicator lights; detecting the state of the electronic device to obtain a current first state of the electronic device, including: for each indicator light, detecting, by the thread corresponding to the indicator light, the indicator light-related state of the electronic device to obtain a first state of the electronic device currently indicated by the indicator light and detected by the first thread; obtaining event information corresponding to the first state of the electronic device, and writing the event information corresponding to the first state into a target linked list, to control the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light and the control logic of the first indicator light indicated by the target linked list to which the event information corresponding to the first state is written, including: obtaining, by the first thread, the event information corresponding to the first state of the electronic device, writing the event information corresponding to the first state into the target linked list, and controlling the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light and the control logic of the first indicator light indicated by the target linked list to which the event information corresponding to the first state is written.

[0011] In a possible implementation, the method further includes: obtaining the global state of the electronic device, and determining whether the global state is a third state, where a non-third state indicates that the part of the indicator lights of the electronic device are controlled; if the global state is the non-third state, obtaining, by the first thread, the event information corresponding to the first state of the electronic device, writing the event information corresponding to the first state into the target linked list, and controlling the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light and the control logic of the first indicator light indicated by the target linked list to which the event information corresponding to the first state is written; and the method further includes: if the global state of the electronic device is the third state, obtaining event information corresponding to the third state of the electronic device, where the event information corresponding to the third state is used to indicate all third indicator lights that need to be controlled and the control logic of the third indicator lights; writing the event information corresponding to the third state into the target linked list, and controlling the third indicator light indicated by the target linked list based on the lighting mode of the third indicator light and the control logic of the third indicator light indicated by the target linked list to which the event information corresponding to the third state is written.

[0012] In a second aspect, the embodiment provides a control device of an indicator light, comprising: an obtaining module, configured to obtain a target linked list, the target linked list being used to indicate lighting modes of each indicator light of an electronic device; a detecting module, configured to detect a state of the electronic device to obtain a first state of the electronic device at present; a control module, configured to obtain event information corresponding to the first state of the electronic device, the event information corresponding to the first state being used to indicate a first indicator light to be controlled and a control logic of the first indicator light; and write the event information corresponding to the first state into the target linked list, so as to control the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light and the control logic of the first indicator light indicated by the target linked list to which the event information corresponding to the first state is written.

[0013] In a third aspect, an electronic device is provided, comprising: a processor; a memory, the memory storing computer readable instructions, the computer readable instructions being executed by the processor to implement the control method of the indicator light as described above.

[0014] In a fourth aspect, a computer readable storage medium is provided, the computer readable storage medium storing computer readable instructions, the computer readable instructions being executed by the processor to implement the control method of the indicator light as described above.

[0015] In a fifth aspect, a computer program product is provided, comprising computer instructions, the computer instructions being executed by the processor to implement the control method of the indicator light as described above.

[0016] In the embodiment, by obtaining a target linked list, the target linked list being used to indicate lighting modes of each indicator light of an electronic device; detecting a state of the electronic device to obtain a first state of the electronic device at present; obtaining event information corresponding to the first state of the electronic device, the event information corresponding to the first state being used to indicate a first indicator light to be controlled and a control logic of the first indicator light; and writing the event information corresponding to the first state into the target linked list, so as to control the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light and the control logic of the first indicator light indicated by the target linked list to which the event information corresponding to the first state is written, all control logics of the indicator lights can be managed by the target linked list, and the control logic of the LED indicator light and the business logic are not coupled, so as to improve flexibility of configuration. BRIEF DESCRIPTION OF DRAWINGS

[0017] The accompanying drawings, which are incorporated herein and form part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles behind the application. It is apparent that the accompanying drawings described below are only some embodiments of the present application, and other drawings can be obtained by those skilled in the art without creative effort on the basis of these drawings.

[0018] Figure 1 is a flow chart of a control method of an indicator light according to an embodiment of the present application.

[0019] Figure 2 is a flow chart of a control method of an indicator light according to another embodiment of the present application.

[0020] Figure 3 is a block diagram of a control device of an indicator light according to an embodiment of the present application.

[0021] Figure 4 shows a structural schematic diagram of a computer system of an electronic device suitable for implementing embodiments of the present application. DETAILED DESCRIPTION

[0022] Embodiments of the present application will be described in detail below with reference to drawings, examples of which are shown in the accompanying drawings, in which the same or similar components or components having the same or similar functions are denoted throughout by the same or similar reference numerals. The embodiments described below with reference to the accompanying drawings are exemplary and are intended only to explain the present application, and cannot be understood as limiting the present application.

[0023] In order to enable those skilled in the art to better understand the present application, the technical solutions in the embodiments of the present application will be described clearly and completely below with reference to the accompanying drawings in the embodiments of the present application. Obviously, the described embodiments are only some of the embodiments of the present application, not all. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0024] In the following description, the terms "first\second" and the like are merely to distinguish similar objects, and do not represent a specific order of the objects. Understandably, "first\second" can be interchanged in a specific order or sequence as allowed, so that the embodiments of the present application described herein can be implemented in an order other than that illustrated or described herein.

[0025] "Multiple" referred to herein means two or more. "And / or" describes the association relationship between the associated objects, which means that there can be three relationships, for example, A and / or B can represent the three cases of A alone, A and B together, and B alone. The character " / " generally represents a "or" relationship between the front and rear associated objects. In the following description, "some embodiments or some embodiment modes" describe a subset of all possible embodiments, but it can be understood that "some embodiments" can be the same subset or different subset of all possible embodiments, and can be combined with each other without conflict.

[0026] In current embedded device development, LED indicator light as an important human-computer interaction display tool is widely used in device state indication and other scenarios. However, the LED control logic is tightly coupled with the business logic, and lacks flexible configuration mechanism, and a large amount of code needs to be modified when the LED indication logic needs to be adjusted.

[0027] Therefore, the embodiment provides a control method and device of an indicator light, an electronic device and a storage medium, which can reduce the coupling between the LED control logic and the business logic, and improve the flexibility of configuration.

[0028] The implementation details of the technical solutions of the embodiments of the present application are described in detail as follows: Figure 1 A flowchart of a control method of an indicator light according to an embodiment of the present application is shown, which can be executed by an electronic device. The electronic device can be a terminal or the like. The terminal can be a hunting camera, a smart phone, a tablet computer, a notebook computer, a desktop computer, a smart television, a smart home device, a vehicle-mounted terminal, etc., which is not limited here. The terminal of the embodiment can be an embedded terminal, for example.

[0029] Referring to FIG. 1, Figure 1 The method includes at least steps S110 to S140, which are described in detail as follows: S110, obtaining a target linked list, the target linked list being used to indicate the lighting mode of each indicator light of the electronic device.

[0030] In the embodiment, the target linked list can be stored in the electronic device, so as to be created when the indicator light control is needed. In the embodiment, the target linked list can indicate the lighting mode of each indicator light of all the indicator lights of the electronic device, or can indicate the lighting mode of each indicator light of all the non-faulty indicator lights of the electronic device. The lighting mode can refer to the way in which the indicator light is lit, for example, whether it is high-level lighting or low-level lighting, etc., and the lighting modes of different indicator lights can be different. The embodiment can accurately control the on-off of the indicator light by indicating the lighting mode of each indicator light of the electronic device through the target linked list.

[0031] S120, detecting the state of the electronic device to obtain the first state of the electronic device.

[0032] In the embodiment, the first state can be at least one of a network configuration state, a network configuration completion state, a network configuration failure state, an upgrade state, an upgrade failure state, an upgrade success state, a formatting state, a factory reset state, a shooting state, a data transmission state, a shutdown state or a restart state, etc., which is not limited here according to the state possessed by the electronic device and the actual state of the electronic device.

[0033] It should be noted that the first state of the embodiment can be a single state or a composite state, which is determined according to actual conditions and is not limited herein.

[0034] In S130, event information corresponding to the first state of the electronic device is acquired, and the event information corresponding to the first state is used to indicate a first indicator light to be controlled and control logic of the first indicator light.

[0035] In the embodiment, the event information and the mapping relationship between the event information and the state can be preconfigured, so that when the first state of the electronic device is determined, the event information corresponding to the first state can be determined based on the mapping relationship between the event information and the state. In the embodiment, the event information corresponding to different states can be different, which is beneficial to knowing the current state of the electronic device through the control result of the indicator light. The event information can be different, which means that the indicator light to be controlled and / or the control logic are different, which is not limited herein. In the embodiment, the first indicator light can be one or more, which is not limited herein. The control logic can be a control manner of the indicator light. For example, the control manner can be to control the indicator light to be turned on or off, when the indicator light is controlled to be turned on, the control manner can be to control the indicator light to be always on or to flash, and the control manner can also be to control the duration of the indicator light to be always on or to flash, when the indicator light is controlled to flash, the control manner can also be to control the frequency of the indicator light to flash, which is not limited herein.

[0036] In S140, the event information corresponding to the first state is written into a target chain table, and the first indicator light indicated by the target chain table is controlled based on the lighting manner of the first indicator light indicated by the target chain table and the control logic of the first indicator light to which the event information corresponding to the first state is written.

[0037] For example, assuming that the first state is a network configuration state, the event information corresponding to the first state can be to control at least one yellow indicator light, and the corresponding control logic is to flash for 5 seconds. When the first indicator light indicated by the target chain table is controlled based on the lighting manner of the first indicator light indicated by the target chain table and the control logic of the first indicator light to which the event information corresponding to the first state is written, the at least one yellow indicator light can be controlled to flash for 5 seconds and then be turned off based on the lighting manner of each yellow indicator light in the at least one yellow indicator light.

[0038] For example, assuming that the first state is a network configuration failure state, the event information corresponding to the first state can be that at least one red indicator light is to be controlled, and the corresponding control logic is to be constantly on for 5 seconds. When the first indicator light indicated by the target chain table is controlled based on the lighting mode of each red indicator light in the at least one red indicator light and the control logic of the first indicator light, the at least one red indicator light can be controlled to be constantly on for 5 seconds and then turned off.

[0039] For example, assuming that the first state is a network configuration success state, the event information corresponding to the first state can be that at least one green indicator light is to be controlled, and the corresponding control logic is to be constantly on. When the first indicator light indicated by the target chain table is controlled based on the lighting mode of each green indicator light in the at least one green indicator light and the control logic of the first indicator light, the at least one green indicator light can be controlled to be constantly on.

[0040] It should be noted that, in the embodiment, one indicator light can correspond to one separate target chain table, or all indicator lights can share one target chain table. It should be understood that, when all indicator lights share one target chain table, the control of all indicator lights can be implemented through the one chain table, which is beneficial to unified control and management of the indicator lights.

[0041] In the embodiment, the target chain table is obtained, the target chain table being used to indicate the lighting modes of the indicator lights of the electronic device; the state of the electronic device is detected to obtain a first state of the electronic device; the event information corresponding to the first state of the electronic device is obtained, the event information corresponding to the first state being used to indicate a first indicator light to be controlled and control logic of the first indicator light; and the event information corresponding to the first state is written into the target chain table, so that the first indicator light indicated by the target chain table is controlled based on the lighting mode of the first indicator light indicated by the target chain table and the control logic of the first indicator light. In this way, the control logic of all indicator lights can be managed through the target chain table, without coupling the control logic of the indicator lights and the business, thereby reducing the coupling between the control logic of the LED indicator light and the business logic, and improving the flexibility of configuration.

[0042] In a possible implementation manner, the target chain table is obtained, including: In response to the electronic device being powered on, the polarity of the interface to which each indicator light of the electronic device is connected is acquired, the polarity of the interface being used to indicate that the interface controls the indicator light connected thereto to light up when a first level is detected or controls the indicator light connected thereto to light up when a second level is detected, the first level being greater than the second level; and the polarity of the interface to which each indicator light is connected is registered to obtain a target linked list.

[0043] In this embodiment, the electronic device can be powered on or restarted. The interface in this embodiment may, for example, be a General-Purpose Input / Output (GPIO) interface. The GPIO interface allows a user to control its input and output states through programming, thereby enabling interaction with external devices. It can be configured as an input mode (receiving signals) or an output mode (sending signals) as needed, or have both input and output functions. The first level can be understood as a high level, and the second level can be understood as a low level, that is, the polarity of the interface is used to indicate whether the interface to which the indicator light is connected is high level valid or low level valid. If it is high level valid, a high level signal can be provided to the interface, thereby causing the indicator light connected to the interface to light up. If it is low level valid, a low level signal can be provided to the interface, thereby causing the indicator light connected to the interface to light up. In this embodiment, the polarity of the interface to which each indicator light is connected can be registered in the target linked list to obtain a target linked list used to indicate the lighting mode of each indicator light of the electronic device. In this embodiment, the flashing of the indicator light connected to the interface can be controlled through the duty cycle of the first level and the second level.

[0044] In this embodiment, in response to the electronic device being powered on, the polarity of the interface to which each indicator light of the electronic device is connected is acquired, the polarity of the interface being used to indicate that the interface controls the indicator light connected thereto to light up when a first level is detected or controls the indicator light connected thereto to light up when a second level is detected, the first level being greater than the second level; and the polarity of the interface to which each indicator light is connected is registered to obtain a target linked list, so that the polarity of the interface to which each indicator light is connected is acquired each time the electronic device is powered on. Thus, even if the interface to which the indicator light is connected is updated, the polarity of the interface can be updated to the target linked list in a timely manner, thereby improving the accuracy of the lighting control of the indicator light.

[0045] In another possible implementation, the target linked list can also be manually written.

[0046] In a possible implementation, the event information includes indicator light state information, flash light frequency information, control duration information, and a callback function to be executed after the control duration arrives, the indicator light state information is used to indicate a light-on, light-off, or flash light, and the callback function is used to indicate an action to be executed; the first indicator light indicated by the target chain table is controlled based on the light-on mode of the first indicator light indicated by the target chain table and the control logic of the first indicator light, and the control includes: The first indicator light indicated by the target chain table is controlled based on the light-on mode of the first indicator light indicated by the target chain table and the indicator light state information, the flash light frequency information, and the control duration information in the first indicator light; and the method further includes: if the callback function is not empty, controlling the electronic device to execute the action indicated by the callback function after the control duration indicated by the control duration information arrives.

[0047] In this embodiment, the control duration information is used to indicate the duration of the control. If the flash light frequency information is empty, the flash light can not be turned on or can be turned on at a fixed flash light frequency. When the control duration information is empty, there is no control time, so the indicator light can be always on or always off; or the control duration is fixed. If the callback function is empty, no processing is performed after the control duration arrives, or the state before the control is restored, which is not limited herein. It should be understood that the action indicated by the callback function can be set as needed, for example, restarting, or restoring the previous state, which is not limited herein.

[0048] For example, assuming that the first state is a factory reset state, the indicator light is controlled to indicate that the electronic device is in the factory reset state (for example, the green light and the yellow light are simultaneously flashed for 10 seconds), and then the callback function is used to control the electronic device to restart.

[0049] In this embodiment, the first indicator light indicated by the target chain table is controlled based on the light-on mode of the first indicator light indicated by the target chain table and the indicator light state information, the flash light frequency information, and the control duration information in the first indicator light; and the method further includes: if the callback function is not empty, controlling the electronic device to execute the action indicated by the callback function after the control duration indicated by the control duration information arrives, so that the action indicated by the callback function can be directly performed after the state of the electronic device is indicated by the indicator light, and the electronic device can timely execute the action indicated by the callback function.

[0050] In another possible implementation, the event information can also not need to be provided with the callback function, so that the storage resources required for storing the target chain table can be reduced.

[0051] In a possible implementation, the method further includes: In response to the electronic device switching from the first state to the second state, event information corresponding to the second state is acquired, the event information corresponding to the second state being used to indicate a second indicator light that needs to be controlled and control logic of the second indicator light, wherein the first indicator light and the second indicator light are different, the indicator light state corresponding to the first indicator light is different from the indicator light state corresponding to the second indicator light, the flashing light frequency corresponding to the first indicator light is different from the flashing light frequency corresponding to the second indicator light, the control duration corresponding to the first indicator light is different from the control duration corresponding to the second indicator light, and / or the callback function corresponding to the first indicator light is different from the callback function corresponding to the second indicator light; the event information corresponding to the second state is written into the target linked list, so as to control the second indicator light indicated by the target linked list based on the lighting mode of the second indicator light and the control logic of the second indicator light indicated by the target linked list to which the event information corresponding to the second state is written.

[0052] The first state and the second state can be different states, which are not limited herein. For example, the first state is an upgrade state, and the second state can be an upgrade success state. For example, the first state is an upgrade failure state, and the second state can be a restart state or a shutdown state. The event information corresponding to different states can be different. The event information corresponding to the second state can refer to the description of the event information corresponding to the first state, which is not repeated herein.

[0053] In the embodiment, in response to the electronic device switching from the first state to the second state, event information corresponding to the second state is acquired, the event information corresponding to the second state being used to indicate a second indicator light that needs to be controlled and control logic of the second indicator light, wherein the first indicator light and the second indicator light are different, the indicator light state corresponding to the first indicator light is different from the indicator light state corresponding to the second indicator light, the flashing light frequency corresponding to the first indicator light is different from the flashing light frequency corresponding to the second indicator light, the control duration corresponding to the first indicator light is different from the control duration corresponding to the second indicator light, and / or the callback function corresponding to the first indicator light is different from the callback function corresponding to the second indicator light; the event information corresponding to the second state is written into the target linked list, so as to control the second indicator light indicated by the target linked list based on the lighting mode of the second indicator light and the control logic of the second indicator light indicated by the target linked list to which the event information corresponding to the second state is written. Thus, when the state of the electronic device changes, the second indicator light indicated by the target linked list can be controlled based on the lighting mode of the second indicator light and the control logic of the second indicator light indicated by the target linked list to which the event information corresponding to the second state is written, so that the changed second state can be known through the indicator light, which is beneficial to improve user experience.

[0054] In a possible implementation, the method further includes: deleting the event information corresponding to the first state in the target chain table.

[0055] In this embodiment, the event information corresponding to the first state can be deleted after the event information corresponding to the second state is written, or the event information corresponding to the first state can be deleted in the process of controlling the second indicator light indicated by the target chain table. The embodiment does not limit the timing of deleting the event information corresponding to the first state.

[0056] In this embodiment, by deleting the event information corresponding to the first state in the target chain table, the storage resources required by the target chain table can be reduced.

[0057] In another possible implementation, the method further includes: retaining the event information corresponding to the first state in the target chain table, so that in the case that the electronic device recovers from the second state to the first state, the first indicator light indicated by the target chain table is controlled based on the lighting mode of the first indicator light and the control logic of the first indicator light indicated by the target chain table in which the event information corresponding to the first state is written.

[0058] For example, the second state of the embodiment can be a formatting state or a data transmission state. Generally, after formatting or data transmission, it is necessary to recover to the previous state.

[0059] In this embodiment, the event information corresponding to the first state in the target chain table can be retained, so that in the case that the electronic device recovers from the second state to the first state, the first indicator light indicated by the target chain table is controlled based on the lighting mode of the first indicator light and the control logic of the first indicator light indicated by the target chain table in which the event information corresponding to the first state is written. Therefore, it is not necessary to reacquire and write the event information corresponding to the first state after recovering to the first state, thereby improving the timeliness of indicating the first state by the indicator light after recovering to the first state, and reducing the computing resource.

[0060] It should be noted that in this embodiment, whether the event information corresponding to the first state needs to be deleted can be determined by the action indicated by the callback function. Alternatively, if the action indicated by the callback function is to recover to the previous state, the event information corresponding to the first state does not need to be deleted; if the action indicated by the callback function is another action, the event information corresponding to the first state can be deleted. In another possible implementation, whether to recover to the previous state can also be determined by the control logic of the operating system of the electronic device. In another possible implementation, whether to recover to the previous state can also be determined according to the second state.

[0061] In a possible implementation, the method further includes: creating threads corresponding to the indicators; detecting the state of the electronic device to obtain a current first state of the electronic device, including: for each indicator, detecting, by the thread corresponding to the indicator, the indicator-related state of the electronic device to obtain a first state of the electronic device currently indicated by the indicator and detected by the first thread.

[0062] Correspondingly, obtaining event information corresponding to the first state of the electronic device, writing the event information corresponding to the first state into a target linked list, and controlling the first indicator indicated by the target linked list based on the lighting mode of the first indicator indicated by the target linked list and the control logic of the first indicator, including: obtaining, by the first thread, event information corresponding to the first state of the electronic device, writing the event information corresponding to the first state into a target linked list, and controlling the first indicator indicated by the target linked list based on the lighting mode of the first indicator indicated by the target linked list and the control logic of the first indicator.

[0063] In this embodiment, the threads corresponding to the indicators can be created when the electronic device is powered on. Then, the indicator-related state is detected by the thread corresponding to the indicator, and when the first thread corresponding to one of the indicators detects the first state indicated by the indicator, the event information corresponding to the first state of the electronic device is obtained by the first thread, the event information corresponding to the first state is written into a target linked list, and the first indicator indicated by the target linked list is controlled based on the lighting mode of the first indicator indicated by the target linked list and the control logic of the first indicator.

[0064] For example, the thread corresponding to the yellow indicator is used to detect the network configuration state, the thread corresponding to the red indicator is used to detect the network configuration failure state, and the thread corresponding to the green indicator is used to detect the network configuration success state.

[0065] In this embodiment, by creating threads corresponding to the indicators, for each indicator, detecting, by the thread corresponding to the indicator, the indicator-related state of the electronic device to obtain a first state of the electronic device currently indicated by the indicator and detected by the first thread, obtaining, by the first thread, event information corresponding to the first state of the electronic device, writing the event information corresponding to the first state into a target linked list, and controlling the first indicator indicated by the target linked list based on the lighting mode of the first indicator indicated by the target linked list and the control logic of the first indicator, the operation between different indicators can be reduced, and thus the indication accuracy of the indicators can be improved.

[0066] It should be noted that if the second thread detects that the electronic device switches to the second state, the second thread can obtain the event information corresponding to the second state, and the event information corresponding to the second state is used to indicate the second indicator light to be controlled and the control logic of the second indicator light, wherein the first indicator light and the second indicator light are different, the indicator light state corresponding to the first indicator light is different from the indicator light state corresponding to the second indicator light, the flashing frequency corresponding to the first indicator light is different from the flashing frequency corresponding to the second indicator light, the control duration corresponding to the first indicator light is different from the control duration corresponding to the second indicator light, and / or the callback function corresponding to the first indicator light is different from the callback function corresponding to the second indicator light; the event information corresponding to the second state is written into the target linked list, so as to control the second indicator light indicated by the target linked list based on the lighting mode of the second indicator light and the control logic of the second indicator light indicated by the target linked list to which the event information corresponding to the second state is written.

[0067] In another possible implementation, all indicator lights can share one thread, so that the thread resources required for indicator light control can be reduced.

[0068] In a possible implementation, the first thread is used to obtain the event information corresponding to the first state of the electronic device, the event information corresponding to the first state is written into the target linked list, the target linked table is obtained, and the first indicator light indicated by the target linked list is controlled based on the lighting mode of the first indicator light and the control logic of the first indicator light indicated by the target linked list to which the event information corresponding to the first state is written. The global state of the electronic device is obtained, and it is determined whether the global state is a third state. The non-third state indicates that part of the indicator lights of the electronic device are controlled. If the global state is the non-third state, the first thread is used to obtain the event information corresponding to the first state of the electronic device, and the event information corresponding to the first state is written into the target linked list, so as to control the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light and the control logic of the first indicator light indicated by the target linked list to which the event information corresponding to the first state is written.

[0069] In the embodiment, if the global state is the non-third state, it is indicated that all indicator lights do not need to be controlled, and at this time, the first thread can be used to obtain the event information corresponding to the first state of the electronic device, the event information corresponding to the first state is written into the target linked list, and the first indicator light indicated by the target linked list is controlled based on the lighting mode of the first indicator light and the control logic of the first indicator light indicated by the target linked list to which the event information corresponding to the first state is written.

[0070] However, if the global state of the electronic device is the third state, event information corresponding to the third state of the electronic device is acquired, the event information corresponding to the third state is used to indicate all third indicator lights that need to be controlled and control logic of the third indicator lights; and the event information corresponding to the third state is written into the target chain table, so that the third indicator lights indicated by the target chain table are controlled based on the lighting mode of the third indicator lights and the control logic of the third indicator lights indicated by the target chain table to which the event information corresponding to the third state is written.

[0071] In this embodiment, if the global state of the electronic device is the third state, it indicates that all indicator lights need to be controlled at this time, and if the indicator lights continue to indicate the first state at this time, confusion will occur. Therefore, at this time, event information corresponding to the third state of the electronic device is acquired, and the event information corresponding to the third state is used to indicate all third indicator lights that need to be controlled and control logic of the third indicator lights; and the event information corresponding to the third state is written into the target chain table, so that the third indicator lights indicated by the target chain table are controlled based on the lighting mode of the third indicator lights and the control logic of the third indicator lights indicated by the target chain table to which the event information corresponding to the third state is written.

[0072] It should be noted that the third state can be represented by a global identifier in this embodiment. For example, when the global identifier is a true value, it is determined to be the third state, otherwise, it is not the third state. The non-third state can also be referred to as the fourth state.

[0073] In this embodiment, a global state is set, and it is determined whether the global state is the third state in which all indicator lights need to be controlled. Different processing is performed according to whether the global state is the third state or the non-third state, thereby improving the accuracy of the indicator lights.

[0074] It should be noted that in this embodiment, a thread can be used to detect the global state of the electronic device, and when the global state is the third state, the identifier of the third state is written into the global state list. Then, each thread reads the identifier in the global state list, and when the identifier in the global state list is the identifier of the third state, the identifier in the global state list is waited for to be the identifier of the non-third state. Then, event information corresponding to the state is acquired and written into the target chain table for control of the indicator lights. In another possible implementation, the state identifier of the third state can also be written into the global identifier list by using a callback function.

[0075] Next, another embodiment for controlling the indicator lights is provided.

[0076] Please refer to Figure 2 , Figure 2is a flow chart of a control method of an indicator light according to another embodiment of the present application, which can be executed by a control system of the indicator light, which can be, for example, a software system, for example, an operating system, which can include an application layer, a Framework layer, a hardware abstraction layer (HAL) layer and a driver layer. The application layer directly faces users or application programs, and provides interactive interfaces and business logic. The Framework layer is between the application layer and the HAL layer, and provides development frameworks and basic services. The HAL layer is between the operating system and the hardware, and abstracts hardware details to provide a unified interface. The driver layer directly interacts with the hardware, and is a software layer that controls hardware operations.

[0077] The method shown in the figure can include: Figure 2 S210, the application layer starts.

[0078] S220, the application layer performs indicator light initialization.

[0079] S230, the indicator light control module registers the light position GPIO.

[0080] In this embodiment, the indicator light control module can be deployed in the system framework (Framework) layer, the hardware abstraction layer (HAL) layer or the driver layer of the operating system. Registering the light position GPIO can be registering the polarity of the GPIO.

[0081] S240, the indicator light control module creates a linked list.

[0082] The linked list of this embodiment can refer to the description of the target linked list in the above embodiment, and will not be repeated here.

[0083] S250, the application layer creates a light-on thread.

[0084] S260, the application layer detects the state of the electronic device through the thread cycle.

[0085] S270, the application layer detects that the electronic device has changed from a state.

[0086] In this embodiment, it can be detected whether the electronic device switches from another state to the first state, or whether the electronic device switches from the first state to the second state, which is not limited here.

[0087] S280, the indicator light control module pushes the modification into the linked list.

[0088] This embodiment can be writing the event information of the current state into the linked list.

[0089] S290, the indicator light control module controls the indicator light based on the linked list.

[0090] ​In the embodiment, S290 includes: S2901, traversing the linked list by the thread.

[0091] In the embodiment, the event information of the current state can be determined by traversing the linked list by the thread.

[0092] S2902, performing the change of the linked list.

[0093] In the embodiment, the latest event information in the linked list can be performed to control the indicator light.

[0094] S2903, reaching the control duration.

[0095] In the embodiment, the time of controlling the indicator light can reach the control duration. Alternatively, if the indicator light is controlled to flash, and the indicator light flashes at a fixed frequency, whether the control duration is reached can be determined by the number of times of flashing.

[0096] S2904, executing the callback function.

[0097] The application layer and the indicator light control module of the embodiment can jointly perform the steps of the control method of the indicator light of the above embodiment.

[0098] Specifically, when initializing the LED module, the initialization work of the LED module can be performed first after the device is powered on. The initialization process includes: creating a global array and an enumeration corresponding to the LED, registering the GPIO after the device is powered on, and recording the GPIO and high and low levels of the LED to be used in the global array (also known as the linked list) in advance. The global array is obtained by subsequent query. Since the high and low levels are added, different hardware can be adapted. Whether the high level is effective or the low level is effective, as long as the electrode is registered when registering, it can be adapted.

[0099] In the embodiment, when creating the underlying linked list and the thread, a time slicing polling algorithm mechanism is adopted to create the linked list to control the underlying GPIO. The application layer will press the event into the linked list. When the time slicing reaches the preset value, the event in the linked list is taken out and executed. The event content includes: the GPIO of the light to be controlled, the state to be changed (turning on the light, turning off the light, flashing the light), the flashing frequency (if it is not flashing, the value is empty), the time to be controlled (the default -1 is always executed), the callback function to be executed after the time (empty if it is not executed).

[0100] In setting the device state, since the LED display needs to be adjusted according to the device state, for example, whether the SD card exists or the network is normal, the corresponding enumeration needs to be created according to the LED requirements. For example, the network state enumeration includes the no SIM card state, the network registration state, the normal state, the network registration failure, the network exception, etc. Each state corresponds to a light situation, and the device system needs to set these states in real time according to the scene.

[0101] In the cycle of detecting the state of the electronic device and lighting, the corresponding thread is created according to the number of LEDs, each thread acquires the corresponding device state, and the lighting event is created according to the device state. For example, in the network state, the network light displays yellow 5-second flashing when registering the network, the network is normal, the green light is always on, and the network is abnormal, the red light is always on. After creating the corresponding event, it is sent to the underlying linked list, and the linked list controls the corresponding light to perform the operation. At the same time, it also supports complex combination requirements, such as the requirement that a certain state light flashes red for 5 seconds and then shuts down. As long as the lighting time and the callback function of shutting down are added when creating the event, it can be normally executed.

[0102] In addition, the embodiment also sets up an exception mechanism: Mechanism 1: Save the last called LED state: save the last event state before each call to the event, and if the same state is found, it will not be changed to prevent repeated calls to GPIO from causing exceptions. At the same time, it can also meet some special cases, such as the abnormal red light for 5 seconds and then restore the last state of this kind of requirement.

[0103] Mechanism 2: Set up special states and initial states: since it is a multi-thread operation, the state of some LED lights is not changed by a single system state, but by a combination of multiple system states, such as system upgrade failure requiring all lights to flash red for 10 seconds and then restore the original state. Here, if all LED lights are modified directly using events, since the state detection thread is very fast, the thread will still change the LED according to the current system state in these 10 seconds, which may cause confusion. Therefore, a special global state list is needed when these special situations occur, which needs to be separated from the normal state judgment. When a state event in the list is true, the LED light state is not changed. Finally, when the special situation ends, all LED states need to be changed to the initial state, so that the LED thread finds that the state this time is different from the last saved state, and the last LED display is restored.

[0104] In the embodiment, by providing a unified GPIO configuration interface, all GPIO lamps to be used are initialized and created during system initialization, including the valid level polarity, so that different hardware can be adapted. Moreover, by modularly managing the underlying GPIO control, a polling linked list is established to gradually execute the control lamp instructions passed by the application layer, and unified management is established. Moreover, a state management variable is established for each lamp, and the system indicates the lamp to be modified by modifying the state, and then the lamp thread modifies the lamp by searching for the state, instead of directly modifying the lamp in the system, so that the lamp management is clearer, the coupling is reduced, and the transplantation is facilitated. Moreover, an independent single thread and linked list are established to separately manage the lamps, so as to prevent other system tasks from interfering with the lamp operation. In addition, the complex underlying setting code is packaged, a simple calling interface is reserved, and the functions are divided into (1) turning on the lamp, (2) turning off the lamp, (3) fast flashing, (4) slow flashing, and there are also dynamic parameters such as the number of flashing times and the key callback, so as to meet the diversity of requirements.

[0105] It should be understood that the unified GPIO management mechanism reduces the repeated development work, the standardized interface design improves the code reusability, the perfect state management avoids the control conflict, the separate thread control avoids the system delay and lag, the state callback mechanism supports the complex interaction logic, and the diversity of requirements is met.

[0106] The device embodiment of the present application is introduced below, which can be used to execute the method in the above-mentioned embodiments of the present application. For details not disclosed in the device embodiment of the present application, refer to the above-mentioned method embodiments of the present application.

[0107] Figure 3 is a block diagram of a control device of an indicator lamp according to an embodiment of the present application, as shown in Figure 3 The control device of the indicator lamp includes an acquisition module 310, a detection module 320 and a control module 330, wherein: The acquisition module 310 is configured to acquire a target linked list, the target linked list being used to indicate the lighting modes of the indicator lamps of an electronic device; the detection module 320 is configured to detect the state of the electronic device to obtain a first state of the electronic device; the control module 330 is configured to acquire event information corresponding to the first state of the electronic device, the event information corresponding to the first state being used to indicate a first indicator lamp to be controlled and the control logic of the first indicator lamp; and the control module 330 is configured to write the event information corresponding to the first state into the target linked list, so as to control the first indicator lamp indicated by the target linked list based on the lighting mode of the first indicator lamp and the control logic of the first indicator lamp indicated by the target linked list to which the event information corresponding to the first state is written.

[0108] In a possible implementation, the acquisition module 310 acquires the target chain table, and is configured to: in response to the electronic device being powered on, acquire polarities of interfaces to which respective indicator lights of the electronic device are connected, the polarity of an interface being used to indicate that the interface controls the indicator light connected to the interface to light up when a first level is detected or controls the indicator light connected to the interface to light up when a second level is detected, the first level being greater than the second level; and register the polarities of the interfaces to which the respective indicator lights are connected to obtain the target chain table.

[0109] In a possible implementation, the event information includes indicator light state information, flash light frequency information, control duration information, and a callback function to be executed after the control duration arrives, the indicator light state information is used to indicate lighting, extinguishing, or flashing, and the callback function is used to indicate an action to be executed; when the control module 330 controls the first indicator light indicated by the target chain table based on the lighting mode of the first indicator light and the control logic of the first indicator light indicated by the event information corresponding to the first state written in the target chain table, the control module 330 is configured to: control the first indicator light indicated by the target chain table based on the lighting mode of the first indicator light and the indicator light state information, the flash light frequency information, and the control duration information in the first indicator light indicated by the target chain table; and the control module 330 is further configured to: if the callback function is not empty, after the control duration indicated by the control duration information arrives, control the electronic device to execute the action indicated by the callback function.

[0110] In a possible implementation, the control module 330 is further configured to: in response to the electronic device switching from the first state to a second state, acquire event information corresponding to the second state, the event information corresponding to the second state being used to indicate a second indicator light to be controlled and a control logic of the second indicator light, wherein the first indicator light and the second indicator light are different, the indicator light state corresponding to the first indicator light is different from the indicator light state corresponding to the second indicator light, the flash light frequency corresponding to the first indicator light is different from the flash light frequency corresponding to the second indicator light, the control duration corresponding to the first indicator light is different from the control duration corresponding to the second indicator light, and / or the callback function corresponding to the first indicator light is different from the callback function corresponding to the second indicator light; and write the event information corresponding to the second state into the target chain table, to control the second indicator light indicated by the target chain table based on the lighting mode of the second indicator light and the control logic of the second indicator light indicated by the target chain table to which the event information corresponding to the second state is written.

[0111] In a possible implementation, the control module 330 is further configured to: delete the event information corresponding to the first state in the target chain table; or, retain the event information corresponding to the first state in the target chain table, so as to control the first indicator light indicated by the target chain table based on the lighting mode of the first indicator light indicated by the target chain table in which the event information corresponding to the first state is written and the control logic of the first indicator light, in a case where the electronic device recovers from the second state to the first state.

[0112] In a possible implementation, the acquisition module 310 is further configured to: create a thread corresponding to each indicator light; when the detection module 320 detects the state of the electronic device to obtain the first state of the electronic device at present, the detection module 320 is configured to: for each indicator light, detect the indicator light related state of the electronic device through the thread corresponding to the indicator light to obtain the first state of the electronic device at present indicated by the indicator light detected by the first thread; and when the control module 330 acquires the event information corresponding to the first state of the electronic device, writes the event information corresponding to the first state into the target chain table, and controls the first indicator light indicated by the target chain table based on the lighting mode of the first indicator light indicated by the target chain table in which the event information corresponding to the first state is written and the control logic of the first indicator light, the control module 330 is configured to: acquire the event information corresponding to the first state of the electronic device through the first thread, write the event information corresponding to the first state into the target chain table, and control the first indicator light indicated by the target chain table based on the lighting mode of the first indicator light indicated by the target chain table in which the event information corresponding to the first state is written and the control logic of the first indicator light.

[0113] In a possible implementation, the control module 330 obtains event information corresponding to the first state of the electronic device through the first thread, writes the event information corresponding to the first state into the target linked list, obtains the target linked table, and when the first indicator light indicated by the target linked list is controlled based on the lighting mode of the first indicator light indicated by the target linked list in which the event information corresponding to the first state is written and the control logic of the first indicator light, the control module 330 is configured to: obtain a global state of the electronic device, and determine whether the global state is a third state, where a non-third state indicates that the part of the indicator lights of the electronic device are controlled; if the global state is a non-third state, the control module 330 obtains event information corresponding to the first state of the electronic device through the first thread, writes the event information corresponding to the first state into the target linked list, and controls the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light indicated by the target linked list in which the event information corresponding to the first state is written and the control logic of the first indicator light; and the control module 330 is further configured to: if the global state of the electronic device is a third state, obtain event information corresponding to the third state of the electronic device, where the event information corresponding to the third state is used to indicate all third indicator lights that need to be controlled and the control logic of the third indicator lights; write the event information corresponding to the third state into the target linked list, and control the third indicator light indicated by the target linked list based on the lighting mode of the third indicator light indicated by the target linked list in which the event information corresponding to the third state is written and the control logic of the third indicator light.

[0114] Figure 4 A structural diagram of a computer system of an electronic device suitable for implementing the embodiments of the present application is shown. It should be noted that, Figure 4 The computer system 400 of the electronic device shown is only an example and should not impose any limitation on the functions and use range of the embodiments of the present application. The electronic device can be used to execute the control method of the indicator light provided by the application.

[0115] As Figure 4 shown, the computer system 400 includes a central processing unit (CPU) 401, which can perform various appropriate actions and processes according to programs stored in a read-only memory (ROM) 402 or programs loaded from a storage portion 408 into a random access memory (RAM) 403, such as performing the methods in the above embodiments. In the RAM 403, various programs and data required for system operation are also stored. The CPU 401, the ROM 402, and the RAM 403 are connected to each other through a bus 404. An input / output (I / O) interface 405 is also connected to the bus 404.

[0116] The following components are connected to the I / O interface 405: an input part 406 including a keyboard, a mouse, etc.; an output part 407 including a display such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), etc., and a speaker, etc.; a storage part 408 including a hard disk, etc.; and a communication part 409 including a network interface card such as a LAN (Local Area Network) card, a modem, etc. The communication part 409 performs communication processing via a network such as the Internet. A drive 410 is also connected to the I / O interface 405 as necessary. A removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, etc. is attached to the drive 410 as necessary, so that a computer program read out therefrom is installed in the storage part 408 as necessary.

[0117] In particular, according to embodiments of the present application, the processes described above with reference to the flowcharts can be implemented as a computer software program. For example, embodiments of the present application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for executing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network by the communication part 409, and / or installed from the removable medium 411. When the computer program is executed by the central processing unit (CPU) 401, various functions defined in the system of the present application are executed.

[0118] It should be noted that the computer-readable medium in the embodiments of the present application can be a computer-readable signal medium or a computer-readable storage medium or any combination thereof. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination thereof. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM), a flash memory, an optical fiber, a portable compact disk read-only memory (Compact Disc Read-Only Memory, CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination thereof. In the present application, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus. In the present application, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take various forms, including but not limited to an electromagnetic signal, an optical signal, or any suitable combination thereof. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, transmit, propagate or transport a program for use by or in conjunction with an instruction execution system, device or apparatus. The program code contained on the computer-readable medium can be transmitted using any suitable medium, including but not limited to wireless, wired, or the like, or any suitable combination thereof.

[0119] The flowcharts and block diagrams in the drawings illustrate the possible implementation architectures, functions and operations of the systems, methods and computer program products according to various embodiments of the present application. In the flowcharts or block diagrams, each block can represent a module, a program segment or a part of code, which contains one or more executable instructions for implementing the specified logical functions. It should also be noted that in some alternative implementations, the functions noted in the blocks can occur in different orders than that shown in the drawings. For example, two blocks that are shown in succession can actually be executed substantially in parallel, and sometimes in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams or flowcharts, and the combination of blocks in the block diagrams or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.

[0120] The units described in the embodiments of the present application can be implemented by software, or by hardware, or by a combination of software and hardware. The units described can also be located in a single processor. In some cases, the names of the units do not limit the units themselves.

[0121] As another aspect, the present application also provides a computer readable storage medium, which can be included in the electronic device described in the above embodiments, or can exist separately without being assembled into the electronic device. The computer readable storage medium carries computer readable instructions, which, when executed by a processor, implement the method in any of the above embodiments.

[0122] In the embodiments of the present application, the term "module" or "unit" refers to a computer program or a part of a computer program with a predetermined function, and works together with other related parts to achieve a predetermined target, and can be implemented entirely or partially by using software, hardware (such as a processing circuit or a memory), or a combination thereof, and similarly, one processor (or multiple processors or memories) can be used to implement one or more modules or units. In addition, each module or unit can be a whole module or unit of the function of the module or unit, or a part of the module or unit.

[0123] According to an aspect of the embodiments of the present application, a computer program product is provided, which includes computer instructions stored in a computer readable storage medium. A processor of an electronic device reads the computer instructions from the computer readable storage medium, and the processor executes the computer instructions to cause the electronic device to perform the method in any of the above embodiments.

[0124] It should be noted that although several modules or units of the device for action execution are mentioned in the above detailed description, such a division is not mandatory. Indeed, according to the embodiments of the present application, the features and functions of two or more modules or units described above can be embodied in one module or unit. Conversely, the features and functions of one module or unit described above can be further divided into multiple modules or units.

[0125] Those skilled in the art can easily understand, through the above description of the embodiments, that the example embodiments described herein can be implemented by software, or by software in combination with necessary hardware. Therefore, the technical solutions according to the embodiments of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, a USB flash disk, a mobile hard disk, or the like) or on a network, and includes a number of instructions to enable a computing device (which can be a personal computer, a server, a touch terminal, or a network device, etc.) to perform the methods according to the embodiments of the present application.

[0126] Other embodiments of the present application will be apparent to those skilled in the art from consideration of the specification and practice of the embodiments disclosed herein. It is intended that the present application cover any and all variations of the present application that come within the scope of the claims and that the terms describe and cover both structural and functional equivalents. Therefore, it is intended that the application not be limited to the exact cartoms recited.

[0127] It is to be understood that the application is not limited to the precise details of construction and the above-described embodiments and that various modifications and changes can be effected therein by one skilled in the art without departing from the scope of the application. The scope of the application should be determined by the terms of the appended claims and their legal equivalents.

Claims

1. A method for controlling an indicator light, characterized in that, include: Obtain the target linked list, which is used to indicate the lighting mode of each indicator light in the electronic device; The state of the electronic device is detected to obtain the current first state of the electronic device; Obtain event information corresponding to the first state of the electronic device. The event information corresponding to the first state is used to indicate the first indicator light that needs to be controlled and the control logic of the first indicator light. The event information corresponding to the first state is written into the target linked list, so as to control the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light indicated by the target linked list containing the event information corresponding to the first state and the control logic of the first indicator light.

2. The method according to claim 1, characterized in that, The process of obtaining the target linked list includes: In response to the power-on of the electronic device, the polarity of the interface to which each indicator light of the electronic device is connected is obtained. The polarity of the interface is used to indicate whether the interface controls the indicator light connected to the interface to turn on when a first level is detected or controls the indicator light connected to the interface to turn on when a second level is detected, wherein the first level is greater than the second level. Register the polarity of the interfaces to which each indicator light is connected to to obtain the target linked list.

3. The method according to claim 1, characterized in that, The event information includes indicator light status information, flashing frequency information, control duration information, and callback function to be executed after the control duration is reached, which are used to indicate the control logic. The indicator light status information is used to indicate whether the light is on, off, or flashing, and the callback function is used to indicate the action to be performed. The control of the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light indicated by the target linked list corresponding to the first state and the control logic of the first indicator light includes: Based on the lighting mode of the first indicator light indicated by the target linked list, and the indicator light status information, flashing frequency information, and control duration information in the first indicator light, the first indicator light indicated by the target linked list is controlled; The method further includes: If the callback function is not empty, then after the control duration indicated by the control duration information is reached, the electronic device is controlled to execute the action indicated by the callback function.

4. The method according to claim 3, characterized in that, The method further includes: In response to the electronic device switching from a first state to a second state, event information corresponding to the second state is obtained. The event information corresponding to the second state is used to indicate the second indicator light that needs to be controlled and the control logic of the second indicator light. The first indicator light and the second indicator light are different, the indicator light state corresponding to the first indicator light is different from the indicator light state corresponding to the second indicator light, the flashing frequency corresponding to the first indicator light is different from the flashing frequency corresponding to the second indicator light, the control duration corresponding to the first indicator light is different from the control duration corresponding to the second indicator light, and / or the callback function corresponding to the first indicator light is different from the callback function corresponding to the second indicator light. The event information corresponding to the second state is written into the target linked list, so as to control the second indicator light indicated by the target linked list based on the lighting mode of the second indicator light indicated by the target linked list containing the event information corresponding to the second state and the control logic of the second indicator light.

5. The method according to claim 4, characterized in that, The method further includes: Delete the event information corresponding to the first state in the target linked list; or... The event information corresponding to the first state in the target linked list is retained so that, when the electronic device recovers from the second state to the first state, the first indicator light indicated by the target linked list, based on the lighting mode of the first indicator light indicated by the target linked list containing the event information corresponding to the first state and the control logic of the first indicator light, can be controlled.

6. The method according to claim 1, characterized in that, The method further includes: Create threads corresponding to each indicator light; The step of detecting the state of the electronic device to obtain the current first state of the electronic device includes: For each indicator light, the thread corresponding to the indicator light detects the state of the electronic device related to the indicator light, and obtains the first state of the electronic device as indicated by the indicator light as detected by the first thread; The step of obtaining event information corresponding to the first state of the electronic device, writing the event information corresponding to the first state into the target linked list, and controlling the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light indicated by the target linked list containing the event information corresponding to the first state and the control logic of the first indicator light includes: The first thread obtains event information corresponding to the first state of the electronic device, writes the event information corresponding to the first state into the target linked list, and controls the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light indicated by the target linked list containing the event information corresponding to the first state and the control logic of the first indicator light.

7. The method according to claim 6, characterized in that, The step involves obtaining event information corresponding to the first state of the electronic device through the first thread, writing the event information corresponding to the first state into the target linked list to obtain the target linked list, and controlling the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light indicated by the target linked list containing the event information corresponding to the first state and the control logic of the first indicator light, including: Obtain the global state of the electronic device and determine whether the global state is a third state. If it is not a third state, it means that some indicator lights of the electronic device are controlled. If the global state is not the third state, the first thread obtains the event information corresponding to the first state of the electronic device, writes the event information corresponding to the first state into the target linked list, and controls the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light indicated by the target linked list containing the event information corresponding to the first state and the control logic of the first indicator light. The method further includes: If the global state of the electronic device is the third state, then the event information corresponding to the third state of the electronic device is obtained. The event information corresponding to the third state is used to indicate all the third indicator lights that need to be controlled and the control logic of the third indicator lights. The event information corresponding to the third state is written into the target linked list, so as to control the third indicator lights indicated by the target linked list based on the lighting mode of the third indicator lights and the control logic of the third indicator lights indicated by the target linked list containing the event information corresponding to the third state.

8. A control device for an indicator light, characterized in that, include: An acquisition module is used to acquire a target linked list, which is used to indicate the lighting mode of each indicator light in the electronic device; The detection module is used to detect the state of the electronic device and obtain the current first state of the electronic device; The control module is used to acquire event information corresponding to the first state of the electronic device. The event information corresponding to the first state is used to indicate the first indicator light that needs to be controlled and the control logic of the first indicator light. The event information corresponding to the first state is written into the target linked list, so as to control the first indicator light indicated by the target linked list based on the lighting mode of the first indicator light indicated by the target linked list containing the event information corresponding to the first state and the control logic of the first indicator light.

9. An electronic device, characterized in that, include: processor; A memory storing computer-readable instructions that, when executed by the processor, implement the method as described in any one of claims 1-7.

10. A computer-readable storage medium storing computer-readable instructions thereon, characterized in that, When the computer-readable instructions are executed by a processor, the method as described in any one of claims 1-7 is implemented.