Thermal printer control method and related equipment

By acquiring the circuit diagram of the image to be printed and the thermal printhead, the working status and heating time of the heating line are determined, which solves the problem of misalignment of segments or lines when the power supply has a weak load capacity in high-resolution thermal printers, and achieves efficient print quality and energy consumption management.

CN118494025BActive Publication Date: 2024-11-22ZHUHAI XPRINTER ELECTRONICS TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410966774.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-18
Publication Date
2024-11-22
Estimated Expiration
2044-07-18

AI Technical Summary

Technical Problem

When a high-resolution thermal printer prints a large area with a weak power supply, it can cause misalignment of paragraphs or lines in the vertical direction of text or images.

Method used

By acquiring the image to be printed and the circuit diagram of the thermal printhead heating wires, image processing is performed to determine the areas that need to be printed continuously. Based on the area location and circuit diagram, the working status of the heating wires is determined, and the heating time is determined based on the temperature and pressure values. Some heating wires are set to a stopped state to reduce energy consumption.

Benefits of technology

It effectively avoids vertical misalignment of text or images during large-scale printing, reduces energy consumption, and improves print quality and efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118494025B_ABST
    Figure CN118494025B_ABST
Patent Text Reader

Abstract

The present invention provides a thermal printer control method and related equipment, which relates to the field of data processing technology. The method includes: obtaining an image to be printed of a thermal printer and a line distribution diagram of multiple heating lines on a thermal print head; performing image processing on the image to be printed to obtain a first area, the first area is used to characterize an area that needs to be printed continuously; determining the working state of each heating line in the thermal print head according to the position coordinate data and the line distribution diagram of the first area; when the working state of at least one heating line is a running state, determining the heating time of the thermal print head according to the temperature value and pressure value of the thermal print head. In this way, when encountering an area that needs to be printed continuously, the working state of some heating lines can be set to a stop state, thereby reducing the energy consumption requirements for the load, thereby avoiding obvious paragraph or line misalignment in the vertical direction of the printed text or image when printing in a large range.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of data processing, and in particular to a thermal printer control method and related equipment. Background Art

[0002] The printing method of a thermal printer is to heat the coated thermal paper through a thermal head unit, which causes a chemical reaction on the thermal paper, thereby achieving the printing of text and images.

[0003] However, currently thermal printers usually pursue compactness and portability while improving the printing resolution. In this case, ensuring high resolution requires more heating wires on the thermal print head, and more heating wires means higher power during thermal printing, while compactness and portability usually means smaller battery capacity or battery voltage.

[0004] In the process of implementing the present invention, the inventors found that when the power supply load capacity of a high-resolution thermal printer is weak, large-scale printing may result in obvious vertical misalignment of paragraphs or lines in the printed text or images. Summary of the invention

[0005] The embodiment of the present invention provides a thermal printer control method and related equipment to solve the problem in the prior art that when the power supply load capacity of a high-resolution thermal printer is weak, large-scale printing may result in obvious paragraph or line misalignment in the vertical direction of the printed text or image.

[0006] In a first aspect, an embodiment of the present invention provides a method for controlling a thermal printer, wherein the thermal printer includes a thermal print head, wherein the thermal print head includes a plurality of heating wires, and each of the heating wires can operate independently. The method includes:

[0007] Acquire the image to be printed by the thermal printer and the line distribution diagram of the multiple heating lines on the thermal print head;

[0008] Performing image processing on the image to be printed to obtain a first area, where the first area is used to represent an area that needs to be continuously printed;

[0009] Determine the working state of each of the heating lines in the thermal print head according to the position coordinate data of the first area and the line distribution map, wherein the working state includes a running state and a stopping state;

[0010] When at least one of the heating lines is in a running state, determining a heating time of the thermal print head according to a temperature value and a pressure value of the thermal print head;

[0011] The temperature value is the temperature value on the thermal print head, and the pressure value is the pressure value between the thermal print head and the thermal paper.

[0012] Optionally, before determining the heating time of the thermal print head based on the temperature value and the pressure value of the thermal print head, the method further comprises:

[0013] Determine the magnitude relationship between the temperature value of the thermal print head and a first temperature threshold and a second temperature threshold, wherein the first temperature threshold is the minimum temperature required for printing on the thermal paper, and the second temperature threshold is the overheat protection temperature of the thermal printer;

[0014] When the temperature value of the thermal print head is less than the first temperature threshold or the temperature value of the thermal print head is greater than the second temperature threshold, controlling the thermal printer to stop running;

[0015] When the temperature value of the thermal print head is greater than or equal to the first temperature threshold and the temperature value of the thermal print head is less than the second temperature threshold, the thermal printer is controlled to operate.

[0016] Optionally, a plurality of temperature sensors are provided on the thermal print head, and a plurality of pressure sensors are provided on the thermal print head. Before determining the heating time of the thermal print head according to the temperature value and the pressure value of the thermal print head, the method further comprises:

[0017] Acquire sub-temperature values ​​at different positions on the thermal print head respectively through the multiple sensors;

[0018] Calculating the temperature value of the thermal print head according to the plurality of sub-temperature values;

[0019] respectively acquiring sub-pressure values ​​at different positions on the thermal print head through the multiple pressure sensors;

[0020] The pressure value of the thermal print head is calculated according to the multiple sub-temperature values.

[0021] Optionally, performing image processing on the image to be printed to obtain the first area comprises:

[0022] Gray-scale the image to be printed to obtain a gray-scale image;

[0023] Based on Gaussian kernels of different sizes, a convolution operation is performed on the grayscale image to obtain a plurality of first images, where the first images are images of the grayscale image after Gaussian blurring;

[0024] Performing edge detection on the plurality of first images respectively to obtain a plurality of second images, each of the second images corresponds to one of the first images, each of the second images includes a second area, and the second area is used to represent an area that needs to be continuously printed;

[0025] A region with the smallest pixel area in each of the second regions included in the second images is determined as the first region.

[0026] Optionally, performing edge detection on the plurality of first images respectively to obtain the plurality of second images comprises:

[0027] The first Sobel operator is used to perform edge detection on the multiple first images in the x-axis direction, and the second Sobel operator is used to perform edge detection on the multiple first images in the y-axis direction, so as to obtain the multiple second images.

[0028] Optionally, determining the working state of each heating line in the thermal print head according to the position coordinate data of the first area and the line distribution map includes:

[0029] Calculating a first time when the thermal print head reaches the first area based on the position coordinate data of the first area;

[0030] At the first moment, based on the area size of the first region, the working state of each of the heating lines in the thermal print head is determined.

[0031] In a second aspect, an embodiment of the present invention further provides a thermal printer control device, wherein the thermal printer includes a thermal print head, wherein the thermal print head includes a plurality of heating wires, and each of the heating wires can operate independently. The device includes:

[0032] An acquisition module, used for acquiring the image to be printed by the thermal printer and the line distribution diagram of the multiple heating lines on the thermal print head;

[0033] An image processing module, used for performing image processing on the image to be printed to obtain a first area, wherein the first area is used for representing an area that needs to be continuously printed;

[0034] A first determining module, configured to determine a working state of each of the heating lines in the thermal print head according to the position coordinate data of the first area and the line distribution map, wherein the working state includes a running state and a stopping state;

[0035] A second determining module is used to determine the heating time of the thermal print head according to the temperature value and the pressure value of the thermal print head when the working state of at least one of the heating lines is the running state;

[0036] The temperature value is the temperature value on the thermal print head, and the pressure value is the pressure value between the thermal print head and the thermal paper.

[0037] Optionally, the device further comprises:

[0038] a judgment module, used to judge the relationship between the temperature value of the thermal print head and a first temperature threshold and a second temperature threshold, wherein the first temperature threshold is the minimum temperature required for printing on the thermal paper, and the second temperature threshold is the overheat protection temperature of the thermal printer;

[0039] A first control module, configured to control the thermal printer to stop running when the temperature value of the thermal print head is less than the first temperature threshold or the temperature value of the thermal print head is greater than the second temperature threshold;

[0040] The second control module is used to control the thermal printer to operate when the temperature value of the thermal print head is greater than or equal to the first temperature threshold and the temperature value of the thermal print head is less than the second temperature threshold.

[0041] In a third aspect, an embodiment of the present invention further provides a terminal device, comprising a processor, a memory, and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the above-mentioned thermal printer control method when executed by the processor.

[0042] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, wherein the computer program implements the steps of the above-mentioned thermal printer control method when executed by a processor.

[0043] The embodiment of the present invention obtains the image to be printed of the thermal printer and the line distribution map of the multiple heating lines on the thermal print head; performs image processing on the image to be printed to obtain a first area, the first area is used to characterize the area that needs to be printed continuously; determines the working state of each heating line in the thermal print head according to the position coordinate data of the first area and the line distribution map, the working state includes a running state and a stopped state; when the working state of at least one of the heating lines is the running state, determines the heating time of the thermal print head according to the temperature value and pressure value of the thermal print head; wherein the temperature value is the temperature value on the thermal print head, and the pressure value is the pressure value between the thermal print head and the thermal paper. In this way, when encountering an area that needs to be printed continuously, the working state of some heating lines can be set to a stopped state, thereby reducing the energy consumption requirement for the load, thereby avoiding the obvious paragraph or line misalignment of the printed text or image in the vertical direction when printing in a large range. BRIEF DESCRIPTION OF THE DRAWINGS

[0044] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0045] Figure 1 It is one of the flow charts of the thermal printer control method provided by the embodiment of the present invention;

[0046] Figure 2 is a schematic structural diagram of a thermal printer control device provided by an embodiment of the present invention;

[0047] Figure 3 It is a schematic diagram of the hardware structure of the terminal device provided in an embodiment of the present invention. DETAILED DESCRIPTION

[0048] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0049] See also Figure 1 , Figure 1 This is one of the flow charts of a thermal printer control method provided by an embodiment of the present invention, comprising the following steps:

[0050] Step 101, obtaining an image to be printed by the thermal printer and a line distribution diagram of the multiple heating lines on the thermal print head;

[0051] It should be understood that the method of obtaining the image to be printed by the thermal printer may be receiving input from a hard disk, or may be obtained through Bluetooth, and no further limitation is made here.

[0052] It should be understood that obtaining the line distribution diagram of the multiple heating lines on the thermal print head can be understood as obtaining parameter information of the thermal printer product, which can be pre-stored in the thermal printer.

[0053] Step 102: performing image processing on the image to be printed to obtain a first area, where the first area is used to represent an area that needs to be continuously printed;

[0054] It should be understood that the first area can be understood as a long horizontal line or a large black area, and no further limitation is given here.

[0055] Step 103: determining the working state of each heating line in the thermal print head according to the position coordinate data of the first area and the line distribution map, wherein the working state includes a running state and a stopped state;

[0056] Step 104: when at least one of the heating lines is in a running state, determining a heating time of the thermal print head according to a temperature value and a pressure value of the thermal print head;

[0057] The temperature value is the temperature value on the thermal print head, and the pressure value is the pressure value between the thermal print head and the thermal paper.

[0058] It should be understood that determining the heating time of the thermal print head based on the temperature value and pressure value of the thermal print head can be understood as: setting a heating time benchmark, when the temperature value and the pressure value are both low, it is necessary to extend the heating time more on the basis of the heating time benchmark; when the temperature value is low or the pressure value is low, it is necessary to appropriately extend the heating time on the basis of the heating time benchmark; when the temperature value and the pressure value are both high, it is necessary to appropriately reduce the heating time on the basis of the heating time benchmark.

[0059] In an embodiment of the present application, by obtaining the image to be printed of the thermal printer and the line distribution map of the multiple heating lines on the thermal print head; performing image processing on the image to be printed to obtain a first area, the first area is used to characterize the area where continuous printing is required; according to the position coordinate data of the first area and the line distribution map, the working state of each heating line in the thermal print head is determined, and the working state includes a running state and a stopped state; when the working state of at least one of the heating lines is a running state, the heating time of the thermal print head is determined according to the temperature value and pressure value of the thermal print head; wherein the temperature value is the temperature value on the thermal print head, and the pressure value is the pressure value between the thermal print head and the thermal paper. In this way, when encountering an area where continuous printing is required, the energy consumption requirement for the load can be reduced by setting the working state of some heating lines to a stopped state, thereby avoiding the obvious paragraph or line misalignment of the printed text or image in the vertical direction when printing in a large range.

[0060] Optionally, in some embodiments, the following steps are included:

[0061] Step 1: Establish a preprocessing model based on the print head characteristics to obtain range parameters;

[0062] a. First, determine the minimum basic printing time calculation of the thermal print head: confirm the rated power parameters of the selected power supply, substitute the selected thermal print head heating unit's printing energy calculation formula, calculate the time required to reach the printing energy at the standard temperature, and then add the actual compensation parameters to obtain the minimum printing time under the rated power;

[0063] The calculation formula of the minimum printing time is as follows:

[0064] ;

[0065] Among them, the Used to characterize the minimum printing time, Used to characterize the common circuit resistance, the Used to express the maximum number of heating points at a time, Used to characterize the average resistance of the heating point, Used to characterize the internal resistance of the driver IC when it is turned on and the Used to characterize the printing voltage.

[0066] b. Calculation of maximum printing time of thermal print head:

[0067] The calculation formula of the maximum printing time of the thermal print head is as follows:

[0068] ;

[0069] Among them, the Used to characterize the maximum printing time, Used to characterize the common circuit resistance, the Used to express the minimum number of heating points per time, Used to characterize the average resistance of the heating point, Used to characterize the internal resistance of the driver IC when it is turned on. For characterizing the printing voltage and the Used to represent the number of segments.

[0070] c. Confirm the minimum data transmission time under the maximum load of the thermal print head:

[0071] The calculation formula of the minimum data transmission time is as follows:

[0072] ;

[0073] Among them, the Used to characterize the minimum data transmission time, Used to indicate the number of bytes sent, For characterization The bus clock frequency, the Used to characterize the number of data transmission lines.

[0074] d. Confirm the minimum and maximum range of step time by selecting motor parameters and subdividing the number of steps;

[0075] e. Get the head chip point count and temperature change curve, voltage change curve through the thermal print head parameters and battery parameters;

[0076] f. The basic printing compensation coefficient is obtained by introducing the feedback of thermal print head temperature change, battery voltage change, and heating unit change into the system

[0077] Step 2: According to the number of current thermal print head heating lines, the maximum effective number of continuous heating units applied on a single line is extracted through bitwise AND operation, and the number of head points and the temperature change curve threshold are combined to calculate whether the current heating line adopts the fast heating mode;

[0078] Step 3: When the rapid heating mode is reached, the number of segments of the corresponding row heating line in the data structure is configured according to the minimum number of segments, and the minimum basic Inking time is substituted into the Inking time formula to calculate the rapid heating basic value;

[0079] Step 4: In the fast heating mode, the dynamic basic heating level is adjusted through the point number and temperature change curve. The heating level of the fast heating mode is adjusted downward. According to the above minimum printing time formula, the sum of the basic values ​​of all current heating line segments is not less than ;

[0080] Step 5: When the rapid heating mode is not reached, the conventional mode is used to process the heating unit segmentation of the row heating line. According to the current resolution and the number of heating lines, the heating units on each heating line are evenly distributed.

[0081] Step 6: In normal mode, use the default heating level parameters and calculate the maximum inking time according to the above formula to obtain the sum of the basic values ​​of all current heating line segments not greater than ;

[0082] Step 7: Obtain the sum of all base values ​​in the current line through the above steps 4 and 6, and start concentration coefficient compensation. Use the concentration coefficient curve obtained by the pre-experimentation of the thermal print head specification to compensate the concentration points of the base values ​​of each heating line and update the heating base value.

[0083] Step 8: Start temperature coefficient compensation according to step 7, obtain the current temperature of the thermal print head through the temperature rise coefficient curve obtained by the pre-experiment of the thermal print head specification, look up the table to obtain the compensation coefficient, and compensate the heating base value of each heating line to update the heating base value;

[0084] Step 9: Start voltage coefficient compensation according to step 8, obtain the voltage coefficient curve through lithium battery specifications and discharge curve experiments, obtain the current lithium battery voltage value and then look up the table to obtain the compensation coefficient, compensate the heating base value of each heating line, and update the heating base value;

[0085] Step 10: The above steps 7-9 can superimpose various influencing factors, perform amplification, scaling, filtering, limiting and other operations in a preset range, and finally obtain a reasonable heating basic value.

[0086] Step 11: Get the actual heating value, which is the heating base value + the minimum data transmission time under the maximum load of the thermal print head. The actual heating value should not be greater than the number of motor subdivision steps × the maximum step time, otherwise there will be errors in the front-end data calculation;

[0087] Step 12: At the start-up stage, the motor starts feeding paper at the initial speed of the motor according to the number of motor subdivision steps × the minimum value of the step time. At this time, the motor is close to the maximum initial speed. When printing starts to obtain a line of data, the actual heating value is calculated in segments as described above. According to the difference between the actual single-line time corresponding to the current motor initial speed and the actual heating value, when the difference is greater than 15 times the actual single-line feeding time of the motor, the number of segments is reduced to improve the paper printing efficiency. Otherwise, linear deceleration is performed according to the current difference.

[0088] Step 13: When the actual single-stroke paper feeding time of the motor is close to the actual heating value, the paper is fed according to the current actual heating value.

[0089] Step 14: When the rapid heating mode is entered from step 3, the temperature of the thermal head is usually higher than the normal temperature. By quickly increasing the current of the whole machine in a short time, the content is printed at a speed lower than 1 / 2 of the single paper speed. The above steps 7-10 can limit the heating of the horizontal lines in a large range at the expense of some energy consumption. The effect of the black block image is improved, and the motor current is suppressed, avoiding the heating problem caused by the brake jitter and a series of problems caused by the heating;

[0090] Step 15: Since the collected temperature data and voltage data fluctuate according to the actual situation, a change curve is established for the corresponding thermal print head through experiments. Even when the actual environment fluctuates, the device can respond dynamically to compensate for the impact of related fluctuations on the system, and limit the final effect within the adjustable range, thereby achieving a stable closed loop of the system;

[0091] It should be understood that through the above method, the embodiments of the present application can also have the following beneficial effects: it is not dependent on specific processor peripheral requirements, reducing hardware selection restrictions and costs; it dynamically adjusts the mode according to the current printing data, and has a strong ability to cope with complex printing situations; the algorithm complexity is low, and the time complexity is low; it fully considers the impact of the characteristics of each hardware and software device, and has a good optimization effect on high-resolution and large-range printing.

[0092] Optionally, in some embodiments, before determining the heating time of the thermal print head based on the temperature value and the pressure value of the thermal print head, the method further includes:

[0093] Determine the magnitude relationship between the temperature value of the thermal print head and a first temperature threshold and a second temperature threshold, wherein the first temperature threshold is the minimum temperature required for printing on the thermal paper, and the second temperature threshold is the overheat protection temperature of the thermal printer;

[0094] When the temperature value of the thermal print head is less than the first temperature threshold or the temperature value of the thermal print head is greater than the second temperature threshold, controlling the thermal printer to stop running;

[0095] When the temperature value of the thermal print head is greater than or equal to the first temperature threshold and the temperature value of the thermal print head is less than the second temperature threshold, the thermal printer is controlled to operate.

[0096] In an embodiment of the present invention, through the above method, when the temperature of the thermal print head is too high, the thermal printer can be controlled to stop running to improve safety; and when the temperature of the thermal print head is too low, the thermal printer can be controlled to stop running to avoid wasting thermal paper.

[0097] Optionally, in some embodiments, a plurality of temperature sensors are provided on the thermal print head, and a plurality of pressure sensors are provided on the thermal print head. Before determining the heating time of the thermal print head according to the temperature value and the pressure value of the thermal print head, the method further includes:

[0098] Acquire sub-temperature values ​​at different positions on the thermal print head respectively through the multiple sensors;

[0099] Calculating the temperature value of the thermal print head according to the plurality of sub-temperature values;

[0100] respectively acquiring sub-pressure values ​​at different positions on the thermal print head through the multiple pressure sensors;

[0101] The pressure value of the thermal print head is calculated according to the multiple sub-temperature values.

[0102] In an embodiment of the present invention, the temperature and pressure values ​​obtained in the above manner can be made more accurate, so that more precise control can be achieved, and the operation can be stopped when the temperature of the thermal print head is too high to improve safety; and the operation can be stopped when the temperature of the thermal print head is too low to avoid wasting thermal paper.

[0103] Optionally, in some embodiments, performing image processing on the image to be printed to obtain the first area includes:

[0104] Gray-scale the image to be printed to obtain a gray-scale image;

[0105] Based on Gaussian kernels of different sizes, a convolution operation is performed on the grayscale image to obtain a plurality of first images, where the first images are images of the grayscale image after Gaussian blurring;

[0106] Performing edge detection on the plurality of first images respectively to obtain a plurality of second images, each of the second images corresponds to one of the first images, each of the second images includes a second area, and the second area is used to represent an area that needs to be continuously printed;

[0107] A region with the smallest pixel area in each of the second regions included in the second images is determined as the first region.

[0108] It should be understood that the Gaussian kernel may be 3×3, 4×4, or 5×5, and no further limitation is given here;

[0109] Furthermore, based on Gaussian kernels of different sizes, the grayscale image is convolved, and the first image obtained is bound to be different. The area with the smallest pixel area is selected from the grayscale image and determined as the first area. In this way, the thermal printing control method can be used to avoid the operation of the heating line in some pixel areas that do not belong to the continuous printing area, thereby saving energy consumption.

[0110] It should be understood that is a Gaussian kernel, which indicates that the maximum weight of the central pixel is 4, the weight of the pixel slightly away from the central pixel is 2, and the weight of the pixel slightly away from the central pixel is 1. That is, the Gaussian kernel is convolved with each pixel in the first image to achieve Gaussian blur.

[0111] Optionally, in some embodiments, performing edge detection on the plurality of first images respectively to obtain the plurality of second images comprises:

[0112] The first Sobel operator is used to perform edge detection on the multiple first images in the x-axis direction, and the second Sobel operator is used to perform edge detection on the multiple first images in the y-axis direction, so as to obtain the multiple second images.

[0113] Optionally, in some embodiments, determining the working state of each heating line in the thermal print head according to the position coordinate data of the first area and the line distribution map includes:

[0114] Calculating a first time when the thermal print head reaches the first area based on the position coordinate data of the first area;

[0115] At the first moment, based on the area size of the first region, the working state of each of the heating lines in the thermal print head is determined.

[0116] It should be understood that the thermal printer usually prints on thermal paper in a horizontal line, so the first moment when the thermal print head moves to the first area can be known based on the moving speed of the thermal print head and the position coordinate data of the first area.

[0117] In the embodiment of the present invention, through the above method, the working state of each heating wire in the thermal print head can be accurately controlled at the first moment, thereby improving the control accuracy.

[0118] See also Figure 2 , Figure 2 2 is a schematic diagram of the structure of a thermal printer control device 200 provided in an embodiment of the present invention, wherein the thermal printer includes a thermal print head, and the thermal print head includes a plurality of heating wires, and each of the heating wires can operate independently and include:

[0119] A first acquisition module 201 is used to acquire the image to be printed by the thermal printer and the line distribution diagram of the multiple heating lines on the thermal print head;

[0120] An image processing module 202 is used to perform image processing on the image to be printed to obtain a first area, where the first area is used to represent an area that needs to be continuously printed;

[0121] A first determination module 203, configured to determine a working state of each of the heating lines in the thermal print head according to the position coordinate data of the first area and the line distribution map, wherein the working state includes a running state and a stopped state;

[0122] A second determination module 204 is used to determine the heating time of the thermal print head according to the temperature value and the pressure value of the thermal print head when the working state of at least one of the heating lines is the running state;

[0123] The temperature value is the temperature value on the thermal print head, and the pressure value is the pressure value between the thermal print head and the thermal paper.

[0124] Optionally, in some embodiments, the device further comprises:

[0125] a judgment module, used to judge the relationship between the temperature value of the thermal print head and a first temperature threshold and a second temperature threshold, wherein the first temperature threshold is the minimum temperature required for printing on the thermal paper, and the second temperature threshold is the overheat protection temperature of the thermal printer;

[0126] A first control module, configured to control the thermal printer to stop running when the temperature value of the thermal print head is less than the first temperature threshold or the temperature value of the thermal print head is greater than the second temperature threshold;

[0127] The second control module is used to control the thermal printer to operate when the temperature value of the thermal print head is greater than or equal to the first temperature threshold and the temperature value of the thermal print head is less than the second temperature threshold.

[0128] Optionally, in some embodiments, a plurality of temperature sensors are provided on the thermal print head, a plurality of pressure sensors are provided on the thermal print head, and the device further comprises:

[0129] A second acquisition module, used to respectively acquire sub-temperature values ​​at different positions on the thermal print head through the multiple temperature sensors;

[0130] A first calculation module, configured to calculate a temperature value of the thermal print head according to the plurality of sub-temperature values;

[0131] A third acquisition module, configured to respectively acquire sub-pressure values ​​at different positions on the thermal print head through the multiple pressure sensors;

[0132] The second calculation module is used to calculate the pressure value of the thermal print head according to the multiple sub-temperature values.

[0133] Optionally, in some embodiments, the image processing module includes:

[0134] A grayscale submodule, used for grayscale the image to be printed to obtain a grayscale image;

[0135] Obtaining a submodule, for performing a convolution operation on the grayscale image based on Gaussian kernels of different sizes to obtain a plurality of first images, wherein the first images are images of the grayscale image after Gaussian blurring;

[0136] an edge detection submodule, configured to perform edge detection on the plurality of first images respectively to obtain a plurality of second images, each of the second images corresponding to one of the first images, each of the second images including a second area, and the second area being used to represent an area to be continuously printed;

[0137] The first determination submodule is configured to determine a region with the smallest pixel area in each of the second regions included in the second images as the first region.

[0138] Optionally, in some embodiments, the edge detection submodule is further used for:

[0139] The first Sobel operator is used to perform edge detection on the multiple first images in the x-axis direction, and the second Sobel operator is used to perform edge detection on the multiple first images in the y-axis direction, so as to obtain the multiple second images.

[0140] Optionally, in some embodiments, the first determining module includes:

[0141] a calculation submodule, configured to calculate a first moment when the thermal print head reaches the first area based on the position coordinate data of the first area;

[0142] The second determining submodule is used to determine the working state of each of the heating wires in the thermal print head based on the area size of the first region at the first moment.

[0143] The thermal printer control device 200 provided in the embodiment of the present invention can realize Figure 1 To avoid repetition, the various processes implemented in the method embodiment are not described here.

[0144] Figure 3 A hardware structure diagram of a terminal device 300 for implementing various embodiments of the present invention includes a processor 301, a memory 302, and a computer program stored in the memory and executable on the processor. The processor 301 is connected to the memory 302 via a bus 303. When the computer program is executed by the processor, the various processes of the thermal printer control method embodiment described above are implemented, and the same technical effect can be achieved. To avoid repetition, it will not be described here.

[0145] The embodiment of the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, each process of the thermal printer control method embodiment is implemented, and the same technical effect can be achieved. To avoid repetition, it is not repeated here. The computer-readable storage medium is, for example, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.

[0146] Those skilled in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.

[0147] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.

[0148] In the embodiments provided in the present application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of the units is only a logical function division. There may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.

[0149] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.

[0150] In addition, each functional unit in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.

[0151] If the functions are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, or the part of the technical solution, can be embodied in the form of a software product. The computer software product is stored in a storage medium, including several instructions for a computer device (which can be a personal computer, server, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: various media that can store program codes, such as USB flash drives, mobile hard disks, ROM, RAM, magnetic disks, or optical disks.

[0152] The above is only a specific embodiment of the present invention, but the protection scope of the present invention is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed by the present invention, which should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention should be based on the protection scope of the claims.

Claims

1. A thermal printer control method, characterized in that: The thermal printer includes a thermal print head, the thermal print head includes a plurality of heating wires, and each of the heating wires can operate independently, and the method includes: Acquire the image to be printed by the thermal printer and the line distribution diagram of the multiple heating lines on the thermal print head; Performing image processing on the image to be printed to obtain a first area, where the first area is used to represent an area that needs to be continuously printed; Determine the working state of each of the heating lines in the thermal print head according to the position coordinate data of the first area and the line distribution map, wherein the working state includes a running state and a stopping state; Determining the working state of each heating line in the thermal print head according to the position coordinate data of the first area and the line distribution map includes: Calculating a first time when the thermal print head reaches the first area based on the position coordinate data of the first area; At the first moment, based on the area size of the first region, determining the working state of each of the heating lines in the thermal print head; When at least one of the heating lines is in a running state, determining a heating time of the thermal print head according to a temperature value and a pressure value of the thermal print head; Wherein, the temperature value is the temperature value of the thermal print head, and the pressure value is the pressure value between the thermal print head and the thermal paper; The performing image processing on the image to be printed to obtain the first area comprises: Gray-scale the image to be printed to obtain a gray-scale image; Based on Gaussian kernels of different sizes, a convolution operation is performed on the grayscale image to obtain a plurality of first images, where the first images are images of the grayscale image after Gaussian blurring; Performing edge detection on the plurality of first images respectively to obtain a plurality of second images, each of the second images corresponds to one of the first images, each of the second images includes a second area, and the second area is used to represent an area that needs to be continuously printed; Determine the region with the smallest pixel area in each of the second regions included in the second images as the first region; Before determining the heating time of the thermal print head according to the temperature value and the pressure value of the thermal print head, the method further includes: Determine the magnitude relationship between the temperature value of the thermal print head and a first temperature threshold and a second temperature threshold, wherein the first temperature threshold is the minimum temperature required for printing on the thermal paper, and the second temperature threshold is the overheat protection temperature of the thermal printer; When the temperature value of the thermal print head is less than the first temperature threshold or the temperature value of the thermal print head is greater than the second temperature threshold, controlling the thermal printer to stop running; When the temperature value of the thermal print head is greater than or equal to the first temperature threshold and the temperature value of the thermal print head is less than the second temperature threshold, the thermal printer is controlled to operate.

2. The method according to claim 1, characterized in that The thermal print head is provided with a plurality of temperature sensors, and the thermal print head is provided with a plurality of pressure sensors. Before determining the heating time of the thermal print head according to the temperature value and the pressure value of the thermal print head, the method further comprises: Acquire sub-temperature values ​​at different positions on the thermal print head respectively through the multiple temperature sensors; Calculating the temperature value of the thermal print head according to the plurality of sub-temperature values; respectively acquiring sub-pressure values ​​at different positions on the thermal print head through the multiple pressure sensors; The pressure value of the thermal print head is calculated based on the multiple sub-pressure values.

3. The method according to claim 1, characterized in that: The performing edge detection on the plurality of first images respectively to obtain the plurality of second images comprises: The first Sobel operator is used to perform edge detection on the multiple first images in the x-axis direction, and the second Sobel operator is used to perform edge detection on the multiple first images in the y-axis direction, so as to obtain the multiple second images.

4. A thermal printer control device, characterized in that: The thermal printer includes a thermal print head, the thermal print head includes a plurality of heating wires, and each of the heating wires can operate independently, and the device includes: An acquisition module, used for acquiring the image to be printed by the thermal printer and the line distribution diagram of the multiple heating lines on the thermal print head; An image processing module, used for performing image processing on the image to be printed to obtain a first area, wherein the first area is used for representing an area that needs to be continuously printed; A first determining module, configured to determine a working state of each of the heating lines in the thermal print head according to the position coordinate data of the first area and the line distribution map, wherein the working state includes a running state and a stopping state; The first determination module includes: a calculation submodule, configured to calculate a first time when the thermal print head reaches the first area based on the position coordinate data of the first area; a second determination submodule, configured to determine, at the first time, a working state of each of the heating wires in the thermal print head based on the area size of the first area; A second determining module is used to determine the heating time of the thermal print head according to the temperature value and the pressure value of the thermal print head when the working state of at least one of the heating lines is the running state; Wherein, the temperature value is the temperature value of the thermal print head, and the pressure value is the pressure value between the thermal print head and the thermal paper; The image processing module comprises: A grayscale submodule, used for grayscale the image to be printed to obtain a grayscale image; Obtaining a submodule, for performing a convolution operation on the grayscale image based on Gaussian kernels of different sizes to obtain a plurality of first images, wherein the first images are images of the grayscale image after Gaussian blurring; an edge detection submodule, configured to perform edge detection on the plurality of first images respectively to obtain a plurality of second images, each of the second images corresponding to one of the first images, each of the second images including a second area, and the second area being used to represent an area to be continuously printed; A first determining submodule, configured to determine a region with the smallest pixel area in each of the second regions included in the second image as the first region; a judgment module, used to judge the relationship between the temperature value of the thermal print head and a first temperature threshold and a second temperature threshold, wherein the first temperature threshold is the minimum temperature required for printing on the thermal paper, and the second temperature threshold is the overheat protection temperature of the thermal printer; A first control module, configured to control the thermal printer to stop running when the temperature value of the thermal print head is less than the first temperature threshold or the temperature value of the thermal print head is greater than the second temperature threshold; The second control module is used to control the thermal printer to operate when the temperature value of the thermal print head is greater than or equal to the first temperature threshold and the temperature value of the thermal print head is less than the second temperature threshold.

5. A terminal device, characterized in that: The invention comprises a processor, a memory and a computer program stored in the memory and executable on the processor, wherein the computer program implements the steps of the thermal printer control method according to any one of claims 1 to 3 when executed by the processor.

6. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the thermal printer control method according to any one of claims 1 to 3 are implemented.