A dimming method based on straight line fitting and curvature adjustment
By using linear fitting and curvature adjustment methods in exponential dimming, the problems of large resource consumption and low accuracy in the existing technology are solved, and high-precision exponential dimming is achieved, providing a more comfortable visual experience.
Patent Information
- Application Number
- CN202411770038.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-04
- Publication Date
- 2025-05-13
- Estimated Expiration
- 2044-12-04
AI Technical Summary
Existing exponential dimming methods require a large number of storage resources and computing resources, and have low accuracy, making it difficult to achieve linear brightness changes to provide a comfortable visual experience.
The dimming method based on linear fitting and curvature adjustment is adopted. Linear fitting is performed by dividing multiple fitting intervals, and the number of times and counting values are used to generate the adjustment value, reducing the need for storage and computing resources and improving accuracy.
It realizes high-precision exponential dimming, reduces the consumption of storage and computing resources, and provides a more comfortable and delicate visual experience.
Smart Images

Figure CN119255429B_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of electrical control, and in particular to a dimming method based on straight line fitting and curvature adjustment. Background Art
[0002] The brightness of a light-emitting diode (LED) can be achieved by adjusting the driving current of the LED. The pulse width modulation (PWM) dimming method can control the average driving current of the LED by changing the duty cycle of the PWM signal, thereby adjusting the brightness of the LED. The higher the duty cycle of the PWM signal, the higher the brightness; otherwise, the lower the duty cycle of the PWM signal, the lower the brightness. The switching frequency of the LED is much higher than the recognition frequency of the human eye, so the human eye will not feel the flickering of the light, but only the brightness change. In practical applications, the LED needs to have a uniform brightness change, that is, a linear brightness change. However, due to the different sensitivity of the human eye to high brightness and low brightness, the human eye can only recognize the linear change of brightness when the switching duty cycle changes exponentially. In order to make the human eye have a more comfortable dimming experience, the exponential dimming method is widely used.
[0003] Existing exponential dimming methods include lookup table method, formula method, straight line fitting method, etc. The lookup table method can pre-set the PWM configuration value so that the relationship between the PWM configuration value and the high-level duration of the PWM signal conforms to the exponential mapping relationship. This method requires the storage of a large amount of data for table lookup output, which consumes a lot of storage resources. The formula method requires the use of a large number of multipliers or adders to perform complex calculations to achieve exponential dimming, which is difficult to implement, has a large calculation delay, and requires a large amount of computing resources; the straight line fitting method uses multiple straight lines to fit the exponential dimming curve, which requires a large amount of computing resources in the fitting process and has low accuracy. Summary of the invention
[0004] In view of the technical problems existing in the prior art, the present application proposes a dimming method based on straight-line fitting and curvature adjustment, comprising: obtaining a PWM configuration value, wherein the PWM configuration value is a binary number, and a plurality of fitting intervals are divided based on its value range; the sequence number of the fitting interval is a decimal number determined based on at least the first part of the content of the PWM configuration value; judging the fitting interval in which the PWM configuration value is located based on the first part of the content of the PWM configuration value; when the PWM configuration value is other than its maximum value and the fitting interval in which the PWM configuration value is located is the first fitting interval, obtaining a straight-line fitting result based on the PWM configuration value and the fitting interval in which the PWM configuration value is located; wherein the straight-line fitting result The number of bits is greater than the number of bits of the PWM configuration value; the first fitting interval is an interval starting from the minimum value of the PWM configuration value; an initial value of the number of adjustments is obtained based on the second part of the PWM configuration value; when the initial value of the number of adjustments is not 0 and the fitting interval where the PWM configuration value is located is a fitting interval other than the first fitting interval, the first stage adjustment is performed on the straight line fitting result, including: generating a corresponding first adjustment value based on the count value and the fitting interval where the PWM configuration value is located, and performing a first stage adjustment operation on the straight line fitting result using the first adjustment value, and the number of adjustments is reduced to 0 after each first stage adjustment operation.
[0005] In particular, the method, wherein, when the PWM configuration value is located in other fitting intervals except the first fitting interval, the straight line fitting result corresponding to each of the PWM configuration values includes a first part, a second part and a third part in order from the lowest bit to the highest bit; the straight line fitting result is a binary number with a fixed number of bits, the first part of which includes one or more 0s, wherein the number of 0s is the serial number of the fitting interval where the PWM configuration value is located minus 1; the second part of which includes the value of the lowest X bits of the PWM configuration value, wherein X is an integer greater than or equal to 5; the lowest bit of the third part of which is 1, and if there are any remaining bits, they are 0.
[0006] In particular, in the method, when the PWM configuration value is located in the first fitting interval, the PWM configuration value is used as the straight line fitting result.
[0007] In particular, in the method described, when the PWM configuration value is a maximum value, the straight line fitting result is a preset fixed value.
[0008] In particular, the method, based on the PWM configuration value, obtains the number of adjustments, including: when the Xth bit from the lowest bit of the PWM configuration value is 0, the number of adjustments is a decimal number corresponding to the value of the lowest X-1 bits of the PWM configuration value, where X is an integer greater than or equal to 5; when the Xth bit from the lowest bit of the PWM configuration value is 1, the number of adjustments is a decimal number corresponding to the value of the lowest X-1 bits of the PWM configuration value after bit-by-bit inversion.
[0009] In particular, in the method described, when the number of adjustments is zero or the fitting interval where the PWM configuration value is located is the first fitting interval, the straight line fitting result is set as the final adjustment result.
[0010] In particular, the method, wherein the first adjustment value is obtained based on the fitting interval where the count value and the PWM configuration value are located, and when the PWM configuration value is located in the highest sequence number fitting interval, the lowest F bits of the count value are bit-by-bit inverted to obtain the first adjustment value; wherein F is an integer greater than or equal to 4; when the PWM configuration value is located in other fitting intervals except the highest sequence number fitting interval and the second fitting interval, the result of bit-by-bit inversion of the lowest F bits of the count value is shifted right to obtain the first adjustment value, the number of shifts is less than F and is the difference between the highest sequence number and the sequence number of the fitting interval where the PWM configuration value is located, and the remaining bits are 0; when the PWM configuration value is located in the second fitting interval, the value of the inverted Fth bit of the count value from the lowest bit and the value of the first bit of the count value from the lowest bit are ANDed to obtain the result as the lowest bit of the first adjustment value, and the remaining bits are 0.
[0011] In particular, the method further includes, when the initial value of the adjustment times is not 0, performing a second stage adjustment; wherein, when the PWM configuration value is located in other fitting intervals outside the highest fitting interval, a second adjustment value is obtained based on a formula corresponding to the fitting interval and a count value, including: when the difference between the sequence number of the fitting interval where the PWM configuration value is located and the sequence number of the highest fitting interval is 1 or 3, the second adjustment value is a value inverted from the first bit of the count value from the lowest bit; when the difference between the sequence number of the fitting interval where the PWM configuration value is located and the sequence number of the highest fitting interval is 2, the second adjustment value is a value inverted from the second bit of the count value from the lowest bit; when the difference between the sequence number of the fitting interval where the PWM configuration value is located and the sequence number of the highest fitting interval is greater than or equal to 4, the second adjustment value is 0; when the difference between the sequence number of the fitting interval where the PWM configuration value is located and the sequence number of the highest fitting interval is equal to 5, and the decimal number corresponding to the lowest F bit of the count value is 13, the second adjustment value is 1, wherein F is an integer greater than or equal to 4.
[0012] In particular, the method further includes that, when the PWM configuration value is located in the highest sequence number fitting interval, the number of adjustment of the second stage adjustment is 1, and the second adjustment value is the initial value of the number of adjustment; or, when the PWM configuration value is located in the highest sequence number fitting interval, the number of adjustment of the second stage adjustment is the initial value of the adjustment value, and the second adjustment value is 1.
[0013] In particular, in the method, the sum of all first adjustment values and all second adjustment values is a total adjustment value, and the total adjustment value is symmetrical in the same fitting interval.
[0014] The present application also relates to an electronic device, comprising an LED dimming device, wherein the LED dimming device is configured to execute any of the above methods.
[0015] Particularly, the electronic device further comprises an LED light emitting element.
[0016] The dimming method based on straight line fitting and curvature adjustment proposed in the present application adopts a combination of straight line fitting and curvature adjustment, uses a more optimized algorithm, and uses less storage and computing resources to achieve exponential dimming with higher precision. BRIEF DESCRIPTION OF THE DRAWINGS
[0017] Below, the preferred embodiments of the present application will be further described in detail with reference to the accompanying drawings, wherein:
[0018] Figure 1 Shown is a schematic diagram of an LED dimming target curve according to an embodiment of the present application;
[0019] Figure 2 The figure is a schematic diagram of a straight line fitting result curve according to an embodiment of the present application;
[0020] Figure 3 Shown is a flow chart of a straight line fitting method according to an embodiment of the present application;
[0021] Figure 4 FIG. 1 is a schematic diagram of a curve showing changes in a trimming value with a PWM configuration value according to an embodiment of the present application;
[0022] Figure 5 Shown is a flow chart of a curvature adjustment method according to an embodiment of the present application;
[0023] Figure 6 The figure shows a schematic diagram of a curve before and after adjustment of a straight line fitting result according to an embodiment of the present application;
[0024] Figure 7 FIG. 4 is a schematic diagram of dimming simulation results according to an embodiment of the present application. DETAILED DESCRIPTION
[0025] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application.
[0026] In the following detailed description, reference may be made to the various specification drawings that are part of the present application and are used to illustrate specific embodiments of the present application. In the accompanying drawings, similar reference numerals describe substantially similar components in different figures. The various specific embodiments of the present application are described below in sufficient detail so that a person of ordinary skill in the art with relevant knowledge and skills in the art can implement the technical solutions of the present application. It should be understood that other embodiments may also be used or structural, logical or electrical changes may be made to the embodiments of the present application.
[0027] The technologies, methods and devices known to those skilled in the art may not be discussed in detail, but where appropriate, the technologies, methods and devices shall be considered as part of the specification. The lines between the units in the drawings are only for the convenience of explanation, indicating that at least the units at both ends of the lines are communicating with each other, and are not intended to limit the unconnected units from being unable to communicate. In addition, the number of lines between two units is intended to indicate at least the number of signals involved in the communication between the two units or at least the output terminals, and is not intended to limit the two units to only be able to communicate with each other through the signals shown in the figure.
[0028] The traditional exponential dimming method either uses calculation modules such as adders and multipliers to fit the dimming curve, or uses a lookup table to map PWM to the calculation value of an exponential function, and obtains the final dimming control value corresponding to the PWM configuration value in a certain way. In this process, a large number of calculation or storage units are consumed.
[0029] The dimming method based on straight line fitting and curvature adjustment proposed in this application adopts a combination of straight line fitting and curvature adjustment to reduce the demand for storage and computing resources, and realizes exponential dimming with higher precision through a more optimized algorithm, providing users with a more comfortable and delicate visual experience.
[0030] Figure 1 FIG. 4 is a schematic diagram of an LED dimming target curve according to an embodiment of the present application. Figure 1The LED dimming target curve shown is an exponential curve. The horizontal axis represents the PWM configuration value, and its value is a decimal number corresponding to an eight-bit binary number. The vertical axis represents the dimming control value corresponding to the PWM configuration value, and its value is a decimal number corresponding to a 12-bit binary number. The LED dimming device generates a PWM signal of a corresponding duty cycle based on the dimming control value. In the LED dimming target curve, the larger the value of the PWM configuration value, the higher the duty cycle of the generated PWM signal, the higher the brightness of the LED, and the higher the slope of the curve; the smaller the value of the PWM configuration value, the lower the duty cycle of the generated PWM signal, the lower the brightness of the LED, and the lower the slope of the curve. According to one embodiment of the present application, the number of bits of the dimming control value is greater than the number of bits of the PWM configuration value.
[0031] Figure 2 FIG. 1 is a schematic diagram of a straight line fitting result curve according to an embodiment of the present application. The horizontal axis represents the PWM configuration value, and the vertical axis represents the straight line fitting result. Figure 2 As shown, the LED dimming target curve is fitted by M segments of linear functions, where M is an integer greater than or equal to 1.
[0032] According to one embodiment, the PWM configuration value is divided into M fitting intervals in sequence with its minimum value as the starting value, and the LED dimming target curve is divided into M segments according to the fitting intervals.
[0033] According to an embodiment of the present application, an LED dimming device includes a register. The register is configured to receive a PWM configuration value of an N-bit binary number, where N is an integer greater than or equal to 1.
[0034] In one embodiment of the present application, the register is configured to receive an eight-bit binary PWM configuration value, and the decimal range corresponding to the numerical range of the PWM configuration value is 0-255. With the minimum value of the PWM configuration value as the starting value, the PWM configuration value is divided into a plurality of fitting intervals in order of each 32 PWM configuration values. The dimming control value corresponding to the PWM configuration value in the fitting interval with the minimum value of the PWM configuration value as the starting value and a fitting interval adjacent thereto changes little, so these two fitting intervals can be combined as the first fitting interval. The first fitting interval includes PWM configuration values 0-31 and 32-63; the second fitting interval includes PWM configuration values 64-95; the third fitting interval includes PWM configuration values 96-127; the fourth fitting interval includes PWM configuration values 128-159; the fifth fitting interval includes PWM configuration values 160-191; the sixth fitting interval includes PWM configuration values 192-223; the seventh fitting interval includes PWM configuration values 224-254 and the maximum value 255 of the PWM configuration value. In the first fitting interval, as the PWM configuration value increases, the change of the dimming control value is relatively the slowest; from the second to the sixth fitting intervals, as the PWM configuration value increases, the change of the dimming control value gradually becomes faster; in the seventh fitting interval, as the PWM configuration value increases, the change of the dimming control value is the fastest relative to other fitting intervals.
[0035] According to one embodiment, within the fitting interval of each PWM configuration value, a straight line fitting is performed on the LED dimming target curve to obtain M linear functions based on different fitting intervals. The linear function can be modeled as:
[0036] Y=K(Xb)
[0037] Wherein, X represents the PWM configuration value. Y represents the straight line fitting result. K represents the slope of the linear function, and b represents the offset. In different fitting intervals, the modeled linear function has different slopes K, and the corresponding relationship between the PWM configuration value and the straight line fitting result is also different. In some embodiments of the present application, in two adjacent fitting intervals, the K value of the linear function fitted in the latter fitting interval is twice the K value of the linear function fitted in the previous fitting interval; except for the first fitting interval, the difference between the offsets b of the linear functions of two adjacent fitting intervals is 32, corresponding to the width of each fitting interval. Here, the PWM configuration value included in the latter fitting interval is greater than the PWM configuration value included in the previous fitting interval.
[0038] In the following detailed description, the PWM configuration value includes an eight-bit binary number. Taking the minimum value of the PWM configuration value as the starting value, the value range of the PWM configuration value is divided into seven fitting intervals in sequence to illustrate the dimming method proposed in the present application. Among them, the first fitting interval is a fitting interval with the minimum PWM configuration value as the starting value, for example Figure 2 The first fitting interval in (PWM configuration value 0~63); the starting value of the PWM configuration value of the highest numbered fitting interval is greater than the PWM configuration values contained in other fitting intervals, for example Figure 2 The seventh fitting interval (PWM configuration value 224-255) in FIG. 1 is a seventh fitting interval (PWM configuration value 224-255). It can be understood that the fitting interval can also be divided by taking the maximum value of the PWM configuration value as the starting point and dividing in the order of gradually decreasing PWM configuration values.
[0039] The PWM configuration value is divided into two parts, and the values of the first part of the PWM configuration value corresponding to different fitting intervals are different. The decimal number determined by the content of the first part of the PWM configuration value can be used as the serial number of the fitting interval and the fitting interval where the PWM configuration value is located. The value of the first part of the PWM configuration value corresponding to the highest serial number fitting interval is the largest. The second part of the PWM configuration value corresponds to a trimming point within a fitting interval. It can be understood that the first part and the second part of the PWM configuration value can include different bits, but the sum of the bits of the two parts is the sum of the bits of the PWM configuration value. For example, when the PWM configuration value is 9 digits, the PWM configuration value can be divided into 16 fitting intervals, and the upper four bits of the PWM configuration value in each fitting interval are the first part, and the values of the first part of the PWM configuration value in different fitting intervals are different; the lower five bits of the PWM configuration value are the second part.
[0040] According to one embodiment, the first part of the PWM configuration value includes the highest N bits of the PWM configuration value; the second part of the PWM configuration value includes the remaining bits of the PWM configuration value except the highest N bits. The sum of the number of bits of the first part and the second part of the PWM configuration value is the total number of bits of the PWM configuration value, wherein N is an integer greater than or equal to 3.
[0041] In the following description, the PWM configuration value is divided into two parts: the highest three bits and the lowest five bits. The first part corresponds to the fitting interval where the PWM configuration value is located, and the lowest five bits of the PWM configuration value correspond to the adjustment points in the fitting interval. Figure 2For example, the highest three digits of the PWM configuration value included in the first fitting interval are 000 or 001. Except for the first fitting interval, the highest three digits of the PWM configuration values included in other fitting intervals are the same. For example, when the highest three digits of the PWM configuration value are 010, the PWM configuration value is located in the second fitting interval; when the highest three digits of the PWM configuration value are 011, the PWM configuration value is located in the third fitting interval; when the highest three digits of the PWM configuration value are 100, the PWM configuration value is located in the fourth fitting interval; when the highest three digits of the PWM configuration value are 101, the PWM configuration value is located in the fifth fitting interval; when the highest three digits of the PWM configuration value are 110, the PWM configuration value is located in the sixth fitting interval; when the highest three digits of the PWM configuration value are 111, the PWM configuration value is located in the seventh fitting interval.
[0042] The reason why the lowest five bits of the PWM configuration value are selected as the adjustment point is that no matter how many bits the total number of PWM configuration values is, the accuracy of determining the adjustment point using the lowest five bits is relatively high and basically meets the use requirements. Of course, the user can adjust the number of bits of the PWM configuration value used as the coordinates of the adjustment point according to the needs within the scope of protection of this application.
[0043] Figure 3 The figure shows a flow chart of a straight line fitting method according to an embodiment of the present application. According to an embodiment, the straight line fitting method can be executed by an LED dimming device.
[0044] Step 301, obtaining PWM configuration value.
[0045] According to one embodiment, the PWM configuration values may be specified by a user.
[0046] Step 302: determine the fitting interval of the PWM configuration value based on the highest three digits of the PWM configuration value.
[0047] Step 303: When the PWM configuration value is within the first fitting interval (eg Figure 2 When the first fitting interval is within 0~63), the value of the straight line fitting result is set to the current PWM configuration value.
[0048] According to one embodiment, the number of bits of the straight line fitting result is higher than the number of bits of the PWM configuration value.
[0049] Step 304, when the PWM configuration value is in other fitting intervals except the first fitting interval, the value of the straight line fitting result includes a first part, a second part and a third part from the lowest bit to the highest bit, wherein the first part includes one or more 0s, and the corresponding decimal number is 0, wherein the number of 0s is the sequence number of the fitting interval where the PWM configuration value is located minus 1; the second part includes the lowest five bits of the PWM configuration value; the lowest bit of the third part is 1, and if there are any other bits, they are 0.
[0050] According to an embodiment of the present application, based on the first part of the content of the PWM configuration value, for example, the highest three digits, the straight line fitting result can be generated by splicing in real time, or the first part and / or the third part of the straight line fitting result corresponding to the PWM configuration value in the fitting interval and the PWM configuration value in the fitting interval can be obtained by looking up a table. The advantage of obtaining part of the straight line fitting result by looking up a table is that the processing speed of this method is relatively high. Of course, those skilled in the art can obtain part of the straight line fitting result by other methods within the scope of protection of the present application.
[0051] Step 305: When the value of the PWM configuration value is the maximum value, the value of the straight line fitting result is set to a fixed value. The fixed value can be obtained based on the LED dimming target curve. According to one embodiment of the present application, the fixed value is a dimming control value corresponding to the maximum value of the PWM configuration value.
[0052] Table 1
[0053]
[0054] Table 1 shows a list of correspondences between various fitting intervals and their straight-line fitting results according to an embodiment of the present application. The first and second columns represent different fitting intervals and the corresponding PWM configuration value ranges, including seven fitting intervals and the maximum value of the PWM configuration value; the third column represents the linear function corresponding to each fitting interval; the fourth column represents the first part of the PWM configuration value, i.e., the highest three digits; the fifth and sixth columns are the minimum and maximum values of the PWM configuration value in each fitting interval, respectively; the seventh and eighth columns represent the slope and offset of the linear function corresponding to each fitting interval, where the slope K is a decimal number; the ninth column is the algorithm for the straight-line fitting result corresponding to each fitting interval. The straight-line fitting result corresponding to the maximum value of the PWM configuration value is a fixed value, which can be obtained through the LED dimming target curve. In the first fitting interval, the straight-line fitting result corresponding to the PWM configuration value is itself.
[0055] In Table 1, when the highest three bits of the PWM configuration value are 111, it is determined that the PWM configuration value is located in the seventh fitting interval (224≤X≤254), the linear function corresponding to the fitting interval is Y=64(X-192), the slope of the linear function is 64, the offset is 192 (the corresponding binary number is 11000000), and the minimum and maximum values of the PWM configuration value are 11100000 and 11111110 respectively. The number of 0s included in the first part of the straight line fitting result corresponding to the PWM configuration value is seven minus one, the second part includes the lowest five bits of the PWM configuration value, and the third part includes one 1, a total of 12 binary bits. When the highest three bits of the acquired PWM configuration value are 110, the PWM configuration value is located in the sixth fitting interval (192≤X≤223), the number of 0s included in the first part of the straight line fitting result corresponding to the PWM configuration value is six minus one, the second part includes the lowest five bits of the PWM configuration value, the lowest bit of the third part is 1, and the remaining bits are 0; and so on. When the highest three digits of the acquired PWM configuration value are 000 or 001, the PWM configuration value is in the first fitting interval (0≤X≤63), and the straight line fitting result corresponding to the PWM configuration value is the value of the PWM configuration value. When the maximum value of the PWM configuration value is 255, the corresponding straight line fitting result is 4095.
[0056] In the straight line fitting process, registers are used to store the correspondence between a small amount of PWM configuration values and straight line fitting results. The straight line fitting results corresponding to the PWM configuration values can be obtained without the need for arithmetic logic units, which greatly reduces the consumption of circuit computing resources and storage resources.
[0057] In order to improve the fitting accuracy, after obtaining the straight line fitting result of the PWM configuration value, the straight line fitting result is adjusted multiple times using the curvature adjustment method to obtain the adjustment result corresponding to the PWM configuration value, and the adjustment result is used as the dimming control value to control the duty cycle of the PWM signal, and a smoother exponential curve is obtained by adjusting the straight line fitting result. Among them, the method for obtaining the straight line fitting result of the LED dimming target curve is not limited to the straight line fitting method proposed in the above embodiment, and can also be other methods.
[0058] In a fitting interval, the lowest five digits of the PWM configuration value correspond to the adjustment point in the fitting interval, so a corresponding relationship is established between the lowest five digits of the PWM configuration value and the total adjustment value, and the total adjustment value is used to adjust the straight line fitting result corresponding to the PWM configuration value.
[0059] Table 2
[0060]
[0061] Table 2 shows a table corresponding to the lowest five bits of the PWM configuration value and the total trimming value according to an embodiment. The first column in pwm_config[4:0] represents the decimal number corresponding to the lowest five bits of the PWM configuration value, and the second column in pwm_config[4:0] represents the lowest five bits of the PWM configuration value. The first to seventh columns of trim_value represent the fitting intervals divided based on the value range of the PWM configuration value, and the total trimming value corresponding to the PWM configuration value in each fitting interval, where the total trimming value is a decimal number. For example, in the seventh fitting interval 224≤x≤255, when the lowest five bits of the PWM configuration value are 01000, the corresponding total trimming value is a decimal number 100. In different fitting intervals, the total trimming values corresponding to different PWM configuration values are different. The total trimming value corresponding to the PWM configuration value in the highest numbered fitting interval is greater than the total trimming value corresponding to the PWM configuration value in other fitting intervals.
[0062] In Table 2, within any fitting interval, the total trim value is symmetrical. When the lowest five bits of the PWM configuration value change from small to large, the total trim value is symmetrical about the middle value of the lowest five bits of the PWM configuration value. Within a fitting interval, based on the binary number of the fifth bit of the PWM configuration value from the low bit, the PWM configuration value can be divided into two categories: the fifth bit is 0 and the fifth bit is 1. The trim value ranges of the two categories are the same but the change trends are opposite. For example, in the fitting interval 224≤x≤255, the value of the fifth bit of the PWM configuration value from the low bit can divide the lowest five bits of the PWM configuration value into two categories: 00000~01111 and 10000~11111. In the first category (00000~01111), the lowest four bits of the PWM configuration value change from 0000 to 1111, and the decimal number corresponding to the total trim value changes from the minimum value (0) to the maximum value (135). In the second category (10000~11111), the lowest four bits of the PWM configuration value change from 0000 to 1111, and the decimal number corresponding to the total adjustment value changes from the maximum value (135) to the minimum value (0). At this time, the result of inverting the lowest four bits in the second part of the PWM configuration value bit by bit and matching it with the total adjustment value can obtain the same result as the first category. In other words, among the lowest five bits of the PWM configuration value, the highest bit can be used to determine the category of the PWM configuration value in a fitting interval, and the remaining four bits are used to determine the adjustment point in the fitting interval.
[0063] Figure 4 The figure shows a curve diagram of the change of the trimming value with the PWM configuration value according to an embodiment of the present application. The horizontal axis represents the decimal number corresponding to the lowest five digits of the PWM configuration value; the vertical axis represents the total trimming value. Different curves represent the change of the total trimming value in different fitting intervals.
[0064] like Figure 4As shown, from the minimum value of the lowest five bits of the PWM configuration value to the middle value of the lowest five bits of the PWM configuration value, the difference between the total adjustment values corresponding to two adjacent PWM configuration values is taken as the step value, and the step value decreases as the PWM configuration value increases. This decrease in step value is reflected in the fact that when a tangent line is drawn through the corresponding point of the PWM configuration value on any curve, the slope of the tangent line gradually decreases. Based on the symmetrical relationship of the total adjustment values within the same fitting interval, the step values also have a symmetrical relationship. The curvature adjustment method changes the slope of the linear function corresponding to each fitting interval by changing the step value between two adjacent total adjustment values, and adjusts the linear function corresponding to each fitting interval into a curve.
[0065] According to an embodiment, when the total adjustment value increases first and then decreases in a fitting interval, the final adjustment result may be the difference between the straight line fitting result and the total adjustment value.
[0066] According to another embodiment of the present application, when the total adjustment value decreases first and then increases in a fitting interval, the final adjustment result may be the sum of the straight line fitting result and the total adjustment value.
[0067] In one embodiment of the present application, the total adjustment value corresponding to the PWM configuration value is divided into multiple adjustment values, and the straight line fitting result is adjusted multiple times.
[0068] Table 3
[0069]
[0070] Table 3 shows a table of the correspondence between the number of adjustments and the lowest five digits of the PWM configuration value according to an embodiment of the present application. The first column is the decimal number corresponding to the lowest five digits of the PWM configuration value, and the second column is the corresponding number of adjustments. Based on the symmetry of the total adjustment value in the same fitting interval, the number of adjustments also has a symmetrical relationship, and the number of adjustments is symmetrical about the middle value of the lowest five digits of the PWM configuration value. For example, when the decimal number corresponding to the lowest five digits of the PWM configuration value increases from 0 to 15, the number of adjustments increases from 0 to 15; when the decimal number corresponding to the lowest five digits of the PWM configuration value increases from 16 to 31, the number of adjustments decreases from 15 to 0.
[0071] According to one embodiment, the number of adjustments is obtained based on the content of the second part of the PWM configuration value. In one embodiment, based on the symmetrical relationship of the number of adjustments within the same fitting interval, the number of adjustments is obtained using the lowest four bits of the PWM configuration value. The reason why the value of the lowest four bits of the PWM configuration value is selected to generate the initial value of the number of adjustments is that no matter how many total bits of the PWM configuration value are, within a fitting interval, the accuracy of generating the number of adjustments using the lowest four bits of the PWM configuration value is already relatively high, which basically meets the use requirements. Of course, the user can adjust the number of bits of the PWM configuration value used to generate the initial value of the number of adjustments according to needs within the scope of protection of this application.
[0072] According to an embodiment of the present application, based on the symmetry of the total adjustment value within the same fitting interval, the adjustment values used in each adjustment also have a symmetrical relationship.
[0073] In one embodiment of the present application, the LED dimming device includes a counter, and the counter is configured to count cyclically and cumulatively from zero and output the count value. When the counter starts counting from zero, the PWM outputs a high level until the count value reaches the dimming control value corresponding to the PWM configuration value, and the PWM outputs a low level, thereby controlling the duty cycle output of the PWM. One or more adjustment values are generated based on the count value, and the straight line fitting result is adjusted multiple times based on the adjustment value to obtain the final adjustment result, and the final adjustment result is used as the dimming control value. According to one embodiment, the counter can be a component originally included in the electronic device where the LED light-emitting element is located, so the working state and value of the counter are not controlled by the dimming device, but serve the electronic device as a whole. Here, it is only required that the value of the binary counter is greater than or equal to, for example, 4 bits. Of course, the user can use other counters as needed and use the count value of the counter to obtain the adjustment value.
[0074] According to one embodiment, the adjustment process of the straight line fitting result may include one or more stages. The number of adjustment times in each stage is obtained according to the PWM configuration value. The sum of all adjustment values used in each stage is the total adjustment value.
[0075] In some embodiments, during the counting process of the counter, different fitting intervals correspond to different algorithms, and a first adjustment value is obtained based on different algorithms and the counting value of the counter. The first stage adjustment can use the first adjustment value to adjust the straight line fitting result.
[0076] Table 4
[0077]
[0078] Table 4 shows a list of first adjustment values according to an embodiment of the present application. Among them, the first column in the counter pwm_cnt[4:0] represents the decimal number corresponding to the lowest five digits of the count value, and the second column is the lowest five digits of the count value. The second to eighth columns are the first adjustment values used for each adjustment from the seventh fitting interval to the first fitting interval, and the total of the first adjustment values used for all previous adjustments. The last line is the first adjustment value algorithm corresponding to each fitting interval. In the counting process of the count value starting from zero, the first stage curvature adjustment is performed in the counting process from 0 to 15, and the lowest four digits of the count value change from 0000 (decimal number 0) to 1111 (decimal number 15).
[0079] According to one embodiment, each time the counter counts once, a first trimming value is generated based on the lowest four bits of the count value, and a trimming is completed using the first trimming value. Accordingly, each time a trimming is completed, the number of trimming times is reduced by one.
[0080] The selection of the number of bits of the count value is related to the adjustment accuracy and is not limited to the value of the lowest four bits. Here, the value of the lowest four bits of the count value is selected as the first adjustment value because the accuracy of the first adjustment value generated thereby has basically met the use requirements. Of course, the user can adjust the number of bits of the count value used as the first adjustment value according to the needs within the scope of protection of this application.
[0081] For example, when the count value is counted from 0 to 15, the first stage adjustment is performed, and the adjustment value algorithm corresponding to the PWM configuration value in the seventh fitting interval (224≤x≤255) is to invert the lowest four bits of the count value bit by bit. When the PWM configuration value is adjusted for the first time, the count value of the counter is 0, and the decimal number corresponding to the first adjustment value obtained based on the adjustment value algorithm is 15, and the decimal number corresponding to the accumulated first adjustment value is 15. When the PWM configuration value is adjusted for the second time, the count value of the counter is 1, and the decimal number corresponding to the first adjustment value obtained is 14, and the decimal number corresponding to the accumulated first adjustment value after the two adjustments is 29. When the PWM configuration value is adjusted for the third time, the count value of the counter is 2, and the decimal number corresponding to the first adjustment value obtained is 13, and the decimal number corresponding to the accumulated first adjustment value after the two adjustments is 42.
[0082] Figure 5 FIG. 1 is a flow chart of a curvature adjustment method according to an embodiment of the present application. According to an embodiment, the curvature adjustment method can be executed by an LED dimming device.
[0083] Step 501, obtaining straight line fitting results and PWM configuration values.
[0084] Step 502, based on the second part of the PWM configuration value, obtains an initial value of the number of adjustment times, which may specifically include steps 5021-5023.
[0085] Step 5021, determine whether the fifth bit from the lowest bit of the PWM configuration value is 0. If yes, execute step 5022, otherwise, execute step 5023.
[0086] Step 5022: when the fifth bit from the lowest bit of the PWM configuration value is 0, the initial value of the adjustment times is set to the decimal number corresponding to the lowest four bits of the PWM configuration value.
[0087] Step 5023: when the fifth bit from the lowest bit of the PWM configuration value is 1, the initial value of the adjustment times is set to a decimal number corresponding to the result of bit-by-bit inversion of the lowest four bits of the PWM configuration value.
[0088] Step 503, determine whether the initial value of the adjustment times is 0 or whether the PWM configuration value is in the first fitting interval. When the initial value of the adjustment times is not 0 and the PWM configuration value is in other fitting intervals except the first fitting interval, jump to 505; when the initial value of the adjustment times is 0 or the PWM configuration value is in the first fitting interval, jump directly to 504 and use the straight line fitting result as the final adjustment result.
[0089] Step 505 , determining the fitting interval of the PWM configuration value based on the highest three digits of the PWM configuration value, obtaining a first adjustment value algorithm corresponding to the fitting interval, and obtaining a first adjustment value based on the first adjustment value algorithm.
[0090] According to one embodiment, the straight line fitting result is set as the initial value of the adjustment result of the first stage adjustment.
[0091] Step 506, determine whether the trimming enable signal is valid. If the trimming enable signal is valid, jump to 508 to perform the first stage trimming; if the trimming enable signal is invalid at this time, it is necessary to execute step 507 to wait for the count value to be updated until the trimming enable signal is valid and then jump to 508.
[0092] According to one embodiment, when the decimal number corresponding to the lowest four digits of the count value of the counter is 0 and the number of adjustments is not 0, the adjustment enable signal jumps from the invalid state to the valid state and lasts until the number of adjustments is 0, after which the adjustment enable signal jumps to the invalid state. In this case, the LED dimming control device starts to perform the first stage adjustment on the straight line fitting result.
[0093] According to another embodiment, when the trimming number is 0, the trimming enable signal is in an invalid state.
[0094] Step 508 , obtaining a first trimming value based on the first trimming value algorithm and the lowest four bits of the count value.
[0095] According to one embodiment, when the PWM configuration value is within the highest numbered fitting interval (eg, the seventh fitting interval 224≤x≤255 in Table 4), the lowest four bits of the first trimming value are the result of bit-by-bit inversion of the lowest four bits of the count value.
[0096] According to one embodiment, when the PWM configuration value is located in the highest numbered fitting interval and other fitting intervals other than the second fitting interval, the result of bit-by-bit inversion of the lowest four bits of the count value is shifted right to obtain the first adjustment value, the number of shifts is less than 4 and is the difference between the highest number and the number of the fitting interval where the PWM configuration value is located, and the remaining bits are 0. Specifically, when the PWM configuration value is located in the sixth fitting interval, the lowest three bits of the first adjustment value are the result of bit-by-bit inversion of the second to fourth bits of the count value from the low bit, and the remaining bits are 0. When the PWM configuration value is located in the fifth fitting interval, the lowest two bits of the first adjustment value are the result of bit-by-bit inversion of the third and fourth bits of the count value from the low bit, and the remaining bits are 0. When the PWM configuration value is located in the fourth and third fitting intervals, the lowest bit of the first adjustment value is the result of bit-by-bit inversion of the fourth bit of the count value from the low bit, and the remaining bits are 0.
[0097] According to one embodiment, when the PWM configuration value is in the second fitting interval (for example, the second fitting interval 64≤x<96 in Table 4), the result obtained by performing an AND operation on the inverted value of the fourth bit of the count value from the low bit and the value of the first bit of the count value from the low bit is used as the lowest bit of the first adjustment value, and the remaining bits are 0.
[0098] Step 509, updating the adjustment result of the first stage adjustment. The difference between the adjustment result of the first stage adjustment and the first adjustment value is updated as the adjustment result of the first stage adjustment.
[0099] Step 510, updating the adjustment times of the first stage adjustment, and updating the value obtained by subtracting 1 from the adjustment times as the adjustment times.
[0100] According to one embodiment, a first adjustment value is obtained based on the fitting interval where the PWM configuration value is located and the current count value of the counter, and the first adjustment value is subtracted from the straight line fitting result to obtain the adjustment result, and the number of adjustments is reduced accordingly.
[0101] Step 511 , determining whether the number of adjustment times in the first stage adjustment is equal to 0. If the number of adjustment times is equal to 0, executing step 513 , otherwise jumping to step 508 .
[0102] In some embodiments, the first stage adjustment is completed on the straight line fitting result to meet the dimming requirement, and the adjustment result of the first stage adjustment can be used as the final adjustment result.
[0103] Optionally, according to other embodiments, the adjustment of the straight line fitting result may further include a second stage adjustment, in which the adjustment result of the first stage adjustment is adjusted using the second adjustment value to obtain a higher dimming accuracy.
[0104] Table 5
[0105]
[0106] Table 5 shows a list of second adjustment values according to an embodiment of the present application. Among them, the first column of pwm_cnt[4:0] represents the decimal number corresponding to the lowest five digits of the count value, and its value increases from 16 to 31; its second column represents the lowest five digits of the count value. The second to seventh columns are the second adjustment values and the accumulated second adjustment values corresponding to the count value in each fitting interval from the seventh fitting interval to the first fitting interval. The last line of Table 5 is the second adjustment value algorithm corresponding to each fitting interval. According to an embodiment of the present application, when adjusting the straight line fitting result, the first stage adjustment is performed when the decimal number corresponding to the count value is 0~15; the second stage adjustment is performed when the decimal number corresponding to the count value is 16~31.
[0107] In Table 5, for the PWM configuration value in the seventh fitting interval (224≤x≤255), when the count value starts from 16 to 32, the second trimming value is always 1, and the decimal value corresponding to the second trimming value accumulated successively is 15. For the PWM configuration value in the sixth fitting interval (192≤x<224), the second trimming value is the result obtained by inverting the lowest bit of the count value. When the lowest bit of the count value is 0, the second trimming value is 1; when the lowest bit of the count value is 1, the second trimming value is 0. When the count value starts from 16 to 32, the decimal value corresponding to the second trimming value accumulated successively is 8.
[0108] According to one embodiment, the adjustment result of the first stage adjustment is obtained as the initial value of the adjustment result of the second stage adjustment.
[0109] Step 513, performing a second stage adjustment on the first stage adjustment result using the second adjustment value.
[0110] For the highest numbered fitting interval, the second stage adjustment can be performed on the adjustment results of the first stage. The following two methods can be used.
[0111] In one embodiment, the number of times of the second stage adjustment is 1. The difference between the adjustment result of the first stage adjustment and the second adjustment value is used as the final adjustment result. That is, the adjustment result of the first stage adjustment is adjusted once to obtain the final adjustment result. The second adjustment value is the initial value of the number of times of adjustment.
[0112] In another embodiment, the adjustment result of the first stage adjustment is adjusted multiple times, and the second adjustment value of each adjustment is 1. The number of adjustments is the number of adjustments in the first stage adjustment.
[0113] According to one embodiment, for other fitting intervals except the highest number fitting interval, the second adjustment value is used to perform multiple adjustments on the adjustment result of the first stage adjustment, and the adjustment result of the first stage adjustment is successively subtracted from the second adjustment value to obtain the adjustment result of the second stage adjustment, and the number of adjustments is correspondingly reduced by one. Among them, the number of adjustments of the second stage adjustment can be the same as the number of adjustments of the first stage adjustment. The fitting interval where the PWM configuration value is located is determined based on the highest three bits of the PWM configuration value, and the second adjustment value is obtained by a corresponding algorithm. When the difference between the fitting interval number where the PWM configuration value is located and the highest fitting interval number is 1 or 3, the second adjustment value is the value of the first bit of the count value from the lowest bit inverted. When the difference between the fitting interval number where the PWM configuration value is located and the highest fitting interval number is 2, the second adjustment value is the value of the second bit of the count value from the lowest bit inverted. When the difference between the fitting interval number where the PWM configuration value is located and the highest fitting interval number is equal to 4, the second adjustment value is 0. When the difference between the fitting interval number where the PWM configuration value is located and the highest fitting interval number is equal to 5, and the decimal number corresponding to the lowest four bits of the count value from the low bit is 13, the second adjustment value is 1.
[0114] According to one embodiment, the sum of all first trimming values and all second trimming values is the total trimming value.
[0115] Step 514: taking the adjustment result of the second stage adjustment as the final adjustment result and setting it as the dimming control value.
[0116] Table 6 shows a list of examples of two-stage adjustments for the highest-numbered fitting interval according to an embodiment of the present application. Among them, the first column is the decimal number corresponding to the PWM configuration value, which is located in the seventh fitting interval (224≤x≤255). The second column is the decimal number corresponding to the lowest five digits of the PWM configuration value, and the third column is the number of adjustments obtained based on the PWM configuration value. The fourth column represents the total adjustment value after the straight-line fitting result is adjusted in two stages, and the total adjustment value is the sum of all the first adjustment values and all the second adjustment values. The fifth column represents the adjustment result of the first stage adjustment obtained after the straight-line fitting result is reduced by the first adjustment value multiple times, wherein the numerical value in each row of the formula represents the value of the first adjustment value reduced each time the adjustment is made from left to right. The sixth column represents the final adjustment result obtained by reducing the adjustment result of the first stage adjustment by the second adjustment value.
[0117] Table 6
[0118]
[0119] Taking the PWM configuration value of 225 in Table 6 as an example, the fifth binary number from the lowest bit is 0, and the initial value of the number of adjustments is 1 based on the lowest four binary numbers 0001. When the adjustment enable signal is valid, the straight line fitting result corresponding to the PWM configuration value 225 is adjusted in the first stage. After obtaining the lowest four bits of the count value and inverting them bit by bit, the first adjustment value obtained is 15. The straight line fitting result corresponding to the PWM configuration value 225 is adjusted once, and the difference between the straight line fitting result and the first adjustment value (corresponding to the decimal number 15) is used as the adjustment result of the first stage adjustment. In the second stage adjustment, the number of adjustments is 1, the second adjustment value is 1, and the difference between the adjustment result of the first stage adjustment and the second adjustment value is used as the final adjustment result. The decimal number corresponding to the first and second adjustment values is 16. The lowest five bits of the PWM configuration value are different in different fitting intervals, and the corresponding adjustment values are also different.
[0120] According to another embodiment of the present application, the second stage adjustment may be performed on the straight line fitting result first, and the first stage adjustment may be performed on the adjustment result of the second stage adjustment, and the final adjustment result may be used as the dimming control value.
[0121] In the above-mentioned straight line fitting and curvature adjustment method, each step can be freely combined according to actual needs to obtain a dimming control value corresponding to the PWM configuration value.
[0122] According to one embodiment, when the count value output by the counter is 0, the PWM signal jumps to a high level; when the count value reaches the dimming control value, the PWM signal jumps to a low level. At this time, the duty cycle of the PWM output is (exp_value+1) / 4096, where exp_value represents the dimming control value. In one embodiment, when the PWM configuration value increases from 0 to 255, the duty cycle of the PWM signal increases according to an exponential curve, and the brightness of the LED light increases evenly. When the PWM configuration value decreases from 255 to 0, the duty cycle of the PWM signal decreases according to an exponential curve, and the brightness of the LED light decreases evenly.
[0123] Without consuming any computing resources, the straight line fitting result is obtained through the corresponding relationship between the PWM configuration value and the straight line fitting result. In the curvature adjustment process, only one subtractor / adder is needed to complete the adjustment of the straight line fitting result and obtain the final adjustment result in the original LED dimming device, so that the dimming curve formed by the final adjustment result is smoother.
[0124] Figure 6 Shown is a schematic diagram of a curve before and after adjustment of a straight line fitting result according to an embodiment of the present application. Figure 6The horizontal axis represents the PWM configuration value, and the vertical axis represents the adjustment result. Curve 1 is the curve formed by the straight line fitting result, and curve 2 is the curve obtained after adjusting the straight line fitting result. Figure 6 In the figure, the LED dimming target curve obtained after adjusting the straight line fitting result has a smoother transition and is more similar to an exponential curve.
[0125] Figure 7 The figure is a schematic diagram of dimming simulation results according to an embodiment of the present application. The value of the PWM configuration value pwm_config[7:0] is 240 (the corresponding binary number is 11110000), and the value of the straight line fitting result line_func[11:0] is 3072 (the corresponding binary number is 110000000000). Figure 7 In the embodiment, the trimming of the straight line fitting result includes the first stage trimming and the second stage trimming. The fifth binary number of the PWM configuration value is 1, and the lowest four binary numbers of the PWM configuration value are bit-by-bit inverted to obtain the value of the number of trimming times, which is 15. When the decimal number corresponding to the lower four bits of the count value pwm_cnt[3:0] is 0, the trimming enable signal sub_en jumps to a high level, and the lowest four bits of the count value are obtained and bit-by-bit inverted to obtain the first trimming value 15. At this time, the decimal number corresponding to trim[3:0] is the first trimming value, and the first trimming value is 15. In the first stage trimming process, the count value pwm_cnt[3:0] is counted from 0 to 15, and the decimal numbers corresponding to the first trimming values obtained 15 times based on the first trimming value algorithm are 15, 14, 13...2, 1 in sequence, and the first trimming value is subtracted from the straight line fitting result 3072 in sequence to obtain the trimming result 2952 of the first stage trimming. When the decimal number corresponding to the lowest four bits of the count value pwm_cnt[3:0] is 16, the second stage of trimming begins. In this case, the decimal number corresponding to trim[3:0] is the second trimming value, and the value of the second trimming value is 1. The trimming result 2952 of the first stage trimming is subtracted from the second trimming value 15 times in sequence, and the decimal number corresponding to the final trimming result exp_value[11:0] is 2937. The duty cycle of the PWM signal output by the LED dimming device is (2937+1) / 4096.
[0126] The present application also includes an electronic device, including an LED dimming control device and an LED device. The LED dimming control device performs any dimming method as described above. The LED dimming configuration device includes a register and a counter. The counter is configured to count cyclically from zero and output a count value, and the count value output by the counter ranges from 0 to 4095.
[0127] In some embodiments, the original circuit of the LED dimming control device includes a register and a timer, and the LED dimming control device only needs to add an additional subtractor to obtain the exponential adjustment result in real time through cumulative subtraction operation.
[0128] The three commonly used exponential dimming methods in the prior art directly correspond the PWM configuration value to the dimming control value through complex calculations or table lookups, which consumes a lot of computing resources or storage resources. The dimming method based on straight line fitting and curvature adjustment proposed in this application adopts a combination of straight line fitting and real-time adjustment to reduce the consumption of storage resources and computing resources, and uses a more optimized algorithm to obtain a higher precision exponential adjustment result, which has higher stability and higher precision, as well as faster processing speed, providing users with a more comfortable and delicate visual experience.
[0129] The above embodiments are only used to illustrate the present invention, but not to limit the present invention. Ordinary technicians in the relevant technical field can make various changes and modifications without departing from the scope of the present invention. Therefore, all equivalent technical solutions should also fall within the scope of the present invention.
Claims
1. A dimming method based on straight line fitting and curvature adjustment, comprising: Acquire a PWM configuration value, wherein the PWM configuration value is a binary number, and divide a plurality of fitting intervals based on its value range; The serial number of the fitting interval is a decimal number determined based on at least the first part of the PWM configuration value; Determine the fitting interval based on the first part of the PWM configuration value; When the PWM configuration value is a value other than its maximum value and the fitting interval in which it is located is a first fitting interval, a straight line fitting result is obtained based on the PWM configuration value and the fitting interval in which it is located; wherein the number of bits of the straight line fitting result is greater than the number of bits of the PWM configuration value; and the first fitting interval is an interval starting with the minimum value of the PWM configuration value; Obtaining an initial value of the number of adjustment times based on the second part of the PWM configuration value; When the initial value of the adjustment times is not 0 and the fitting interval where the PWM configuration value is located is a fitting interval other than the first fitting interval, the straight line fitting result is adjusted in the first stage, including: Generate a corresponding first adjustment value based on the count value and the fitting interval where the PWM configuration value is located, and use the first adjustment value to perform a first stage adjustment operation on the straight line fitting result, wherein the number of adjustments is reduced to 0 after each first stage adjustment operation; The first part of the PWM configuration value includes the highest N bits of the PWM configuration value; the second part of the PWM configuration value includes the remaining bits of the PWM configuration value except the highest N bits; the sum of the number of bits of the first part and the second part of the PWM configuration value is the total number of bits of the PWM configuration value; N is an integer greater than or equal to 3; Among them, when the Xth bit from the lowest bit of the PWM configuration value is 0, the number of adjustments is a decimal number corresponding to the value of the lowest X-1 bits of the PWM configuration value, where X is an integer greater than or equal to 5; when the Xth bit from the lowest bit of the PWM configuration value is 1, the number of adjustments is a decimal number corresponding to the value of the lowest X-1 bits of the PWM configuration value after bit-by-bit inversion.
2. The method according to claim 1, wherein: When the PWM configuration value is located in other fitting intervals except the first fitting interval, the straight line fitting result corresponding to each of the PWM configuration values includes a first part, a second part and a third part in order from the lowest bit to the highest bit; The straight line fitting result is a binary number with a fixed number of bits, the first part of which includes one or more 0s, where the number of 0s is the serial number of the fitting interval where the PWM configuration value is located minus 1; The second part includes the value of the least significant X bits of the PWM configuration value, where X is an integer greater than or equal to 5; The least significant bit of the third part is 1, and the remaining bits, if any, are 0.
3. The method according to claim 1, wherein: When the PWM configuration value is in the first fitting interval, the PWM configuration value is used as the straight line fitting result.
4. The method according to claim 1, wherein: When the PWM configuration value is a maximum value, the straight line fitting result is a preset fixed value.
5. The method according to claim 1, when the initial value of the adjustment times is zero or the fitting interval where the PWM configuration value is located is the first fitting interval, setting the straight line fitting result as the final adjustment result.
6. The method according to claim 1, wherein: Acquire the first adjustment value based on the count value and the fitting interval where the PWM configuration value is located, When the PWM configuration value is in the highest number fitting interval, the lowest F bits of the count value are inverted bit by bit to obtain a first adjustment value; wherein F is an integer greater than or equal to 4; When the PWM configuration value is located in other fitting intervals except the highest number fitting interval and the second fitting interval, the result of inverting the lowest F bits of the count value bit by bit is shifted right to obtain a first adjustment value, the number of shifts is less than F and is the difference between the highest number and the fitting interval number where the PWM configuration value is located, and the remaining bits are 0; When the PWM configuration value is in the second fitting interval, the inverted value of the Fth bit from the lowest bit of the count value and the value of the first bit from the lowest bit of the count value are ANDed together to obtain a result as the lowest bit of the first adjustment value, and the remaining bits are 0.
7. The method according to claim 6 further comprises, when the initial value of the adjustment times is not 0, performing a second stage adjustment; wherein, When the PWM configuration value is located in other fitting intervals outside the highest fitting interval, a second adjustment value is obtained based on a formula corresponding to the fitting interval and a count value, including: When the difference between the fitting interval number of the PWM configuration value and the fitting interval number of the highest fitting interval number is 1 or 3, the second adjustment value is the inverse value of the first bit of the count value from the lowest bit; When the difference between the fitting interval number of the PWM configuration value and the fitting interval number of the highest number is 2, the second adjustment value is the inverse value of the second bit from the lowest bit of the count value; When the difference between the sequence number of the fitting interval where the PWM configuration value is located and the sequence number of the highest sequence number fitting interval is greater than or equal to 4, the second adjustment value is 0; When the difference between the fitting interval number of the PWM configuration value and the highest fitting interval number is equal to 5, and the decimal number corresponding to the lowest F bits of the count value is 13, the second adjustment value is 1, where F is an integer greater than or equal to 4.
8. The method according to claim 7, further comprising: When the PWM configuration value is in the highest number fitting interval, the adjustment times of the second stage adjustment are 1, and the second adjustment value is the initial value of the adjustment times; or, When the PWM configuration value is located in the highest sequence number fitting interval, the adjustment times of the second stage adjustment are the initial value of the adjustment times, and the second adjustment value is 1.
9. The method according to claim 8, wherein: The sum of all the first adjustment values and all the second adjustment values is a total adjustment value, and the total adjustment value is symmetrical in the same fitting interval.
10. An electronic device, comprising an LED dimming device, wherein: The LED dimming device is configured to execute the method according to any one of claims 1-9. The electronic device according to claim 10 , further comprising an LED light emitting element.
Citation Information
Patent Citations
Dimming curve generation method, dimming curve generation device, and LED lighting device
CN111511077A
Backlight adjustment method, computer readable storage medium and terminal equipment
CN118658429A