Method and apparatus for brightness adjustment, electronic device, and storage medium
By calculating the brightness level variation coefficient and duty cycle, and gradually adjusting the duty cycle of the PWM output, the problem of uneven light brightness variation is solved, thus improving the user's dimming experience.
Patent Information
- Application Number
- CN202211260583.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-10-14
- Publication Date
- 2026-02-27
- Estimated Expiration
- 2042-10-14
AI Technical Summary
In existing technologies, there is a problem with light brightness adjustment: the human eye cannot perceive changes in brightness. Especially when the brightness level is high or low, the light brightness changes unevenly, resulting in poor visual effects.
By acquiring the clock frequency and output waveform frequency of the PWM, the brightness level change coefficient and duty cycle are calculated using a preset algorithm. The correspondence between the brightness level and the duty cycle is stored, and the duty cycle of the PWM output is gradually adjusted to achieve a smooth change in the brightness of the light.
It achieves a smooth change in light brightness according to the brightness level, improves the user's dimming experience, and avoids the problem of light brightening rapidly or flickering.
Smart Images

Figure CN115589649B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of lighting, for example to a method and apparatus for brightness adjustment, an electronic device and a storage medium. BACKGROUND
[0002] In real life, users often need to adjust the brightness of the light. The existing technology usually corresponds the brightness level of the light to the duty cycle of the PWM output, and the duty cycle of the PWM output increases with the increase of the brightness level. Thus, the brightness of the light is adjusted by linearly changing the duty cycle of the PWM (Pulse Width Modulation).
[0003] In the process of implementing the embodiments of the present disclosure, it is found that at least the following problems exist in the related art:
[0004] Since the PWM duty cycle and the brightness of the LED light often have a linear relationship, increasing the duty cycle of the PWM output will cause the light to brighten rapidly in the case of low brightness level. In the case of high brightness level, the brightness of the light may not be perceived by the human eye even if the duty cycle of the PWM output is continuously increased. For example, the duty cycle of the PWM output corresponding to the brightness level 2 is 2%, the duty cycle of the PWM output corresponding to the brightness level 12 is 12%, and the duty cycle of the PWM output corresponding to the brightness level 22 is 22%. In the case of adjusting the brightness level of the light from 2 to 12, the duty cycle of the PWM output will be increased by 10% based on the duty cycle of 2%. At this time, the brightness of the light with the brightness level 12 is 6 times the brightness of the light with the brightness level 2. However, if the brightness level is adjusted from 12 to 22, the duty cycle of the PWM output will also be increased by 10% based on the duty cycle of 12%. At this time, the brightness of the light with the brightness level 22 is twice the brightness of the light with the brightness level 12. It can be seen that the brightness of the light does not change uniformly with the change of the brightness level, which causes poor visual effect of the human eye. SUMMARY
[0005] The following presents a simplified summary of some aspects of the disclosed embodiments in order to provide a basic understanding of such embodiments. The summary is not an extensive overview of the disclosure and is not intended to identify key / critical elements of the embodiments or to delineate the scope of the embodiments. Its sole purpose is to present some aspects of the disclosed embodiments in a simplified form as a prelude to the more detailed description that is presented later.
[0006] The embodiments of the present disclosure provide a method and apparatus for brightness adjustment, an electronic device and a storage medium, so that the brightness of the light can change smoothly with the change of the brightness level.
[0007] In some embodiments, the method for brightness adjustment comprises: obtaining a clock frequency and an output waveform frequency of a pulse width modulation (PWM), the PWM being used to control light brightness; calculating the clock frequency and the output waveform frequency according to a first preset algorithm to obtain a brightness level variation coefficient, the brightness level variation coefficient being used to represent a ratio between brightness corresponding to two adjacent brightness levels; calculating the brightness level variation coefficient and a preset duty cycle corresponding to a lowest brightness level according to a second preset algorithm to obtain a duty cycle corresponding to each brightness level; and adjusting the duty cycle output by the PWM according to the duty cycle corresponding to each brightness level to adjust the light brightness.
[0008] In some embodiments, before adjusting the duty cycle output by the PWM according to the duty cycle corresponding to each brightness level, the method further comprises: storing a correspondence between brightness levels and duty cycles in a preset database.
[0009] In some embodiments, adjusting the duty cycle output by the PWM according to the duty cycle corresponding to each brightness level comprises: in response to a brightness adjustment instruction, determining an initial brightness level and a target brightness level corresponding to the brightness adjustment instruction; obtaining a duty cycle corresponding to the initial brightness level and a duty cycle corresponding to the target brightness level in the database; obtaining a difference between the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level; calculating the difference and a number of times to be adjusted according to a third preset algorithm to obtain a duty cycle to be adjusted; and adjusting the duty cycle output by the PWM according to the duty cycle to be adjusted until the duty cycle output by the PWM is gradually adjusted from the duty cycle corresponding to the initial brightness level to the duty cycle corresponding to the target brightness level.
[0010] In some embodiments, determining the initial brightness level and the target brightness level corresponding to the brightness adjustment instruction comprises: determining a brightness level contained in the brightness adjustment instruction as the target brightness level corresponding to the brightness adjustment instruction; and determining a brightness level of a current light brightness as the initial brightness level corresponding to the brightness adjustment instruction.
[0011] In some embodiments, the device for brightness adjustment comprises: a first obtaining module configured to obtain a clock frequency and an output waveform frequency of a pulse modulation signal PWM used for controlling light brightness; a first calculating module configured to calculate the clock frequency and the output waveform frequency according to a first preset algorithm to obtain a brightness level variation coefficient, the brightness level variation coefficient being used to represent a ratio between brightness corresponding to two adjacent brightness levels; a second calculating module configured to calculate the brightness level variation coefficient and a preset duty cycle corresponding to a lowest brightness level according to a second preset algorithm to obtain a duty cycle corresponding to each brightness level; and an adjusting module configured to adjust the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level to adjust the light brightness.
[0012] In some embodiments, the device for brightness adjustment further comprises a storage module configured to store a correspondence between brightness levels and duty cycles in a preset database.
[0013] In some embodiments, the adjusting module is configured to adjust the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level by: determining an initial brightness level and a target brightness level corresponding to a brightness adjustment instruction in response to the brightness adjustment instruction; obtaining a duty cycle corresponding to the initial brightness level and a duty cycle corresponding to the target brightness level in the database; obtaining a difference between the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level; calculating the difference and a number of times to be adjusted according to a third preset algorithm to obtain a duty cycle to be adjusted; and adjusting the duty cycle of the PWM output according to the duty cycle to be adjusted until the duty cycle of the PWM output is gradually adjusted from the duty cycle corresponding to the initial brightness level to the duty cycle corresponding to the target brightness level.
[0014] In some embodiments, determining the initial brightness level and the target brightness level corresponding to the brightness adjustment instruction comprises: determining a brightness level contained in the brightness adjustment instruction as the target brightness level corresponding to the brightness adjustment instruction; and determining a brightness level of current light brightness as the initial brightness level corresponding to the brightness adjustment instruction.
[0015] In some embodiments, the electronic device comprises a processor and a memory storing program instructions, the processor being configured to execute the above-mentioned method for brightness adjustment when running the program instructions.
[0016] In some embodiments, the storage medium stores program instructions, the program instructions being executed to perform the above-mentioned method for brightness adjustment when running.
[0017] The method, device, electronic device and storage medium for brightness adjustment provided by the embodiments of the present disclosure can achieve the following technical effects: the brightness level change coefficient is obtained by calculating the clock frequency and the output waveform frequency according to the first preset algorithm. The duty cycle corresponding to each brightness level is obtained by calculating the preset duty cycle corresponding to the lowest brightness level and the brightness level change coefficient according to the second preset algorithm. Then, the duty cycle of the PWM output is adjusted according to the duty cycle corresponding to each brightness level, so as to adjust the light brightness. Since the brightness level change coefficient represents the ratio between the brightness corresponding to two brightness levels, no matter whether the brightness level is high or low, the ratio between the light brightness after the brightness level is adjusted and the light brightness before the brightness level is adjusted is equal to the brightness level change coefficient. Therefore, the light brightness can change smoothly with the change of the brightness level.
[0018] The foregoing general description and the following description are only exemplary and explanatory, and are not intended to limit the present application. BRIEF DESCRIPTION OF DRAWINGS
[0019] One or more embodiments are illustrated by way of example with reference to the accompanying drawings, which are schematic and not intended to be limiting of the embodiments, and in which like reference numerals designate similar items in the figures, and wherein:
[0020] Figure 1 is a schematic diagram of a method for brightness adjustment provided by an embodiment of the present disclosure;
[0021] Figure 2 is a schematic diagram of another method for brightness adjustment provided by an embodiment of the present disclosure;
[0022] Figure 3 is a schematic diagram of another method for brightness adjustment provided by an embodiment of the present disclosure;
[0023] Figure 4 is a schematic diagram of another method for brightness adjustment provided by an embodiment of the present disclosure;
[0024] Figure 5 is a schematic diagram of a device for brightness adjustment provided by an embodiment of the present disclosure;
[0025] Figure 6 is a structural schematic diagram of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION
[0026] In order to enable more detailed understanding of the features and technical contents of the embodiments of the present disclosure, the implementation of the embodiments of the present disclosure is described in detail below, and the attached drawings are only used for reference and do not limit the embodiments of the present disclosure. In the following technical description, in order to facilitate explanation, through multiple details, a sufficient understanding of the disclosed embodiments is provided. However, one or more embodiments can still be implemented without these details. In other cases, well-known structures and devices can be simplified to facilitate the drawings.
[0027] The terms "first", "second", and the like in the specification and claims of the embodiments of the present disclosure and the above-mentioned drawings are used to distinguish similar objects, and do not necessarily describe a specific order or sequence. It should be understood that the data thus used can be interchanged under appropriate circumstances, so that the embodiments of the present disclosure described herein can be implemented. In addition, the terms "include" and "have" and any variations thereof are intended to cover non-exclusive inclusion.
[0028] Unless otherwise specified, the term "multiple" means two or more.
[0029] In the embodiments of the present disclosure, the character " / " represents an "or" relationship between the objects before and after it. For example, A / B represents: A or B.
[0030] The term "and / or" is a description of the association between objects, which means that there can be three relationships. For example, A and / or B, which means: A or B, or, A and B, the three relationships.
[0031] The term "corresponding" can refer to an association or binding relationship. A and B correspond to each other means that there is an association or binding relationship between A and B.
[0032] In order to enable the light brightness to change smoothly with the change of the brightness level. That is, in the case of low light brightness level, continue to increase the brightness level, which will not cause the light to brighten quickly. And in the case of high light brightness level, continue to increase the brightness level, and the human eye can also feel the change of the light brightness. The present application calculates the brightness level change coefficient by using the clock frequency and the output waveform frequency according to the first preset algorithm. And according to the second preset algorithm, the preset duty cycle corresponding to the lowest brightness level and the brightness level change coefficient are calculated to obtain the duty cycle corresponding to each brightness level respectively. Then adjust the duty cycle of PWM output according to the duty cycle corresponding to each brightness level respectively, to adjust the light brightness. Since the brightness level change coefficient represents the ratio between the brightness corresponding to two brightness levels respectively, in the case of high brightness level or low brightness level, the ratio between the light brightness after adjusting one level higher brightness level and the light brightness before adjusting is equal to the brightness level change coefficient. Thus, the light brightness can change smoothly with the change of the brightness level.
[0033] In combination Figure 1 As shown in the embodiments of the present disclosure, a method for brightness adjustment is provided, comprising:
[0034] In step S101, the electronic device acquires a clock frequency and an output waveform frequency of a PWM, which is used to control the brightness of the light.
[0035] In step S102, the electronic device calculates the brightness level change coefficient according to a first preset algorithm using the clock frequency and the output waveform frequency, wherein the brightness level change coefficient is used to represent the ratio between the brightness corresponding to two adjacent brightness levels.
[0036] In step S103, the electronic device calculates the duty cycle corresponding to each brightness level according to a second preset algorithm using the brightness level change coefficient and the preset duty cycle corresponding to the lowest brightness level.
[0037] In step S104, the electronic device adjusts the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level to adjust the brightness of the light.
[0038] The method for brightness adjustment provided by the embodiments of the present disclosure can obtain the brightness level change coefficient by calculating the clock frequency and the output waveform frequency according to the first preset algorithm, and can obtain the duty cycle corresponding to each brightness level by calculating the preset duty cycle corresponding to the lowest brightness level and the brightness level change coefficient according to the second preset algorithm. Then, the duty cycle of the PWM output is adjusted according to the duty cycle corresponding to each brightness level to adjust the brightness of the light. Since the brightness level change coefficient represents the ratio between the brightness corresponding to two adjacent brightness levels, the ratio between the brightness of the light after the brightness level is increased by one and the brightness of the light before the adjustment is equal to the brightness level change coefficient, whether the brightness level is high or low. Therefore, the brightness of the light can change smoothly with the change of the brightness level. Thus, in the case of low brightness level, increasing the brightness level will not cause the light to brighten rapidly. In the case of high brightness level, increasing the brightness level will make the human eye feel the change of the brightness of the light, thereby improving the user's experience of dimming.
[0039] Optionally, calculating the brightness level change coefficient according to the first preset algorithm using the clock frequency and the output waveform frequency comprises: obtaining the brightness level change coefficient by calculating clk the clock frequency, f pwm the output waveform frequency, Here, is the reciprocal of the PWM resolution, Duty1 is the preset duty cycle corresponding to the lowest brightness level, and N is the total number of brightness levels. Since the PWM resolution is the smallest unit for adjusting the duty cycle of the PWM output, a more precise brightness level variation coefficient can be obtained by calculating the brightness level variation coefficient using the PWM resolution.
[0040] In some embodiments, the light brightness is divided into N brightness levels, and the preset duty cycle corresponding to the lowest brightness level 1 is Duty1. Let the brightness level variation coefficient be x. Then the duty cycle corresponding to brightness level 1 is Duty1 × x. 0 The duty cycle corresponding to brightness level 2 is Duty1×x 1 The duty cycle corresponding to brightness level 3 is Duty1×x 2 ..., the duty cycle corresponding to brightness level N is Duty1×x N-1 When the light brightness is at the highest brightness level N, the PWM will continuously output a high level. Therefore, the duty cycle corresponding to brightness level N is... Furthermore, the brightness level variation coefficient can be derived.
[0041] Optionally, the duty cycle corresponding to each brightness level is calculated according to the second preset algorithm using the preset duty cycle corresponding to the lowest brightness level and the brightness level change coefficient, including: calculating the duty cycle of each brightness level. m =Duty1×x m-1 Obtain the alternative duty cycles corresponding to the m-th brightness level, where Duty m Let be the duty cycle corresponding to the m-th brightness level, where m is a positive integer less than or equal to N. If the candidate duty cycle for the m-th brightness level is not an integer, round it to the nearest integer to obtain the duty cycle for the m-th brightness level. If the candidate duty cycle for the m-th brightness level is an integer, directly use the candidate duty cycle for the m-th brightness level as the duty cycle for the m-th brightness level.
[0042] Optionally, before adjusting the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level, the method further includes: storing the correspondence between brightness level and duty cycle in a preset database.
[0043] Combination Figure 2 As shown, this disclosure provides a method for brightness adjustment, including:
[0044] In step S201, the electronic device acquires the clock frequency and output waveform frequency of the PWM; the PWM is used to control the brightness of the light.
[0045] In step S202, the electronic device calculates the luminance level change coefficient according to the first preset algorithm using the clock frequency and the output waveform frequency.
[0046] In step S203, the electronic device calculates the duty cycle corresponding to each luminance level according to the second preset algorithm using the luminance level change coefficient and the preset duty cycle corresponding to the lowest luminance level.
[0047] In step S204, the electronic device stores the correspondence between the luminance level and the duty cycle in a preset database.
[0048] In step S205, the electronic device adjusts the duty cycle of the PWM output according to the duty cycle corresponding to each luminance level to adjust the light luminance.
[0049] The method for luminance adjustment provided by the embodiments of the present disclosure calculates the luminance level change coefficient according to the first preset algorithm using the clock frequency and the output waveform frequency, calculates the duty cycle corresponding to each luminance level according to the second preset algorithm using the preset duty cycle corresponding to the lowest luminance level and the luminance level change coefficient, and then adjusts the duty cycle of the PWM output according to the duty cycle corresponding to each luminance level to adjust the light luminance. Since the luminance level change coefficient represents the ratio between the luminance corresponding to two luminance levels, the ratio between the light luminance after the luminance level is increased by one and the light luminance before the adjustment is equal to the luminance level change coefficient, whether the luminance level is high or low. Therefore, the light luminance changes smoothly with the change of the luminance level. Thus, when the luminance level is low, increasing the luminance level will not cause the light to brighten rapidly. When the luminance level is high, increasing the luminance level allows the human eye to perceive the change in light luminance, thereby improving the user's experience of adjusting the light.
[0050] Optionally, the duty cycle of the PWM output is adjusted according to the duty cycle corresponding to each brightness level, comprising: in response to a brightness adjustment instruction, determining an initial brightness level and a target brightness level corresponding to the brightness adjustment instruction. Obtaining the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level in the database. Obtaining the difference between the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level. According to the third preset algorithm, the difference and the number of times to be adjusted are calculated to obtain the to-be-adjusted duty cycle. The duty cycle of the PWM output is adjusted according to the to-be-adjusted duty cycle until the duty cycle of the PWM output is gradually adjusted from the duty cycle corresponding to the initial brightness level to the duty cycle corresponding to the target brightness level. In this way, the duty cycle of the PWM output can be gradually adjusted from the duty cycle corresponding to the initial brightness level to the duty cycle corresponding to the target brightness level, so that the light brightness can be gradually adjusted, and the human eye cannot flicker the light.
[0051] In combination Figure 3 The embodiments of the present disclosure provide a method for brightness adjustment, comprising:
[0052] In step S301, the electronic device obtains the clock frequency and the output waveform frequency of the pulse width modulation (PWM). The PWM is used to control the light brightness.
[0053] In step S302, the electronic device calculates the brightness level change coefficient by using the clock frequency and the output waveform frequency according to a first preset algorithm, wherein the brightness level change coefficient is used to represent the ratio between the brightness corresponding to two adjacent brightness levels.
[0054] In step S303, the electronic device calculates the duty cycle corresponding to each brightness level by using the brightness level change coefficient and the preset duty cycle corresponding to the lowest brightness level according to a second preset algorithm.
[0055] In step S304, the electronic device stores the correspondence between the brightness level and the duty cycle in a preset database.
[0056] In step S305, the electronic device determines an initial brightness level and a target brightness level corresponding to a brightness adjustment instruction in response to the brightness adjustment instruction.
[0057] In step S306, the electronic device obtains the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level in the database.
[0058] In step S307, the electronic device obtains the difference between the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level.
[0059] In step S308, the electronic device calculates the to-be-adjusted duty cycle by using the difference and the number of times to be adjusted according to a third preset algorithm.
[0060] In step S309, the electronic device adjusts the duty cycle of the PWM output according to the duty cycle to be adjusted until the duty cycle of the PWM output gradually adjusts from the duty cycle corresponding to the initial brightness level to the duty cycle corresponding to the target brightness level.
[0061] By using the method for brightness adjustment provided in the embodiments of the present disclosure, the brightness level change coefficient is obtained by calculating the clock frequency and the output waveform frequency according to the first preset algorithm. The duty cycle corresponding to each brightness level is obtained by calculating the preset duty cycle corresponding to the lowest brightness level and the brightness level change coefficient according to the second preset algorithm. Then, the duty cycle of the PWM output is adjusted according to the duty cycle corresponding to each brightness level, so as to adjust the light brightness. Since the brightness level change coefficient represents the ratio between the brightness corresponding to two brightness levels, no matter whether the brightness level is high or low, the ratio between the light brightness after the brightness level is continuously increased by one level and the light brightness before the adjustment is equal to the brightness level change coefficient. It can be seen that the light brightness can change smoothly with the change of the brightness level. Thus, in the case that the light brightness level is low, continuously increasing the brightness level will not cause the light to brighten rapidly. In the case that the light brightness level is high, continuously increasing the brightness level enables the human eye to feel the change of the light brightness, thereby improving the user's experience of dimming. And by adjusting the duty cycle of the PWM output according to the duty cycle to be adjusted, the light brightness can be gradually adjusted, so that the human eye cannot perceive the frequency flicker of the light.
[0062] Optionally, the duty cycle to be adjusted is obtained by calculating the difference and the number of times to be adjusted according to a third preset algorithm, including: calculating the difference between the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level, and calculating the number of times to be adjusted by using the difference and the preset interval time period according to the third preset algorithm. The duty cycle to be adjusted is obtained. Wherein, Duty p Duty dst is the duty cycle corresponding to the initial brightness level, Duty src is the duty cycle corresponding to the target brightness level, Duty dst Duty src is the difference between the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level, and s is the number of times to be adjusted.
[0063] Optionally, the number of times to be adjusted is obtained by calculating the time to be adjusted and the preset interval time period according to a fourth preset algorithm. The time to be adjusted and the preset interval time period are included in the brightness adjustment instruction.
[0064] In some embodiments, the preset interval time period is 25 milliseconds. The to-be-adjusted time is 1 second, so that the to-be-adjusted number is 40. Since the visual frame number of the human eye when relaxed is 24 frames per second, and when concentrating, it will not exceed 30 frames per second. Therefore, in the case that the duty cycle of the PWM output is adjusted 40 times in 1 second, the user will not be able to perceive the flicker of the light. In turn, the user's dimming experience can be improved.
[0065] In some embodiments, the to-be-adjusted number s is obtained by calculating s = T P / T Q , wherein T P is the to-be-adjusted time, and T Q is the preset interval time period.
[0066] Optionally, adjusting the duty cycle of the PWM output according to the to-be-adjusted duty cycle comprises: adjusting the duty cycle of the PWM output according to the to-be-adjusted duty cycle every preset interval time period until the total number of adjustments is equal to the to-be-adjusted number. At this time, the duty cycle of the PWM output is equal to the duty cycle corresponding to the target brightness level. In this way, the duty cycle of the PWM output can be adjusted from the duty cycle corresponding to the initial brightness level to the duty cycle corresponding to the target brightness level within the to-be-adjusted time. That is, the light brightness can be gradually adjusted within the to-be-adjusted time.
[0067] In combination with FIG. 1, Figure 4 The embodiments of the present disclosure provide a method for brightness adjustment, comprising:
[0068] In step S401, the electronic device obtains the clock frequency and the output waveform frequency of the pulse width modulation (PWM). The PWM is used to control the light brightness.
[0069] In step S402, the electronic device calculates the brightness level change coefficient according to a first preset algorithm using the clock frequency and the output waveform frequency. The brightness level change coefficient is used to represent the ratio between the brightness corresponding to two adjacent brightness levels.
[0070] In step S403, the electronic device calculates the duty cycle corresponding to each brightness level according to a second preset algorithm using the brightness level change coefficient and the preset duty cycle corresponding to the lowest brightness level.
[0071] In step S404, the electronic device stores the correspondence between the brightness level and the duty cycle in a preset database.
[0072] In step S405, the electronic device determines the initial brightness level and the target brightness level corresponding to the brightness adjustment instruction in response to the brightness adjustment instruction.
[0073] In step S406, the electronic device obtains the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level from the database.
[0074] In step S407, the electronic device obtains the difference between the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level.
[0075] In step S408, the electronic device calculates the to-be-adjusted duty cycle according to the third preset algorithm using the difference and the to-be-adjusted number of times.
[0076] In step S409, the electronic device adjusts the duty cycle of the PWM output according to the to-be-adjusted duty cycle every preset interval of time until the total number of adjustments is equal to the to-be-adjusted number of times.
[0077] The method for brightness adjustment provided by the embodiments of the present disclosure comprises the following steps: calculating the brightness level change coefficient according to the first preset algorithm using the clock frequency and the output waveform frequency; calculating the duty cycle corresponding to each brightness level according to the second preset algorithm using the preset duty cycle corresponding to the lowest brightness level and the brightness level change coefficient; and adjusting the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level, so as to adjust the light brightness. Since the brightness level change coefficient represents the ratio between the brightness corresponding to two brightness levels, the ratio between the light brightness after the brightness level is continuously increased by one and the light brightness before the adjustment is equal to the brightness level change coefficient, whether the brightness level is high or low. Therefore, the light brightness can change smoothly with the change of the brightness level. In the case of low light brightness level, increasing the brightness level will not cause the light to brighten rapidly. In the case of high light brightness level, increasing the brightness level will enable the human eye to feel the change of the light brightness, thereby improving the user's experience of dimming. Furthermore, adjusting the duty cycle of the PWM output using the to-be-adjusted duty cycle can gradually adjust the light brightness, so that the human eye cannot perceive the frequency flicker of the light.
[0078] In some embodiments, the initial brightness level corresponding to the brightness adjustment instruction is 1, and the target brightness level corresponding to the brightness adjustment instruction is 2. The difference n between the duty cycle corresponding to the initial brightness level 1 and the duty cycle corresponding to the target brightness level 2 is obtained. The to-be-adjusted duty cycle n / t is obtained by dividing n by the to-be-adjusted number of times t. The duty cycle of the PWM output is increased by n / t every preset interval of time, and the duty cycle of the PWM output is equal to the duty cycle corresponding to the target brightness level 2 when the total number of adjustments is equal to t.
[0079] Optionally, the adjusting the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level comprises: in response to the brightness adjustment instruction, determining an initial brightness level and a target brightness level corresponding to the brightness adjustment instruction. Taking the duty cycle corresponding to the initial brightness level as a starting point, adjusting the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level in the database, until the duty cycle of the PWM output is equal to the duty cycle corresponding to the target brightness level. The brightness levels stored in the database are arranged in order from low to high.
[0080] In some embodiments, the brightness adjustment instruction represents adjusting the brightness level of the light to level 5, and the initial brightness level is level 2. That is, the current duty cycle of the PWM is the duty cycle corresponding to the brightness level 2. The duty cycle corresponding to the brightness level 3, the duty cycle corresponding to the brightness level 4, the duty cycle corresponding to the brightness level 5 and the duty cycle corresponding to the brightness level 6 are obtained from the database. The current duty cycle of the PWM is adjusted to the duty cycle corresponding to the brightness level 3, the duty cycle corresponding to the brightness level 4, the duty cycle corresponding to the brightness level 5 and the duty cycle corresponding to the brightness level 6 in turn. That is, the duty cycle of the PWM output is equal to the duty cycle corresponding to the target brightness level 6.
[0081] Optionally, the determining the initial brightness level and the target brightness level corresponding to the brightness adjustment instruction comprises: determining the brightness level contained in the brightness adjustment instruction as the target brightness level corresponding to the brightness adjustment instruction; and determining the brightness level of the current light brightness as the initial brightness level corresponding to the brightness adjustment instruction.
[0082] In combination Figure 5 As shown in the figure, the embodiment of the present disclosure provides a device for brightness adjustment, comprising: a first obtaining module 501, a first calculating module 502, a second calculating module 503 and an adjusting module 504. The first obtaining module 501 is configured to obtain the clock frequency and the output waveform frequency of the pulse width modulation (PWM). The PWM is used to control the brightness of the light. The first calculating module 502 is configured to calculate the brightness level change coefficient according to a first preset algorithm using the clock frequency and the output waveform frequency; the brightness level change coefficient is used to represent the ratio between the brightness corresponding to two adjacent brightness levels. The second calculating module 503 is configured to calculate the duty cycle corresponding to each brightness level according to a second preset algorithm using the brightness level change coefficient and the preset duty cycle corresponding to the lowest brightness level. The adjusting module 504 is configured to adjust the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level, so as to adjust the brightness of the light.
[0083] The device for brightness adjustment provided in the embodiment of the present disclosure is used to obtain a brightness level change coefficient by calculating the clock frequency and the output waveform frequency according to a first preset algorithm. The duty cycle corresponding to each brightness level is obtained by calculating the preset duty cycle corresponding to the lowest brightness level and the brightness level change coefficient according to a second preset algorithm. Then, the duty cycle of the PWM output is adjusted according to the duty cycle corresponding to each brightness level, so as to adjust the light brightness. Since the brightness level change coefficient represents the ratio between the brightness corresponding to two brightness levels, no matter whether the brightness level is high or low, the ratio between the light brightness after the brightness level is continuously increased by one level and the light brightness before the adjustment is equal to the brightness level change coefficient. It can be seen that the light brightness can change smoothly with the change of the brightness level. In this way, in the case that the light brightness level is low, the light brightness will not become bright rapidly when the brightness level is continuously increased. In the case that the light brightness level is high, the user can also feel the change of the light brightness when the brightness level is continuously increased, thereby improving the user experience of dimming.
[0084] Optionally, the device for brightness adjustment further comprises a storage module configured to store the correspondence between the brightness level and the duty cycle in a preset database.
[0085] Optionally, the adjusting module is configured to adjust the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level in the following manner: in response to a brightness adjustment instruction, determining an initial brightness level and a target brightness level corresponding to the brightness adjustment instruction. Obtaining the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level in the database. Obtaining the difference between the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level. Calculating the to-be-adjusted duty cycle by using the difference and the to-be-adjusted number of times according to a third preset algorithm. Adjusting the duty cycle of the PWM output according to the to-be-adjusted duty cycle until the duty cycle of the PWM output is gradually adjusted from the duty cycle corresponding to the initial brightness level to the duty cycle corresponding to the target brightness level.
[0086] Optionally, the initial brightness level and the target brightness level corresponding to the brightness adjustment instruction are determined in the following manner: determining the brightness level contained in the brightness adjustment instruction as the target brightness level corresponding to the brightness adjustment instruction, and determining the brightness level of the current light brightness as the initial brightness level corresponding to the brightness adjustment instruction.
[0087] In combination with Figure 6As shown, the electronic device provided by the embodiment of the present disclosure includes a processor 600 and a memory 601. Optionally, the electronic device can further include a communication interface 602 and a bus 603. The processor 600, the communication interface 602 and the memory 601 can complete mutual communication through the bus 603. The communication interface 602 can be used for information transmission. The processor 600 can invoke the logical instructions in the memory 601 to execute the method for brightness adjustment of the above-mentioned embodiments.
[0088] By using the electronic device provided by the embodiment of the present disclosure, the brightness level change coefficient is obtained by calculating the clock frequency and the output waveform frequency according to the first preset algorithm. The duty cycle corresponding to each brightness level is obtained by calculating the preset duty cycle corresponding to the lowest brightness level and the brightness level change coefficient according to the second preset algorithm. Then, the duty cycle of the PWM output is adjusted according to the duty cycle corresponding to each brightness level, so as to adjust the light brightness. Since the brightness level change coefficient represents the ratio between the brightness corresponding to two brightness levels, no matter whether the brightness level is high or low, the ratio between the light brightness after continuously increasing the brightness level by one and the light brightness before the adjustment is equal to the brightness level change coefficient. It can be seen that the light brightness can change smoothly with the change of the brightness level. In this way, in the case that the light brightness level is low, continuously increasing the brightness level will not cause the light to become bright rapidly. In the case that the light brightness level is high, the user can also feel the change of the light brightness by continuously increasing the brightness level, thereby improving the user's experience of dimming.
[0089] In some embodiments, the electronic device is a computer, a mobile phone or a tablet computer, etc.
[0090] In addition, the logical instructions in the memory 601 described above can be implemented in the form of a software function unit and sold or used as an independent product, which can be stored in a computer readable storage medium.
[0091] The memory 601 as a computer readable storage medium can be used to store software programs, computer executable programs, such as program instructions / modules corresponding to the method in the embodiment of the present disclosure. The processor 600 executes the program instructions / modules stored in the memory 601, thereby executing the function application and data processing, i.e. implementing the method for brightness adjustment in the above-mentioned embodiments.
[0092] The memory 601 can include a program storage area and a data storage area, wherein the program storage area can store an operating system, at least one application required by a function; the data storage area can store data created according to the use of the terminal device, and the like. In addition, the memory 601 can include a high-speed random access memory, and can also include a nonvolatile memory.
[0093] The embodiment of the present disclosure provides a storage medium, which stores program instructions, and the program instructions perform the method for brightness adjustment when running.
[0094] The embodiment of the present disclosure provides a computer program product, which comprises a computer program stored on a computer readable storage medium, and the computer program comprises program instructions, and the program instructions make a computer execute the method for brightness adjustment when the program instructions are executed by the computer.
[0095] The computer readable storage medium described above can be a transitory computer readable storage medium or a non-transitory computer readable storage medium.
[0096] The technical solution of the embodiment of the present disclosure can be embodied in the form of a software product. The computer software product is stored in a storage medium and includes one or more instructions to make a computer device (which can be a personal computer, a server, or a network device, etc.) execute all or part of the steps of the method described in the embodiment of the present disclosure. The aforementioned storage medium can be a non-transitory storage medium, including a U disk, a mobile hard disk, a read-only memory (ROM, Read-Only Memory), a random access memory (RAM, Random Access Memory), a magnetic disk or an optical disk, and various media that can store program codes, or can be a transitory storage medium.
[0097] The foregoing description and accompanying drawings fully illustrate embodiments of this disclosure to enable those skilled in the art to practice them. Other embodiments may include structural, logical, electrical, procedural, and other changes. The embodiments represent only possible variations. Individual components and functions are optional unless explicitly required, and the order of operation may vary. Parts and features of some embodiments may be included in or replace parts and features of other embodiments. Moreover, the terminology used in this application is for describing embodiments only and is not intended to limit the claims. As used in the description of embodiments and claims, the singular forms “a,” “an,” and “the” are intended to equally include the plural forms unless the context clearly indicates otherwise. Similarly, the term “and / or” as used in this application means including one or more of the associated listed items and all possible combinations thereof. Additionally, when used in this application, the term "comprise" and its variations "comprises" and / or "comprising" refer to the presence of stated features, integrals, steps, operations, elements, and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or groups thereof. Without further limitations, an element defined by the phrase "comprises a..." does not exclude the presence of other identical elements in the process, method, or apparatus that includes said element. In this document, each embodiment may focus on the differences from other embodiments, and similar or identical parts between embodiments can be referred to mutually. For methods, products, etc., disclosed in the embodiments, if they correspond to the method section disclosed in the embodiments, the relevant parts can be referred to the description of the method section.
[0098] Those skilled in the art will recognize that the units and algorithm steps of the various examples 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 implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of the embodiments of this disclosure. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0099] In the embodiments disclosed herein, the disclosed methods, products (including but not limited to apparatuses, devices, etc.), can be implemented in other manners. For example, the described apparatus embodiments can be implemented only in a form of a logical function, and can be implemented by using a manner such as software (for example, application program) or the like. In some embodiments, a plurality of units or components can be combined or integrated into another system, or some features can be ignored or not executed. In addition, the displayed or discussed coupling or direct coupling or indirect coupling between different units, or the coupling or direct coupling or indirect coupling between the displayed or discussed communication connections can be in a form of electrical, mechanical or other forms.
[0100] The flowcharts and block diagrams in the drawings show the possible implementation architectures, functions and operations of the system, method and computer program product according to the embodiments of the present disclosure. In this regard, each block in the flowcharts or block diagrams can represent a module, a program segment or a part of code containing one or more executable instructions for implementing a specified logical function. In some alternative implementations, the functions noted in the blocks can occur in an order different from that noted in the drawings. For example, two consecutive blocks can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the functions involved. In the descriptions corresponding to the flowcharts and block diagrams in the drawings, the operations or steps corresponding to different blocks can also occur in an order different from that disclosed in the descriptions, and sometimes there is no specific order between different operations or steps. For example, two consecutive operations or steps can actually be executed substantially in parallel, and sometimes they can be executed in reverse order, depending on the functions involved. Each block in the block diagrams and / or flowcharts, and the combination of blocks in the block diagrams and / or flowcharts, can be implemented by a dedicated hardware-based system that performs the specified functions or actions, or can be implemented by a combination of dedicated hardware and computer instructions.
Claims
1. A method for brightness adjustment, characterized by, The method comprises the steps of: acquiring a clock frequency and an output waveform frequency of a pulse width modulation (PWM); the PWM is used for controlling light brightness; calculating the clock frequency and the output waveform frequency according to a first preset algorithm to obtain a brightness level change coefficient; the brightness level change coefficient is used for representing a ratio between brightnesses corresponding to two adjacent brightness levels respectively; calculating the brightness level change coefficient and a preset duty cycle corresponding to a lowest brightness level according to a second preset algorithm to obtain a duty cycle corresponding to each brightness level respectively; adjusting the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level respectively to adjust the light brightness; According to the first preset algorithm, the clock frequency and the output waveform frequency are used for calculation to obtain a brightness level change coefficient, including: through calculation obtaining a brightness level change coefficient; wherein, x is the brightness level change coefficient, f clk is the clock frequency, f pwm is the output waveform frequency, is the reciprocal of the resolution of the PWM, Duty1 is a preset duty ratio corresponding to the lowest brightness level, and N is the total number of brightness levels. According to the second preset algorithm, the duty ratio corresponding to each luminance level is obtained by calculating Duty m = Duty1×x m-1 obtaining the candidate duty ratio corresponding to the mth luminance level; wherein Duty m is the candidate duty ratio corresponding to the mth luminance level, and m is a positive integer less than or equal to N; in the case that the candidate duty ratio corresponding to the mth luminance level is not an integer, the candidate duty ratio is rounded off to be the duty ratio corresponding to the mth luminance level; in the case that the candidate duty ratio corresponding to the mth luminance level is an integer, the candidate duty ratio corresponding to the mth luminance level is taken as the duty ratio corresponding to the mth luminance level.
2. The method of claim 1, wherein, before the step of adjusting the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level respectively, the method further comprises the step of: storing a corresponding relationship between a brightness level and a duty cycle in a preset database.
3. The method of claim 2, wherein, The step of adjusting the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level respectively comprises the steps of: in response to a brightness adjustment instruction, determining an initial brightness level and a target brightness level corresponding to the brightness adjustment instruction; acquiring, in the database, a duty cycle corresponding to the initial brightness level and a duty cycle corresponding to the target brightness level; acquiring a difference between the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level; calculating the difference and a to-be-adjusted number of times according to a third preset algorithm to obtain a to-be-adjusted duty cycle; adjusting the duty cycle of the PWM output according to the to-be-adjusted duty cycle until the duty cycle of the PWM output is gradually adjusted from the duty cycle corresponding to the initial brightness level to the duty cycle corresponding to the target brightness level.
4. The method of claim 3, wherein, The step of determining the initial brightness level and the target brightness level corresponding to the brightness adjustment instruction comprises the steps of: determining a brightness level contained in the brightness adjustment instruction as a target brightness level corresponding to the brightness adjustment instruction; and determining a brightness level of a current light brightness as an initial brightness level corresponding to the brightness adjustment instruction.
5. An apparatus for brightness adjustment, characterized by, The method comprises the steps of: a first acquiring module is configured to acquire a clock frequency and an output waveform frequency of a pulse width modulation (PWM) used for controlling light brightness; a first calculating module is configured to calculate the clock frequency and the output waveform frequency according to a first preset algorithm to obtain a brightness level change coefficient; the brightness level change coefficient is used for representing a ratio between brightnesses corresponding to two adjacent brightness levels respectively; a second calculating module is configured to calculate the brightness level change coefficient and a preset duty cycle corresponding to a lowest brightness level according to a second preset algorithm to obtain a duty cycle corresponding to each brightness level respectively; an adjusting module is configured to adjust the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level respectively to adjust the light brightness; According to the first preset algorithm, the clock frequency and the output waveform frequency are used for calculation to obtain a brightness level change coefficient, including: through calculation obtaining a brightness level change coefficient; wherein, x is the brightness level change coefficient, f clk is the clock frequency, f pwm is the output waveform frequency, is the reciprocal of the resolution of the PWM, Duty1 is a preset duty ratio corresponding to the lowest brightness level, and N is the total number of brightness levels. According to the second preset algorithm, the duty ratio corresponding to each luminance level is obtained by using the luminance level variation coefficient and the preset duty ratio corresponding to the minimum luminance level, including: calculating Duty m =Duty1×x m-1 obtaining the candidate duty ratio corresponding to the mth luminance level; wherein Duty m is the candidate duty ratio corresponding to the mth luminance level, and m is a positive integer less than or equal to N; in the case that the candidate duty ratio corresponding to the mth luminance level is not an integer, rounding the candidate duty ratio to obtain the duty ratio corresponding to the mth luminance level; in the case that the candidate duty ratio corresponding to the mth luminance level is an integer, taking the candidate duty ratio corresponding to the mth luminance level as the duty ratio corresponding to the mth luminance level.
6. The apparatus of claim 5, wherein, a storage module is further configured to store a corresponding relationship between a brightness level and a duty cycle in a preset database.
7. The apparatus of claim 6, wherein, The adjusting module is configured to adjust the duty cycle of the PWM output according to the duty cycle corresponding to each brightness level respectively in the following manner: in response to a brightness adjustment instruction, determining an initial brightness level and a target brightness level corresponding to the brightness adjustment instruction; acquire a duty cycle corresponding to the initial brightness level and a duty cycle corresponding to the target brightness level in the database; acquire a difference between the duty cycle corresponding to the initial brightness level and the duty cycle corresponding to the target brightness level; calculate the duty cycle to be adjusted according to a third preset algorithm by using the difference and the number of times to be adjusted, to obtain a duty cycle to be adjusted; adjust the duty cycle of the PWM output according to the duty cycle to be adjusted until the duty cycle of the PWM output is gradually adjusted from the duty cycle corresponding to the initial brightness level to the duty cycle corresponding to the target brightness level.
8. The apparatus of claim 7, wherein, determining the initial brightness level and the target brightness level corresponding to the brightness adjustment instruction comprises: determining the brightness level contained in the brightness adjustment instruction as the target brightness level corresponding to the brightness adjustment instruction; and determining the brightness level of the current light brightness as the initial brightness level corresponding to the brightness adjustment instruction.
9. An electronic device comprising a processor and a memory having stored program instructions, wherein the program instructions, when executed by the processor, cause the electronic device to perform the method of any one of claims 1-8. The processor is configured to execute the method for brightness adjustment according to any one of claims 1 to 4 when the program instructions are executed.
10. A storage medium storing program instructions, characterized in that, The program instructions, when executed, perform the method for brightness adjustment according to any one of claims 1 to 4.
Citation Information
Patent Citations
Display control method and device
CN101901578A
Instrument backlight adjusting method and device
CN110890071A