Starburst-based electronic paper image compression and picture brushing method and system
Patent Information
- Application Number
- CN202611023498.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-10
- Publication Date
- 2026-10-16
AI Technical Summary
[0006]本发明的目的是提供一种基于星闪的电子纸图像压缩刷图方法及系统,解决了现有BLE电子纸刷图带宽低、内存占用高、三色图层同步差、链路易断连、压缩效率不足的技术缺陷,实现了:
[0054] 1) High transmission efficiency and lower power consumption: Based on SLE large MTU link + five-level layered RLE compression, the compression ratio of solid color images reaches up to 5330:1, which greatly reduces the amount of wireless transmission data and reduces the number of fragmentation and retransmission power consumption; GBN cumulative acknowledgment reduces packet loss retransmission overhead.
Smart Images

Figure CN122933913A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the fields of wireless image transmission and three-color electronic paper display technology, and particularly to an electronic paper image compression and printing method and system based on star-flicker. Background Technology
[0002] Currently, electronic paper (e-ink screens) boasts advantages such as zero backlight, low power consumption, eye protection, and image retention even after power failure, making them widely used in electronic price tags, desktop signs, double-sided electronic posters, and industrial display terminals. Existing wireless image printing solutions mostly use BLE Bluetooth for image transmission, which suffers from the following core drawbacks: 1. Insufficient transmission bandwidth and high retransmission overhead: The BLE standard MTU is relatively small; a single-layer original image on an 800×480 three-color electronic paper is 48,000 bytes, resulting in numerous uncompressed image fragments. Retransmission after wireless packet loss is time-consuming and power-consuming. Conventional long-length RLE compression only adapts to single repetition lengths, leading to low compression efficiency in large-area solid-color electronic paper scenarios. 2. Poor wireless link reliability and uncontrolled power consumption: BLE connection intervals are mismatched with large-screen image transmission, causing link timeouts and disconnections during transmission congestion. 3. Lack of a continuous keep-alive mechanism, resulting in frequent disconnections during retransmission. 4. Lack of a unique device identifier, leading to broadcast conflicts when multiple devices are networked.
[0003] 2. Large terminal memory usage: Traditional solutions require receiving all image compression data completely, decompressing it as a whole, storing it in a large cache, and then driving the screen. This results in a large MCU RAM overhead, which is difficult for low-cost lightweight chips like WS63 to handle, and can easily lead to memory overflow and system crashes.
[0004] 3. Poor efficiency of synchronous refresh of three-color layers: Black, white and red electronic paper need to be written to the black and red two layers of video memory separately. Existing solutions often merge the layers for overall transmission. The asynchronous layer data is prone to screen distortion. The rendering logic of black and white and three-color modes is separated, resulting in code redundancy, complex scheduling, and hardware bus conflicts: Double-sided electronic paper shares the SPI drive bus and has no chip select mutual exclusion timing. Simultaneous operation of dual screens will cause SPI data disorder and display abnormalities.
[0005] SparkLink Low Energy (SLE) is a next-generation low-power wireless technology launched by the SparkLink Alliance. Compared with BLE, it has a larger MTU, lower latency, and higher concurrent reliability. However, there is currently no mature integrated solution for SLE transmission, compression, and streaming decompression that is suitable for layered printing on three-color e-paper. Therefore, there is an urgent need for a wireless e-paper printing system that is compatible with SLE links, features layered RLE compression, lightweight and reliable transmission, and low-memory streaming decompression. Summary of the Invention
[0006] The purpose of this invention is to provide a method and system for compressing and printing electronic paper images based on star-flicker technology. This method addresses the technical shortcomings of existing BLE electronic paper printing methods, such as low bandwidth, high memory consumption, poor synchronization of the three-color layers, frequent link disconnections, and insufficient compression efficiency. The invention achieves the following:
[0007] (1) A large MTU low-power wireless transmission link is built based on SLE Star Flash, and a lightweight Go-Back-N sliding window protocol is used to ensure lossless and reliable transmission of image data and reduce retransmission power consumption.
[0008] (2) Design a five-level variable length improved RLE layered compression algorithm to significantly compress the amount of transmitted data for the large area of solid color characteristics of electronic paper, and distinguish the black and red layers for independent encoding;
[0009] (3) A streaming byte-by-byte decompression mechanism is proposed, and the global complete decompression cache is cancelled, which greatly reduces the RAM usage of the WS63 terminal and improves the real-time rendering speed;
[0010] (4) Adopting a black and red double buffer layered storage architecture, unifying the black and white / three-color rendering path, simplifying task scheduling, and avoiding screen tearing due to layer asynchrony;
[0011] (5) Generate a unique device identity based on Die-ID hash, fix the SLE broadcast / connection parameters, and combine layered keep-alive and watchdog tasks to ensure long-term stable low-power operation;
[0012] (6) Implement SPI bus chip select mutual exclusion timing to solve the conflict problem of double-sided electronic paper sharing the bus and standardize the power-on, refresh and sleep hardware timing of three-color electronic paper.
[0013] To achieve the above-mentioned objectives, the technical solution adopted by this invention is as follows:
[0014] An electronic paper image compression and printing system based on SLE (Sparkling Electron Lighting) includes a transmitter, an SLE SLE wireless link, and a WS63 receiver terminal.
[0015] The transmitting end is used to perform layered processing on the original three-color electronic paper image, and to perform improved five-level variable-length RLE compression on the black layer and red layer respectively to generate layered compressed data packets, and encapsulate the image transmission frame according to the Go-Back-N frame format through the SLE GATT Write interface and send it down;
[0016] The SLE Star Flash wireless link is configured with fixed broadcast and connection parameters, providing a low-power, large-MTU wireless transmission channel to carry image data frames and bidirectional notification ACK messages;
[0017] The WS63 receiving terminal includes a layered software architecture, comprising, in sequence, an application entry layer, an initialization orchestration layer, a communication layer, a protocol layer, a rendering bridge layer, a driver layer, and a hardware abstraction layer.
[0018] The communication layer includes a sle_server.c communication service module, which is used to receive image frames sent from the SLE link and complete the 0xA5 frame header verification.
[0019] The protocol layer includes an img_msg.c module, which implements a lightweight Go-Back-N reliable transmission protocol with a window size of 6. It maintains only a single expected sequence number expect_seq, discards out-of-order frames directly, and returns cumulative acknowledgments (ACKs) for in-order frames.
[0020] The rendering bridge layer epd_ble.c constructs an independent image processing message queue to asynchronously schedule rendering tasks;
[0021] The driver layer integrates the epd_rle.c streaming decompressor and the epd_driver.c electronic paper hardware driver; the streaming decompressor parses the RLE compressed stream byte by byte, and the decoded output bytes are directly written to the SPI bus without allocating a global complete decompression buffer;
[0022] The receiving terminal is configured with a black-red double buffer storage structure. In the three-color mode, the black layer compressed data is cached first, and the red layer compressed data is cached after the cache is completed. The two layers of data are merged and rendered after they are ready. In the black-and-white mode, the pre-coded all-zero red layer RLE data packets are reused, and the same three-color rendering path is reused.
[0023] The driver layer completes SPI bus mutual exclusion chip selection, panel power-on, layer display memory writing, 0x12 refresh trigger and deep sleep control according to the three-color electronic paper hardware timing sequence.
[0024] The receiving terminal returns a link keep-alive frame, an image reception ACK, and a rendering completion notification message to the sending end through the SLE Notify channel.
[0025] As an improvement, the improved five-level variable-length RLE compression includes five types of packet coding units:
[0026] LITERAL type tag 0x00~0x7F, raw data output directly, maximum length 128B;
[0027] REPEAT_SHORT type tag 0x80~0xBF, short repeating pixels;
[0028] REPEAT_MEDIUM type tag 0xC0~0xDF, medium-length repetition;
[0029] REPEAT_LONG type tag 0xE0, long solid color block;
[0030] REPEAT_EXTRA_LONG type tag 0xF0, full-screen ultra-long solid color block;
[0031] Each compressed data packet has a 4-byte big-endian header that stores the original layer byte length for pre-allocating resources during streaming decoding.
[0032] As an improvement, the unified format of the Go-Back-N frame includes: 1B frame header 0xA5, 1B message type Type, 1B sequence number Seq, 2B little-endian payload length, and 0~480B image payload.
[0033] The message types include host-sent IMG_START, IMG_DATA, and IMG_END, and device-sent IMG_ACK, IMG_RENDER_DONE, and bidirectional IMG_KEEPALIVE.
[0034] The IMG_START frame payload is fixed at 6 bytes, carrying the protocol version, transmission window size, total transmission length, and 8-bit cumulative checksum.
[0035] As an improvement, the fixed parameters of the SLE link include: broadcast interval 850ms, connection interval 125ms, connection monitoring timeout 5000ms, MTU=520B, and broadcast channels CH0 / CH1 / CH2; the device generates a unique Device ID based on the Die-ID using FNV1a-64 hash, derives the link address and device name, and injects them into the broadcast packet.
[0036] As an improvement, the WS63 receiving terminal has a built-in multi-priority task scheduling feature:
[0037] watchdog_task (priority 5, 5s cycle) Independent hardware watchdog keep-alive;
[0038] EpdTestTask (priority 10) completes device identity injection and full module serial initialization upon power-up;
[0039] img_process_task (priority 14, message-driven) handles image message queues, buffer management, and rendering scheduling;
[0040] The keepalive_task (priority 30, 1s cycle) continuously sends SLE keepalive frames during rendering blocking to prevent the link from being disconnected.
[0041] As an improvement, the streaming decompression mechanism process is as follows: parse the compressed stream 4B Header to obtain the original layer size, parse the five-level RLE Packet byte by byte, write each byte of pixel data decoded to the SPI hardware interface immediately via callback, write the black layer data to the 0x10 memory and invert the bits, write the original red layer data to the 0x13 memory, send the 0x12 refresh command after all data is written, and cyclically read the BUSY pin until it is idle before executing panel power-off and deep sleep.
[0042] As an improvement, double-sided electronic paper uses a shared SPI bus and a chip select mutual exclusion mechanism:
[0043] Only the target screen's CS pin is pulled low, while the other side's CS pin remains high. The chip select is released after a single byte transmission is completed to avoid bus conflicts.
[0044] As an improvement, a star-flash-based electronic paper image compression and printing method, applied to the system described in any one of claims 1 to 7, is characterized by comprising the following steps:
[0045] S1. System power-on initialization: Create watchdog timer, link keep-alive, and e-paper main task; load device Die-ID hash to generate unique identity; configure GPIO / SPI hardware interface; initialize e-paper driver; start SLE broadcast and GATT service; create image message queue and enter idle waiting state;
[0046] S2. Layered image compression at the sending end: The original three-color image is split into a black layer and a red layer, and each layer is independently compressed using a five-level variable-length RLE algorithm to generate a black layer compressed stream and a red layer compressed stream.
[0047] S3 and SLE reliable transmission: The sending end sends IMG_START, multi-frame IMG_DATA, and IMG_END layered data packets sequentially according to the GBN frame format via SLE GATT Write, with a maximum of 6 frames concurrently in the sliding window;
[0048] S4. Receiver layered buffer: After the communication layer verifies the frame header, it is sent to the GBN protocol layer. Frames in order are stored in the black buffer / red buffer. Out-of-order frames are discarded directly and the current expected sequence number ACK is replied. In the three-color mode, the red layer data is received after the black layer buffer is completed. In the black-and-white mode, the pre-coded all-zero red layer RLE is directly loaded.
[0049] S5, Streaming Decompression and Rendering: The scheduling task retrieves the dual-layer compressed stream, calls the streaming RLE decompressor to decode it byte by byte, and directly outputs it to the SPI bus to write to the corresponding display memory area of the electronic paper; sends a refresh command, and waits for BUSY to be released to complete the image display;
[0050] S6. Feedback and Resource Release: After rendering is complete, IMG_RENDER_DONE is sent to the sender via SLE Notify; double buffer memory is released, the electronic paper enters deep sleep, and the system returns to an idle state to wait for the next frame of image transmission.
[0051] As an improvement, in step S4, the Go-Back-N receiver state machine only maintains a single expect_seq variable, and the states are divided into Idle, B_Receiving (black layer reception), B_Done (black layer ready), R_Receiving (red layer reception), R_Done (double layer ready), Render, and Cleanup (resource release). When the new image START frame arrives, the residual buffer is automatically released to complete the abnormal recovery.
[0052] As an improvement, the compression effect in step S2 is adapted to electronic paper image scenarios: the compression ratio of solid color images can reach 5330:1, the compression ratio of images with logo backgrounds is about 24:1, the compression ratio of text pages is about 16:1, the compression ratio of natural texture images is 4.8:1, and the compression ratio of high-frequency alternating pixel images is 1:1.
[0053] The beneficial effects of this invention are as follows:
[0054] 1) High transmission efficiency and lower power consumption: Based on SLE large MTU link + five-level layered RLE compression, the compression ratio of solid color images reaches up to 5330:1, which greatly reduces the amount of wireless transmission data and reduces the number of fragmentation and retransmission power consumption; GBN cumulative acknowledgment reduces packet loss retransmission overhead.
[0055] 2) Extremely low terminal memory usage: Streaming byte-by-byte decompression eliminates the need for global image caching, eliminating the need to allocate a 48,000-byte single-layer buffer. The small-memory WS63 chip operates stably, preventing memory overflow crashes.
[0056] 3) Synchronized and stable display of three-color layers: Black and red layers are transmitted independently with double buffering. The data of both layers is refreshed in a unified manner after they are complete to avoid layer misalignment and screen tearing. Black and white / three-color layers reuse the same rendering path, making the code concise and easy to maintain.
[0057] 4) High reliability and low power consumption of wireless links: Based on Die-ID hash for unique device identification, broadcast without conflict; fixed SLE low power connection parameters, 1-second cycle independent keep-alive task to prevent rendering blocking and disconnection; independent watchdog to ensure the system does not reset.
[0058] 5) Strong hardware compatibility: Standardized three-color electronic paper complete driving timing, SPI chip select mutual exclusion solves bus conflicts of double screen; hardware abstraction layer unifies peripheral interface, adapting to a variety of e-ink screens and MCU platforms.
[0059] 6) High real-time performance: The receiving, decompression, and SPI output pipelines are executed in parallel, with no data copying waiting, which greatly reduces the overall image refresh time and is suitable for high-frequency updating electronic paper signage scenarios. Attached Figure Description
[0060] Figure 1System overview block diagram of this invention (transmitter, SLE star link, WS63 receiver terminal);
[0061] Figure 2 : A schematic diagram of the seven-layer software layering architecture of the WS63 terminal in this invention;
[0062] Figure 3 : Internal architecture diagram of SLE communication and GBN transmission protocol in this invention;
[0063] Figure 4 : A diagram of the layered architecture for driving electronic paper displays in this invention;
[0064] Figure 5 : A complete power-on initialization flowchart of the terminal system in this invention;
[0065] Figure 6 : A schematic diagram illustrating the complete end-to-end image data stream flow in this invention;
[0066] Figure 7 : A schematic diagram of the overall structure of the five-level variable-length RLE compressed package in this invention;
[0067] Figure 8 : A schematic diagram of the Go-Back-N unified data frame format in this invention;
[0068] Figure 9 : Finite state machine transition diagram of the GBN receiver in this invention;
[0069] Figure 10 : Flowchart of the hardware driver for RLE streaming decompression and byte-by-byte output in this invention;
[0070] Figure 11 : Flowchart of the black-red double-buffered state machine in this invention;
[0071] Figure 12 : Flowchart of the initialization timing of the three-color electronic paper panel in this invention;
[0072] Figure 13 : Timing diagram of double-sided electronic paper SPI chip select mutual exclusion in this invention;
[0073] Figure 14 : Flowchart of electronic paper refresh and deep sleep operation in this invention;
[0074] Figure 15 : A diagram of the structure of the Star Flash Broadcast Announce + Scan Response Message in this invention. Detailed Implementation
[0075] To facilitate a clearer understanding of the present invention, the technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Identical components are denoted by the same reference numerals. It should be noted that the terms "front," "rear," "left," "right," "up," and "down" used in the following description refer to directions in the accompanying drawings, while the terms "inner" and "outer" refer to directions toward or away from the geometric center of a specific component, respectively.
[0076] The technical solutions in the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not all of them. Based on the embodiments in this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0077] It should be noted that the terms "first" and "second" in this application are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of indicated technical features. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include at least one of that feature. In the description of this application, "multiple" means at least two, such as two, three, etc., unless otherwise explicitly specified. Furthermore, the terms "comprising" and "having," and any variations thereof, are intended to cover non-exclusive inclusion. For example, a process, method, system, product, or apparatus that includes a series of steps or units is not limited to the listed steps or units, but may optionally include steps or units not listed, or may optionally include other steps or units inherent to these processes, methods, products, or apparatuses.
[0078] like Figures 1-13 As shown, an electronic paper image compression and printing system based on SLE (Sparkling Electron Lighting) consists of three parts: a transmitter, an SLE wireless link, and a WS63 receiver terminal.
[0079] Sending end: Host computer, which completes image layering, five-level RLE compression, GBN frame encapsulation, and SLE GATT data transmission;
[0080] SLE Star Flash Wireless Link: SSAPS application layer protocol stack, configured with MTU=520B, 125ms connection interval, 850ms broadcast interval, carrying image data frames and bidirectional Notify notifications;
[0081] WS63 receiver terminal: Seven-layer layered software architecture, from top to bottom: application entry layer, initialization orchestration layer, communication layer, protocol layer, rendering bridge layer, driver layer, hardware abstraction layer, hardware driver for 7.5-inch 800×480 black, red and white three-color electronic paper, supporting double-sided SPI time-division drive.
[0082] Functions of core modules at each layer:
[0083] 1) Application entry layer test_entry.c: System startup, multi-task creation, watchdog and link keep-alive registration;
[0084] 2) Initialize orchestration layer dual_tricolor_test.c: serial coordination hardware, communication, and driver module initialization process;
[0085] 3) Communication layer sle_server.c, sle_server_adv.c: SLE service creation, device broadcasting, GATT data reception, frame header verification;
[0086] 4) Protocol layer img_msg.c: Window N=6 simplifies the Go-Back-N receiver, sequence number verification, cumulative ACK, and state machine management;
[0087] 5) Rendering bridge layer epd_ble.c: Image message queue, double buffer state scheduling, rendering task distribution;
[0088] 6) Driver layer epd_driver.c, epd_rle.c: Electronic paper hardware timing, five-level RLE streaming decompression, SPI data output;
[0089] 7) Hardware Abstraction Layer dev_config.c: Unifies GPIO and SPI hardware access interfaces, shielding the differences in underlying hardware.
[0090] 1. Improved five-level variable-length RLE layered compression algorithm
[0091] The sending end splits the original image into two independent layers, a black layer and a red layer, and performs RLE encoding on each layer. A 4-byte big-endian header is added to the beginning of the compressed packet to record the original byte length of each layer. Five scenarios are defined where the packet covers all pixels in a repetitive manner:
[0092] 1) LITERAL (0x00~0x7F): Scattered, non-repeating pixels, directly output raw bytes, maximum 128B per output;
[0093] 2) REPEAT_SHORT (0x80~0xBF): Short, monochromatic repeats;
[0094] 3) REPEAT_MEDIUM (0xC0~0xDF): Medium-length color block;
[0095] 4) REPEAT_LONG (0xE0): Long segment of solid color region;
[0096] 5) REPEAT_EXTRA_LONG (0xF0): Full-screen solid color background, supports tens of millions of pixels of repeated encoding.
[0097]
[0098] Compression efficiency is quantified by the B / run metric, adapting to typical e-paper scenarios: the compression ratio of solid color posters can reach 5330:1, graphic logo pages 24:1, and plain text 16:1, significantly reducing the number of bytes transmitted wirelessly via SLE.
[0099] 2. Lightweight Go-Back-N Reliable Transmission Protocol
[0100] The protocol layer implements a simplified GBN receiving logic, with a fixed transmitting window of 6. The receiving end only maintains a single expected_seq sequence number, eliminating the need for a sliding window buffer and reducing MCU resource consumption.
[0101] Unified transmission frame structure: 0xA5 frame header (1B) + Type (1B) + Seq sequence number (1B) + Payload length (2B little endian) + image payload (0~480B), with a maximum of 485B per frame, matching SLE 520B MTU;
[0102] The frame type distinguishes downlink transmission commands (IMG_START / IMG_DATA / IMG_END), uplink feedback (IMG_ACK / IMG_RENDER_DONE), and bidirectional keepalive (IMG_KEEPALIVE).
[0103] The IMG_START frame carries the protocol version, window size, total transmission length, and 8-bit cumulative checksum, and is used for session initialization verification.
[0104] Transmission process: The sending end sends START → multiple consecutive DATA frames → the receiving end replies with ACK in sequence → all data transmission is completed and END is reached; if no ACK is received within the timeout period, the sending end backtracks and retransmits the earliest unacknowledged frame; out-of-order frames are discarded and the current expect_seq is returned for acknowledgment.
[0105] 3. Black-red double-buffered hierarchical caching and mode compatibility mechanism
[0106] The receiving terminal sets up two independent compressed data buffers, g_image_buffer (black layer) and g_image_buffer_red (red layer). The state machine transition logic is as follows:
[0107] 1) Idle: No buffer is occupied, waiting for the SLE IMG_START frame;
[0108] 2) B_Receiving: Receives compressed data from the black layer and stores it in the black buffer. Once reception is complete, sets the B_Done flag.
[0109] 3) Three-color mode: After B_Done, enter R_Receiving to receive red layer data and store it in the red buffer; in black and white mode, directly jump to black and white rendering;
[0110] 4) R_Done: Double-layer cache is ready; call the three-color merge rendering interface.
[0111] 5) Black and white mode optimization: Reuse the pre-encoded 5-byte all-zero REPEAT_EXTRA_LONG red layer RLE data packet, share the same three-color rendering function, eliminate the need for a separate black and white decompression path, and simplify code maintenance.
[0112] After rendering is complete, both buffer memory blocks are released uniformly, a rendering completion notification is reported, and the process returns to the Idle state. Residual cache is automatically released before new image transmission begins, enabling self-recovery from anomalies.
[0113] 4. RLE streaming decompression low-memory mechanism
[0114] The driver layer epdRleDecodeStream() implements byte-by-byte streaming decoding. Its core innovation is that it does not buffer the complete decompressed image, but outputs pixel data to SPI while parsing the RLE byte stream.
[0115] 1) Read the compressed stream 4B header to obtain the total number of original pixel bytes of the layer;
[0116] 2) Loop through single-byte tags, match them with five-level Packet types, and parse the repeat length and pixel value;
[0117] 3) After decoding 1 byte of pixel data, immediately call epdSendData to write it to the SPI hardware;
[0118] 4) The black layer pixels are bitwise inverted and written to the electronic paper's memory address 0x10, and the original red layer data is written to the memory address 0x13.
[0119] 5) After all the data from both layers has been sent, send the 0x12 refresh command and read the BUSY pin repeatedly until the refresh is complete;
[0120] 6) Execute 0x02 power-off and 0x07+0xA5 deep sleep to reduce static power consumption.
[0121] This mechanism completely eliminates the need for a full image decompression buffer, reducing RAM usage by over 90%, and is compatible with low-cost MCUs with small memory, such as the WS63.
[0122] 5. SLE Device Identification and Low-Power Link Parameters
[0123] The device reads the Die-ID at the factory, generates a 64-bit unique Device ID through FNV1a-64 hash, derives the SLE link address and device name, and writes it into the broadcast AD data packet to achieve conflict-free discovery of multiple devices.
[0124] Fixed link parameters for battery-powered, low-power scenarios:
[0125] Broadcast interval 850ms, connection interval 125ms, connection monitoring timeout 5000ms, maximum delay 499 events, broadcast channels CH0 / 1 / 2, connectable and scannable broadcast mode;
[0126] The terminal has a built-in independent keepalive_task (1-second cycle) that continuously sends bidirectional keepalive frames during image rendering blocking to avoid transmission timeouts and disconnections; and an independent 5-second cycle watchdog task that kicks the watchdog normally when rendering is blocked to prevent system hardware reset.
[0127] 6. Double-sided electronic paper SPI mutual exclusion and timing standardization
[0128] The hardware abstraction layer unifies the SPI 16MHz timing with CPOL=0 / CPHA=0; double-sided electronic paper shares the SPI bus, with chip select mutual exclusion rules: at any given time, only one screen's CS pin is pulled low, while the other screen remains high; after a single byte SPI transmission is completed, the CS pin is pulled high to release the bus, completely eliminating bus data conflicts;
[0129] Standardized three-color electronic paper complete operation sequence: hardware reset → power setting → power on and wait for BUSY → panel parameter configuration → 800×480 resolution writing → layer data distribution → 0x12 refresh → wait for BUSY release → panel power off → deep sleep.
[0130] Complete steps of the image brushing method of this invention
[0131] S1 terminal power-on initialization:
[0132] Create four priority tasks: watchdog_task, EpdTestTask, img_process_task, and keepalive_task; read the Die-ID hash to generate a unique device ID; initialize GPIO and SPI hardware; execute the electronic paper panel reset power-on sequence; start SLE broadcast and GATT services; create an image message queue and enter Idle idle waiting.
[0133] S2 transmitter image layered compression:
[0134] The host reads the original three-color bitmap, splits it into independent black and red layers, and performs five-level variable-length RLE encoding on each layer to generate two layered compressed byte streams.
[0135] S3 SLE Star Flash Reliable Layered Transmission:
[0136] The transmitting end encapsulates GBN frame sequences for the black and red layers respectively, and sends IMG_START, multiple frames of IMG_DATA, and IMG_END in sequence; the SLE GATT channel is fragmented and sent, with a maximum of 6 frames sent in parallel in a sliding window; the receiving end sle_server.c verifies the 0xA5 frame header, and sends valid frames to the img_msg.c protocol module.
[0137] S4 GBN ordered reception and double buffered storage:
[0138] The protocol layer verifies the Seq sequence number. If it matches expect_seq, it stores the corresponding black / red buffer and marks the layer as ready. Out-of-order frames are discarded and the current expect_seq is returned as IMG_ACK. In the three-color mode, the double-layer buffer is waited for to be ready. In the black and white mode, the pre-encoded all-zero red layer RLE is loaded.
[0139] S5 streaming RLE decompression and SPI-driven rendering:
[0140] The img_process_task schedules the rendering process, calls the streaming decompressor to parse the black and red compressed streams byte by byte, and outputs pixel data to the corresponding display memory of the electronic paper in real time to the SPI bus; after all layers are written, the 0x12 refresh is triggered, and the BUSY pin is polled in a loop to wait for the refresh to finish.
[0141] S6 Feedback Reporting and Resource Release / Hibernation:
[0142] After the refresh is complete, an IMG_RENDER_DONE notification is sent to the host via SLE Notify; osal_vfree releases the black and red buffer memory; and an electronic paper power-off and deep sleep command is sent, returning the system to Idle state and waiting for the next frame of image transmission. Detailed Implementation
[0143] Example 1: 7.5-inch 800×480 three-color single-sided electronic paper printing system
[0144] Hardware configuration: Transmitter PC host; Wireless link StarSpark SLE module; Receiver terminal main controller WS63; Display panel Waveshare 7.5-inch three-color electronic paper, single layer raw data 48000 bytes, SPI clock 16MHz, CPOL=0 / CPHA=0.
[0145] Step 1: Terminal power-on initialization:
[0146] Start four scheduled tasks, in order of priority from low to high: watchdog_task(5), EpdTestTask(10), img_process_task(14), keepalive_task(30); read the chip Die-ID and generate a 64-bit DeviceID using FNV1a-64; configure SPI and GPIO pins; execute the electronic paper hardware reset timing (RST pulled low for 2ms and then high for 200ms); issue power setting and resolution 0x61 instructions; start SLE broadcast (interval 850ms) and GATT service; create an image message queue and enter Idle.
[0147] Step 2: Host-level layered RLE compression:
[0148] Import the graphic poster image (large white background + black text + a small amount of red logo), split it into black and red layers; use level 5 RLE encoding, use REPEAT_EXTRA_LONG for the large white background, use LITERAL for the text edges, and the compression ratio is about 24:1; generate compressed byte streams for black and red layers respectively.
[0149] Step 3: SLE GBN Layered Transfer
[0150] The black layer encapsulates the GBN frame sequence as follows: IMG_START → 12 frames IMG_DATA → IMG_END; SLE GATT Write is performed, with 6 frames sent concurrently in a window; the receiver verifies the frame header 0xA5, and the Seq is sequentially 0, 1, 2..., returning IMG_ACK confirmation for each frame; once all black layer data is received, it is marked B_Done and stored in g_image_buffer; then the red layer compressed packet is sent to g_image_buffer_red and marked R_Done.
[0151] Step 4: Streaming decompression and rendering
[0152] The `img_process_task` triggers the three-color merging rendering; `epdRleDecodeStream` parses the black layer compressed stream byte by byte, decodes the pixels, inverts them bit by bit, and writes them to the 0x10 memory via real-time SPI; it parses the red layer compressed stream and writes it directly to the 0x13 memory; after all data is sent, it sends the 0x12 refresh command, reads the 0x71 BUSY pin in a loop, and waits for about 5 seconds for the refresh to complete.
[0153] Step 5: Feedback and Sleep:
[0154] SLE Notify sends IMG_RENDER_DONE to the host computer; releases two compressed buffers; issues 0x02 power-off and 0x07+0xA5 deep sleep commands, and the terminal returns to Idle to wait for the next frame.
[0155] Example 2: Printing images in black and white mode on double-sided three-color electronic paper
[0156] The hardware is the same as in Example 1, except that a second electronic paper of the same specifications is added, sharing the SPI bus and dual chip select pins CS_A and CS_B; it transmits black and white text pages without the need for red pixels.
[0157] 1) The host only generates a black layer RLE compressed stream and sends down a black layer GBN frame; after the receiver B_Done, it determines the black and white mode and loads the built-in precoded all-zero REPEAT_EXTRA_LONG red layer RLE data packet.
[0158] 2) SPI chip select mutual exclusion timing: First pull CS_A low, then pull CS_A high after a single byte transmission is completed; then pull CS_B low to send the same image data, and pull CS_B high to release the bus. The two screens can be driven in a time-sharing manner without bus conflict.
[0159] 3) Reuse the three-color streaming decompression rendering function, uniformly write to 0x10 and 0x13 video memory (red layer all zeros) to trigger refresh; after completion, hibernate. The process is completely unified with the three-color mode, and no new independent rendering code is required.
[0160] Example 3: Solid Color Full-Screen Electronic Paper Image Transmission
[0161] The full-screen pure white poster uses REPEAT_EXTRA_LONG Packet for all layers during host compression, achieving a compression ratio of 5330:1; SLE transmission requires only a small number of IMG_DATA fragments, resulting in an extremely low retransmission probability; the receiving end uses streaming decompression to output a large number of repetitive pixels in a single output, and SPI continuous output improves the image refresh speed by more than 90%.
[0162] The above description is merely a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the present invention should be included within the scope of protection of the present invention.
Claims
1. A star-flash-based electronic paper image compression and printing system, characterized in that, Includes the transmitter, SLE Star Flash wireless link, and WS63 receiver terminal; The transmitting end is used to perform layered processing on the original three-color electronic paper image, and to perform improved five-level variable-length RLE compression on the black layer and red layer respectively to generate layered compressed data packets, and encapsulate the image transmission frame according to the Go-Back-N frame format through the SLE GATT Write interface and send it down; The SLE Star Flash wireless link is configured with fixed broadcast and connection parameters, providing a low-power, large-MTU wireless transmission channel to carry image data frames and bidirectional notification ACK messages; The WS63 receiving terminal includes a layered software architecture, comprising, in sequence, an application entry layer, an initialization orchestration layer, a communication layer, a protocol layer, a rendering bridge layer, a driver layer, and a hardware abstraction layer. The communication layer includes a sle_server.c communication service module, which is used to receive image frames sent from the SLE link and complete the 0xA5 frame header verification. The protocol layer includes an img_msg.c module, which implements a lightweight Go-Back-N reliable transmission protocol with a window size of 6. It maintains only a single expected sequence number expect_seq, discards out-of-order frames directly, and returns cumulative acknowledgments (ACKs) for in-order frames. The rendering bridge layer epd_ble.c constructs an independent image processing message queue to asynchronously schedule rendering tasks; The driver layer integrates the epd_rle.c streaming decompressor and the epd_driver.c electronic paper hardware driver; the streaming decompressor parses the RLE compressed stream byte by byte, and the decoded output bytes are directly written to the SPI bus without allocating a global complete decompression buffer; The receiving terminal is configured with a black-red double buffer storage structure. In the three-color mode, the black layer compressed data is cached first, and the red layer compressed data is cached after the cache is completed. The two layers of data are merged and rendered after they are ready. In the black-and-white mode, the pre-coded all-zero red layer RLE data packets are reused, and the same three-color rendering path is reused. The driver layer completes SPI bus mutual exclusion chip selection, panel power-on, layer display memory writing, 0x12 refresh trigger and deep sleep control according to the three-color electronic paper hardware timing sequence. The receiving terminal returns a link keep-alive frame, an image reception ACK, and a rendering completion notification message to the sending end through the SLE Notify channel.
2. The system according to claim 1, characterized in that, The improved five-level variable-length RLE compression includes five types of packet coding units: LITERAL type tag 0x00~0x7F, raw data output directly, maximum length 128B; REPEAT_SHORT type tag 0x80~0xBF, short repeating pixels; REPEAT_MEDIUM type tag 0xC0~0xDF, medium-length repetition; REPEAT_LONG type tag 0xE0, long solid color block; REPEAT_EXTRA_LONG type tag 0xF0, full-screen ultra-long solid color block; Each compressed data packet has a 4-byte big-endian header that stores the original layer byte length for pre-allocating resources during streaming decoding.
3. The system according to claim 1, characterized in that, The Go-Back-N frame unified format includes: 1B frame header 0xA5, 1B message type Type, 1B sequence number Seq, 2B little-endian payload length, and 0~480B image payload. The message types include host-sent IMG_START, IMG_DATA, and IMG_END, and device-sent IMG_ACK, IMG_RENDER_DONE, and bidirectional IMG_KEEPALIVE. The IMG_START frame payload is fixed at 6 bytes, carrying the protocol version, transmission window size, total transmission length, and 8-bit cumulative checksum.
4. The system according to claim 1, characterized in that, The fixed parameters of the SLE link include: broadcast interval 850ms, connection interval 125ms, connection monitoring timeout 5000ms, MTU=520B, and broadcast channels CH0 / CH1 / CH2; the device generates a unique Device ID based on the Die-ID using FNV1a-64 hash, derives the link address and device name, and injects them into the broadcast packet.
5. The system according to claim 1, characterized in that, The WS63 receiving terminal has built-in multi-priority scheduling tasks: watchdog_task (priority 5, 5s cycle) Independent hardware watchdog keep-alive; EpdTestTask (priority 10) completes device identity injection and full module serial initialization upon power-up; img_process_task (priority 14, message-driven) handles image message queues, buffer management, and rendering scheduling; The keepalive_task (priority 30, 1s cycle) continuously sends SLE keepalive frames during rendering blocking to prevent the link from being disconnected.
6. The system according to claim 1, characterized in that, The streaming decompression mechanism is as follows: parse the compressed stream 4BHeader to obtain the original layer size, parse the five-level RLE Packet byte by byte, and immediately write each byte of pixel data to the SPI hardware interface via callback. The black layer data is written to the 0x10 memory and bitwise inverted, and the original red layer data is written to the 0x13 memory. After all data is written, the 0x12 refresh command is sent. After the BUSY pin is read in a loop until it is idle, the panel is powered off and put into deep sleep mode.
7. The system according to claim 1, characterized in that, Double-sided electronic paper shares an SPI bus and employs a chip select mutual exclusion mechanism: Only the CS pin of the target screen is pulled low, while the CS pin on the other side remains high. The chip select is released after a single byte transmission is completed to avoid bus conflicts.
8. A method for compressing and printing electronic paper images based on star-flickering, applied to the system described in any one of claims 1 to 7, characterized in that, The process includes the following steps: S1, System power-on initialization: Create watchdog timer, link keep-alive, e-paper main task; Load device Die-ID hash to generate unique identity; Configure GPIO / SPI hardware interface; Initialize e-paper driver; Start SLE broadcast and GATT service; Create an image message queue and enter an idle waiting state; S2. Layered image compression at the sending end: The original three-color image is split into a black layer and a red layer, and each layer is independently compressed using a five-level variable-length RLE algorithm to generate a black layer compressed stream and a red layer compressed stream. S3 and SLE reliable transmission: The sending end sends IMG_START, multi-frame IMG_DATA, and IMG_END layered data packets sequentially according to the GBN frame format via SLE GATT Write, with a maximum of 6 frames concurrently in the sliding window; S4. Receiver layered buffer: After the communication layer verifies the frame header, it is sent to the GBN protocol layer. Frames in order are stored in the black buffer / red buffer. Out-of-order frames are discarded directly and the current expected sequence number ACK is replied. In the three-color mode, the red layer data is received after the black layer buffer is completed. In the black-and-white mode, the pre-coded all-zero red layer RLE is directly loaded. S5, Streaming Decompression and Rendering: The scheduling task retrieves the dual-layer compressed stream, calls the streaming RLE decompressor to decode it byte by byte, and directly outputs it to the SPI bus to write to the corresponding display memory area of the electronic paper; sends a refresh command, and waits for BUSY to be released to complete the image display; S6. Feedback and Resource Release: After rendering is complete, IMG_RENDER_DONE is sent to the sender via SLE Notify; double buffer memory is released, the electronic paper enters deep sleep, and the system returns to an idle state to wait for the next frame of image transmission.
9. The method according to claim 8, characterized in that, In step S4, the Go-Back-N receiver state machine maintains only a single expect_seq variable, with states including Idle, B_Receiving (black layer reception), B_Done (black layer ready), R_Receiving (red layer reception), R_Done (double layer ready), Render, and Cleanup (resource release). When the new image START frame arrives, the residual buffer is automatically released to complete the abnormal recovery.
10. The method according to claim 8, characterized in that, In step S2, the compression effect is adapted to the electronic paper image scene: the compression ratio of solid color images can reach 5330:1, the compression ratio of images with logo backgrounds is about 24:1, the compression ratio of text pages is about 16:1, the compression ratio of natural texture images is 4.8:1, and the compression ratio of high frequency alternating pixel images is 1:1.