An intelligent LED lamp strip control system based on an STC8 single-chip microcomputer and a control method thereof
Patent Information
- Application Number
- CN202610942642.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-06-29
- Publication Date
- 2026-09-22
AI Technical Summary
[0005]因此,本发明提供了一种基于STC8单片机的智能LED灯带控制方法解决现有技术存在的多控制器协同运行中组内灯带帧结束时刻不一致以及异常输出后共同灯效相位分离的问题
[0017]本发明有益效果为:通过生成占位数据段并形成等长灯效帧,实现不同本地有效灯珠数量下颜色数据输出长度统一;通过基于全部帧输出完成记录执行组级帧确认,在确认成功时推进共同灯效相位,在确认未成功时保持灯效帧序号和共同灯效相位并重新输出当前灯效帧,实现灯效相位与组内输出状态绑定,提升协同控制稳定性和显示一致性。
Smart Images

Figure CN122803109A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent lighting control technology, and in particular to an intelligent LED strip control system and control method based on an STC8 microcontroller. Background Technology
[0002] LED strip light control technology is applied to architectural lighting, landscape display, and indoor atmosphere adjustment. Conventional solutions use a microcontroller as the control core, generating color data based on the lighting effect mode and outputting it to the light strip according to the WS2812 single-line timing sequence. In multi-controller scenarios, the main controller sends lighting effect parameters through communication commands or synchronization signals, and each controller completes local data generation, timed output, and reset latching to achieve collaborative display of multiple light strips.
[0003] In existing methods, when multiple controllers operate in collaboration, each controller independently completes data output and reset latching. Due to the influence of local data length and timing deviation, the frame end time of the light strips within the group is difficult to be consistent. In addition, the common lighting effect phase is mostly based on the number of triggers or the state progression completed by a single controller. There is a lack of frame-level confirmation with the participation of controllers, which can easily lead to phase separation after abnormal output. Summary of the Invention
[0004] In view of the aforementioned existing problems, the present invention is proposed.
[0005] Therefore, this invention provides an intelligent LED strip control method based on the STC8 microcontroller to solve the problems of inconsistent end times of LED strip frames within a group and phase separation of common lighting effects after abnormal output in the existing technology.
[0006] To solve the above-mentioned technical problems, the present invention provides the following technical solution:
[0007] In a first aspect, the present invention provides an intelligent LED strip control method based on an STC8 microcontroller, comprising: collecting the number of locally effective LED beads, virtual starting position, and LED bead arrangement direction of each STC8 microcontroller within the same lighting effect control group; determining the number of locally effective LED beads of each STC8 microcontroller as the number of locally effective color data groups; the main STC8 microcontroller using the maximum value among the number of locally effective color data groups as the unified transmission data group number; combining the unified transmission data group number and the number of locally effective color data groups to calculate the number of locally placeholder data groups; establishing a virtual position mapping table; generating an equal-length frame specification; and establishing a current group operation record; the main STC8 microcontroller generating a lighting effect frame control record based on the most recently confirmed lighting effect phase in the current group operation record; and each STC8 microcontroller generating a lighting effect frame control record based on the virtual position mapping table and the common lighting effect in the lighting effect frame control record. The system generates valid color data segments based on phase and lighting effect parameters. It also generates placeholder data segments based on the number of local placeholder data groups in the equal-length frame specification, concatenating these placeholder data segments after the valid color data segments to form equal-length lighting effect frames. After all equal-length lighting effect frames are prepared, the main STC8 microcontroller sends a group-level synchronization trigger pulse. Each STC8 microcontroller continuously outputs valid color data segments and placeholder data segments according to the equal-length frame specification. Once the total number of output color data groups reaches the unified transmission data group number in the equal-length frame specification, a reset latch is executed, and a frame output completion record is generated. The main STC8 microcontroller performs group-level frame confirmation based on all frame output completion records. If group-level frame confirmation is successful, it advances the common lighting effect phase and generates the next lighting effect frame based on the advanced common lighting effect phase. If group-level frame confirmation fails, it maintains the lighting effect frame sequence number and the common lighting effect phase and re-outputs the current lighting effect frame.
[0008] As a preferred embodiment of the intelligent LED strip control method based on STC8 microcontroller described in this invention, the calculation of the number of local placeholder data groups by combining the number of unified transmission data groups and the number of each local valid color data group includes: each STC8 microcontroller reads the local strip configuration record and generates a device strip configuration reporting record; the main STC8 microcontroller collects the device strip configuration reporting records and establishes a target device list based on the lighting effect control group number, the group-level WS2812 protocol type, and the number of color data bits per LED bead in the group level; the main STC8 microcontroller determines the number of local valid LED beads of each STC8 microcontroller in the target device list as the corresponding number of local valid color data groups, and determines the maximum value among the number of local valid color data groups as the number of unified transmission data groups; the main STC8 microcontroller determines the difference between the number of unified transmission data groups and the number of each local valid color data group as the number of local placeholder data groups for the corresponding STC8 microcontroller, and establishes a correspondence between the device address, the number of local valid color data groups, and the number of local placeholder data groups.
[0009] As a preferred embodiment of the intelligent LED strip control method based on STC8 microcontroller described in this invention, the steps of establishing a virtual position mapping table, generating equal-length frame specifications, and establishing the current group operation record include: the main STC8 microcontroller determining the virtual lighting effect position corresponding to each local effective LED based on the virtual starting position, the number of local effective LEDs, and the LED arrangement direction of each STC8 microcontroller in the target device list, and writing the device address, local LED sequence number, and virtual lighting effect position into the virtual position mapping table; the main STC8 microcontroller compiles the target device list, the unified transmission data group quantity, the number of local effective color data groups and the number of local placeholder data groups corresponding to each STC8 microcontroller, and the virtual position... The system generates a fixed-length frame specification by configuring the mapping table, data bit timing, reset latch configuration, and placeholder data fixed values. The main STC8 microcontroller sends the fixed-length frame specification to each STC8 microcontroller in the target device list. Each STC8 microcontroller generates a local fixed-length frame configuration record based on the fixed-length frame specification and performs a consistency check on the local fixed-length frame configuration record. When the consistency check passes, a fixed-length frame specification loading completion record is generated. The main STC8 microcontroller determines the currently valid fixed-length frame specification based on the fixed-length frame specification loading completion records sent by all STC8 microcontrollers in the target device list for the same fixed-length frame specification version. The main STC8 microcontroller establishes the current group operation record based on the currently valid fixed-length frame specification and the group operation recovery record.
[0010] As a preferred embodiment of the intelligent LED strip control method based on the STC8 microcontroller described in this invention, the main STC8 microcontroller generates a lighting effect frame control record based on the most recently confirmed lighting effect phase in the current group's operation record, including: the main STC8 microcontroller reads the most recently confirmed lighting effect frame sequence number, the most recently confirmed lighting effect phase, the current lighting effect mode, and the current lighting effect parameters from the current group's operation record; the main STC8 microcontroller generates a current lighting effect frame sequence number based on the most recently confirmed lighting effect frame sequence number, and determines a common lighting effect phase based on the most recently confirmed lighting effect frame sequence number, the most recently confirmed lighting effect phase, the phase advance amount in the current lighting effect parameters, and the phase full cycle value; the main STC8 microcontroller generates a lighting effect frame control record based on the current lighting effect frame sequence number, the common lighting effect phase, the current lighting effect mode, and the current lighting effect parameters, and sends the lighting effect frame control record to each STC8 microcontroller in the target device list.
[0011] As a preferred embodiment of the intelligent LED strip control method based on STC8 microcontroller described in this invention, the generation of effective color data segments by each STC8 microcontroller according to the virtual position mapping table, the common lighting effect phase in the lighting effect frame control record, and the lighting effect parameters includes: each STC8 microcontroller reading the correspondence between the local LED sequence number and the virtual lighting effect position from the local equal-length frame configuration record to determine the virtual lighting effect position corresponding to each local effective LED; reading the common lighting effect phase from the lighting effect frame control record; and reading the phase full-cycle value, spatial cycle length, and color control point sequence from the lighting effect parameters in the lighting effect frame control record; each STC8 microcontroller... The machine adopts a virtual path phase coupling mapping algorithm to calculate the local LED phase corresponding to each local effective LED based on the common lighting effect phase, virtual lighting effect position, spatial period length, and phase full period value. Each STC8 microcontroller retrieves the color control point sequence based on the local LED phase, and performs linear interpolation on the red, green, and blue channel values of the color control points to generate the red, green, and blue channel values corresponding to each local effective LED. Each STC8 microcontroller generates local effective color data groups according to the local LED sequence number and color channel arrangement order, and arranges all local effective color data groups continuously to generate effective color data segments.
[0012] As a preferred embodiment of the intelligent LED strip control method based on STC8 microcontroller described in this invention, the step of generating placeholder data segments according to the number of local placeholder data groups in the equal-length frame specification, and connecting the placeholder data segments after the valid color data segments to form an equal-length lighting effect frame includes: each STC8 microcontroller copies a fixed value of placeholder data according to the number of local placeholder data groups, generates a number of placeholder color data groups with the same number of local placeholder data groups, and arranges all placeholder color data groups continuously to generate placeholder data segments; when the placeholder data segment contains placeholder color data groups, each STC8 microcontroller connects the placeholder data segment after the valid color data segment to form an equal-length lighting effect frame; when the placeholder data segment does not contain placeholder color data groups, each STC8 microcontroller determines the valid color data segment as an equal-length lighting effect frame; each STC8 microcontroller determines the sum of the number of local valid color data groups and the number of placeholder color data groups as the total number of color data groups, and performs consistency verification with the number of unified transmission data groups.
[0013] As a preferred embodiment of the intelligent LED strip control method based on STC8 microcontroller described in this invention, the process of the main STC8 microcontroller sending a group-level synchronization trigger pulse after all equal-length lighting effect frames are prepared includes: each STC8 microcontroller loading the output parameters of the current lighting effect frame in the equal-length lighting effect frame preparation completion state, generating an equal-length lighting effect frame preparation completion record, and sending the equal-length lighting effect frame preparation completion record to the main STC8 microcontroller; the main STC8 microcontroller establishing a correspondence between the equal-length lighting effect frame preparation completion record and each STC8 microcontroller in the target device list according to the device address. The system performs a verification of the completion of equal-length lighting effect frame preparation, including the version of the equal-length frame specification, the current lighting effect frame sequence number, and the total number of color data groups. When all equal-length lighting effect frame preparation completion records corresponding to all STC8 microcontrollers in the target device list pass the verification, the main STC8 microcontroller generates a group-level synchronization trigger pulse and sends it to each STC8 microcontroller in the target device list through the group-level synchronization trigger line. Each STC8 microcontroller receives the group-level synchronization trigger pulse through the external interrupt input terminal and starts the local data output timer according to the local data bit timing count group.
[0014] As a preferred embodiment of the intelligent LED strip control method based on STC8 microcontroller described in this invention, each STC8 microcontroller continuously outputs valid color data segments and placeholder data segments according to the equal-length frame specification. After the total number of output color data groups reaches the unified transmission data group number in the equal-length frame specification, a reset latch is executed, and a frame output completion record is generated. This includes: each STC8 microcontroller sequentially outputs valid color data segments and placeholder data segments according to the local data bit timing count group, and counts the total number of output color data groups; when the placeholder data segment contains a placeholder color data group, each STC8 microcontroller retains the local data bit after the last color data bit of the valid color data segment is output. The output timer runs continuously, and in the next data bit cycle, it reads and outputs the first color data bit in the placeholder data segment along the continuous storage address of the local lighting effect frame buffer. When the total number of output color data groups reaches the unified transmission data group number, each STC8 microcontroller stops reading color data bits, keeps the data output terminal at a low level, and accumulates the reset latch process count. When the reset latch process count reaches the local reset latch count, each STC8 microcontroller generates a frame output completion record according to the equal-length frame specification version, the current lighting effect frame sequence number, the total number of output color data groups, the reset latch completion status, and the frame output status, and sends the frame output completion record to the master STC8 microcontroller.
[0015] As a preferred embodiment of the intelligent LED strip control method based on the STC8 microcontroller described in this invention, the main STC8 microcontroller performs group-level frame confirmation based on the completion record of all frame outputs. When the group-level frame confirmation is successful, it advances the common lighting effect phase and generates the next lighting effect frame based on the advanced common lighting effect phase. When the group-level frame confirmation is unsuccessful, it maintains the lighting effect frame sequence number and the common lighting effect phase, and re-outputs the current lighting effect frame. This includes: the main STC8 microcontroller determining the group-level frame confirmation result based on the target device list and the completion record of each frame output; when the group-level frame confirmation result is successful, the main STC8 microcontroller updates the most recently confirmed lighting effect frame sequence number, the most recently confirmed lighting effect phase, and the group operation recovery record, generates the next lighting effect frame sequence number based on the most recently confirmed lighting effect frame sequence number, and combines the most recently confirmed lighting effect phase... The common lighting effect phase after advancement is determined by the bit and phase advance amount and the phase full cycle value, and the next lighting effect frame control record is generated. When the group-level frame confirmation result is that the group-level frame confirmation is unsuccessful, the master STC8 microcontroller keeps the most recently confirmed lighting effect frame sequence number, the most recently confirmed lighting effect phase, the current lighting effect frame sequence number, and the common lighting effect phase unchanged, does not update the group operation recovery record, generates the current lighting effect frame re-output record, and sends the current lighting effect frame re-output record to each STC8 microcontroller in the target device list. Each STC8 microcontroller verifies the current equal-length lighting effect frame in its local lighting effect frame buffer according to the current lighting effect frame re-output record. If the verification is successful, the current equal-length lighting effect frame is retained. If the verification fails, the current equal-length lighting effect frame is regenerated according to the current lighting effect frame control record, and an equal-length lighting effect frame preparation completion record is generated.
[0016] Secondly, this invention provides an intelligent LED strip control system based on an STC8 microcontroller, comprising: a specification construction module, used to collect the number of locally effective LED beads, virtual starting position, and LED bead arrangement direction of each STC8 microcontroller, and determine the number of unified transmission data groups and the number of local placeholder data groups; establish a virtual position mapping table, generate equal-length frame specifications and current group operation records; and a lighting effect generation module, used to generate lighting effect frame control records based on the most recently confirmed lighting effect phase, and generate effective color data segments based on the virtual position mapping table, common lighting effect phase, and lighting effect parameters; and generate based on the number of local placeholder data groups. The system consists of a placeholder data segment and a uniform-length lighting effect frame. A synchronization output module sends a group-level synchronization trigger pulse after all uniform-length lighting effect frames are prepared, controlling each STC8 microcontroller to continuously output valid color data segments and placeholder data segments. After the total number of output color data groups reaches the unified transmission data group count, a reset latch is executed, and a frame output completion record is generated. A group-level confirmation module performs group-level frame confirmation based on all frame output completion records. If group-level frame confirmation is successful, the common lighting effect phase is advanced and the next lighting effect frame is generated. If group-level frame confirmation fails, the lighting effect frame sequence number and common lighting effect phase are maintained, and the current lighting effect frame is re-output.
[0017] The beneficial effects of this invention are as follows: by generating placeholder data segments and forming equal-length lighting effect frames, the output length of color data is unified under different local effective LED numbers; by completing the recording and executing group-level frame confirmation based on the output of all frames, the common lighting effect phase is advanced when the confirmation is successful, and the lighting effect frame number and common lighting effect phase are maintained and the current lighting effect frame is re-output when the confirmation is unsuccessful, thereby realizing the binding of the lighting effect phase with the output status within the group, improving the stability of collaborative control and display consistency. Attached Figure Description
[0018] To more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings used in the following description of the embodiments will be briefly introduced. Obviously, the drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0019] Figure 1 This is a flowchart of an intelligent LED strip control method based on the STC8 microcontroller.
[0020] Figure 2 This is a schematic diagram of an intelligent LED strip control system based on the STC8 microcontroller.
[0021] Figure 3 The flowchart for generating equal-length lighting effect frames.
[0022] Figure 4 This is a flowchart for group-level synchronous output and frame confirmation.
[0023] Figure 5 This is a comparison chart of the range at the end of frames within a group under continuous operation conditions.
[0024] Figure 6 This is a comparison chart of phase deviations in common lighting effects under abnormal output conditions. Detailed Implementation
[0025] To make the above-mentioned objects, features and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to the accompanying drawings.
[0026] Many specific details are set forth in the following description in order to provide a full understanding of the invention. However, the invention may also be practiced in other ways different from those described herein, and those skilled in the art can make similar extensions without departing from the spirit of the invention. Therefore, the invention is not limited to the specific embodiments disclosed below.
[0027] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The phrase "in one embodiment" appearing in different places in this specification does not necessarily refer to the same embodiment, nor is it a single or selective embodiment that is mutually exclusive with other embodiments.
[0028] Reference Figures 1-6 This is one embodiment of the present invention, which provides an intelligent LED strip control method based on an STC8 microcontroller, comprising the following steps:
[0029] S1. Collect the number of locally effective LEDs, virtual starting position, and LED arrangement direction of each STC8 microcontroller in the same lighting effect control group. Determine the number of locally effective LEDs of each STC8 microcontroller as the number of locally effective color data groups. The main STC8 microcontroller uses the maximum value among the number of locally effective color data groups as the unified transmission data group number. Combine the unified transmission data group number and the number of locally effective color data groups to calculate the number of local placeholder data groups, establish a virtual position mapping table, generate equal-length frame specifications, and establish the current group operation record.
[0030] S1.1 Read and verify the local LED strip configuration, and generate a device LED strip configuration reporting record.
[0031] Furthermore, after each STC8 microcontroller is powered on, it reads the local LED strip configuration record from the non-volatile memory area, extracts the device address, lighting effect control group number, number of locally valid LEDs, virtual start position, LED arrangement direction, color channel arrangement order, WS2812 protocol type, and number of color data bits per LED from the local LED strip configuration record, and writes the device address, lighting effect control group number, number of locally valid LEDs, virtual start position, LED arrangement direction, color channel arrangement order, WS2812 protocol type, and number of color data bits per LED into the device LED strip configuration reporting record.
[0032] Among them, the number of locally effective LED beads is the total number of LED beads actually participating in the lighting effect control in the WS2812 smart LED light strip connected to the current STC8 microcontroller; the virtual starting position is the position of the first locally effective LED bead in the virtual lighting effect path; the LED bead arrangement direction includes the forward arrangement direction and the reverse arrangement direction; the color channel arrangement order is the arrangement order used by the current WS2812 smart LED light strip when receiving red channel data, green channel data and blue channel data.
[0033] It should be noted that the WS2812 smart LED strip does not return the number of physically cascaded LEDs to the STC8 microcontroller. The number of locally valid LEDs is determined based on the strip's installation configuration, product configuration, and on-site debugging records, and is written into the local strip configuration record. The number of locally valid LEDs covers all controlled LEDs currently connected to the STC8 microcontroller's data output terminal. After the last locally valid LED, no controlled LEDs not included in the locally valid LED count are set.
[0034] Furthermore, each STC8 microcontroller performs configuration verification on the local LED strip configuration record.
[0035] Specifically, each STC8 microcontroller calculates the virtual lighting effect positions corresponding to all locally valid LEDs based on the virtual starting position, the number of locally valid LEDs, and the LED arrangement direction. When the lighting effect control group number matches the lighting effect control group number corresponding to the current lighting effect control task, the number of locally valid LEDs is greater than 0 and does not exceed the number of LEDs that the current STC8 microcontroller is allowed to control, the LED arrangement direction is either forward or reverse, and each calculated virtual lighting effect position is within the range of non-negative integers that the virtual position index field can represent, the device LED strip configuration reporting record is sent to the master. When the following situations occur with the STC8 microcontroller: the lighting control group number is inconsistent with the lighting control group number corresponding to the current lighting control task; the number of locally valid LED beads is not greater than 0; the number of locally valid LED beads exceeds the number of LED beads that the current STC8 microcontroller is allowed to control; the LED bead arrangement direction is not either the forward or reverse arrangement direction; or at least one of the calculated virtual lighting effect positions exceeds the range of non-negative integers that the virtual position index field can represent, the corresponding STC8 microcontroller will be marked as a state of pending confirmation for LED strip configuration, and the addition of the corresponding STC8 microcontroller to the current lighting control group will be stopped.
[0036] It should be noted that the number of LEDs that the STC8 microcontroller can currently control is determined based on the capacity of the color data buffer, the space occupied by the color data of a single LED, and the lighting effect refresh cycle. For example, if a local valid color data group occupies 3 bytes, and the color data buffer capacity is 900 bytes, the color data buffer can store 300 local valid color data groups. The number of LEDs that the STC8 microcontroller can currently control also needs to meet the requirement of completing the color data output within one lighting effect refresh cycle.
[0037] S1.2 Collect the device light strip configuration reporting records, establish a target device list, and determine the number of unified transmission data groups and the number of local placeholder data groups.
[0038] Furthermore, the main STC8 microcontroller collects the device LED strip configuration reporting records sent by each STC8 microcontroller in the same lighting effect control group, sorts them according to the device address, and writes the STC8 microcontrollers with the same lighting effect control group number, the same WS2812 protocol type, and the same number of single LED color data bits into the target device list, and keeps the target device list unchanged during the current equal-length frame specification.
[0039] Specifically, the main STC8 microcontroller reads the group-level WS2812 protocol type and the number of group-level single LED color data bits from the lighting effect control group configuration record. It compares the WS2812 protocol type in the device light strip configuration reporting record with the group-level WS2812 protocol type, and compares the number of single LED color data bits in the device light strip configuration reporting record with the number of group-level single LED color data bits. If both comparison results are consistent, the corresponding device address is written to the target device list. If either the WS2812 protocol type or the number of single LED color data bits is inconsistent, the corresponding STC8 microcontroller is marked as having an inconsistent protocol configuration, and the writing of the corresponding device address to the target device list is stopped.
[0040] It should be noted that the configuration record of the lighting effect control group is written into the non-volatile storage area of the main STC8 microcontroller during the installation and commissioning phase of the lighting effect control group, based on the WS2812 smart LED light strip model and protocol configuration used in the same lighting effect control group.
[0041] It should be noted that within the same lighting effect control group, each STC8 microcontroller uses the same WS2812 protocol type and the same number of color data bits per LED bead, satisfying the requirement that each STC8 microcontroller's complete color data group has the same number of data bits. When different WS2812 smart LED light strips use different color channel arrangement orders, the color channel arrangement order only changes the arrangement order of the red channel data, green channel data, and blue channel data within a local valid color data group, without changing the number of data bits contained in a local valid color data group.
[0042] Furthermore, the main STC8 microcontroller defines the complete color data corresponding to one locally valid LED as a locally valid color data group, and defines the number of locally valid LEDs of each STC8 microcontroller in the target device list as the corresponding number of locally valid color data groups. The number of each locally valid color data group is compared in turn, and the maximum value among the number of locally valid color data groups is determined as the number of unified transmission data groups.
[0043] One local valid color data group includes all color data bits received by a local valid LED in the order of color channel arrangement; the number of unified transmission data groups is the number of the same color data groups used by each STC8 microcontroller in the target device list, and the value of the number of unified transmission data groups is equal to the maximum value among the number of local valid color data groups.
[0044] Furthermore, the main STC8 microcontroller calculates the difference between the number of unified transmission data groups and the number of local valid color data groups of each STC8 microcontroller in the target device list. The difference between the number of unified transmission data groups and the corresponding number of local valid color data groups is determined as the number of local placeholder data groups of the corresponding STC8 microcontroller, and a correspondence is established between the device address, the number of local valid color data groups, and the number of local placeholder data groups.
[0045] Specifically, the main STC8 microcontroller calculates the sum of the number of local valid color data groups and the number of local placeholder data groups to obtain the total number of color data groups for the corresponding STC8 microcontroller. It then verifies the consistency between the total number of color data groups and the number of unified transmission data groups. If the total number of color data groups is consistent with the number of unified transmission data groups, the corresponding number of local placeholder data groups is retained. If the number of local valid color data groups is equal to the number of unified transmission data groups, the number of local placeholder data groups for the corresponding STC8 microcontroller is set to 0.
[0046] S1.3 Configure the virtual lighting effect position according to the virtual starting position and the LED arrangement direction, generate a virtual position mapping table and determine the virtual lighting effect path length.
[0047] Furthermore, the main STC8 microcontroller determines the virtual lighting effect position corresponding to each local valid LED in turn based on the virtual starting position, the number of local valid LEDs, and the LED arrangement direction of each STC8 microcontroller in the target device list, and writes the device address, local LED sequence number, and virtual lighting effect position into the virtual position mapping table.
[0048] Specifically, when the LEDs are arranged in a forward direction, the first local valid LED is mapped to the virtual starting position. Starting from the second local valid LED, the LEDs are mapped sequentially to virtual lighting effect positions with increasing numerical values, following the ascending order of their local LED numbers. When the LEDs are arranged in a reverse direction, the first local valid LED is mapped to the virtual starting position. Starting from the second local valid LED, the LEDs are mapped sequentially to virtual lighting effect positions with decreasing numerical values, following the ascending order of their local LED numbers.
[0049] The device address and the local LED sequence number together correspond to a unique virtual lighting effect position; the virtual lighting effect position is used to determine the spatial order of the corresponding local valid LEDs in the same virtual lighting effect path.
[0050] Furthermore, the main STC8 microcontroller performs a mapping integrity check on the virtual location mapping table and generates a virtual lighting effect path based on the virtual location mapping table that has passed the mapping integrity check.
[0051] Specifically, the main STC8 microcontroller counts the number of mapping entries corresponding to each device address in the virtual location mapping table, counts the number of duplicate virtual lighting effect positions in the virtual location mapping table, and arranges all mapping entries in numerical order of virtual lighting effect positions. When the number of mapping entries corresponding to each device address is the same as the corresponding number of local valid LEDs, the number of duplicate virtual lighting effect positions is 0, and the numerical difference between adjacent virtual lighting effect positions is 1, all mapping entries arranged in numerical order of virtual lighting effect positions are determined as the virtual lighting effect path.
[0052] Furthermore, the main STC8 microcontroller reads the minimum and maximum virtual lighting positions in the virtual lighting path, counts the number of virtual lighting positions contained from the minimum to the maximum virtual lighting position, and determines the counted number of virtual lighting positions as the length of the virtual lighting path.
[0053] It should be noted that the virtual lighting effect position intervals corresponding to adjacent WS2812 smart LED light strips within the same lighting effect control group are arranged continuously according to the installation order of the light strips. If any of the following situations occur: the number of mapping entries is inconsistent with the corresponding number of local valid LED beads, the number of duplicate virtual lighting effect positions is greater than 0, or the numerical difference between adjacent virtual lighting effect positions is not equal to 1, the device light strip configuration reporting record associated with the abnormal mapping entry will be marked as virtual position configuration pending correction, and the generation of long frame specifications based on the current target device list will be stopped.
[0054] S1.4. Collect the number of data groups, virtual location mapping and output timing configuration, generate and load the equal-length frame specification.
[0055] Furthermore, the main STC8 microcontroller reads the lighting effect control group number, group-level WS2812 protocol type, number of group-level single LED color data bits, data bit timing configuration, reset latch configuration, and placeholder data fixed value from the lighting effect control group configuration record. It also reads the color channel arrangement order of each device from the device light strip configuration reporting record. It generates an equal-length frame specification version in ascending order of version number. The equal-length frame specification version, lighting effect control group number, target device list, number of unified transmission data groups, number of local valid color data groups corresponding to each device, number of local placeholder data groups corresponding to each device, virtual location mapping table, virtual lighting effect path length, group-level WS2812 protocol type, number of group-level single LED color data bits, color channel arrangement order corresponding to each device, data bit timing configuration, reset latch configuration, and placeholder data fixed value are collected to generate the equal-length frame specification.
[0056] The equal-length frame specification includes the equal-length frame specification version, lighting effect control group number, target device list, number of unified transmission data groups, number of local valid color data groups corresponding to each device, number of local placeholder data groups corresponding to each device, virtual location mapping table, virtual lighting effect path length, group-level WS2812 protocol type, number of color data bits per LED at the group level, color channel arrangement order corresponding to each device, group-level data bit period, high-level duration and low-level duration corresponding to logic zero, high-level duration and low-level duration corresponding to logic one, reset latch time, and fixed value of placeholder data.
[0057] It should be noted that the data bit timing configuration includes the group-level data bit period, the high-level duration and low-level duration corresponding to logic zero, and the high-level duration and low-level duration corresponding to logic one; the reset latch configuration includes the reset latch time; the data bit timing configuration and the reset latch configuration are determined according to the current WS2812 smart LED light strip protocol configuration file and product specifications; the placeholder data fixed value adopts fixed color data that meets the group-level WS2812 protocol format. In this embodiment, the color data where all color channels are 0 is determined as the placeholder data fixed value.
[0058] Furthermore, the main STC8 microcontroller sends the equal-length frame specification to each STC8 microcontroller in the target device list; each STC8 microcontroller in the target device list reads the equal-length frame configuration content corresponding to its local device address, and generates a local equal-length frame configuration record based on the read equal-length frame configuration content.
[0059] Specifically, each STC8 microcontroller in the target device list reads the equal-length frame specification version, the number of unified transmission data groups, the number of local valid color data groups, the number of local placeholder data groups, the correspondence between local LED sequence numbers and virtual lighting effect positions, the color channel arrangement order, the data bit timing configuration, the reset latch configuration, and the fixed value of the placeholder data from the equal-length frame specification. It converts the data bit timing configuration into a local data bit timing count group, converts the reset latch configuration into a local reset latch count, and writes the equal-length frame specification version, the number of unified transmission data groups, the number of local valid color data groups, the number of local placeholder data groups, the correspondence between local LED sequence numbers and virtual lighting effect positions, the color channel arrangement order, the local data bit timing count group, the local reset latch count, and the fixed value of the placeholder data into the local equal-length frame configuration record.
[0060] It should be noted that each STC8 microcontroller converts the reset latch time into a local reset latch count based on the local system clock frequency, the frequency division factor of the local data output timer, and the timer counting period. During the conversion, the ratio of the reset latch time to the local timer counting period is rounded up to ensure that the actual low-level holding time corresponding to the local reset latch count is not shorter than the reset latch time, and meets the reset latch requirements specified in the WS2812 smart LED strip protocol configuration file and product specifications.
[0061] The local equal-length frame configuration record includes the equal-length frame specification version, the number of unified transmission data groups, the number of local valid color data groups, the number of local placeholder data groups, the correspondence between the local LED sequence number and the virtual lighting effect position, the color channel arrangement order, the local data bit timing count group, the local reset latch count, and the fixed value of the placeholder data; the local data bit timing count group includes logic zero high level count, logic zero low level count, logic one high level count, and logic one low level count.
[0062] Furthermore, each STC8 microcontroller in the target device list performs a consistency check on the local equal-length frame configuration record and generates an equal-length frame specification loading record based on the consistency check content.
[0063] Specifically, when the number of local valid color data groups is consistent with the number of local valid LEDs, the total number of color data groups obtained by calculating the sum of the number of local valid color data groups and the number of local placeholder data groups is consistent with the number of unified transmission data groups, and the number of virtual location mapping entries is consistent with the number of local valid LEDs, a full-length frame specification loading completion record is generated and sent to the main STC8 microcontroller. If any of the following situations occur: the number of local valid color data groups is inconsistent with the number of local valid LEDs, the total number of color data groups is inconsistent with the number of unified transmission data groups, or the number of virtual location mapping entries is inconsistent with the number of local valid LEDs, a full-length frame specification loading exception record is generated and sent to the main STC8 microcontroller, while keeping the corresponding full-length frame specification in an inactive state.
[0064] Furthermore, the main STC8 microcontroller collects the equal-length frame specification loading records sent by each STC8 microcontroller in the target device list, and determines the currently valid equal-length frame specification based on the equal-length frame specification loading records.
[0065] Specifically, when the main STC8 microcontroller receives all STC8 microcontrollers in the target device list that have sent a record of loading completion for the same version of the same length frame specification, it marks the corresponding length frame specification as the currently valid length frame specification; if any STC8 microcontroller in the target device list sends a record of loading error for the length frame specification, or fails to send a record of loading completion for the length frame specification within the specification loading waiting time, the corresponding length frame specification remains in an inactive state.
[0066] It should be noted that the loading waiting time is determined based on the number of devices in the target device list, the data length of the equal-length frame specification, the intra-group communication rate, and the time required for a complete response. The loading waiting time ranges from 2 to 5 times the time required for a complete response. The target device list, the number of unified transmission data groups, the virtual location mapping table, the data bit timing configuration, and the reset latch configuration corresponding to the same equal-length frame specification version remain fixed. When the target device list, the number of locally valid LEDs, the virtual starting position, the LED arrangement direction, and the group-level WS2812 protocol type change, the currently valid equal-length frame specification is marked as pending update, the device LED strip configuration is re-collected, and a new equal-length frame specification version is generated.
[0067] S1.5 Read the most recently confirmed lighting effect status, associate it with the currently valid equal-length frame specification, and generate the current group's running record.
[0068] Furthermore, the main STC8 microcontroller establishes the current group operation record, reads the lighting effect control group number from the current valid equal-length frame specification and writes it into the current group operation record, reads the group operation recovery record from the non-volatile storage area, and performs integrity verification based on the completion mark, record length and check value in the group operation recovery record.
[0069] Specifically, when the group operation recovery record has a valid completion mark, the record length is consistent with the group operation recovery record format, and the check value is consistent with the record content, the main STC8 microcontroller reads the most recently confirmed lighting effect frame number, the most recently confirmed lighting effect phase, the most recently confirmed lighting effect mode, and the most recently confirmed lighting effect parameters from the group operation recovery record. It writes the most recently confirmed lighting effect frame number and the most recently confirmed lighting effect phase into the current group operation record, writes the most recently confirmed lighting effect mode into the current lighting effect mode in the current group operation record, writes the most recently confirmed lighting effect parameters into the current lighting effect parameters in the current group operation record, and writes the current valid equal-length frame specification version into the current group operation record.
[0070] Specifically, when any of the following situations occur: the group operation recovery record lacks a valid completion marker, the record length is inconsistent with the group operation recovery record format, or the check value is inconsistent with the record content, the main STC8 microcontroller reads the initial configuration record of the lighting effect control group, determines the initial lighting effect frame number in the initial configuration record of the lighting effect control group as the most recently confirmed lighting effect frame number, determines the initial lighting effect phase as the most recently confirmed lighting effect phase, writes the most recently confirmed lighting effect frame number and the most recently confirmed lighting effect phase into the current group operation record, writes the initial lighting effect mode into the current lighting effect mode in the current group operation record, writes the initial lighting effect parameters into the current lighting effect parameters in the current group operation record, and writes the current valid equal-length frame specification version into the current group operation record.
[0071] The current group operation record includes the lighting effect control group number, the currently valid equal-length frame specification version, the most recently confirmed lighting effect frame number, the most recently confirmed lighting effect phase, the current lighting effect mode, the current lighting effect parameters, and the group operation status.
[0072] It should be noted that the initial configuration record of the lighting effect control group is written to the non-volatile storage area during the installation and debugging phase of the lighting effect control group; in this embodiment, the initial lighting effect frame number and the initial lighting effect phase are both set to 0; the most recently confirmed lighting effect frame number and the most recently confirmed lighting effect phase only record the lighting effect frame number and common lighting effect phase that have completed group-level frame confirmation, and the lighting effect frame number and common lighting effect phase that have been generated but have not yet completed group-level frame confirmation are not written to the most recently confirmed lighting effect frame number and the most recently confirmed lighting effect phase.
[0073] Furthermore, after the current valid equal-length frame specification is loaded and the current group operation record is generated, the main STC8 microcontroller sets the group operation status in the current group operation record to the state of waiting to generate the lighting effect frame.
[0074] S2. The main STC8 microcontroller generates a lighting effect frame control record based on the most recently confirmed lighting effect phase in the current group's operation record. Each STC8 microcontroller generates a valid color data segment based on the virtual position mapping table, the common lighting effect phase in the lighting effect frame control record, and the lighting effect parameters. It also generates a placeholder data segment based on the number of local placeholder data groups in the equal-length frame specification. The placeholder data segment is then connected to the valid color data segment to form an equal-length lighting effect frame.
[0075] S2.1 Read the lighting effect status in the current group's running record, generate and send out lighting effect frame control records.
[0076] Furthermore, the main STC8 microcontroller reads the current group's running record and extracts the current valid equal-length frame specification version, the most recently confirmed lighting effect frame number, the most recently confirmed lighting effect phase, the current lighting effect mode, the current lighting effect parameters, and the group's running status from the current group's running record.
[0077] The current lighting effect parameters include the phase full cycle value, phase advance amount, spatial cycle length, and color control point sequence. The phase full cycle value is the total phase corresponding to one phase cycle of the current lighting effect mode. The phase advance amount is the common lighting effect phase increment between two adjacent lighting effect frames that have completed group-level frame confirmation. The phase advance amount is determined according to the phase change speed and lighting effect refresh cycle corresponding to the current lighting effect mode. The value is not less than 0 and less than the phase full cycle value. The phase advance amount corresponding to the static lighting effect mode is 0. The spatial cycle length is the number of virtual lighting effect position intervals traversed by the current lighting effect mode to complete one spatial change along the virtual lighting effect path. The color control point sequence includes no less than two color control points arranged in ascending order of control point phase. Each color control point includes control point phase, red channel value, green channel value, and blue channel value. The phase of each control point is not less than 0 and less than the phase full cycle value. The control point phases of different color control points do not overlap.
[0078] It should be noted that the phase change rate is the amount of change in the phase of the common lighting effect per unit time, and the lighting effect refresh cycle is the time interval between the generation of two adjacent lighting effect frames; the phase advance amount is obtained by multiplying the phase change rate and the lighting effect refresh cycle.
[0079] Furthermore, when the group running status in the current group running record is "waiting to generate lighting effect frames," the main STC8 microcontroller increments the sequence number of the most recently confirmed lighting effect frame by one unit to generate the current lighting effect frame sequence number. When the sequence number of the most recently confirmed lighting effect frame is 0, the most recently confirmed lighting effect phase is determined as the common lighting effect phase corresponding to the current lighting effect frame. When the sequence number of the most recently confirmed lighting effect frame is greater than 0, the sum of the most recently confirmed lighting effect phase and the phase advance amount is moduloed by the full-cycle value of the phase, and the modulo result is determined as the common lighting effect phase corresponding to the current lighting effect frame. The main STC8 microcontroller writes the current valid equal-length frame specification version, the current lighting effect frame sequence number, and the common lighting effect phase into the lighting effect frame control record, writes the current lighting effect mode in the current group running record into the lighting effect mode in the lighting effect frame control record, and writes the current lighting effect parameters in the current group running record into the lighting effect parameters in the lighting effect frame control record.
[0080] The lighting effect frame control record includes the current valid equal-length frame specification version, the current lighting effect frame number, the common lighting effect phase, the lighting effect mode, and the lighting effect parameters.
[0081] It should be noted that the most recently confirmed lighting effect phase is the phase state corresponding to the lighting effect frame that has completed group-level frame confirmation; when the current group operation record is generated based on the initial configuration record of the lighting effect control group, the most recently confirmed lighting effect frame number is 0, and the most recently confirmed lighting effect phase in the current group operation record is the initial lighting effect phase. The first generated lighting effect frame uses the initial lighting effect phase as the common lighting effect phase; when the current lighting effect frame has not completed group-level frame confirmation, the most recently confirmed lighting effect frame number and the most recently confirmed lighting effect phase are not updated, and the current lighting effect frame number and the common lighting effect phase are not recalculated.
[0082] Furthermore, the main STC8 microcontroller sends the lighting effect frame control record to each STC8 microcontroller in the target device list, and sets the group running status in the current group running record to the state of waiting to generate equal-length lighting effect frames; each STC8 microcontroller reads the current valid equal-length frame specification version and the current lighting effect frame sequence number in the lighting effect frame control record, and compares the current valid equal-length frame specification version with the equal-length frame specification version in the local equal-length frame configuration record.
[0083] Specifically, when the current valid equal-length frame specification version is consistent with the equal-length frame specification version in the local equal-length frame configuration record, each STC8 microcontroller loads the lighting effect frame control record and establishes an association between the current valid equal-length frame specification version and the current lighting effect frame sequence number and the local lighting effect frame buffer; when the current valid equal-length frame specification version is inconsistent with the equal-length frame specification version in the local equal-length frame configuration record, the local lighting effect frame status of the corresponding STC8 microcontroller is set to the lighting effect frame control record pending confirmation status, and the generation of the current equal-length lighting effect frame is stopped.
[0084] The local lighting effect frame buffer is a storage area in each STC8 microcontroller used to continuously store the current equal-length lighting effect frames. The capacity of the local lighting effect frame buffer is determined based on the number of uniformly transmitted data groups and the storage space occupied by a complete color data group, and is not less than the storage space required for an equal-length lighting effect frame.
[0085] S2.2 Calculate the local LED phase by combining the common lighting effect phase and the virtual lighting effect position, and generate a valid color data segment.
[0086] Furthermore, each STC8 microcontroller reads the correspondence between the local LED sequence number and the virtual lighting effect position in the local equal-length frame configuration record in ascending order of the local LED sequence number, obtains the virtual lighting effect position corresponding to each local valid LED, reads the common lighting effect phase from the lighting effect frame control record, and reads the phase full cycle value, spatial cycle length, and color control point sequence from the lighting effect parameters in the lighting effect frame control record.
[0087] Furthermore, each STC8 microcontroller uses a virtual path phase coupling mapping algorithm to calculate the local LED phase corresponding to each local effective LED based on the common lighting effect phase, the virtual lighting effect position corresponding to each local effective LED, the spatial period length, and the full phase value.
[0088] It should be noted that the virtual path phase coupling mapping algorithm is expressed as:
[0089] ;
[0090] in, The local LED beads are numbered sequentially. For the first The local LED phase corresponding to each locally active LED. For common lighting phase, For the first The virtual lighting effect position corresponding to each locally effective LED. The length of the spatial period. This is the full-cycle phase value. This is the modulo operation.
[0091] It should be noted that, The value ranges from 1 to the number of locally valid LEDs.
[0092] It should be noted that the common lighting phase is the lighting phase corresponding to virtual lighting position 0; the virtual lighting position adopts the non-negative integer number in the virtual position mapping table, and the numerical difference between adjacent virtual lighting positions is 1.
[0093] It should be noted that the common lighting effect phase, local LED phase, and phase full cycle value use the same phase encoding unit and the same fixed-point encoding precision. Each STC8 microcontroller calculates the phase offset corresponding to the virtual lighting effect position according to the same fixed-point encoding precision.
[0094] It should be noted that the spatial cycle length is determined based on the number of virtual lighting effect position intervals traversed by the current lighting effect mode to complete one spatial change along the virtual lighting effect path, and the spatial cycle length is a positive integer. When the spatial cycle length decreases, the phase change between adjacent local effective LEDs increases; when the spatial cycle length increases, the phase change between adjacent local effective LEDs decreases. The phase full cycle value is determined based on the encoding method of the common lighting effect phase. For example, when angle encoding is used, the phase full cycle value is taken as... .
[0095] Furthermore, each STC8 microcontroller, based on the local LED phase, retrieves two color control points in the color control point sequence whose control point phases are located on either side of the local LED phase. It reads the red, green, and blue channel values corresponding to the two color control points, and performs linear interpolation on the red, green, and blue channel values of the two color control points according to the position ratio of the local LED phase between the two control point phases. The color channel values obtained by linear interpolation are then converted into integers according to the same rounding rule to generate the corresponding red, green, and blue channel values of the local valid LED.
[0096] Specifically, when the phase of the local LED bead matches the phase of the control point of a color control point, the red channel value, green channel value, and blue channel value of the corresponding color control point are directly read; when the phase of the local LED bead is between the phase of the end control point and the phase of the start control point in the color control point sequence, cyclic interpolation is performed on the end control point and the start control point according to the phase full cycle value.
[0097] It should be noted that the color control point sequence is determined according to the current lighting effect mode; the color control point sequence corresponding to the gradient lighting effect mode includes multiple different color control points, the color control point sequence corresponding to the chasing lighting effect mode includes lighting control points and extinguishing control points, and each color control point corresponding to the static lighting effect mode uses the same color channel value; when a single color channel uses 8-bit data, the value range of the red channel, green channel, and blue channel is 0 to 255.
[0098] It should be noted that all STC8 microcontrollers use the same rounding rules for color channel values. In this embodiment, the color channel values obtained by linear interpolation are converted into integers using a rounding method. When the rounded color channel value is lower than the minimum color channel value, the minimum color channel value is used; when it is higher than the maximum color channel value, the maximum color channel value is used.
[0099] Furthermore, each STC8 microcontroller reads the red, green, and blue channel values corresponding to each local valid LED in ascending order of local LED serial number, and arranges the red, green, and blue channel values corresponding to each local valid LED into a local valid color data group according to the color channel arrangement order in the local equal-length frame configuration record.
[0100] Specifically, when the color channel arrangement order is green channel, red channel, and blue channel, the local valid color data group is written in the order of green channel value, red channel value, and blue channel value; when the color channel arrangement order adopts other channel order allowed by the WS2812 protocol, the local valid color data group is written in the color channel arrangement order recorded in the local equal-length frame configuration record.
[0101] Furthermore, each STC8 microcontroller is numbered according to the local LED sequence, and all local valid color data groups are continuously written into the local lighting effect frame buffer to generate a valid color data segment, and the number of local valid color data groups in the valid color data segment is counted.
[0102] One locally valid color data group corresponds to one locally valid LED.
[0103] Furthermore, each STC8 microcontroller verifies the consistency between the number of local valid color data groups in the valid color data segment and the number of local valid color data groups in the local equal-length frame configuration record. If the two quantities are consistent, the valid color data segment is retained; if the two quantities are inconsistent, the local lighting effect frame status is set to the valid color data segment pending confirmation status, and the generation of placeholder data segments is stopped.
[0104] S2.3. Generate placeholder data segments based on the number of local placeholder data groups, and connect the valid color data segments and placeholder data segments to form equal-length lighting effect frames.
[0105] Furthermore, each STC8 microcontroller reads the number of local placeholder data groups and the fixed value of placeholder data from the local equal-length frame configuration record, copies the fixed value of placeholder data according to the number of local placeholder data groups, generates placeholder color data groups with the same number of local placeholder data groups, and arranges all placeholder color data groups continuously to generate placeholder data segments.
[0106] The number of data bits in a placeholder color data group is the same as the number of data bits in a local valid color data group; the fixed value of the placeholder data uses color data where all color channels are 0; the placeholder color data group does not establish a correspondence with the local valid LEDs.
[0107] Specifically, when the number of local placeholder data groups is greater than 0, placeholder data segments are generated according to the number of local placeholder data groups; when the number of local placeholder data groups is equal to 0, the number of placeholder color data groups in the placeholder data segment is determined to be 0.
[0108] It should be noted that the number of locally valid LEDs covers all the controlled LEDs connected to the data output terminal of the current STC8 microcontroller. The placeholder color data group is arranged after all the locally valid color data groups. Under the condition of continuous color data transmission and no reset latch is performed, the placeholder color data group passes through all the locally valid LEDs in sequence and is output by the data output terminal of the last locally valid LED, without changing the locally valid color data groups already received by each locally valid LED.
[0109] Furthermore, when the number of local placeholder data groups is greater than 0, each STC8 microcontroller writes the placeholder data segment into the local lighting effect frame buffer at the consecutive storage location immediately following the valid color data segment, and connects the placeholder data segment after the valid color data segment to form an equal-length lighting effect frame; when the number of local placeholder data groups is equal to 0, each STC8 microcontroller determines the valid color data segment as an equal-length lighting effect frame.
[0110] In the equal-length light effect frame, the color data groups are arranged in the following order: all local valid color data groups and all placeholder color data groups. When the number of local placeholder data groups is greater than 0, the starting storage position of the placeholder data segment is immediately followed by the ending storage position of the valid color data segment.
[0111] Furthermore, each STC8 microcontroller determines the total number of color data groups in the equal-length lighting effect frame by summing the number of local valid color data groups in the valid color data segment and the number of placeholder color data groups in the placeholder data segment, and performs consistency verification between the total number of color data groups and the number of unified transmission data groups in the local equal-length frame configuration record.
[0112] Specifically, when the total number of color data groups is consistent with the number of unified transmission data groups, the equal-length frame specification version corresponding to the equal-length lighting effect frame is consistent with the currently valid equal-length frame specification version in the lighting effect frame control record, and the current lighting effect frame sequence number corresponding to the equal-length lighting effect frame is consistent with the current lighting effect frame sequence number in the lighting effect frame control record, the local lighting effect frame status is set to the equal-length lighting effect frame preparation completion status, an equal-length lighting effect frame preparation completion record is generated, and the equal-length lighting effect frame preparation completion record is sent to the main STC8 microcontroller; when any of the following situations occurs: the total number of color data groups is inconsistent with the number of unified transmission data groups, the equal-length frame specification version is inconsistent, or the current lighting effect frame sequence number is inconsistent, the local lighting effect frame status is set to the equal-length lighting effect frame pending confirmation status, and the generation of the equal-length lighting effect frame preparation completion record is stopped.
[0113] The record for the preparation of equal-length lighting effect frames includes the device address, the version of the equal-length frame specification, the current lighting effect frame sequence number, the number of local valid color data groups, the number of local placeholder data groups, and the total number of color data groups.
[0114] After all equal-length lighting effect frames are prepared, the main STC8 microcontroller sends a group-level synchronization trigger pulse. Each STC8 microcontroller continuously outputs valid color data segments and placeholder data segments according to the equal-length frame specification. After the total number of output color data groups reaches the unified transmission data group number in the equal-length frame specification, a reset latch is executed, and a frame output completion record is generated.
[0115] S3.1 Collect the record of the preparation of equal-length light effect frames, verify that all equal-length light effect frames are ready and send the group-level synchronization trigger pulse.
[0116] Furthermore, after generating the equal-length lighting effect frame preparation completion record and before sending the equal-length lighting effect frame preparation completion record, each STC8 microcontroller reads the local data bit timing counter group, local reset latch counter, group-level single LED color data bit quantity, unified transmission data group quantity, local valid color data group quantity, and local placeholder data group quantity from the local equal-length frame configuration record. It also reads the local lighting effect frame buffer associated with the current valid equal-length frame specification version and the current lighting effect frame sequence number, and executes the loading of the output parameters of the current lighting effect frame.
[0117] Furthermore, each STC8 microcontroller clears the number of data bits already output for the current color data group, the total number of color data groups already output, and the reset latch process count to zero, keeps the data output terminal at a low level, and enables the external interrupt input terminal corresponding to the group-level synchronization trigger line; after completing the loading of output parameters and clearing the count, each STC8 microcontroller maintains the equal-length light effect frame preparation completion state and sends the equal-length light effect frame preparation completion record to the master STC8 microcontroller.
[0118] Among them, the number of data bits output in the current color data group is used to record the number of data bits that have been output in the current complete color data group; the total number of output color data groups is used to record the number of complete color data groups that have been output in the current equal-length light effect frame; the reset latch process count is used to record the cumulative count of the data output terminal holding a low level after all color data groups have been output; and the local reset latch count is the completion threshold corresponding to the reset latch process count.
[0119] Furthermore, the group-level synchronization trigger line connects the synchronization output terminal of the main STC8 microcontroller to the external interrupt input terminal of each STC8 microcontroller in the target device list; when the main STC8 microcontroller belongs to the target device list, the external interrupt input terminal of the main STC8 microcontroller is also connected to the group-level synchronization trigger line; each external interrupt input terminal adopts the same effective edge triggering method.
[0120] Furthermore, the main STC8 microcontroller collects the preparation completion records of equal-length lighting effect frames sent by each STC8 microcontroller in the target device list, establishes a correspondence between each equal-length lighting effect frame preparation completion record and each STC8 microcontroller in the target device list according to the device address, and performs equal-length lighting effect frame preparation completion verification on the equal-length frame specification version, the current lighting effect frame sequence number, and the total number of color data groups.
[0121] Specifically, the main STC8 microcontroller compares the device addresses in the equal-length lighting effect frame preparation completion record with the target device list item by item. When each device address in the target device list has a corresponding equal-length lighting effect frame preparation completion record, the equal-length frame specification version in each equal-length lighting effect frame preparation completion record is consistent with the currently valid equal-length frame specification version, the current lighting effect frame sequence number in each equal-length lighting effect frame preparation completion record is consistent with the current lighting effect frame sequence number in the lighting effect frame control record, and the total number of color data groups in each equal-length lighting effect frame preparation completion record is consistent with the number of unified transmission data groups, then all equal-length lighting effect frames are determined to be ready.
[0122] It should be noted that if there is an STC8 microcontroller in the target device list that has not sent a record of preparation completion for equal-length lighting effect frames, or if any record of preparation completion for equal-length lighting effect frames fails the verification of preparation completion for equal-length lighting effect frames, the main STC8 microcontroller will not send a group-level synchronization trigger pulse and will keep the current lighting effect frame sequence number and common lighting effect phase unchanged.
[0123] Furthermore, after confirming that all equal-length lighting effect frames are ready, the main STC8 microcontroller switches the synchronization output from idle level to active level, and restores the synchronization output to idle level after reaching the synchronization trigger pulse width, generating a group-level synchronization trigger pulse.
[0124] It should be noted that the synchronous trigger pulse width is determined based on the minimum identifiable pulse width of the external interrupt input terminal of the STC8 microcontroller, the propagation delay of the group-level synchronous trigger line, and the response time of the interface level conversion circuit, and is typically between 2 microseconds and 20 microseconds. When the upper limit of the allowable pulse width given in the STC8 microcontroller product specification is less than 20 microseconds, the synchronous trigger pulse width shall not exceed the upper limit of the allowable pulse width, and shall not be less than the minimum identifiable pulse width of the external interrupt input terminal. The group-level synchronous trigger pulse is transmitted through a group-level synchronous trigger line independent of the data output terminal.
[0125] Furthermore, after each STC8 microcontroller receives the valid edge of the group-level synchronization trigger pulse at its external interrupt input terminal, it blocks the repeated external interrupt trigger corresponding to the current lighting effect frame, sets the current read address of the local lighting effect frame buffer to the starting storage location of the valid color data segment, and starts the local data output timer according to the loaded local data bit timing counter group.
[0126] It should be noted that each STC8 microcontroller has completed the loading of output parameters and the clearing of the count before the group-level synchronization trigger pulse arrives. The external interrupt handling process only executes the current read address setting and the start of the local data output timer, so as to reduce the start time difference of each STC8 microcontroller after receiving the group-level synchronization trigger pulse.
[0127] S3.2. Continuously output equal-length light effect frames according to the local data bit timing count group. After reaching the unified number of data groups to be transmitted, perform a reset latch and generate a frame output to complete the record.
[0128] Furthermore, each STC8 microcontroller reads the color data bits in the valid color data segment and the placeholder data segment in sequence according to the storage order in the local lighting effect frame buffer. Based on the logic value of the current color data bit, it reads the corresponding high-level count and low-level count from the local data bit timer count group, and controls the data output terminal to output high and low levels in sequence through the local data output timer.
[0129] Specifically, when the current color data bit is logic zero, each STC8 microcontroller keeps the data output terminal at a high level according to the logic zero high level count, and then keeps the data output terminal at a low level according to the logic zero low level count; when the current color data bit is logic one, each STC8 microcontroller keeps the data output terminal at a high level according to the logic one high level count, and then keeps the data output terminal at a low level according to the logic one low level count; after the high and low level outputs corresponding to a color data bit are completed, the number of output data bits of the current color data group is increased by 1.
[0130] Furthermore, when the number of data bits output in the current color data group reaches the number of color data bits for a single LED at the group level, each STC8 microcontroller will increment the total number of output color data groups by 1, clear the number of output data bits in the current color data group to zero, and continue reading the next complete color data group from the local lighting effect frame buffer.
[0131] Specifically, when the total number of output color data groups is less than the number of local valid color data groups, each STC8 microcontroller continues to read and output the local valid color data groups in the valid color data segment; when the total number of output color data groups reaches the number of local valid color data groups and the number of local placeholder data groups is greater than 0, each STC8 microcontroller continues to read and output the placeholder color data groups in the placeholder data segment along the continuous storage address of the local lighting effect frame buffer.
[0132] It should be noted that after the last color data bit in the valid color data segment is output, each STC8 microcontroller does not stop the local data output timer, and outputs the first color data bit in the placeholder data segment according to the next data bit cycle, so that there is no continuous low level between the valid color data segment and the placeholder data segment that reaches the duration corresponding to the local reset latch count.
[0133] Furthermore, when the number of local placeholder data groups is equal to 0, each STC8 microcontroller will output all local valid color data groups to reach the number of unified transmission data groups; when the number of local placeholder data groups is greater than 0, each STC8 microcontroller will output all local valid color data groups and all placeholder color data groups to reach the number of unified transmission data groups.
[0134] Furthermore, once the total number of output color data groups reaches the unified transmission data group count, each STC8 microcontroller stops reading color data bits from the local lighting effect frame buffer, keeps the data output terminal at a low level, and accumulates the reset latching process count through the local data output timer.
[0135] Specifically, when the reset latch process count reaches the local reset latch count in the local equal-length frame configuration record, each STC8 microcontroller sets the reset latch completion status to the completion status, stops the local data output timer, and retains the current valid equal-length frame specification version, the current lighting effect frame sequence number, and the total number of output color data groups.
[0136] It should be noted that each STC8 microcontroller adopts the same data bit timing configuration in the same equal-length frame specification, and converts the data bit timing configuration into a local data bit timing count group that matches the local clock frequency; each STC8 microcontroller enters the reset latch after outputting a complete color data group corresponding to the same number of transmitted data groups, so that the WS2812 smart LED light strips corresponding to different local effective LED beads have the same number of color data group outputs and consistent reset latch entry conditions.
[0137] Furthermore, after successfully completing the output and reset latch of all color data groups, each STC8 microcontroller sets the frame output status to the normal completion state. Based on the device address, the current valid equal-length frame specification version, the current lighting effect frame sequence number, the number of local valid color data groups, the number of local placeholder data groups, the total number of output color data groups, the reset latch completion status, and the frame output status, a frame output completion record is generated and sent to the main STC8 microcontroller.
[0138] The frame output completion record includes the device address, the equal-length frame specification version, the current lighting effect frame sequence number, the number of local valid color data groups, the number of local placeholder data groups, the total number of output color data groups, the reset latch completion status, and the frame output status. When generating the frame output completion record, the current valid equal-length frame specification version is written into the equal-length frame specification version in the frame output completion record.
[0139] It should be noted that when any of the following occurs: the current read address of the local lighting effect frame buffer reaches the storage end address of the equal-length lighting effect frame and the total number of output color data groups has not yet reached the number of unified transmission data groups; the number of data bits output in the current color data group exceeds the number of color data bits of a single LED at the group level; or the total number of output color data groups exceeds the number of unified transmission data groups, each STC8 microcontroller stops reading color data bits, keeps the data output terminal at a low level, and continues to accumulate the reset latch process count; after the reset latch process count reaches the local reset latch count, the reset latch completion status is set to the completion status, the frame output status is set to the output abnormal status, a frame output completion record is generated based on the number of complete color data groups that have been output before the abnormality occurred, and the frame output completion record is sent to the main STC8 microcontroller.
[0140] It should be noted that after the current lighting effect frame completes the reset latch and sends the frame output to complete the recording, each STC8 microcontroller continues to block the repeated external interrupt triggering corresponding to the current lighting effect frame; when the next lighting effect frame completes the loading of output parameters and enters the equal-length lighting effect frame preparation state, the external interrupt input terminal corresponding to the group-level synchronization trigger line is re-enabled.
[0141] In this embodiment, to verify the impact of equal-length lighting effect frames and unified reset latch conditions on the consistency of frame end within a group, continuous operation tests were conducted using the method of this invention and the conventional control method under the same STC8 microcontroller, WS2812 smart LED light strip, power supply conditions, and lighting effect refresh cycle. The conventional control method refers to each STC8 microcontroller generating color data only according to the number of locally valid LED beads and independently executing reset latch after local output, without using the number of locally placeholder data groups, the number of uniformly transmitted data groups, or group-level synchronous trigger pulses. During the test, the time when each data output terminal within the same lighting effect frame entered the reset latch was recorded, and the difference between the maximum and minimum times was used as the range of frame end times within the group. Figure 5 As shown, the range of the method of the present invention remains in a low and stable range, indicating that the placeholder data segment unifies the total number of color data groups, the group-level synchronous trigger pulse unifies the output starting point, and improves the stability and display consistency of the coordinated output of the LED strips within the group.
[0142] S4. The main STC8 microcontroller completes the recording and execution of group-level frame confirmation based on the output of all frames. When the group-level frame confirmation is successful, it advances the common lighting effect phase and generates the next lighting effect frame based on the advanced common lighting effect phase. When the group-level frame confirmation is unsuccessful, it retains the lighting effect frame number and common lighting effect phase and re-outputs the current lighting effect frame.
[0143] S4.1, Collect frame output completion record, and perform group-level frame confirmation on the current lighting effect frame.
[0144] Furthermore, after the main STC8 microcontroller sends the group-level synchronization trigger pulse, it starts the group-level frame confirmation waiting timer corresponding to the current lighting effect frame, and receives the frame output completion record sent by each STC8 microcontroller in the target device list.
[0145] It should be noted that the main STC8 microcontroller determines the maximum output time of the current equal-length lighting effect frame based on the number of unified transmission data groups, the number of color data bits of the group-level single LED bead, and the data bit timing configuration. It determines the maximum reset latch time based on the local reset latch count of each STC8 microcontroller in the target device list. It also determines the maximum aggregation time of all frame output completion records based on the number of devices in the target device list, the data length of the frame output completion record, and the intra-group communication rate. The group-level frame confirmation waiting time is set to 1.2 to 2 times the sum of the maximum output time, the maximum reset latch time, and the maximum aggregation time. The specific multiple is determined based on the maximum transmission delay of the frame output completion record during intra-group communication testing.
[0146] Furthermore, the main STC8 microcontroller establishes a correspondence between each frame output completion record and each STC8 microcontroller in the target device list based on the device address in the frame output completion record, and performs group-level frame confirmation on the equal-length frame specification version, current lighting effect frame sequence number, total number of output color data groups, reset latch completion status and frame output status in each frame output completion record.
[0147] Specifically, the main STC8 microcontroller compares the device addresses in the frame output completion record with the target device list item by item, verifying that each device address in the target device list has a corresponding frame output completion record; compares the equal-length frame specification version in each frame output completion record with the currently valid equal-length frame specification version; compares the current lighting effect frame sequence number in each frame output completion record with the current lighting effect frame sequence number in the lighting effect frame control record; compares the total number of output color data groups in each frame output completion record with the number of unified transmission data groups; and reads the reset latch completion status and frame output status in each frame output completion record.
[0148] Furthermore, each device address in the target device list has a corresponding frame output completion record; the equal-length frame specification version in each frame output completion record is consistent with the currently valid equal-length frame specification version; the current lighting effect frame sequence number in each frame output completion record is consistent with the current lighting effect frame sequence number in the lighting effect frame control record; the total number of output color data groups in each frame output completion record is consistent with the number of unified transmission data groups; each reset latch completion status is in the completion status; and when each frame output status is in the normal completion status, the main STC8 microcontroller sets the group-level frame confirmation result of the current lighting effect frame to group-level frame confirmation successful.
[0149] Furthermore, if, at the end of the group-level frame confirmation waiting time, there are still STC8 microcontrollers in the target device list that have not sent a frame output completion record, or if any of the following occurs: inconsistent equal-length frame specification version, inconsistent current lighting effect frame sequence number, inconsistent total number of output color data groups, reset latch completion status is not a completion status, or frame output status is not a normal completion status, the master STC8 microcontroller will set the group-level frame confirmation result of the current lighting effect frame to "group-level frame confirmation unsuccessful".
[0150] Furthermore, the main STC8 microcontroller generates a group-level frame confirmation record based on the current valid equal-length frame specification version, the current lighting effect frame sequence number, the common lighting effect phase, the target device list, the output completion record of all received frames, and the group-level frame confirmation result.
[0151] The group-level frame confirmation record includes the current valid equal-length frame specification version, the current lighting effect frame sequence number, the common lighting effect phase, the device address of the sent frame output completion record, the device address of the unsent frame output completion record, the group-level frame confirmation result, and the reason for the unsuccessful group-level frame confirmation. The reason for the unsuccessful group-level frame confirmation is determined based on the record fields that failed the group-level frame confirmation and the device address of the unsent frame output completion record.
[0152] S4.2. Generate the next lighting effect frame or re-output the current lighting effect frame based on the group-level frame confirmation result.
[0153] Furthermore, when the group-level frame confirmation result is successful, the main STC8 microcontroller writes the current lighting effect frame sequence number in the lighting effect frame control record to the most recently confirmed lighting effect frame sequence number in the current group operation record, writes the common lighting effect phase in the lighting effect frame control record to the most recently confirmed lighting effect phase in the current group operation record, and keeps the current lighting effect mode and current lighting effect parameters in the current group operation record unchanged.
[0154] Furthermore, the main STC8 microcontroller writes the current valid equal-length frame specification version, the most recently confirmed lighting effect frame number, the most recently confirmed lighting effect phase, the current lighting effect mode, and the current lighting effect parameters into the group operation recovery record.
[0155] It should be noted that the group operation recovery record is only updated when the group-level frame confirmation result is a successful group-level frame confirmation; the group operation recovery record is not updated when a single STC8 microcontroller completes reset latching or when some STC8 microcontrollers complete frame output.
[0156] Furthermore, the main STC8 microcontroller increments the sequence number of the most recently confirmed lighting effect frame by 1 and generates the sequence number of the next lighting effect frame; it reads the phase advance amount and the phase full period value in the current lighting effect parameters, adds the phase of the most recently confirmed lighting effect to the phase advance amount, and performs a modulo operation on the phase full period value of the sum, and determines the common lighting effect phase after the advance as the modulo result.
[0157] It should be noted that the common lighting effect phase is advanced only once after the current lighting effect frame completes the group-level frame confirmation; when the sum of the most recently confirmed lighting effect phase and the phase advancement amount reaches the full phase period value, the remainder result continues to change from the starting position of the full phase period.
[0158] Furthermore, the main STC8 microcontroller generates a next lighting effect frame control record based on the current valid equal-length frame specification version, the next lighting effect frame sequence number, the advanced common lighting effect phase, the current lighting effect mode, and the current lighting effect parameters. It then sends the next lighting effect frame control record to each STC8 microcontroller in the target device list and sets the group running status in the current group running record to the state of waiting to generate equal-length lighting effect frames.
[0159] Furthermore, each STC8 microcontroller reads the advanced common lighting effect phase, lighting effect mode, and lighting effect parameters from the control record of the next lighting effect frame. Based on the correspondence between the local LED sequence number and the virtual lighting effect position, it calculates the local LED phase corresponding to each local valid LED. Based on the local LED phase, it performs linear interpolation on the color control point sequence to generate the red channel value, green channel value, and blue channel value corresponding to each local valid LED. Then, it generates the valid color data segment corresponding to the next lighting effect frame according to the local LED sequence number and the color channel arrangement order.
[0160] Furthermore, each STC8 microcontroller generates a placeholder data segment corresponding to the next lighting effect frame based on the number of local placeholder data groups and the fixed value of the placeholder data. The placeholder data segment is then connected to the valid color data segment to generate the next equal-length lighting effect frame. After loading the output parameters and clearing the output count for the next lighting effect frame, each STC8 microcontroller generates an equal-length lighting effect frame preparation completion record and sends the equal-length lighting effect frame preparation completion record to the main STC8 microcontroller.
[0161] Furthermore, the main STC8 microcontroller establishes a correspondence between the record of the preparation completion of the equal-length light effect frame corresponding to the next light effect frame and each STC8 microcontroller in the target device list based on the device address, and performs equal-length light effect frame preparation completion verification on the equal-length frame specification version, the sequence number of the next light effect frame, and the total number of color data groups; when all the equal-length light effect frame preparation completion records corresponding to all STC8 microcontrollers in the target device list pass the equal-length light effect frame preparation completion verification, the main STC8 microcontroller sends the group-level synchronization trigger pulse corresponding to the next light effect frame.
[0162] Furthermore, if the group-level frame confirmation result is unsuccessful, the main STC8 microcontroller keeps the most recently confirmed lighting effect frame number, the most recently confirmed lighting effect phase, the current lighting effect mode, and the current lighting effect parameters unchanged in the current group operation record, does not update the group operation recovery record, and keeps the current lighting effect frame number and common lighting effect phase unchanged in the current lighting effect frame control record.
[0163] Furthermore, the main STC8 microcontroller generates a current lighting effect frame re-output record based on the current valid equal-length frame specification version, the current lighting effect frame sequence number, the common lighting effect phase, the reason for the group-level frame confirmation failure, and the current number of re-output attempts. The current lighting effect frame re-output record is then sent to each STC8 microcontroller in the target device list.
[0164] The current lighting effect frame re-output record includes the current valid equal-length frame specification version, the current lighting effect frame number, the common lighting effect phase, the number of re-outputs, and the reason for the failure of group-level frame confirmation. The current number of re-outputs is associated with the current lighting effect frame number. It is set to 1 when the current lighting effect frame first fails to confirm the group-level frame, and incremented by 1 for each subsequent failure of group-level frame confirmation in the current lighting effect frame. When the current lighting effect frame completes the group-level frame confirmation and generates the control record for the next lighting effect frame, the current number of re-outputs is cleared to zero. The count is reset when the next lighting effect frame fails to confirm the group-level frame.
[0165] Furthermore, after each STC8 microcontroller receives the current lighting effect frame re-output record, it compares the current valid equal-length frame specification version and the current lighting effect frame sequence number in the current lighting effect frame re-output record with the current valid equal-length frame specification version and the current lighting effect frame sequence number associated with the local lighting effect frame buffer.
[0166] Specifically, when the two currently valid equal-length frames have the same specification version, the two currently valid lighting effect frames have the same sequence number, and the equal-length lighting effect frames in the local lighting effect frame buffer are within the valid storage range, each STC8 microcontroller retains the current equal-length lighting effect frame in the local lighting effect frame buffer; when any of the following occurs, such as the current valid equal-length frame specification version is inconsistent, the current lighting effect frame sequence number is inconsistent, or the equal-length lighting effect frame in the local lighting effect frame buffer is not within the valid storage range, each STC8 microcontroller reads the common lighting effect phase, lighting effect mode, and lighting effect parameters from the current lighting effect frame control record, recalculates the local lamp phase corresponding to each local valid lamp according to the correspondence between the local lamp sequence number and the virtual lighting effect position, and regenerates the valid color data segment and placeholder data segment corresponding to the current lighting effect frame to generate the current equal-length lighting effect frame.
[0167] Furthermore, each STC8 microcontroller reloads the local data bit timing counter group, local reset latch counter, group-level single LED color data bit count, unified transmission data group count, local valid color data group count, and local placeholder data group count of the current lighting effect frame. It clears the number of data bits already output in the current color data group, the total number of output color data groups, and the reset latch process count to zero, re-enabled the external interrupt input terminal corresponding to the group-level synchronization trigger line, generates a record of the equal-length lighting effect frame preparation completion, and sends the record of the equal-length lighting effect frame preparation completion to the main STC8 microcontroller.
[0168] Furthermore, the main STC8 microcontroller establishes a correspondence between the newly generated equal-length lighting effect frame preparation completion record and each STC8 microcontroller in the target device list based on the device address, and performs equal-length lighting effect frame preparation completion verification on the equal-length frame specification version, the current lighting effect frame sequence number, and the total number of color data groups; when all equal-length lighting effect frame preparation completion records corresponding to all STC8 microcontrollers in the target device list pass the equal-length lighting effect frame preparation completion verification, the main STC8 microcontroller resends the group-level synchronization trigger pulse corresponding to the current lighting effect frame.
[0169] Furthermore, after receiving the retransmitted group-level synchronization trigger pulse, each STC8 microcontroller outputs valid color data segments and placeholder data segments sequentially according to the local data bit timing count group. When the total number of output color data groups reaches the unified transmission data group count, each STC8 microcontroller keeps its data output terminal at a low level and accumulates the reset latch process count. When the reset latch process count reaches the local reset latch count, each STC8 microcontroller regenerates the frame output completion record and sends it to the master STC8 microcontroller.
[0170] It should be noted that the maximum number of re-outputs is determined based on the lighting effect refresh cycle, the number of consecutive anomalies in the group communication test, and the allowable lighting effect pause time, and is usually 1 to 3 times. When the current number of re-outputs reaches the maximum number of re-outputs and the group-level frame confirmation result is still that the group-level frame confirmation is unsuccessful, the main STC8 microcontroller keeps the current lighting effect frame number and common lighting effect phase unchanged, does not update the group operation recovery record, sets the group operation status in the current group operation record to the group-level output abnormal status, and stops generating the next lighting effect frame.
[0171] In this embodiment, to verify the impact of group-level frame confirmation on the ability to maintain the common lighting effect phase after abnormal output, the method of this invention and the conventional control method were run under the same lighting effect mode, phase advance amount, lighting effect refresh cycle, and abnormal triggering conditions. The conventional control method refers to the main STC8 microcontroller advancing the common lighting effect phase according to a predetermined number of triggers. Even when a frame output by each STC8 microcontroller is incomplete, it continues to generate the next lighting effect frame, without determining the group-level frame confirmation result based on the completion of all frame outputs. During the test, the same abnormal output conditions were applied to consecutive lighting effect frames, and the maximum deviation between the actual displayed phase of each STC8 microcontroller and the common lighting effect phase was recorded. Figure 6 As shown, the common lighting effect phase deviation of conventional control methods continues to increase, while the deviation of the method of the present invention remains within a low range; when the group-level frame confirmation fails, the lighting effect frame number and common lighting effect phase are maintained, and the current lighting effect frame is re-output to prevent the incomplete output state from entering the next phase, thereby improving the continuity of lighting effect and the reliability of collaborative control during the abnormal recovery process.
[0172] This embodiment also provides an intelligent LED strip control system based on an STC8 microcontroller, including:
[0173] The specification construction module is used to collect the number of local valid LEDs, virtual starting position, and LED arrangement direction of each STC8 microcontroller, determine the number of unified transmission data groups and the number of local placeholder data groups; establish a virtual position mapping table, generate equal-length frame specifications and current group operation records;
[0174] The lighting effect generation module is used to generate lighting effect frame control records based on the most recently confirmed lighting effect phase, and generate valid color data segments based on the virtual position mapping table, common lighting effect phase, and lighting effect parameters; it also generates placeholder data segments based on the number of local placeholder data groups and forms equal-length lighting effect frames.
[0175] The synchronous output module is used to send group-level synchronous trigger pulses after all equal-length light effect frames are prepared, controlling each STC8 microcontroller to continuously output valid color data segments and placeholder data segments; after the total number of output color data groups reaches the unified transmission data group number, a reset latch is executed, and a frame output completion record is generated.
[0176] The group-level confirmation module is used to perform group-level frame confirmation based on the completion record of all frame outputs. When the group-level frame confirmation is successful, the common lighting effect phase is advanced and the next lighting effect frame is generated. When the group-level frame confirmation is unsuccessful, the lighting effect frame number and the common lighting effect phase are maintained and the current lighting effect frame is re-output.
[0177] In summary, this invention achieves uniform color data output length under different local effective LED numbers by generating placeholder data segments and forming equal-length lighting effect frames; and by performing group-level frame confirmation based on the completion record of all frame outputs, advancing the common lighting effect phase when confirmation is successful, and maintaining the lighting effect frame sequence number and common lighting effect phase and re-outputting the current lighting effect frame when confirmation is unsuccessful, thereby binding the lighting effect phase with the output state within the group and improving the stability of collaborative control and display consistency.
[0178] It should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and are not intended to limit it. Although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications or equivalent substitutions can be made to the technical solutions of the present invention without departing from the spirit and scope of the technical solutions of the present invention, and all such modifications or substitutions should be covered within the scope of the claims of the present invention.
Claims
1. A method for controlling intelligent LED strip lights based on an STC8 microcontroller, characterized in that, include: The system collects the number of locally effective LEDs, virtual starting positions, and LED arrangement directions of each STC8 microcontroller within the same lighting effect control group. The number of locally effective LEDs of each STC8 microcontroller is determined as the number of locally effective color data groups. The main STC8 microcontroller uses the maximum value among the number of locally effective color data groups as the unified transmission data group number. Combining the unified transmission data group number and the number of locally effective color data groups, the system calculates the number of local placeholder data groups, establishes a virtual position mapping table, generates equal-length frame specifications, and establishes the current group operation record. The main STC8 microcontroller generates a lighting effect frame control record based on the most recently confirmed lighting effect phase in the current group's operation record. Each STC8 microcontroller generates a valid color data segment based on the virtual position mapping table, the common lighting effect phase in the lighting effect frame control record, and the lighting effect parameters. It also generates a placeholder data segment based on the number of local placeholder data groups in the equal-length frame specification. The placeholder data segment is then concatenated after the valid color data segment to form an equal-length lighting effect frame. After all equal-length lighting effect frames are prepared, the main STC8 microcontroller sends a group-level synchronization trigger pulse. Each STC8 microcontroller continuously outputs valid color data segments and placeholder data segments according to the equal-length frame specification. After the total number of output color data groups reaches the unified transmission data group number in the equal-length frame specification, a reset latch is executed, and a frame output completion record is generated. The main STC8 microcontroller completes the recording and execution of group-level frame confirmation based on the output of all frames. When the group-level frame confirmation is successful, it advances the common lighting effect phase and generates the next lighting effect frame based on the advanced common lighting effect phase. When the group-level frame confirmation is unsuccessful, it retains the lighting effect frame number and common lighting effect phase and re-outputs the current lighting effect frame.
2. The intelligent LED strip control method based on STC8 microcontroller as described in claim 1, characterized in that, The calculation of the number of local placeholder data groups by combining the number of unified transmission data groups and the number of each local valid color data group includes: Each STC8 microcontroller reads the local LED strip configuration record and generates a device LED strip configuration reporting record. The main STC8 microcontroller collects the LED strip configuration reporting records of the equipment and establishes a target device list based on the lighting effect control group number, the group-level WS2812 protocol type, and the number of color data bits of a single LED bead in the group. The main STC8 microcontroller determines the number of locally valid LEDs for each STC8 microcontroller in the target device list as the corresponding number of locally valid color data groups, and determines the maximum value among the number of locally valid color data groups as the number of unified transmission data groups. The main STC8 microcontroller determines the difference between the number of uniformly transmitted data groups and the number of each local valid color data group as the number of local placeholder data groups for the corresponding STC8 microcontroller, and establishes the correspondence between the device address, the number of local valid color data groups, and the number of local placeholder data groups.
3. The intelligent LED strip control method based on the STC8 microcontroller as described in claim 2, characterized in that, The steps of establishing a virtual location mapping table, generating equal-length frame specifications, and establishing the current group operation record include: The main STC8 microcontroller determines the virtual lighting effect position corresponding to each local valid LED based on the virtual starting position, the number of local valid LEDs, and the LED arrangement direction of each STC8 microcontroller in the target device list, and writes the device address, local LED sequence number, and virtual lighting effect position into the virtual position mapping table. The main STC8 microcontroller collects the target device list, the number of unified transmission data groups, the number of local valid color data groups and local placeholder data groups corresponding to each STC8 microcontroller, the virtual position mapping table, the data bit timing configuration, the reset latch configuration, and the fixed value of the placeholder data, and generates the equal-length frame specification. The main STC8 microcontroller sends the equal-length frame specification to each STC8 microcontroller in the target device list. Each STC8 microcontroller generates a local equal-length frame configuration record according to the equal-length frame specification, performs a consistency check on the local equal-length frame configuration record, and generates an equal-length frame specification loading completion record when the consistency check passes. The main STC8 microcontroller determines the currently valid equal-length frame specification based on the equal-length frame specification loading completion records sent by all STC8 microcontrollers in the target device list for the same equal-length frame specification version. The main STC8 microcontroller establishes the current group operation record based on the current valid equal-length frame specification and the group operation recovery record.
4. The intelligent LED strip control method based on STC8 microcontroller as described in claim 1, characterized in that, The main STC8 microcontroller generates a lighting effect frame control record based on the most recently confirmed lighting effect phase in the current group's operation record, including: The main STC8 microcontroller reads the most recently confirmed lighting effect frame number, the most recently confirmed lighting effect phase, the current lighting effect mode, and the current lighting effect parameters from the current group's running record; The main STC8 microcontroller generates the current lighting effect frame number based on the most recently confirmed lighting effect frame number, and determines the common lighting effect phase based on the most recently confirmed lighting effect frame number, the most recently confirmed lighting effect phase, the phase advance amount in the current lighting effect parameters, and the phase full cycle value. The main STC8 microcontroller generates a lighting effect frame control record based on the current lighting effect frame sequence number, common lighting effect phase, current lighting effect mode, and current lighting effect parameters, and sends the lighting effect frame control record to each STC8 microcontroller in the target device list.
5. The intelligent LED strip control method based on STC8 microcontroller as described in claim 4, characterized in that, Each STC8 microcontroller generates a valid color data segment based on the virtual position mapping table, the common lighting effect phase in the lighting effect frame control record, and the lighting effect parameters, including: Each STC8 microcontroller reads the correspondence between the local LED sequence number and the virtual lighting effect position from the local equal-length frame configuration record, determines the virtual lighting effect position corresponding to each local valid LED, reads the common lighting effect phase from the lighting effect frame control record, and reads the phase full cycle value, spatial cycle length and color control point sequence from the lighting effect parameters in the lighting effect frame control record. Each STC8 microcontroller uses a virtual path phase coupling mapping algorithm to calculate the local LED phase corresponding to each local effective LED based on the common lighting effect phase, virtual lighting effect position, spatial period length, and phase full period value. Each STC8 microcontroller retrieves the color control point sequence based on the local LED phase, performs linear interpolation on the red, green, and blue channel values of the color control points, and generates the red, green, and blue channel values corresponding to each local valid LED. Each STC8 microcontroller generates a local valid color data group according to the local LED bead sequence number and color channel arrangement order. All local valid color data groups are arranged continuously to generate a valid color data segment.
6. The intelligent LED strip control method based on STC8 microcontroller as described in claim 1, characterized in that, The step of generating placeholder data segments based on the number of local placeholder data groups in the equal-length frame specification, and concatenating the placeholder data segments after the valid color data segments to form an equal-length lighting effect frame includes: Each STC8 microcontroller copies a fixed value of placeholder data according to the number of local placeholder data groups, generates a placeholder color data group with the same number of local placeholder data groups, and arranges all placeholder color data groups continuously to generate a placeholder data segment. When the placeholder data segment contains a placeholder color data group, each STC8 microcontroller will connect the placeholder data segment after the valid color data segment to form an equal-length light effect frame. When the placeholder data segment does not contain the placeholder color data group, each STC8 microcontroller will determine the valid color data segment as an equal-length light effect frame. Each STC8 microcontroller determines the total number of color data groups by summing the number of locally valid color data groups and the number of placeholder color data groups, and performs a consistency verification between the total number of color data groups and the number of unified transmission data groups.
7. The intelligent LED strip control method based on STC8 microcontroller as described in claim 6, characterized in that, After all equal-length lighting effect frames are prepared, the main STC8 microcontroller sends group-level synchronization trigger pulses, including: Each STC8 microcontroller loads the output parameters of the current lighting effect frame when the equal-length lighting effect frame is ready, generates an equal-length lighting effect frame ready completion record, and sends the equal-length lighting effect frame ready completion record to the main STC8 microcontroller. The main STC8 microcontroller establishes a correspondence between the equal-length lighting effect frame preparation completion record and each STC8 microcontroller in the target device list based on the device address, and performs equal-length lighting effect frame preparation completion verification on the equal-length frame specification version, the current lighting effect frame sequence number, and the total number of color data groups. When all the equal-length lighting effect frames corresponding to the STC8 microcontrollers in the target equipment list have passed the equal-length lighting effect frame preparation completion verification, the main STC8 microcontroller generates a group-level synchronization trigger pulse and sends the group-level synchronization trigger pulse to each STC8 microcontroller in the target equipment list through the group-level synchronization trigger line. Each STC8 microcontroller receives the group-level synchronization trigger pulse through the external interrupt input terminal and starts the local data output timer according to the local data bit timing counter group.
8. The intelligent LED strip control method based on the STC8 microcontroller as described in claim 7, characterized in that, Each STC8 microcontroller continuously outputs valid color data segments and placeholder data segments according to the equal-length frame specification. After the total number of output color data groups reaches the unified transmission data group number in the equal-length frame specification, a reset latch is executed, and a frame output completion record is generated, including: Each STC8 microcontroller outputs valid color data segments and placeholder data segments sequentially according to the local data bit timing counter group, and counts the total number of color data groups that have been output; When the placeholder data segment contains placeholder color data groups, each STC8 microcontroller keeps its local data output timer running continuously after the last color data bit of the valid color data segment is output, and reads and outputs the first color data bit in the placeholder data segment along the continuous storage address of the local lighting effect frame buffer in the next data bit cycle. When the total number of output color data groups reaches the unified transmission data group number, each STC8 microcontroller stops reading color data bits, keeps the data output terminal at a low level, and accumulates the reset latch process count. When the reset latch process count reaches the local reset latch count, each STC8 microcontroller generates a frame output completion record based on the equal-length frame specification version, the current lighting effect frame sequence number, the total number of output color data groups, the reset latch completion status, and the frame output status, and sends the frame output completion record to the main STC8 microcontroller.
9. The intelligent LED strip control method based on the STC8 microcontroller as described in claim 7 or 8, characterized in that, The main STC8 microcontroller completes the recording and execution of group-level frame confirmation based on the output of all frames. When the group-level frame confirmation is successful, it advances the common lighting effect phase and generates the next lighting effect frame based on the advanced common lighting effect phase. When the group-level frame confirmation fails, it maintains the lighting effect frame sequence number and common lighting effect phase, and re-outputs the current lighting effect frame, including: The main STC8 microcontroller determines the group-level frame confirmation result based on the target device list and the output record of each frame. When the group-level frame confirmation result is successful, the main STC8 microcontroller updates the most recently confirmed lighting effect frame sequence number, the most recently confirmed lighting effect phase, and the group operation recovery record. It generates the next lighting effect frame sequence number based on the most recently confirmed lighting effect frame sequence number, determines the common lighting effect phase after advancement by combining the most recently confirmed lighting effect phase, phase advance amount, and phase full cycle value, and generates the next lighting effect frame control record. When the group-level frame confirmation result is that the group-level frame confirmation is unsuccessful, the main STC8 microcontroller keeps the most recently confirmed lighting effect frame sequence number, the most recently confirmed lighting effect phase, the current lighting effect frame sequence number, and the common lighting effect phase unchanged, does not update the group operation recovery record, generates the current lighting effect frame re-output record, and sends the current lighting effect frame re-output record to each STC8 microcontroller in the target device list. Each STC8 microcontroller re-outputs the record to verify the current equal-length lighting effect frame in its local lighting effect frame buffer based on the current lighting effect frame. If the verification passes, the current equal-length lighting effect frame is retained. If the verification fails, the current equal-length lighting effect frame is regenerated based on the control record of the current lighting effect frame, and an equal-length lighting effect frame is generated to prepare for the completion of the record.
10. A smart LED strip control system based on an STC8 microcontroller, based on the smart LED strip control method based on an STC8 microcontroller as described in any one of claims 1 to 9, characterized in that, include: The specification construction module is used to collect the number of local valid LEDs, virtual starting position, and LED arrangement direction of each STC8 microcontroller, determine the number of unified transmission data groups and the number of local placeholder data groups; establish a virtual position mapping table, generate equal-length frame specifications and current group operation records; The lighting effect generation module is used to generate lighting effect frame control records based on the most recently confirmed lighting effect phase, and generate valid color data segments based on the virtual position mapping table, common lighting effect phase, and lighting effect parameters; it also generates placeholder data segments based on the number of local placeholder data groups and forms equal-length lighting effect frames. The synchronous output module is used to send group-level synchronous trigger pulses after all equal-length light effect frames are prepared, controlling each STC8 microcontroller to continuously output valid color data segments and placeholder data segments; after the total number of output color data groups reaches the unified transmission data group number, a reset latch is executed, and a frame output completion record is generated. The group-level confirmation module is used to perform group-level frame confirmation based on the completion record of all frame outputs. When the group-level frame confirmation is successful, the common lighting effect phase is advanced and the next lighting effect frame is generated. When the group-level frame confirmation is unsuccessful, the lighting effect frame number and the common lighting effect phase are maintained and the current lighting effect frame is re-output.