Intelligent lighting device multi-device synchronization anti-drift method and system

By employing a multi-level time compensation mechanism between master and slave devices, the animation drift problem caused by crystal oscillator frequency differences, thread scheduling fluctuations, network transmission delays, and polling processing delays in intelligent lighting devices is solved, achieving high-precision synchronous display of multiple devices and low communication overhead.

CN122179050BActive Publication Date: 2026-07-24SHENZHEN LINKLITE SMART LIGHTING CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
SHENZHEN LINKLITE SMART LIGHTING CO LTD
Filing Date
2026-05-12
Publication Date
2026-07-24

Smart Images

  • Figure CN122179050B_ABST
    Figure CN122179050B_ABST
Patent Text Reader

Abstract

A kind of intelligent lighting device multi-device synchronization anti-drifting method and system, main equipment obtains the accurate phase information of current animation, include current color unit index and unit has passed time;The main equipment carries out first level compensation to phase information according to the preset network delay compensation value, obtains first compensation after phase information, and sends synchronization package to all slave devices in local area network by multicast mode;Each slave device receives synchronization package and records the local time stamp of package, calculates the polling delay between the time stamp of package and current time at own frame cycle processing moment, carries out second level compensation to first compensation after phase information according to the polling delay;Each slave device jumps to the same animation position with main equipment according to second compensation after phase information Internal animation state.The present application effectively offsets network transmission delay and polling processing delay by master-slave device multi-level compensation mechanism, realizes multi-device high-precision synchronization, and is suitable for collaborative control scene such as intelligent lamp strip, bulb etc.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to intelligent lighting technology, and in particular to a method and system for preventing drift of multiple intelligent lighting devices simultaneously. Background Technology

[0002] With the rapid development of smart home technology, smart lighting devices are being used more and more widely in homes, businesses, and industries. To achieve more stunning visual effects, users often deploy multiple smart lighting devices in the same space, such as smart light strips and smart bulbs, and hope that these devices can display dynamic effects in sync, such as "screen-to-move" effects or music-rhythm effects.

[0003] In existing technologies, multiple smart lighting devices communicate via a local area network (LAN) and employ a master-slave architecture for collaborative control. One device acts as the master, responsible for receiving user commands and maintaining animation status; the other devices act as slaves, responsible for receiving commands from the master and executing corresponding animation effects. However, existing technologies suffer from the following technical problems: 1. Drift caused by crystal frequency difference: Each device's crystal oscillator has a slight frequency error. After running for a long time, the animation progress of different devices will accumulate deviation, eventually leading to animation desynchronization.

[0004] 2. Drift caused by thread scheduling differences: Due to changes in CPU scheduling and system load, the execution time of animation rendering threads on each device fluctuates, resulting in asynchronous animation frames on different devices.

[0005] 3. Impact of network transmission delay: When the master device sends a synchronization command to the slave device, the network transmission takes a certain amount of time, which causes the slave device to be behind the current state of the master device when it receives the command.

[0006] 4. Impact of polling processing delay: After receiving the synchronization command from the device, it needs to wait for the next frame cycle to process before the synchronization operation can be actually performed. This waiting time will also cause the accumulation of synchronization errors.

[0007] In summary, existing technologies lack a comprehensive compensation mechanism for various drift sources, such as crystal oscillator frequency differences, thread scheduling fluctuations, network transmission delays, and polling processing delays. This leads to a significant decrease in animation synchronization accuracy after prolonged operation of multiple devices, failing to meet users' demands for a high-quality experience in multi-device collaborative display. Therefore, it is necessary to provide a method and system for anti-drift synchronization of intelligent lighting devices that can effectively eliminate the aforementioned drift effects and achieve high-precision synchronization of multiple devices.

[0008] It should be noted that the information disclosed in the background section above is only for understanding the background of this application, and therefore may include information that does not constitute prior art known to those skilled in the art. Summary of the Invention

[0009] The main objective of this invention is to overcome the deficiencies in the aforementioned background technology and provide a method and system for multi-device synchronous anti-drift of intelligent lighting equipment.

[0010] To achieve the above objectives, the present invention adopts the following technical solution: A method for preventing drift of multiple devices in a smart lighting system during synchronization includes the following steps: S1. The master device obtains the precise phase information of the current animation, the phase information including at least the current color unit index and the elapsed time within the current color unit; S2. The master device performs a first-level compensation process on the phase information according to a preset network delay compensation value to obtain the first-compensated phase information; S3. The master device sends a synchronization packet containing the first compensated phase information to all slave devices in the local area network via multicast; S4. Each of the slave devices receives the synchronization packet and records the local timestamp of the received packet; S5. Each of the slave devices calculates the polling delay between the local timestamp of the received packet and the current frame loop processing time during its own frame loop processing time; S6. Each of the slave devices performs a second-level compensation on the first compensated phase information according to the polling delay to obtain the second compensated phase information; S7. Each of the slave devices jumps its internal animation state to the same animation position as the master device based on the second compensated phase information.

[0011] A multi-device synchronous anti-drift system for intelligent lighting equipment includes: One master device and multiple slave devices are all connected to the same local area network; The master device is configured to: acquire the precise phase information of the current animation, perform first-level compensation based on the network latency compensation value to generate a synchronization packet containing the compensated phase information, and send the synchronization packet to all slave devices in the local area network via multicast. The slave device is configured to: receive the synchronization packet and record the local timestamp of the received packet; calculate the polling delay between the received packet time and the current time during frame loop processing; perform a second-level compensation on the received phase information based on the polling delay; and jump the internal animation state to the same animation position as the master device based on the compensated phase information. The master and slave devices achieve high-precision synchronization of animation states across multiple devices through a multi-level time compensation mechanism. Furthermore, the master and slave devices utilize a three-level time compensation mechanism—comprising the first-level compensation, the second-level compensation, and a hold phase—to achieve accurate and stable high-precision synchronization of animation states across multiple devices.

[0012] The present invention has the following beneficial effects: This invention provides a method and system for preventing drift during multi-device synchronization in intelligent lighting equipment. Through a multi-level time compensation mechanism, it effectively solves the animation drift problem caused by various factors such as crystal oscillator frequency differences, thread scheduling fluctuations, network transmission delays, and polling processing delays after multiple devices have been running for a long time, achieving high-precision synchronized display across multiple devices. Specifically, on the master device side, a first-level compensation is performed on the phase information using a preset network delay compensation value to pre-offset the time delay of synchronization packets during local area network transmission. On the slave device side, a second-level compensation is performed by calculating the polling delay between the packet reception timestamp and the frame loop processing time, eliminating the waiting deviation from packet reception to actual synchronization execution. Furthermore, special processing during the hold phase truncates or modulo-wrappes the time exceeding the animation cycle after compensation, ensuring the smooth continuation of the animation loop. These three-level compensation mechanisms work together to comprehensively offset various sources of deviation affecting synchronization accuracy.

[0013] Building upon this foundation, the present invention further employs a periodic synchronization strategy. The master device automatically triggers synchronization operations at a preset synchronization period. This period can be dynamically determined based on the maximum error of the device's crystal oscillator frequency and the maximum allowable cumulative time error. This limits the phase deviation caused by crystal oscillator drift to a single synchronization period, avoiding cross-period accumulation, while simultaneously balancing synchronization effectiveness with network load and device power consumption. In terms of communication, the present invention uses UDP multicast to send synchronization packets. The master device only needs to send once to simultaneously update all slave devices within the local area network, significantly reducing communication overhead. The synchronization packets employ a lightweight protocol design, requiring only a small number of bytes to transmit complete phase information (including packet header, color unit index, elapsed time, and checksum field), effectively reducing network transmission load.

[0014] In summary, this invention is applicable to collaborative control scenarios of various intelligent lighting devices such as smart light strips, smart bulbs, and smart panel lights. It can maintain a high degree of consistency in the animation status of multiple devices during long-term operation, significantly improving the user's visual experience of dynamic lighting effects.

[0015] Other beneficial effects of the embodiments of the present invention will be further described below. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of the structure of the intelligent lighting device multi-device synchronous anti-drift system according to an embodiment of the present invention.

[0017] Figure 2 This is a schematic diagram of the synchronization process according to an embodiment of the present invention.

[0018] Figure 3 This is a flowchart of the time compensation process on the main device side according to an embodiment of the present invention.

[0019] Figure 4 This is a flowchart of the time compensation process on the slave device side according to an embodiment of the present invention.

[0020] Figure 5 This is a schematic diagram of the packet format of the synchronization packet according to an embodiment of the present invention.

[0021] Figure 6 This is a schematic diagram illustrating the drift cause analysis in an embodiment of the present invention.

[0022] Figure 7 This is a schematic diagram of the time compensation algorithm in an embodiment of the present invention.

[0023] Figure 8 This is a complete call flowchart of the SEEK interface according to an embodiment of the present invention.

[0024] Figure 9 This is a flowchart of the multi-mechanism compensation procedure according to an embodiment of the present invention.

[0025] Figure 10 This is a schematic diagram of the timeline for the synchronization packet processing in an embodiment of the present invention. Detailed Implementation

[0026] The embodiments of the present invention will be described in detail below. It should be emphasized that the following description is merely exemplary and not intended to limit the scope and application of the present invention.

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

[0028] This invention aims to solve the animation drift problem caused by multiple factors such as crystal oscillator frequency differences, thread scheduling fluctuations, network transmission delays, and polling processing delays in smart lighting devices. It proposes a multi-level time compensation synchronization method and system based on a master-slave architecture. The master device performs network delay pre-compensation for phase information, and the slave device performs secondary compensation based on the time difference between packet reception and frame loop. Furthermore, it can be combined with boundary processing in the hold phase to form a multi-level compensation mechanism, which comprehensively offsets various synchronization errors, achieves high synchronization accuracy, low communication overhead, and periodic automatic calibration, and can be widely applied to collaborative control scenarios such as smart light strips, bulbs, and panel lights.

[0029] See Figures 1 to 10 This invention provides a method for preventing drift of multiple intelligent lighting devices simultaneously, comprising the following steps: Step S1. The master device 1 obtains the precise phase information of the current animation, the phase information including at least the current color unit index and the elapsed time within the current color unit.

[0030] In some embodiments, the acquisition of precise phase information of the current animation by the master device in step S1 specifically includes: the master device maintaining the start time and index of the current color unit; and calculating the elapsed time within the current color unit based on the difference between the current system time and the start time of the current color unit.

[0031] Step S2. The master device 1 performs a first-level compensation process on the phase information according to a preset network delay compensation value to obtain the first compensated phase information.

[0032] In some embodiments, the first-level compensation process in step S2 specifically includes: adding the elapsed time in the current color unit to the network latency compensation value to obtain the elapsed time of the compensated unit; determining whether the elapsed time of the compensated unit exceeds the preset duration of the current color unit; if it exceeds, incrementing the index of the current color unit and deducting the preset duration of the current color unit from the elapsed time of the compensated unit to obtain the final first compensated phase information; wherein, each synchronization is only allowed to cross one color unit boundary.

[0033] In some embodiments, the network delay compensation value is a preset positive time offset, which is greater than the upper limit of the typical local area network single-way delay range, in order to ensure that the synchronization packet transmission delay can be offset under various network conditions and avoid insufficient compensation.

[0034] Step S3. The master device 1 sends a synchronization packet containing the first compensated phase information to all slave devices 2 in the local area network via multicast.

[0035] In some embodiments, the packet format of the synchronization packet includes at least: a header field for identifying the type of synchronization packet; a color unit index field for carrying the current color unit index; an elapsed time field for carrying the elapsed time of the current unit after the first compensation, which occupies two bytes; and a check field for verifying the synchronization packet data.

[0036] Step S4. Each of the slave devices 2 receives the synchronization packet and records the local timestamp of the received packet.

[0037] Step S5. Each slave device 2 calculates the polling delay between the local timestamp of the received packet and the current frame loop processing time during its own frame loop processing time.

[0038] Step S6. Each of the slave devices 2 performs a second-level compensation on the first compensated phase information according to the polling delay to obtain the second compensated phase information.

[0039] In some embodiments, the second-level compensation in step S6 specifically includes: adding the elapsed time of the unit in the first compensated phase information obtained from the synchronization packet to the polling delay to obtain the elapsed time of the unit after secondary compensation; determining whether the elapsed time of the unit after secondary compensation exceeds the preset duration of the current color unit, and if it does, truncating it to the preset duration; calculating the start time of the target color unit based on the difference between the current frame loop processing time and the elapsed time of the unit after secondary compensation, as a reference for jumping from the internal animation state of the device.

[0040] In some embodiments, the method further includes a holding phase processing step: after the second-level compensation, it is determined whether the elapsed time of the compensated unit is greater than or equal to the preset total duration of the animation cycle; if so, the elapsed time of the compensated unit is wrapped back to the range of the total duration of the animation cycle through modulo operation, or directly truncated to the total duration of the animation cycle, so as to realize the cyclical continuation of the animation cycle.

[0041] Step S7. Each of the slave devices 2 jumps its internal animation state to the same animation position as the master device 1 according to the second compensated phase information.

[0042] In some embodiments, the master device periodically executes steps S1 to S3 with a preset synchronization cycle. The synchronization cycle is dynamically determined based on the maximum error of the device's crystal oscillator frequency and the maximum allowable cumulative time error, and is used to limit the phase deviation caused by crystal oscillator drift within each synchronization cycle to avoid cross-cycle accumulation.

[0043] In some embodiments, the method further includes a master device self-synchronization step: while or after sending a synchronization packet, the master device calls an internal state jump interface based on the uncompensated original phase information obtained in step S1 to jump its own animation state to the position corresponding to the current phase information, so as to eliminate the drift caused by the master device itself due to crystal oscillator or thread scheduling.

[0044] In some embodiments, the slave device in step S7 calls a unified animation state jump interface, passes in the color unit index and the elapsed time within the unit from the second compensated phase information, and directly jumps the internal animation state to the same animation position as the master device; this jump operation is performed during the frame loop rendering process of the slave device, and after the jump, the start time of the current color unit is updated according to the current frame loop processing time and the elapsed time of the unit after the second compensation, as the timing reference for the subsequent frame loop.

[0045] This invention also provides a multi-device synchronization anti-drift system for intelligent lighting equipment, including a master device 1 and multiple slave devices 2, all connected to the same local area network (LAN). The master device 1 is configured to: acquire the precise phase information of the current animation; perform a first-level compensation based on a network latency compensation value to generate a synchronization packet containing the compensated phase information; and send the synchronization packet to all slave devices 2 within the LAN via multicast. The slave devices 2 are configured to: receive the synchronization packet and record the local timestamp of the received packet; calculate the polling delay between the received packet time and the current time during frame loop processing; perform a second-level compensation on the received phase information based on the polling delay; and jump the internal animation state to the same animation position as the master device 1 based on the compensated phase information. The master device 1 and slave devices 2 achieve high-precision synchronization of the animation states of multiple devices through a multi-level time compensation mechanism.

[0046] In a preferred embodiment, the master device and the slave device achieve high-precision synchronization of the animation states of multiple devices accurately and stably through a three-level time compensation mechanism consisting of the first-level compensation, the second-level compensation, and the holding phase processing.

[0047] The present invention proposes a method and system for multi-device synchronization and anti-drift of intelligent lighting equipment. Through a multi-level time compensation mechanism consisting of network latency compensation at the master device end, polling latency compensation at the slave device end, and boundary processing of the holding stage, it comprehensively offsets various synchronization errors such as crystal oscillator drift, thread scheduling fluctuations, network transmission and polling wait. It is further supplemented by a periodic synchronization strategy to limit error accumulation. Combined with UDP multicast and a lightweight protocol (requiring only 5-byte UDP multicast packets), it achieves low-overhead, highly robust, and accurate synchronization of multi-device animations.

[0048] The following further describes the implementation method and working process of specific embodiments of the present invention.

[0049] A method and system for multi-device synchronization and anti-drift in intelligent lighting equipment is disclosed. This method effectively solves the animation drift problem caused by long-term operation of multiple devices through a three-layer time compensation mechanism, achieving high-precision synchronized display of multiple devices. The specific implementation steps are as follows: The master device obtains precise phase information of the current animation, including the current color unit index and the elapsed time of the current unit; the master device performs a first-level compensation process on this phase information according to a preset network latency compensation value to obtain the first-compensated phase information; the master device broadcasts a synchronization packet containing the first-compensated phase information to all slave devices in the local area network via multicast; each slave device receives the synchronization packet and records its local timestamp, calculating the polling delay between the local timestamp and the frame loop processing time during frame loop processing; each slave device performs a second-level compensation on the first-compensated phase information based on the polling delay to obtain the second-compensated phase information; finally, each slave device jumps its internal animation state to the same animation position as the master device based on the second-compensated phase information.

[0050] In practice, the master device obtains accurate phase information by maintaining the start time and index of the current color unit, and then subtracting the start time of the color unit from the current time to calculate the elapsed time of the current unit. For the first level of compensation, the master device first adds the elapsed time of the current unit to the network latency compensation value to obtain the compensated time. If this time exceeds the duration of the current color unit, the color unit index is incremented by 1, and the corresponding unit duration is deducted from the compensated time. When the slave device performs the second level of compensation, it adds the elapsed time of the unit after the first compensation to the polling latency, and then subtracts the compensated time from the frame loop processing time to obtain the start time of the color unit.

[0051] The compensation process also includes a hold phase. When the time elapsed after compensation reaches or exceeds the preset animation cycle time, it is truncated to within the cycle time. The synchronization packet adopts a standardized format design, including a packet header field that identifies the packet type, an index field that carries the color unit index, a time field indicating the elapsed time after compensation, and a verification field to ensure data integrity.

[0052] In terms of parameter configuration, the network latency compensation value can be set to 200 milliseconds, and the period for the master device to send synchronization packets can be set to 1 hour. In the system architecture, the master device is equipped with phase acquisition, first-level compensation and broadcast modules, and the slave device is equipped with receiving, polling latency calculation, second-level compensation and state transition modules; the master device can also add a timer module to periodically trigger the transmission of synchronization packets, and the slave device can also be configured with a storage module to store the received phase information in local memory.

[0053] At the communication level, multicast transmission can use the UDP multicast protocol, and the master device can also send device location and scenario configuration information to the slave device through the data distribution module.

[0054] System Architecture As shown in Figure 1, at the system level, this solution adopts a master-slave architecture, consisting of one master device 1 and multiple slave devices 2. All devices are connected to the same local area network and complete synchronous data transmission through the UDP multicast protocol.

[0055] The main device is equipped with a timing module, a phase acquisition module, a first-level compensation module, and a broadcast module: the timing module triggers synchronization at a fixed period, the phase acquisition module collects the precise phase of the animation, the first-level compensation module completes network delay pre-compensation, and the broadcast module sends synchronization packets to all slave devices in the local area network via UDP multicast.

[0056] The device is equipped with a receiving module, a polling delay calculation module, a second-level compensation module, and a state transition module: the receiving module receives synchronization packets and records the packet receiving timestamp; the polling delay calculation module calculates the time difference from packet receiving to frame loop; the second-level compensation module completes polling delay correction; and the state transition module calls the animation transition interface to achieve state alignment with the master device.

[0057] Overall synchronization process The complete synchronization process of the equipment is shown in Figure 2 (synchronization process diagram). With periodic synchronization as the core, it sequentially completes phase acquisition, two-level compensation, multicast transmission, and state transition: 1. The main equipment automatically triggers synchronization operations according to a preset 1-hour cycle; 2. The master device obtains the precise phase information of the current animation, for example, color unit index=1, unit elapsed time=300ms; 3. The main device performs the first level of network latency compensation, adding a fixed compensation value of 200ms to the elapsed time; 4. The master device encapsulates the compensated phase information into a synchronization packet and sends it to all slave devices at once via UDP multicast; 5. Receive synchronization packets from the device and record the local packet reception timestamp; 6. From the device, enter frame loop processing and calculate the polling delay between the packet reception timestamp and the frame loop processing time; 7. The slave device completes the second-level compensation based on the polling delay to correct the phase information; 8. Call the SEEK animation state jump interface from the device to jump the internal animation state to a position completely consistent with the main device, and complete the process synchronously.

[0058] Master equipment time compensation process The execution logic of time compensation on the master device side is shown in Figure 3 (Master Device Side Time Compensation Flowchart), and the steps are as follows: 1. The process starts, and the main device obtains the current system time (now) and the start time of the current color unit (start). 2. Calculate the elapsed time for the current color unit: elapsed = now - start; 3. Determine if the elapsed time exceeds the preset duration of the current color unit: If it does, increment the color unit index by 1 and subtract the current color unit duration from the elapsed time; if it does not exceed the preset duration, proceed directly to the next step. 4. Perform the first-level network delay compensation, adding 200ms to the elapsed time to obtain the final compensated phase information; 5. Encapsulate the data according to the synchronization packet format (packet header 0xD2, color unit index, compensated elapsed time, CRC8 checksum), send the synchronization packet via UDP multicast, and the process ends.

[0059] Time compensation process from the device side The time compensation and state transition logic from the device side is shown in Figure 4 (time compensation flowchart from the device side), and the steps are as follows: 1. Receive synchronization packets from the device, record the packet reception time T1, and extract the color unit index and the elapsed time of the first compensated unit within the packet; 2. Wait for the frame loop to begin processing, and obtain the frame loop processing time T2; 3. Calculate the polling delay: poll_delay = T2 - T1; 4. Perform the second level of compensation by adding the elapsed time of the unit after the first compensation to the polling delay to obtain the elapsed time after the second compensation; 5. Hold-up phase processing: Determine whether the elapsed time after the second compensation is greater than or equal to the total duration of the animation cycle. If so, truncate it to the total duration of the animation cycle. 6. Calculate the start time of the target color unit: color_start = T2 - time elapsed after secondary compensation; 7. Call the SEEK interface to jump the internal animation state to the corresponding phase position and complete the synchronization.

[0060] The packet format of the synchronization package is as follows: Figure 5 As shown.

[0061] The synchronization packet uses a 5-byte lightweight encapsulation format. The length, value, and function definition of each field are as follows: 1. Packet header field: 1 byte in length, fixed value 0xD2, used to uniquely identify the type of synchronization packet and distinguish it from other communication messages.

[0062] 2. Color unit index field: 1 byte in length, with a value range of 0-255, used to carry the color unit index information of the current animation.

[0063] 3. Elapsed Time Field: 2 bytes in length, divided into two subfields, high 8 bits and low 8 bits, used to store the elapsed time (millisecond level) of the unit after the first level of compensation.

[0064] 4. CRC8 check field: 1 byte in length, which verifies the first 4 bytes of data to ensure that the data is complete and error-free during the transmission of the synchronization packet.

[0065] This format is extremely simple and efficient, requiring only 5 bytes to complete the transmission of phase information, effectively reducing the transmission load on the local area network.

[0066] Analysis of the causes of drift As shown in Figure 6, the animation drift of multiple devices in smart lighting is mainly caused by three core factors, and the specific sources of deviation are as follows: 1. Crystal frequency difference: Each device has a typical frequency error of ±50ppm in its built-in crystal oscillator. This error will continue to accumulate over time and eventually produce a phase deviation in the animation at the second level.

[0067] 2. Thread scheduling differences: Device CPU scheduling and system load changes can cause fluctuations in the execution time of animation rendering threads. The sleep function may jitter, resulting in uneven frame intervals. Based on a master-slave frame processing time difference of 2ms and 10 frames per second, the animation deviation can reach 72 seconds after the device runs continuously for 1 hour.

[0068] 3. Network transmission delay: There is a local area network transmission delay when the synchronization packet is transmitted from the master device to the slave device. The typical delay range is 1-50ms, which directly causes the slave device to be delayed in receiving phase information.

[0069] Time compensation algorithm principle Figure 7 The principle of the time compensation algorithm is demonstrated. This solution achieves precise alignment of animation states through hierarchical compensation at both the master and slave devices. The complete algorithm execution logic is as follows: 1. The master device first obtains the start time of the current color unit and the current system time. It calculates the elapsed time of the current color unit using the difference between the two, then adds a preset network delay compensation value to complete the first level of compensation. The compensated color unit index and the elapsed time are encapsulated into a synchronization packet and sent to the slave device via UDP multicast. A typical calculation example: the master device's current color unit start time is 500ms, the current system time is 800ms, and the calculated elapsed time is 300ms. After adding a 200ms network delay compensation, the elapsed time becomes 500ms, and the synchronization packet carries the unit index 1 and the elapsed time of 500ms.

[0070] 2. When receiving a synchronization packet from the device, record the packet reception time T1. Wait until the frame loop processing time to obtain the current time T2, and calculate the difference between T2 and T1 to obtain the polling delay. Add the elapsed time after the first compensation in the synchronization packet to the polling delay to complete the second level of compensation. Then, subtract the elapsed time after the second compensation from the frame loop processing time to obtain the target color unit start time. Finally, call the jump interface to achieve complete alignment with the animation state of the master device. In the above example, the polling delay is 20ms, the elapsed time after the second compensation is 520ms, and accurate synchronization is achieved by calculating the target color unit start time.

[0071] SEEK Interface Functionality and Calls The SEEK interface is an animation state transition interface provided by the Scene Show mode engine to the TBL layer. Its core function is to directly jump the internal motion effect state of the device to a specified phase position. It is mainly used for master-slave device synchronization and animation control driven by each frame time.

[0072] The SEEK interface for each scene mode adopts a unified function naming convention, with a fixed naming format of xxx_seek_to. The function input parameters are uniformly xxx_seek_to(uint8_t color_unit_index, uint32_t elapsed_ms). By passing in two sets of parameters, namely the target color unit index and the elapsed time in that unit, the animation jump target position can be accurately located.

[0073] The complete calling process of the SEEK interface is as follows: Figure 8 As shown, the process is divided into four stages: external triggering, engine preprocessing, frame loop execution, and state transition. The specific steps are as follows: 1. External Initiation of Call: The external caller sends a force resync request to the TBL engine; 2. Engine saves information: After receiving a request, the TBL engine saves the target phase information and sets the synchronization pending flag. 3. Frame loop detection execution: When entering the next frame rendering loop, the engine detects the synchronization flag to be processed and obtains the current frame loop processing time T2; 4. Delay Compensation Calculation: Calculate the polling delay based on the packet reception timestamp, complete the secondary compensation of phase information, and then set the SEEK transition state; 5. Execution state transition: Based on the current scene mode type, call the corresponding xxx_seek_to interface function to directly jump the internal animation state to the specified phase position. It can adapt to the synchronous transition of various scene animations such as windmills, halos, rays, kaleidoscopes, squares, tunnels, and sound waves.

[0074] Multi-level compensation mechanism The preferred embodiment of this invention employs a three-level compensation and processing mechanism to comprehensively offset synchronization deviations caused by network transmission, thread polling, and periodic overflow, thereby completely resolving the multi-device animation drift problem. The specific mechanism is as follows: 1. First-level compensation (master device): Before sending the synchronization packet, the master device pre-adds a network delay compensation value to the phase information to directly offset the local area network transmission delay of the synchronization packet.

[0075] 2. Second-level compensation (from the device): After the device receives the synchronization packet, it adds the polling delay from the time of packet reception to the time of frame loop processing to eliminate the waiting deviation from packet reception to actual synchronization execution.

[0076] 3. Third-level processing (holding phase): When the compensated time exceeds the total animation cycle duration, a modulo operation is performed to achieve the animation cycle loop, preventing the animation from stopping at the last frame.

[0077] Figure 9 The complete process of three-level compensation and processing is presented, divided into three stages: compensation at the master equipment end, compensation at the slave equipment end, and processing during the maintenance phase. The specific steps are as follows: 1. First-level compensation on the main equipment side (1) Obtain the current animation phase information: color unit index, unit elapsed time; (2) Perform network latency compensation: elapsed' = elapsed + T_net (T_net is the preset network latency compensation value); (3) Boundary judgment: If elapsed' ≥ the current color unit duration unit_time, increment index by 1 and deduct unit_time from elapsed'; if not, keep the current index and elapsed' directly. (4) Encapsulate the synchronization packet and send it to all slave devices via UDP multicast.

[0078] 2. Second-level compensation from the device side (1) Receive the synchronization packet and record the packet reception time T1; (2) Wait for frame loop processing and obtain the frame loop processing time T2; (3) Calculate the polling delay: poll_delay = T2 - T1; (4) Perform polling delay compensation: elapsed'' = elapsed' + poll_delay, and complete the second level of compensation.

[0079] 3. Third-level holding phase processing (1) Period judgment: If elapsed'' ≥ the total animation period cycle_time, perform the modulo operation elapsed'' = elapsed'' % cycle_time to achieve period wrap-around, and increment the color unit index accordingly; (2) Call the SEEK interface and, based on the final index and elapsed'', jump the internal animation state to the target position consistent with the main device to complete the full process synchronization.

[0080] In a preferred embodiment, the network latency compensation value is set to 200 milliseconds. This value is determined based on a combination of the pre-compensation mechanism, local area network latency characteristics, and actual adaptation requirements.

[0081] After the master device sends a synchronization packet, the transmission of the synchronization packet over the local area network will take time. When the slave device receives the synchronization packet, the animation state of the master device has already advanced by a network transmission delay compared to the time the packet was sent. To compensate for this transmission delay, the master device pre-adds a network delay compensation value to the elapsed time of the units in the phase information before sending the synchronization packet, so that after the slave device receives and processes the synchronization packet, it can accurately jump to the same animation state as the master device.

[0082] In a typical Wi-Fi LAN environment, the normal network one-way latency is 1-50 milliseconds. Network latency compensation values ​​can be determined in two ways: first, the master device periodically sends probe packets to measure the network round-trip latency and estimate the one-way latency, taking 1.5 to 2 times the estimated value as the compensation amount; second, it is derived based on statistical analysis of historical communication data from the device. This embodiment selects 200 milliseconds as an empirical compensation value. This value falls within the 50-500 millisecond range, far exceeding the upper limit of normal LAN latency, and can cover various network conditions such as network congestion and device sleep / wake-up, avoiding insufficient compensation.

[0083] The implementation logic is as follows: The master device first obtains the elapsed time of the original unit of the current animation, and then adds the time to the preset 200 millisecond network latency compensation value to obtain the pre-compensated unit elapsed time. This is used as the phase data carried in the synchronization packet to ensure that the animation state of the slave device is completely aligned with the animation state of the master device after the execution state jumps.

[0084] In a preferred embodiment, the synchronization period is set to 1 hour, which is determined based on a comprehensive calculation of the crystal oscillator drift cumulative error, the human eye perception threshold, and the equipment operating costs.

[0085] Crystal Oscillator Drift Accumulation Analysis: The crystal oscillators of smart lighting devices have an inherent frequency error of ±20-50ppm. This error accumulates over time, causing phase deviations in the animation. Based on standard duration calculations, the cumulative time error after one hour of operation with a 20ppm error is 72 milliseconds, and the cumulative time error after one hour of operation with a 50ppm error is 180 milliseconds.

[0086] Synchronization period calculation logic: The synchronization period is fixedly related to the maximum error of the crystal oscillator and the allowable cumulative error. The cumulative error is equal to the synchronization period length multiplied by the maximum error coefficient of the crystal oscillator. With the allowable maximum cumulative error of 180 milliseconds and the maximum crystal oscillator error of 50 ppm as calculation conditions, the upper limit of the synchronization period can be obtained as 3600 seconds, or 1 hour.

[0087] Crystal oscillator drift error accumulates linearly over time. The 180 millisecond deviation accumulated in 1 hour is within the range that is imperceptible to the human eye. Synchronization once per hour can effectively correct the drift. Too short a synchronization cycle will significantly increase network load and device power consumption. A 1-hour cycle minimizes synchronization overhead while ensuring synchronization effect. The system supports dynamic configuration of the synchronization cycle. For scenarios with higher requirements for synchronization accuracy, such as music rhythm, the cycle can be shortened to 10-30 minutes to adapt to different usage needs.

[0088] Experimental Example 1. Hardware Platform This solution is implemented using the Tuya T1-U series modules, with both the master and slave devices employing the Tuya T1-U-HL module as their core hardware unit. This module features a 120MHz ARM Cortex-M33 core BK7231N processor, 2MB Flash and 256KB SRAM, supports Wi-Fi + Bluetooth dual-mode communication, and operates at a voltage range of 3.0V~3.6V. The master device uses this module as its foundation, connecting to the local area network via Wi-Fi. The 2MB Flash is used to store scene configuration and layout data, and control signals are output to the smart LED strip via a UART interface. The slave device also uses this module; its Wi-Fi module is dedicated to receiving multicast synchronization packets from the local area network, its Flash stores dedicated scene data, and its UART interface drives the RGB LED strip to perform animation display.

[0089] 2. Core Data Structure The system defines four core data structures to carry key information such as animation configuration, color parameters, and synchronization status. The scene display configuration structure stores animation group ID, on / off status, brightness parameters, scene mode, unit running speed, unit switching time, background color, number of color groups, and animation color data. The color data structure stores color parameters such as hue (high and low bits), saturation, brightness, white light brightness, and color temperature to meet comprehensive color control requirements. The synchronization information structure maintains the current color unit start time, local timestamp of received packets, pending synchronization phase data, current color unit index, and synchronization request flag in real time, providing data support for latency compensation and frame loop synchronization. The synchronization phase information structure specifically stores the core phase data of the synchronization packet, including two key parameters: the target color unit index and the elapsed time within the target unit.

[0090] 3. Animation data format The animation uses color units as the smallest unit of execution. A complete animation cycle is composed of multiple color units combined in sequence. Each color unit contains three types of attributes: a fixed color value, duration, and transition method. Taking the red→green→blue gradient animation as an example, three independent color units can be set, each lasting 1000ms, for a total animation cycle of 3000ms. The actual duration of a color unit can be calculated as a percentage. Using 5000ms as the global cycle duration, multiplying the unit duration configuration percentage by the global cycle duration and then dividing by 100% will give the actual millisecond-level duration of a single color unit.

[0091] 4. Master equipment synchronization process implementation The master device triggers synchronization at a fixed interval of 1 hour, using 200ms as the network latency compensation value. The synchronization packet is encapsulated in a lightweight 5-byte format. The master device initiates the synchronization callback process via a timer. First, it checks if the animation is running; if not, synchronization is terminated directly. If running normally, it reads the color unit index and the elapsed time of the current animation, along with phase information such as the unit's elapsed time. Then, it performs network latency pre-compensation on the phase information, adding a 200ms compensation value to the original elapsed time. It then checks if the compensated time exceeds the current color unit's duration; if so, it increments the color unit index and deducts the corresponding unit's duration. A single synchronization is only allowed to cross one unit boundary. After compensation and boundary processing, the master device encapsulates the packet header, color unit index, compensated elapsed time, and CRC8 checksum into a synchronization packet and sends it to all slave devices via UDP multicast. Simultaneously, the master device uses the uncompensated original phase information to complete its own synchronization, eliminating drift caused by its own crystal oscillator and thread scheduling.

[0092] 5. Implement the device synchronization process. The slave device stores synchronization-related data through a synchronization information structure. When a synchronization request flag is detected, it enters the frame loop synchronization processing stage. First, it obtains the current system time and calculates the polling delay from packet reception to frame loop processing by combining it with the local timestamp of the received packet. The elapsed time of the compensated unit in the synchronization packet is added to the polling delay to complete secondary compensation. If the time after secondary compensation exceeds the duration of the current color unit, it is directly truncated to the upper limit of the unit duration. Then, the elapsed time of the compensated unit is subtracted from the frame loop processing time to calculate the start time of the target color unit. Finally, the SEEK interface of the corresponding scene mode is called to complete the precise jump of the animation state. The slave device's forced synchronization interface ensures data operation safety through a mutex lock. The target phase data is written into the synchronization information structure, the packet reception time is recorded, and the synchronization request flag is set. The flag is automatically cleared after the frame loop is read, ensuring the stable and orderly execution of the synchronization process.

[0093] Compensation boundary judgment, synchronization time axis and related parameters The boundary judgment of the elapsed time of the compensated unit follows a fixed logic. If the elapsed time of the compensated unit exceeds the duration of the current color unit, the index of the current color unit is incremented by 1, and the corresponding duration of the current color unit is subtracted from the elapsed time of the compensated unit. The color unit adopts a periodic execution mode. When the device enters the corresponding animation effect, the APP will send the animation period and FPS parameters to the main device. The period is used to define the runtime of a single color, and the FPS is used to determine the frame rate of the current color, i.e., the total number of frames. For example, if the color index is set to 0 to 5, the animation period is 500ms, and the FPS is 10 (fixed at 100ms per frame), then a single color will perform the index increment operation 5 times.

[0094] Complete processing of synchronization packets as follows Figure 10 The synchronization packet processing timeline is shown as follows: T0 is the moment the master device sends the synchronization packet. At this moment, the master device completes the current phase information acquisition and first-level compensation before sending the synchronization packet. T1 is the moment the slave device receives the synchronization packet. The slave device records its local timestamp seek_received_ms. T2 is the slave device's frame loop processing time. At this moment, the device obtains the current system time now_ms. T3 is the slave device's rendering time. The device completes rendering based on the animation state after the SEEK interface jump. The polling delay is the time difference between receiving the packet and the frame loop processing, calculated using the formula poll_delay = T2 - T1.

[0095] The system defines three core time variables to ensure synchronization accuracy. The color unit start time, `cur_color_start_ms`, is a millisecond-level timestamp of the current color unit's start time. The timing starting point is the actual start time of the color unit, not the system start time. Combined with the current time, the elapsed time of the current unit can be calculated using the formula: `elapsed = now - cur_color_start_ms`. This is used to calculate the target color unit's start time from the slave device, achieving perfect alignment with the animation position on the master device. The target color unit start time is calculated using the formula `target_color_start = T2 - compensated_elapsed`, where T2 is the slave device's frame loop processing time, and `compensated_elapsed` is the elapsed time of the unit after secondary compensation. This is used to determine the starting time point when the slave device should render the animation. The elapsed time of the current unit, `color_elapsed_ms`, refers to the elapsed duration from the start of the current color unit to the current moment. The timing starting point is recorded by `cur_color_start_ms`, and the calculation formula is the same as the elapsed time of the unit.

[0096] In the animation data structure, the duration of a color unit is determined by the `unit_time` configuration parameter, which is a variable parameter. It is converted to actual millisecond duration using the formula `unit_time_ms = (global cycle duration 5000ms × unit_time%) / 100%`. For example, when `unit_time` is configured to 20%, the actual unit duration is 1000ms. The animation sequence executes cyclically according to the color unit index. The total cycle duration is equal to the product of the number of units and the duration of a single unit. The current unit index is determined by a modulo operation, using the formula: `cur_index = (running time / unit_time_ms) % total_units`.

[0097] Network latency compensation and polling latency calculation Network latency compensation can lead to two types of discrepancies. If the actual network latency is only 5ms, a fixed compensation of 200ms will cause the slave device to jump to a position approximately 195ms ahead of the master device, resulting in overcompensation. If the network latency exceeds 200ms, insufficient compensation will occur, causing the slave device's animation state to lag behind the master device. This solution uses a fixed network latency compensation of 200ms primarily for three reasons: First, the synchronization period is set to 1 hour. Even if there is an error in a single synchronization, the next synchronization after 1 hour will automatically correct it, and the cumulative amount of a 195ms lead or lag error within a synchronization period is only tens of milliseconds. Second, after receiving the synchronization packet, the slave device needs to wait for frame loop processing. This waiting time, which is usually tens of milliseconds, will be corrected by the second-level polling latency compensation, which can offset the impact of network latency measurement errors to a certain extent. Third, in a home Wi-Fi environment, the actual network latency is usually between 10-50ms. 200ms is a conservative value to cope with the worst-case scenarios such as network congestion and device sleep / wake-up, which can minimize the problem of insufficient compensation.

[0098] The polling delay is calculated using a scheme that weakens the clock synchronization dependency. The polling delay is calculated by the slave device using the formula poll_delay_ms = now_ms - seek_received_ms, where now_ms and seek_received_ms are both based on the slave device's local clock. Therefore, the polling delay measurement result itself is accurate and reliable and is not affected by the clock deviation between the master and slave devices. The master-slave clock skew only affects the compensation calculation of the elapsed time of the unit sent by the master device, which is based on the master device's clock. This solution controls this error to a negligible range through three mechanisms: First, synchronization time skew is eliminated. During each synchronization, the slave device is forced to jump to the current phase position of the master device and update the start time of the color unit. The synchronization time directly clears all previously accumulated skew. Second, polling delay measurement is pure. The calculation of polling delay uses a single local clock source of the slave device throughout, ensuring accurate and unbiased calculations. Third, the synchronization period limits the accumulation limit. This solution has a synchronization period of 1 hour. Calculated with a crystal oscillator deviation of 50ppm, the maximum clock skew is approximately 180ms. Although this value is higher than the typical polling delay of 16-33ms, it is far below the human eye's perception threshold of approximately 200ms for light synchronization skew, and the skew will not accumulate across synchronization periods. Quantitative analysis shows that with a synchronization period of 1 hour and a crystal oscillator deviation of 50ppm, the maximum clock skew is 180ms. Each synchronization forces the slave device to reset to the master device's phase, completely preventing the skew from accumulating across periods.

[0099] The boundary processing after compensation first calculates the elapsed time of the compensated unit as the sum of the elapsed time of the unit carried by the synchronization packet and the polling delay. If the compensated time exceeds the preset duration of the current color unit, it is truncated to the duration of the current color unit. This setting can prevent the slave device from being located at an abnormal animation middle position due to the SEEK logic of the mode function during the animation holding phase, thus ensuring the stability and accuracy of animation rendering.

[0100] Application scenarios This solution is applicable to various intelligent lighting multi-device collaborative control scenarios. Specific application examples are as follows: Intelligent LED Strip Matrix Scene: Multiple intelligent LED strips are spliced ​​together to form a matrix screen, achieving synchronized animation display at the screen level. Music Rhythm Scene: Applied to entertainment venues such as bars and KTVs, intelligent lighting equipment flashes and rhythmically in sync with the music. Festive Decoration Scene: Multiple strings of intelligent LED lights are used for decoration during festivals such as New Year's, achieving a synchronized flashing effect. Architectural Lighting Project Scene: Multiple LED panel lights are deployed on the facade of large buildings, and this solution enables synchronized animation display of the overall lighting.

[0101] In summary, this invention addresses multiple drift factors in the synchronization of multiple devices in intelligent lighting, such as crystal oscillator frequency differences, thread scheduling fluctuations, network transmission delays, and polling processing delays. It proposes a multi-level time compensation synchronization method and system based on a master-slave architecture. Specifically, this invention performs network delay pre-compensation on phase information at the master device end, and performs secondary compensation for polling delay at the slave device end based on the difference between the packet reception timestamp and the frame loop processing time. Further boundary processing during the hold phase can be added, thus forming a multi-level compensation mechanism that comprehensively offsets various synchronization errors, achieving high-precision synchronized display after long-term operation of multiple devices.

[0102] Building upon this foundation, the present invention further employs a periodic synchronization strategy. A timer automatically triggers a complete synchronization operation every preset period (e.g., 1 hour), effectively limiting the cumulative impact of crystal oscillator drift. For communication, UDP multicast is used to send synchronization packets. The master device only needs to send once to simultaneously update all slave devices within the local area network. Furthermore, the synchronization packet uses a lightweight protocol, requiring only 5 bytes to transmit complete phase information, significantly reducing network load and device power consumption. This invention is applicable to collaborative control scenarios for various intelligent lighting devices such as smart light strips, smart bulbs, and smart panel lights. It can stably maintain a high degree of consistency in the animation states of multiple devices during long-term operation, significantly improving the user's dynamic visual experience.

[0103] The above description, in conjunction with specific / preferred embodiments, provides a further detailed explanation of the present invention. It should not be construed that the specific implementation of the present invention is limited to these descriptions. For those skilled in the art, various substitutions or modifications can be made to these described embodiments without departing from the inventive concept, and all such substitutions or modifications should be considered within the scope of protection of the present invention.

Claims

1. A method for synchronous anti-drift of multiple devices in intelligent lighting equipment, characterized in that, Includes the following steps: S1. The master device obtains the precise phase information of the current animation, the phase information including at least the current color unit index and the elapsed time within the current color unit; S2. The master device performs a first-level compensation process on the phase information according to a preset network delay compensation value to obtain the first-compensated phase information; S3. The master device sends a synchronization packet containing the first compensated phase information to all slave devices in the local area network via multicast; S4. Each of the slave devices receives the synchronization packet and records the local timestamp of the received packet; S5. Each of the slave devices calculates the polling delay between the local timestamp of the received packet and the current frame loop processing time during its own frame loop processing time; S6. Each of the slave devices performs a second-level compensation on the first compensated phase information according to the polling delay to obtain the second compensated phase information; S7. Each of the slave devices jumps its internal animation state to the same animation position as the master device based on the second compensated phase information; The method also includes a holding phase processing step: After the second level of compensation, determine whether the elapsed time of the compensated unit is greater than or equal to the preset total duration of the animation cycle; If so, the time elapsed for the compensated unit is wrapped back to the total duration of the animation cycle through modulo operation, or directly truncated to the total duration of the animation cycle, so as to achieve the cyclical continuation of the animation cycle.

2. The method as described in claim 1, characterized in that, The step S1, in which the main device acquires the precise phase information of the current animation, specifically includes: The master device maintains the start time and index of the current color unit; Calculate the elapsed time within the current color unit based on the difference between the current system time and the start time of the current color unit.

3. The method as described in claim 1, characterized in that, The first-level compensation process in step S2 specifically includes: Add the elapsed time within the current color unit to the network latency compensation value to obtain the elapsed time of the compensated unit; Determine whether the elapsed time of the compensated unit exceeds the preset duration of the current color unit; If the time exceeds the limit, the index of the current color unit is incremented, and the preset duration of the current color unit is deducted from the elapsed time of the compensated unit to obtain the final first compensated phase information; wherein, each synchronization is only allowed to cross one color unit boundary.

4. The method as described in claim 1, characterized in that, The second level of compensation in step S6 specifically includes: The elapsed time of the unit in the first compensated phase information obtained from the synchronization packet is added to the polling delay to obtain the elapsed time of the unit after secondary compensation; Determine whether the elapsed time of the second-compensated unit exceeds the preset duration of the current color unit. If it does, truncate it to the preset duration. The start time of the target color unit is calculated based on the difference between the current frame loop processing time and the elapsed time of the unit after secondary compensation, and is used as the reference for jumping from the internal animation state of the device.

5. The method as described in claim 1, characterized in that, The packet format of the synchronization packet includes at least: The header field is used to identify the type of synchronization packet; The color unit index field is used to carry the current color unit index; The Elapsed Time field carries the elapsed time of the current unit after the first compensation; this field occupies two bytes. The validation field is used to validate the data in the synchronization package.

6. The method as described in claim 1, characterized in that, The main device periodically executes steps S1 to S3 according to a preset synchronization cycle. The synchronization cycle is dynamically determined based on the maximum error of the device's crystal oscillator frequency and the maximum allowable cumulative time error. It is used to limit the phase deviation caused by crystal oscillator drift within each synchronization cycle and avoid cross-cycle accumulation.

7. The method as described in claim 1, characterized in that, The network delay compensation value is a preset positive time offset, which is greater than the upper limit of the typical local area network single-way delay range. It is used to ensure that the synchronization packet transmission delay can be offset under various network conditions and to avoid insufficient compensation.

8. The method as described in claim 1, characterized in that, This also includes the master device's own synchronization steps: While or after sending the synchronization packet, the master device calls its internal state jump interface based on the uncompensated original phase information obtained in step S1 to jump its animation state to the position corresponding to the current phase information, so as to eliminate the drift caused by the crystal oscillator or thread scheduling.

9. The method as described in claim 1, characterized in that, In step S7, the slave device calls a unified animation state jump interface, passes in the color unit index and the elapsed time within the unit from the second compensated phase information, and directly jumps the internal animation state to the same animation position as the master device. This jump operation is performed during the frame loop rendering process of the slave device, and after the jump, the start time of the current color unit is updated according to the current frame loop processing time and the elapsed time of the unit after the second compensation, which serves as the timing reference for subsequent frame loops.

10. A multi-device synchronous anti-drift system for intelligent lighting equipment, characterized in that, include: One master device and multiple slave devices are all connected to the same local area network; The master device is configured to: acquire the precise phase information of the current animation, perform first-level compensation based on the network latency compensation value to generate a synchronization packet containing the compensated phase information, and send the synchronization packet to all slave devices in the local area network via multicast. The slave device is configured to: receive the synchronization packet and record the local timestamp of the received packet; calculate the polling delay between the received packet time and the current time during frame loop processing; perform a second-level compensation on the received phase information based on the polling delay; and jump the internal animation state to the same animation position as the master device based on the compensated phase information. The slave device is further configured to: after the second level of compensation, perform a holding phase process: determine whether the elapsed time of the compensated unit is greater than or equal to the preset total duration of the animation cycle; if so, wrap the elapsed time of the compensated unit back to the range of the total duration of the animation cycle through modulo operation, or directly truncate it to the total duration of the animation cycle, so as to realize the cyclical continuation of the animation cycle; The master device and slave device achieve high-precision synchronization of animation states across multiple devices through a multi-level time compensation mechanism.