LED light source control method, device and LED light source equipment
By using serial peripheral interface and code data technology in the LED light source control device, the display mode of the LED light source is adjusted according to the operating status of the control device, and the problem of unstable adjustment of the LED light source display effect in the prior art is solved, and the stability and reliability of the display effect are improved.
Patent Information
- Application Number
- CN202210916841.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-01
- Publication Date
- 2025-04-18
- Estimated Expiration
- 2042-08-01
AI Technical Summary
The existing LED light source control device is unstable when adjusting the LED light source display effect, which affects the reliability of the display effect.
Connecting with the LED light source through a serial peripheral interface, obtain control instructions and convert them into symbol data, determine the target transmission mode of the symbol data according to the current operating status of the control device, and send the symbol data to the LED light source through the serial peripheral interface based on this mode, so that it can be displayed according to the target display mode.
The stability and reliability of LED light source display effect adjustment is improved, so that it can better adapt to the current operating state of the control device.
Smart Images

Figure CN115442946B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of light source control technology, and in particular to an LED light source control method, device and LED light source equipment. Background Art
[0002] With the development of technology, current diode (Light Emitting Diode, LED) light sources can realize intelligent control of LED light sources such as luminous intensity, luminous color and other light language display effects. However, when controlling the LED light source, the current control device is unstable in adjusting the display effect of the LED light source. Summary of the invention
[0003] The embodiments of the present application provide an LED light source control method, device and LED light source equipment, which can improve the stability and reliability of LED light source display effect adjustment.
[0004] In a first aspect, the present application provides a method for controlling an LED light source, which is used for a control device, wherein the control device is connected to the LED light source via a serial peripheral interface, and the method comprises:
[0005] Obtaining a control instruction of the LED light source; wherein the control instruction is used to indicate a target display mode of the LED light source;
[0006] Convert control instructions into symbol data according to a preset coding protocol;
[0007] Determine a target transmission mode of the symbol data according to the current operation state of the control device; wherein the target transmission mode includes at least one of an interrupt transmission mode and a DMA (Direct Memory Access) transmission mode;
[0008] Based on the target sending mode, the symbol data is sent to the LED light source through the serial peripheral interface, so that the LED light source displays according to the target display mode according to the symbol data.
[0009] In a second aspect, the present application provides a control device, comprising:
[0010] A microcontroller, wherein the microcontroller integrates a processor and a serial peripheral unit, the serial peripheral unit is connected to the processor, and a serial peripheral interface of the serial peripheral unit is used to connect to the LED light source;
[0011] Wherein, the processor is used to implement the steps of the aforementioned LED light source control method.
[0012] In a third aspect, the present application provides an LED light source device, comprising:
[0013] The aforementioned control device; and
[0014] LED light source;
[0015] The control device is used to control the LED light source display.
[0016] In a fourth aspect, the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the processor implements the steps of the above-mentioned LED light source control method.
[0017] The present application discloses an LED light source control method, device and LED light source equipment, the method comprising: obtaining a control instruction of the LED light source, converting the control instruction into symbol data according to a preset coding protocol, determining a target transmission mode of the symbol data according to the current operating state of the control device, and sending the symbol data to the LED light source through a serial peripheral interface based on the target transmission mode, so that the LED light source displays according to the symbol data in accordance with the target display mode. By determining the target transmission mode of the symbol data according to the current operating state of the control device, the target transmission mode of the symbol data can be adapted to the current operating state of the control device, thereby improving the stability and reliability of the adjustment of the display effect of the LED light source in the current operating state. BRIEF DESCRIPTION OF THE DRAWINGS
[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings required for use in the description of the embodiments will be briefly introduced below. 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.
[0019] Figure 1 Schematic diagram of the flow of the LED light source control method according to an embodiment of the present application.
[0020] Figure 2 A schematic block diagram of a control device provided in an embodiment of the present application.
[0021] Figure 3 A schematic block diagram of an LED light source device provided in an embodiment of the present application.
[0022] Figure 4 FIG. 4 is a schematic diagram of RGB data in one implementation.
[0023] Figure 5 FIG. 4 is a schematic diagram of a unipolar return-to-zero code in one implementation manner.
[0024] Figure 6 4 is a block diagram of a serial peripheral interface in one implementation.
[0025] Figure 7 FIG. 4 is a schematic diagram of a full-duplex mode based on a serial peripheral interface in one implementation manner.
[0026] Figure 8 FIG. 1 is a schematic diagram of sending symbol data based on a host data sending line in one implementation manner.
[0027] Fig. 9 FIG. 4 is a schematic diagram of a serial peripheral interface timing and data format in one implementation.
[0028] Fig.10 Schematic block diagram of an LED light source device in one embodiment.
[0029] Fig.11 Schematic diagram of a data transmission process in which a control device controls multiple LED light sources in one embodiment. DETAILED DESCRIPTION
[0030] The following will be combined with the drawings in the embodiments of the present application to clearly and completely describe the technical solutions in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0031] The flowcharts shown in the accompanying drawings are only examples and do not necessarily include all the contents and operations / steps, nor must they be executed in the order described. For example, some operations / steps may also be decomposed, combined or partially merged, so the actual execution order may change according to actual conditions.
[0032] The embodiments of the present application provide an LED light source control method, device and LED light source equipment. By determining the target sending mode of the code data according to the current operating state of the control device, the target sending mode of the code data can be adapted to the current operating state of the control device, thereby improving the stability and reliability of the adjustment of the LED light source display effect in the current operating state.
[0033] In conjunction with the accompanying drawings, some embodiments of the present application are described in detail below. In the absence of conflict, the following embodiments and features in the embodiments can be combined with each other.
[0034] See also Figure 1 , Figure 1 The present invention provides a flow chart of a method for controlling an LED light source according to an embodiment of the present invention. The method for controlling an LED light source is used to control the display mode of an LED light source.
[0035] The LED light source control method provided in the embodiment of the present application can be applied to a control device, which is, for example, a chip or circuit in an LED light source device, or can also be a control device for an LED light source or a chip or circuit in a control device.
[0036] The LED light source control method provided in the embodiment of the present application can be applied to LED light source equipment. In the present application, LED light source equipment refers to equipment with an LED light source, such as but not limited to self-moving equipment or power supply equipment, where the self-moving equipment is, for example, a lawn mowing robot, a sweeping robot, a mine clearance robot, a cruise robot, etc., and this embodiment does not specifically limit this.
[0037] See also Figure 2 and Figure 3 , Figure 2 is a schematic block diagram of a control device 100 provided in an embodiment of the present application. Figure 3 It is a schematic block diagram of an LED light source device 10 provided in an embodiment of the present application.
[0038] The control device 100 includes a microcontroller 110, the microcontroller 110 integrates a serial peripheral unit 111 and a processor 112, the serial peripheral unit 111 is connected to the processor 112, and the serial peripheral interface (Serial Peripheral Interface, SPI) of the serial peripheral unit 111 is used to connect to the LED light source 200; wherein the processor 112 is used to implement the steps of the LED light source control method.
[0039] For example, the microcontroller 110 is a GD32 single-chip microcomputer, which has the advantage of low cost. It is understandable that the control device 100 may also include peripheral circuits of the microcontroller 110, such as a power supply circuit, a crystal oscillator circuit, etc., but is certainly not limited thereto.
[0040] By adopting the serial peripheral interface to connect the LED light source 200, advantages such as fast data transmission rate and fast control response can be achieved.
[0041] like Figure 3 As shown, the LED light source device 10 includes: a control device 100 and an LED light source 200 , and the control device 100 is used to control the display of the LED light source 200 .
[0042] In some embodiments, the control device 100 is connected to the LED light source 200 via a serial peripheral interface. For example, the LED light source 200 is an intelligent externally controlled LED light source that can display different colors, for example, an intelligent externally controlled LED light source that can display a combination of RGB (red, green, and blue) three primary colors, but is not limited thereto. Intelligent externally controlled LED light sources are widely used in electronic consumer products, especially for outdoor robots that lack a human-computer interaction interface, which can provide a light language function based on intelligent externally controlled LED light sources.
[0043] like Figure 1 As shown, the LED light source control method includes the following steps S110 to S140.
[0044] Step S110, obtaining a control instruction of the LED light source; wherein the control instruction is used to indicate a target display mode of the LED light source.
[0045] The present application embodiment mainly uses an LED light source that can display a combination of RGB (red, green, and blue) three primary colors as an example for explanation. In other implementations, the LED light source is not limited to an LED light source that displays a combination of RGB three primary colors, and can also be an LED light source that displays a combination of RGBY four primary colors. Figure 4 The RGB data corresponding to each LED light source carried by the control instruction of the LED light source of the RGB three primary colors includes 3×8=24Bit data, that is, the RGB data includes 24 bits of data composed of 0 codes and 1 codes; the first 8Bit data is used to indicate the green (G) component value of the LED light source, the middle 8Bit data is used to indicate the red (R) component value of the LED light source, and the last 8Bit data is used to indicate the blue (B) component value of the LED light source; based on the RGB data, the component values of different preset colors (red, green, and blue) in the LED light source are controlled, and the display mode of the LED light source can be adjusted, such as displaying yellow, purple, or pink.
[0046] In some embodiments, the LED light source device further includes a human-machine interaction device, which is connected to the control device, and the control device is used to control the LED light source according to the user operation detected by the human-machine interaction device. The human-machine interaction device, for example, includes at least one of a button, a knob, a touch screen, etc. Optionally, the control instruction of the LED light source can be determined according to the user operation detected by the human-machine interaction device.
[0047] In some embodiments, the LED light source device further includes a communication device, which is connected to the control device, and the control device can communicate with the terminal device through the communication device; the communication device includes, for example, at least one of a Bluetooth component and a WiFi component, and the terminal device includes, for example, a mobile phone, a tablet computer, a smart home control terminal, etc., of course, it is not limited thereto. Exemplarily, the control device can obtain a control instruction sent by the terminal device, or obtain a target display mode of the LED light source sent by the terminal device, and generate a control instruction of the LED light source according to the target display mode.
[0048] In some embodiments, the control device may determine the control instruction of the LED light source according to at least one of the working state of the target device, device parameters, and environmental parameters detected by the target device, etc. Optionally, the target device may be a device having an LED light source, such as a self-moving device or a power supply device, or may be other devices other than the above devices, which is not particularly limited in this embodiment.
[0049] Exemplarily, based on a preset RGB color to hexadecimal color comparison table and according to the target display mode of the LED light source, for example, displaying pink, it is possible to determine that the control instruction carries RGB data, for example, converting the RGB color of the target display mode into corresponding 24-bit data.
[0050] Step S120: convert the control instruction into symbol data according to a preset coding protocol.
[0051] In some implementations, if the RGB data is directly sent to the LED light source, the LED light source cannot directly display according to the target display mode based on the RGB data. The RGB data may be converted into symbol data that can be recognized by the LED light source.
[0052] Exemplarily, the control instruction is converted into symbol data according to a preset coding protocol, including: converting each binary bit in the control instruction into a unipolar return-to-zero code to obtain symbol data. The symbol data is obtained by converting each bit of the RGB data in the control instruction into a unipolar return-to-zero code that can be recognized by the LED light source, for example, converting the 0 code data in the RGB data into 0xF800 data, and converting the 1 code data in the RGB data into 0xFF80 data. By converting the 0 code data and the 1 code data in the RGB data into symbol data with a wider data width, and controlling the LED light source through the symbol data, the robustness, stability and flexibility of the control can be improved.
[0053] Please refer to Table 1 Figure 5 , each valid code element in the unipolar return-to-zero code must have a high level and a low level. For example, each valid code element starts at a high level, and the valid code element is determined to be a 0 code or a 1 code based on the time width of the high and low levels.
[0054] Table 1 Unipolar return-to-zero code
[0055] name describe Typical Value Tolerance unit T0H 0 code, high level time 0.3 ±0.15 us T1H 1 code, high level time 0.6 ±0.15 us T0L 0 code, low level time 0.9 ±0.15 us T1L 1 code, low level time 0.6 ±0.15 us Trest Reset code, low level time 80 - us
[0056] Unipolar return-to-zero code means that high level and zero level represent binary code 1 and 0 respectively, no voltage represents 0, and constant positive voltage represents 1, but the duration is shorter than the time width of a valid code element, that is, a narrow pulse is emitted. The middle point of the code element time of each valid code element is the sampling time, and the decision threshold is half amplitude level. The main advantage of unipolar return-to-zero code is that it can directly extract the synchronization signal. Therefore, unipolar return-to-zero code is often used as a transition code type when other code types extract synchronization signals. In other words, other code types that are suitable for channel transmission but cannot directly extract synchronization signals can be converted into unipolar return-to-zero code first, and then the synchronization signal can be extracted.
[0057] For example, the symbol data may be sent to the LED light source at a certain frequency through a serial peripheral interface (SPI), so that the LED light source performs display according to the target display mode based on the symbol data.
[0058] Step S130: determining a target transmission mode of the symbol data according to the current operation state of the control device; wherein the target transmission mode includes at least one of an interrupt transmission mode and a DMA (Direct Memory Access) transmission mode.
[0059] The current operation state refers to at least one of the current task operation state, DMA resource state, light effect adjustment frequency of the LED light source, etc. of the control device.
[0060] In some embodiments, the target data transmission mode that matches the working scene of the control device and / or the LED light source can be determined according to at least one of the current task operation state of the control device, the DMA resource state, the light effect adjustment frequency of the LED light source, etc., to improve the stability and reliability of the adjustment of the display effect of the LED light source in each working scene. The transmission mode of the symbol data is flexible and efficient, and has a certain generalization ability and anti-interference ability. By determining the target transmission mode according to at least one of the task operation state, the DMA resource state, the light effect adjustment frequency of the LED light source, etc., the target transmission mode of the symbol data can be adapted to the current operating state of the control device, improving the stability and reliability of the adjustment of the display effect of the LED light source in the current operating state, so that the display effect of the LED light source is stable and reliable, and the light language display effect is stable and reliable.
[0061] Step S140: Based on the target sending mode, the symbol data is sent to the LED light source through the serial peripheral interface, so that the LED light source displays according to the target display mode according to the symbol data.
[0062] Exemplarily, the LED light source decodes the symbol data to obtain a control instruction, and displays in a target display mode according to the control instruction.
[0063] like Figure 6 The figure shows the block diagram of the serial peripheral interface, where APB (Advanced Peripheral Bus) is a peripheral bus that can connect peripherals and serve as a standard on-chip peripheral bus structure. The serial peripheral unit includes a control register, a send / receive control logic, a shift register, a clock generator, and a serial peripheral interface. The serial peripheral interface includes six control lines (PAD): control line SCK (Serial Clock), control line NSS, control line MOSI (Master Output Slave Input), control line MISO (Master Input Slave Output), control line IO2, and control line IO3. The control line SCK is the clock signal line, and the control line NSS is the chip select control line. The control lines MOSI, MISO, IO2, and IO3 are data lines. The control line MOSI can be called the host data transmission line.
[0064] The serial peripheral unit configures the internal registers through the control register. The control register SPI_CTL0 saves temporary data during the transmission process through the included send buffer and receive buffer, and controls the communication speed through the control register frequency division selection. The serial peripheral unit generates the SCK communication clock through the clock generator, and the control line SCK provides the timing of serial input and output operations. The serial peripheral unit transmits the send buffer and receive buffer data through the shift register, and controls the sending and receiving of serial data on the control lines MOSI, MISO, IO2, and IO3. The serial peripheral unit generates control logic according to the SPI command through the send / receive control logic, performs I / O control, generates output signals and controls communication, and controls the receiving communication according to the received SCK signal and NSS signal.
[0065] like Figure 7 The figure shows a schematic diagram of a full-duplex mode based on a serial peripheral interface, where the host is, for example, a control device and the slave is an LED light source; the description of the SPI signal line is shown in Table 2:
[0066] Table 2 Description of SPI signal lines
[0067]
[0068] Exemplarily, the control device can send the symbol data to the LED light source via the host data transmission line MOSI of the serial peripheral interface. Figure 8 Based on the output function of the host data transmission line, by sending a byte or half a byte of data, the 0 code or 1 code of the RGB data of the LED light source is simulated. For example, the clock frequency of the serial peripheral interface can be configured to control the LED light source.
[0069] like Fig. 9 The figure shows the timing and data format of the serial peripheral interface. The CKPL (Clock Polarity) and CKPH (Clock Phase) bits in the SPI_CTL0 control register of the serial peripheral interface determine the timing of the SPI clock and data signals. The CKPL bit determines the level of the SCK clock in the idle state, and the CKPH bit determines whether the first or second clock transition edge is the valid sampling edge.
[0070] In some implementations, the serial peripheral interface of the serial peripheral unit supports an interrupt transmission mode and a DMA transmission mode. The control device can transmit the symbol data to the LED light source through the serial peripheral interface based on the interrupt transmission mode or the DMA transmission mode.
[0071] Exemplarily, the process of sending symbol data in interrupt transmission mode is as follows: the processor of the control device sends symbol data frame by frame through the serial peripheral unit, for example, 16 bits (equal to the width of the valid symbol) of data are sent per frame. After the serial peripheral unit sends each frame of data, there is no data in the sending buffer of the serial peripheral unit, then the serial peripheral unit sends an interrupt request signal indicating that the buffer is empty to the processor. The processor responds to the interrupt signal indicating that the buffer of the serial peripheral unit is empty, and stops the current task to process the interrupt operation of the sending buffer. That is, the next frame of data is filled into the serial peripheral unit for transmission until the symbol data for controlling the LED light source is sent, at which time the interrupt of the serial peripheral unit can be turned off.
[0072] Exemplarily, when the serial peripheral unit starts to send symbol data to the LED light source, each frame of data, such as 16-bit data, is first loaded from the send buffer into the shift register, and then the shift register starts to send the loaded data. After the first bit of each frame of data is sent, the TBE (transmit buffer empty) flag is set to 1, and the TBE flag position 1 is used to indicate that the send buffer is empty. When the symbol data for controlling the LED light source has not been sent, the processor of the control device continues to load data into the shift register of the serial peripheral unit. For example, before the data of the shift register is sent, the data of the next frame can be loaded into the shift register to realize the continuous sending function of the symbol data in the host mode.
[0073] The DMA transmission mode can copy data from one address space to another address space, providing high-speed data transmission between peripherals and memory or between memory and memory. The embodiment of the present application adopts a data transmission method from memory (memory of the control device) to peripherals (LED light source). Specifically, by configuring the memory storage address of the DMA channel as the storage address of the symbol data on the control device, and configuring the peripheral address as the address of the LED light source, for example, the address of the LED light source can be determined according to the pin connected to the LED light source by the serial peripheral interface. The transmission direction is configured as the transmission direction from memory to peripherals, and the width of the data transmission is equal to the width of the valid symbol, for example, 16 bits. The memory adopts address increment transmission, and the peripheral address remains unchanged. Then, the priority of the DMA transmission is configured, and then the symbol data can be sent to the LED light source through the DMA transmission mode by enabling the DMA channel.
[0074] It should be noted that when sending code data in interrupt transmission mode, it will occupy the resources of the control device, such as processor processing resources, and affect the processor's execution of other tasks besides controlling the LED light source. For example, an interrupt signal that the buffer is empty can interrupt the processor from executing other tasks. The DMA transmission mode sets the memory storage address of the DMA channel to the storage address of the code data on the control device, sets the width of the data transmission to the size of the code data, and then turns on the DMA transmission mode. In the DMA transmission mode, after completing the sending of the code data to the LED light source, the identification bit corresponding to the DMA channel is set to indicate that the data transmission of the DMA channel is completed. It can be understood that sending code data based on the DMA transmission mode can reduce the occupancy of the resources of the control device, such as processor processing resources.
[0075] In some embodiments, the running state includes a task operation state. For example, the task operation state is used to indicate whether the control device is in a single-task system or a multi-task system.
[0076] For example, when the control device is in a multi-task system, in addition to controlling the LED light source, it can also be used to perform other tasks, such as obtaining sensor data, controlling the motor, etc., of course, it is not limited to this. At different times, the number of tasks performed by the control device can be the same or different, for example, some tasks can be performed at different times, or they can also be not performed.
[0077] Exemplarily, according to the current operating state of the control device, the target sending mode of the code data is determined, including: when the current operating state is a task operation state, determining the number of tasks according to the task operation state; when the number of tasks is greater than or equal to a task number threshold, determining the target sending mode of the code data to be a DMA sending mode; when the number of tasks is less than the task number threshold, determining the target sending mode of the code data to be an interrupt sending mode.
[0078] For example, when the current number of tasks of the control device is less than the task number threshold, such as when only executing a single task of controlling an LED light source, the interruption of the serial peripheral unit will not affect other tasks, or will have little impact on other tasks, and the target transmission mode of the symbol data can be determined to be the interrupt transmission mode to reduce the occupation of DMA resources. When the number of tasks is greater than or equal to the task number threshold, such as in the case of multiple tasks, the DMA transmission mode can be used to prevent the processor resources of the control device from being occupied by other tasks and affecting the transmission of symbol data, thereby improving the stability and reliability of the transmission of symbol data, and improving the stability and reliability of the adjustment of the display effect of the LED light source; and it can reduce or eliminate the impact of the transmission task of the symbol data on other tasks, for example, it can prevent interruptions from occurring during the transmission of symbol data and affecting the execution of other tasks.
[0079] In some embodiments, the operating state includes a DMA resource state. Exemplarily, determining the target transmission mode of the symbol data according to the current operating state of the control device includes: when the DMA resource state is an occupied state, determining the target transmission mode of the symbol data to be an interrupt transmission mode; when the DMA resource state is an idle state, determining the target transmission mode of the symbol data to be a DMA transmission mode; or when the idle resources in the DMA resource state are less than or equal to a preset resource threshold, determining the target transmission mode of the symbol data to be an interrupt transmission mode; when the idle resources in the DMA resource state are greater than a preset resource threshold, determining the target transmission mode of the symbol data to be a DMA transmission mode.
[0080] Exemplarily, when the DMA resource status of the DMA channel of the serial peripheral unit is idle, or there are many idle DMA resources, such as when a DMA channel is not occupied, the DMA sending mode can be used preferentially to improve the stability and reliability of code data transmission and improve the stability and reliability of LED light source display effect adjustment.
[0081] Exemplarily, when the DMA resource status of the DMA channel of the serial peripheral unit is occupied or the idle DMA resources are insufficient, code data is sent based on the interrupt sending mode; there is no need to wait for sufficient DMA resources, which can improve the sending efficiency of code data, improve the stability and reliability of code data sending, and improve the stability and reliability of LED light source display effect adjustment.
[0082] In some embodiments, the target transmission mode of the symbol data may also be determined according to the light effect adjustment frequency of the LED light source. Exemplarily, when the light effect adjustment frequency of the LED light source is less than or equal to a preset frequency threshold, the target transmission mode of the symbol data is determined to be an interrupt transmission mode. Exemplarily, when the light effect adjustment frequency of the LED light source is greater than a preset frequency threshold, the target transmission mode of the symbol data is determined to be a DMA transmission mode.
[0083] For example, when the LED light source does not need to quickly switch colors and dynamic pipeline effects, that is, the control cycle is long, the target sending mode of the code data can be determined as the interrupt sending mode to reduce the occupancy of DMA resources; when the DMA resources are occupied or insufficient, there is no need to wait for sufficient DMA resources, which can improve the transmission efficiency of the code data.
[0084] In some embodiments, after determining the target sending mode of the code element data according to the current operating state of the control device, the method further includes: obtaining an assignment corresponding to the target sending mode; wherein the assignment corresponds one-to-one to the target sending mode; and calling the target sending mode of the code element data according to the assignment.
[0085] For example, by assigning a value to the mode identification bit of the processor and / or the mode identification bit of the serial peripheral unit, when it is necessary to send symbol data, the corresponding target transmission mode can be called according to the assigned value of the mode identification bit, and the symbol data can be sent to the LED light source through the serial peripheral interface based on the target transmission mode. It can be understood that in some embodiments, after the target transmission mode of the symbol data is determined according to the current operating state of the control device, the target transmission mode does not need to be determined again when the symbol data is subsequently sent, but the target transmission mode of the symbol data can be directly called according to the assigned value, which can improve the transmission efficiency of the symbol data.
[0086] In some embodiments, before sending the symbol data to the LED light source through the serial peripheral interface based on the target sending mode, the method also includes: outputting a first level to the LED light source with a maintenance duration greater than or equal to a first preset duration (such as 200us) to put the LED light source in an idle state; outputting a second level to the LED light source with a maintenance duration greater than or equal to a second preset duration to reset the LED light source.
[0087] By sending the second level to reset the LED light source, the LED light source can be put into a state of being ready to receive symbol data.
[0088] For example, see Figure 5, the valid code element in the unipolar return-to-zero code starts at a high level, and the time width of the high and low levels determines whether the valid code element is a 0 code or a 1 code. If a high level is not sent to put the LED light source in an idle state, the LED light source has a probability of mistakenly treating the high level (such as the high level in the code element data) and the low level in the reset signal (such as the reset code) sent by the control device as a 0 code or a 1 code in the unipolar return-to-zero code, and displaying according to the wrong 0 code or 1 code. The embodiment of the present application can prevent the LED light source from misidentifying the data sent by the control device by outputting a first level with a maintenance time greater than or equal to a first preset time length to the LED light source before sending a second level to reset the LED light source, thereby improving the stability and robustness of the code element data transmission and the stability and reliability of the LED light source display effect adjustment.
[0089] In some embodiments, after sending the symbol data to the LED light source based on the target sending mode, the method also includes: outputting a second level to the LED light source for a duration greater than or equal to a second preset duration to reset the LED light source; outputting a first level to the LED light source for a duration greater than or equal to a first preset duration to put the LED light source in an idle state.
[0090] For example, after the symbol data is sent, the low level sent is maintained for about 200us, that is, the reset signal resets the LED light source. The LED light source displays according to the symbol data based on the reset signal, that is, the reset signal makes the symbol data effective. After sending the second level to reset the LED light source, when the high level sent is maintained for about 200us, the LED light source can be put into an idle state, preventing the LED light source from misidentifying the data sent by the control device, and ensuring the effective reset of the LED light source.
[0091] Optionally, based on the target sending mode, a first level with a maintenance duration greater than or equal to a first preset duration is output to the LED light source through the serial peripheral interface to put the LED light source in an idle state, and / or a second level greater than or equal to a second preset duration is output to reset the LED light source. That is, the LED light source is put into an idle state or reset by sending SPI data, which can ensure low latency control of the LED light source, prevent loss of code data, improve the stability of the LED light source control, and enhance the high concurrency characteristics of the control device.
[0092] In some embodiments, the number of LED light sources is multiple, which can be determined according to application requirements. The multiple LED light sources are connected in sequence, and at least one of the LED light sources is connected to the control device. Fig.10, LED light source D1 is connected to the control device, and LED light source D1, LED light source D2, and LED light source D3 are connected in sequence.
[0093] The control data of the LED light source includes control data of multiple LED light sources, and the control data of the multiple LED light sources correspond to the multiple LED light sources one by one, wherein the control data corresponding to the LED light source D1 connected to the control device can be referred to as the first control data. Fig.11 The symbol data corresponding to the control data (ie, the first control data) of the LED light source D1 is expressed as RGB1, the symbol data corresponding to the control data of the LED light source D2 is expressed as RGB2, and the symbol data corresponding to the control data of the LED light source D3 is expressed as RGB4.
[0094] The control device is used to send symbol data (RGB1, RGB2, RGB3, for example, 3×24 bits in total) corresponding to the control data of the plurality of LED light sources to the LED light source D1 connected to the control device, so that the LED light source D1 connected to the control device displays according to the symbol data RGB1 corresponding to the first control data. The LED light source D1 connected to the control device is also used to send symbol data (RGB2, RGB3) corresponding to the remaining control data except the first control data to the next LED light source D2 connected to the LED light source D1; the LED light source D2 displays according to the symbol data RGB2, and send the remaining symbol data RGB3 to the next LED light source D3 connected to the LED light source D2, and the LED light source D3 displays according to the symbol data RGB3.
[0095] The LED light source control method provided in the embodiment of the present application includes: obtaining a control instruction of the LED light source, converting the control instruction into code data according to a preset coding protocol, determining a target sending mode of the code data according to the current operating state of the control device, and sending the code data to the LED light source through a serial peripheral interface based on the target sending mode, so that the LED light source displays according to the target display mode based on the code data; by determining the target sending mode of the code data according to the current operating state of the control device, the target sending mode of the code data can be adapted to the current operating state of the control device, thereby improving the stability and reliability of the adjustment of the display effect of the LED light source in the current operating state.
[0096] An embodiment of the present application further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, wherein the computer program includes program instructions, and when the computer program is executed by a processor, the processor implements the steps of the LED light source control method provided in the above embodiment.
[0097] The computer-readable storage medium may be an internal storage unit of the control device or LED light source device described in any of the aforementioned embodiments, such as a hard disk or memory of the LED light source device. The computer-readable storage medium may also be an external storage device of the control device or LED light source device, such as a plug-in hard disk, a smart memory card (Smart Media Card, SMC), a secure digital (Secure Digital, SD) card, a flash card (Flash Card), etc., equipped on the control device.
[0098] It should be understood that the terminology used in this application is for the purpose of describing particular embodiments only and is not intended to be limiting of the application.
[0099] It will also be understood that the term "and / or" as used in this application and the appended claims refers to and includes any and all possible combinations of one or more of the associated listed items.
[0100] The above is only a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of various equivalent modifications or replacements within the technical scope disclosed in the present application, and these modifications or replacements should be included in the protection scope of the present application. Therefore, the protection scope of the present application shall be based on the protection scope of the claims.
Claims
1. A method for controlling an LED light source, characterized in that: For a control device, the control device is connected to an LED light source via a serial peripheral interface, the method comprising: Obtaining a control instruction of the LED light source; wherein the control instruction is used to indicate a target display mode of the LED light source; Converting the control instruction into symbol data according to a preset coding protocol; Determining a target transmission mode of the symbol data according to the current operating state of the control device; wherein the target transmission mode includes at least one of an interrupt transmission mode and a DMA transmission mode; Based on the target sending mode, the symbol data is sent to the LED light source through the serial peripheral interface, so that the LED light source displays according to the target display mode based on the symbol data.
2. The LED light source control method according to claim 1, characterized in that: The operating state includes a task operation state; and determining a target sending mode of the symbol data according to the current operating state of the control device includes: When the current running state is a task operation state, determining the number of tasks according to the task operation state; When the number of tasks is greater than or equal to a task number threshold, determining that a target sending mode of the symbol data is a DMA sending mode; When the number of tasks is less than the task number threshold, it is determined that the target sending mode of the symbol data is an interrupt sending mode.
3. The LED light source control method according to claim 1, characterized in that: The operating state includes a DMA resource state; and determining a target transmission mode of the symbol data according to the current operating state of the control device includes: When the DMA resource state is an occupied state, determining the target transmission mode of the symbol data to be an interrupt transmission mode; when the DMA resource state is an idle state, determining the target transmission mode of the symbol data to be a DMA transmission mode; or When the idle resources in the DMA resource state are less than or equal to a preset resource threshold, the target sending mode of the symbol data is determined to be an interrupt sending mode; when the idle resources in the DMA resource state are greater than the preset resource threshold, the target sending mode of the symbol data is determined to be a DMA sending mode.
4. The LED light source control method according to claim 1, characterized in that: The method further comprises: When the light effect adjustment frequency of the LED light source is less than or equal to a preset frequency threshold, determining that the target sending mode of the symbol data is an interrupt sending mode; When the light effect adjustment frequency of the LED light source is greater than the preset frequency threshold, it is determined that the target sending mode of the symbol data is a DMA sending mode.
5. The LED light source control method according to claim 1, characterized in that: After determining the target transmission mode of the symbol data according to the current operating state of the control device, the method further includes: Obtaining an assignment corresponding to the target sending mode; wherein the assignment corresponds to the target sending mode in a one-to-one manner; Based on the assignment, a target sending mode of the symbol data is called.
6. The LED light source control method according to any one of claims 1 to 5, characterized in that: The step of converting the control instruction into symbol data according to a preset coding protocol includes: Each binary bit in the control instruction is converted into a unipolar return-to-zero code to obtain the symbol data.
7. The LED light source control method according to any one of claims 1 to 5, characterized in that: Before sending the symbol data to the LED light source through the serial peripheral interface based on the target transmission mode, the method further includes: Outputting a first electrical level to the LED light source for a duration greater than or equal to a first preset duration, so that the LED light source is in an idle state; A second electrical level is output to the LED light source for a duration greater than or equal to a second preset duration, so as to reset the LED light source.
8. The LED light source control method according to any one of claims 1 to 5, characterized in that: After sending the symbol data to the LED light source through the serial peripheral interface based on the target transmission mode, the method further includes: Outputting a second electrical level to the LED light source for a duration greater than or equal to a second preset duration, so as to reset the LED light source; A first electrical level is output to the LED light source for a duration greater than or equal to a first preset duration, so that the LED light source is in an idle state.
9. A control device, characterized in that: include: A microcontroller, wherein the microcontroller integrates a processor and a serial peripheral unit, the serial peripheral unit is connected to the processor, and a serial peripheral interface of the serial peripheral unit is used to connect to an LED light source; Wherein, the processor is used to implement the steps of the LED light source control method according to any one of claims 1 to 8.
10. An LED light source device, characterized in that: include: The control device as claimed in claim 9; as well as LED light source; The control device is used to control the display of the LED light source.
Citation Information
Patent Citations
Multi-channel light source control method and system based on light source controller
CN113597070A
Method and device for controlling lamp strip, chip and electronic equipment
CN114340097A