A control method for improving the color change transition effect of RGB light emitting diodes
Through the conversion algorithm from HSV color space to RGB color space, the PWM duty cycle of RGB light emitting diode is adjusted, and the problem of uneven brightness of RGB light emitting diodes in color gradient and streaming effects is solved, achieving a color transition that is more in line with human vision. The effect improves the user experience.
Patent Information
- Application Number
- CN202211021834.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-08-24
- Publication Date
- 2024-12-06
- Estimated Expiration
- 2042-08-24
AI Technical Summary
When existing RGB light-emitting diodes realize color gradient and streaming effects, the color transition effect is uneven under the conditions of unsaturated brightness, and the theoretical calculations are inconsistent with the actual presentation, resulting in a decrease in user experience.
Using the conversion algorithm of the parameters of the HSV color space to the RGB color space, the PWM duty cycle suitable for the RGB light emitting diode is calculated by adjusting the hue, saturation and brightness of the HSV color space to achieve a color transition that is more in line with the visual effects of the human eye. .
The color transition effect of RGB light emitting diodes is improved to make them more in line with human visual experience, remove the color distribution with poor hardware display effects, and achieve more uniform and soft color gradients, improving user experience.
Smart Images

Figure CN115397059B_ABST
Abstract
Description
Technical Field
[0001] The invention belongs to the technical field of RGB light emitting diodes, and in particular relates to a control method for improving the color change transition effect of RGB light emitting diodes. Background Art
[0002] RGB light-emitting diode is a commonly used electronic component, used to make smart light strips, signal indicators and many other fields. It is composed of three independent lamp beads: red, green and blue. Any combination of the three colors can produce other colors, such as red and green are on at the same time, blue is not on, it will appear yellow, green and blue are on at the same time, red is not on, it will appear cyan, and all three colors are on to produce white. The control circuit of RGB light-emitting diode is also very simple. In fact, it is three light-emitting diodes. The control circuit of the common positive is as follows Figure 3 As shown in the figure, if you want to light up a certain LED, you only need to give the corresponding control terminal a low level. In actual control, in order to achieve the color gradient of the LED and combine more colors, the control port is usually controlled using PWM. According to the RGB color space, the color component is adjusted by adjusting the duty cycle of the control terminal PWM. For example, if you want the RGB light to display orange (the color components are red 255, blue 127, and green 0), use the microcontroller to control the RED pin to output a low level, the GREEN pin to output a high level, and the BLUE pin to output a PWM signal with a duty cycle of 50%.
[0003] At present, many applications require RGB light-emitting diodes to be designed with streamer or color gradient effects, so that the color of RGB light-emitting diodes transitions softly to improve user experience. When driving existing RGB light-emitting diodes, three PWM waveforms are usually used to control the three pins R, G, and B of the light-emitting diodes respectively. The brightness of the three color lamp beads is adjusted by adjusting the duty cycle of PWM, so as to synthesize different colors according to the principle of RGB three primary colors. In theory, according to the principle of RGB three primary colors, RGB light-emitting diodes can synthesize and display any color. However, in actual control, due to the limitations of manufacturing technology, the light display effect is not completely as uniform and smooth as the theoretical design, especially when the light brightness is not too saturated, such as RED, GREEN and BLUE provide PWM signals with a duty cycle of 80%, then the corresponding color components in theory are red 51, green 51, and blue 51, which should be displayed as dark gray. The actual display effect is three independent points of red, green, and blue with very low brightness, and the display effect is relatively poor. If the RGB value is directly deduced by the program to drive the light-emitting diode, due to device limitations, some colors cannot be perfectly presented as the results of theoretical calculations, resulting in the theoretical calculation of the light gradient effect and the actual presentation are inconsistent. Moreover, since the RGB model is a machine vision model and does not conform to the human vision model, it is difficult to achieve a smooth visual transition by using the directional change of data in the software, which can easily make people feel that the color transition process is abrupt, reducing the user experience. In addition, when making streamer or color gradient effects, several fixed colors are preset and switched, the color types are limited, and the gradient effect is not soft enough.
[0004] In view of this, the present invention is proposed. Summary of the invention
[0005] In view of the problems existing in the prior art, the purpose of the present invention is to provide a control method for improving the color change transition effect of RGB light-emitting diodes. By converting the parameters of the HSV color space into the RGB color space through a conversion algorithm calculation and finally converting it into the RGB color space recognized by the hardware, the physical control mode remains unchanged, the display effect is improved, and at the same time, the hardware cost is not increased.
[0006] In order to achieve the above object, the present invention provides a control method for improving the color change transition effect of RGB light emitting diodes, the steps are as follows:
[0007] S1: Set the initial state of the display; according to the HSV color space required by the system, convert the HSV color space to the RGB color space, and set the PWM duty cycle of the control port according to the converted RGB value, and display the default initial state of the device;
[0008] Among them, for the common anode RGB light-emitting diode, the duty cycle of the RED end is (1-R / 255)*100%, the duty cycle of the GREEN end is (1-G / 255)*100%, and the duty cycle of the BLUE end is (1-B / 255)*100%;
[0009] For common cathode RGB LEDs, the duty cycle of the RED end is (R / 255)*100%, the duty cycle of the GREEN end is (G / 255)*100%, and the duty cycle of the BLUE end is (B / 255)*100%;
[0010] S2: Adjust the parameters of the HSV color space according to business logic requirements;
[0011] S3: Convert the adjusted parameters of the HSV color space to the RGB color space. The conversion formula is:
[0012] C=V×S
[0013] X=C×(1-|(H / 60°)mod2-1|)
[0014] m=VC
[0015]
[0016] (R, G, B) = ((r+m)×255, (g+m)×255, (b+m)×255)
[0017] Among them, H is the hue of the HSV color space, S is the saturation of the HSV color space, V is the lightness of the HSV color space, R is the red of the RGB color space, G is the green of the RGB color space, B is the blue of the RGB color space, and C, V, S, X and m are all intermediate operation codes;
[0018] S4: setting the PWM duty cycle of the control port according to the RGB value calculated by the conversion formula in S3 to adjust the light display effect;
[0019] S5: Repeat the operation process of S3-S5 according to business logic requirements.
[0020] Preferably, the specific steps are as follows:
[0021] S1: Select a common anode RGB light-emitting diode, set the saturation and brightness to 1, and the hue H starts to display from 0°. According to the conversion formula:
[0022] C=V×S=1
[0023] X=C×(1-|(H / 60°)mod2-1|)=0
[0024] m=VC=0
[0025]
[0026] (R,G,B)=((r+m)×255,(g+m)×255,(b+m)×255)=(255,0,0)
[0027] At this time, the corresponding color is red. According to the conversion formula, the duty cycle of the control terminal is (1-R / 255)*100%. The processor controls the duty cycle of RED to 0%, and the duty cycle of GREEN and BLUE pins to 100%.
[0028] S2: Create a streamer effect, adjust the parameters of the HSV color space, keep the saturation and brightness at 1, and step the hue by 10 degrees, that is, H = 0 + 10°, S = 1, V = 1;
[0029] S3: Convert the adjusted parameters of the HSV color space to the RGB color space and substitute them into the conversion formula for calculation:
[0030] C=V×S=1
[0031] X=C×(1-|(H / 60°)mod2-1|)=0.167
[0032] m=VC=0
[0033]
[0034] (R,G,B)=((r+m)×255,(g+m)×255,(b+m)×255)=(255,43,0)
[0035] S4: According to the calculation result of the above conversion formula, the processor needs to control the duty cycle of the RED pin to be (1-255 / 255)*100%=0, the duty cycle of the GREEN pin PWM to be (1-43 / 255)*100%=83%, and the duty cycle of the BLUE pin to be (1-0 / 255)*100%=100%, so that 36 different colors of streamer gradient effects can be evenly transitioned within one streamer cycle;
[0036] Preferably, if the color tone in S2 steps by 1 degree, 360 different colors of streamer gradient effects can be presented in one streamer cycle;
[0037] Preferably, if the hue H is kept unchanged in S2 and the brightness is changed continuously from 0 to 1, a breathing effect of maintaining a certain color and presenting a gradual brightness change under the color can be obtained.
[0038] The present invention provides a control method for improving the color change transition effect of RGB light-emitting diodes, which has the following beneficial effects:
[0039] 1. This method first performs color calculation in the HSV color space that is more in line with human perception, and then converts the calculation result into the RGB color space suitable for RGB light-emitting diode hardware driver through color space coordinate conversion, thereby improving the control effect of the RGB light-emitting diode. The physical control mode remains unchanged by calculating through the conversion algorithm and finally converting it into the RGB space recognized by the hardware, thereby improving the display effect without increasing the hardware cost. Moreover, the color calculation is performed in the HSV color space, and the HSV color space describes the color information through hue H, saturation S and lightness V, which is more intuitive and in line with the recognition habits of the human eye, and more in line with human perception.
[0040] 2. By controlling the higher saturation, the color distribution with poor hardware display effect, such as gray, can be removed, so that the LED color display is highly consistent with the theoretical calculation and display distortion can be avoided. BRIEF DESCRIPTION OF THE DRAWINGS
[0041] Figure 1 A flow chart of a control method for improving the color change transition effect of an RGB light emitting diode provided by the present invention.
[0042] Figure 2 A flow chart of a control method for improving the streamer gradient transition effect of RGB light emitting diodes provided by the present invention.
[0043] Figure 3 This is the connection diagram of the common anode RGB light-emitting diode circuit. DETAILED DESCRIPTION
[0044] The present invention is further described below in conjunction with specific embodiments and drawings to help understand the content of the present invention.
[0045] like Figure 1-3 As shown, a control method for improving the color change transition effect of RGB light-emitting diodes provided by the present invention, the steps are as follows:
[0046] S1: Set the initial state of the display; according to the HSV color space required by the system, convert the HSV color space to the RGB color space, and set the PWM duty cycle of the control port according to the converted RGB value, and display the default initial state of the device;
[0047] Among them, Figure 3 As shown, for the common anode RGB light-emitting diode, the duty cycle of the RED end is (1-R / 255)*100%, the duty cycle of the GREEN end is (1-G / 255)*100%, and the duty cycle of the BLUE end is (1-B / 255)*100%;
[0048] For common cathode RGB LEDs, the duty cycle of the RED end is (R / 255)*100%, the duty cycle of the GREEN end is (G / 255)*100%, and the duty cycle of the BLUE end is (B / 255)*100%;
[0049] S2: Adjust the parameters of the HSV color space according to business logic requirements;
[0050] S3: Convert the adjusted HSV color space parameters to RGB color space. The conversion formula is:
[0051] C=V×S
[0052] X=C×(1-|(H / 60°)mod2-1|)
[0053] m=VC
[0054]
[0055] (R, G, B) = ((r+m)×255, (g+m)×255, (b+m)×255)
[0056] Among them, H is the hue of the HSV color space, S is the saturation of the HSV color space, V is the lightness of the HSV color space, R is the red of the RGB color space, G is the green of the RGB color space, B is the blue of the RGB color space, and C, V, S, X and m are all intermediate operation codes;
[0057] S4: Set the PWM duty cycle of the control port according to the RGB value calculated by the conversion formula in S3 to adjust the light display effect;
[0058] S5: Repeat the operation process of S3-S5 according to business logic requirements.
[0059] In many decoration and dynamic indication scenarios, users usually need the LEDs to maintain bright colors, high brightness, and gradual light changes. They only need to ensure that the brightness and saturation are at a high level, and dynamically adjust the H value to cycle between 0° and 360° to achieve bright colors, high brightness, and even transition of different colors to achieve gradual light changes.
[0060] like Figure 2 As shown, the present invention provides a control method for improving the streamer gradient transition effect of RGB light emitting diodes, and the specific steps are as follows:
[0061] S1: Select a common anode RGB light-emitting diode, set the saturation and brightness to 1, and the hue H starts to display from 0°. According to the conversion formula:
[0062] C=V×S=1
[0063] X=C×(1-|(H / 60°)mod2-1|)=0
[0064] m=VC=0
[0065]
[0066] (R,G,B)=((r+m)×255,(g+m)×255,(b+m)×255)=(255,0,0)
[0067] At this time, the corresponding color is red. According to the conversion formula, the duty cycle of the control terminal is (1-R / 255)*100%. The processor controls the duty cycle of RED to 0%, and the duty cycle of GREEN and BLUE pins to 100%.
[0068] S2: Create a streamer effect, adjust the parameters of the HSV color space, keep the saturation and brightness at 1, and step the hue by 10 degrees, that is, H = 0 + 10°, S = 1, V = 1;
[0069] S3: Convert the adjusted HSV color space parameters to RGB color space and substitute them into the conversion formula for calculation:
[0070] C=V×S=1
[0071] X=C×(1-|(H / 60°)mod2-1|)=0.167
[0072] m=VC=0
[0073]
[0074] (R,G,B)=((r+m)×255,(g+m)×255,(b+m)×255)=(255,43,0)
[0075] S4: According to the calculation results of the above conversion formula, the processor needs to control the duty cycle of the RED pin to be (1-255 / 255)*100%=0, the duty cycle of the GREEN pin PWM to be (1-43 / 255)*100%=83%, and the duty cycle of the BLUE pin to be (1-0 / 255)*100%=100%, so that 36 different colors of streamer gradient effects can be evenly transitioned within one streamer cycle.
[0076] For example, if the color tone in S2 steps by 10 degrees, 36 different colors can be presented in one streamer cycle. If the color tone in S2 steps by 1 degree, 360 different colors can be presented in one streamer cycle. The transition effect is uniform and soft, which conforms to the human eye visual model and greatly improves the user experience.
[0077] Among them, the HSV color space is a color space created based on the intuitive characteristics of color, namely hue, saturation and brightness, also known as the hexagonal cone model. The RGB color space is a color standard in the industry, which obtains different colors by changing and superimposing the three color channels of red, green and blue. The color space is also called a color model, color space or color system. It is a description of color in a generally acceptable way under certain standards. In essence, the color space is an explanation of the coordinate system and subspace, and each color in the system is represented by a single point.
[0078] The present invention studies the color space model. The HSV color space describes color information through hue (H), saturation (S) and brightness (V), which is more intuitive and in line with the human eye recognition habits, and more in line with human perception. Therefore, when driving the light-emitting diode, the color is first calculated in the HSV color space, and then converted to the RGB color space to display the required color through hardware control, so as to achieve a softer transition effect and a full color system and high-quality display effect. When making a streamer transition effect, the saturation and brightness can be set to 1, and the color can be continuously changed by continuously adjusting the hue, while ensuring that the highest brightness effect under the color is presented. If the demand is to maintain a certain color and present a breathing effect of brightness gradient under the color, the hue H can be kept unchanged, and its brightness V can be changed continuously from 0 to 1. By the conversion calculation of the HSV color space, it is more convenient to achieve a higher-quality program color effect and ensure the effect of color transition.
[0079] The invention concept is described in detail using specific examples herein, and the description of the above embodiments is only used to help understand the core idea of the invention. It should be pointed out that any obvious modification, equivalent substitution or other improvement made by a person of ordinary skill in the art without departing from the invention concept should be included in the protection scope of the present invention.
Claims
1. A control method for improving the color change transition effect of RGB light-emitting diodes, characterized in that: Here are the steps: S1: Set the initial state of the display; according to the HSV color space required by the system, convert the HSV color space to the RGB color space, and set the PWM duty cycle of the control port according to the converted RGB value, and display the default initial state of the device; Among them, for the common anode RGB light-emitting diode, the duty cycle of the RED end is (1-R / 255)*100%, the duty cycle of the GREEN end is (1-G / 255)*100%, and the duty cycle of the BLUE end is (1-B / 255)*100%; For common cathode RGB LEDs, the duty cycle of the RED end is (R / 255)*100%, the duty cycle of the GREEN end is (G / 255)*100%, and the duty cycle of the BLUE end is (B / 255)*100%; S2: Adjust the parameters of the HSV color space according to business logic requirements; S3: Convert the adjusted parameters of the HSV color space to the RGB color space, and the conversion formula is: Among them, H is the hue of the HSV color space, S is the saturation of the HSV color space, V is the lightness of the HSV color space, R is the red of the RGB color space, G is the green of the RGB color space, B is the blue of the RGB color space, and C, V, S, X and m are all intermediate operation codes; S4: setting the PWM duty cycle of the control port according to the RGB value calculated by the conversion formula (1) in S3 to adjust the light display effect; S5: Repeat the operation process of S3-S5 according to business logic requirements.
2. A control method for improving the color change transition effect of RGB light emitting diodes according to claim 1, characterized in that: The specific steps of S1-S4 are as follows: SS1: Use common anode RGB light-emitting diodes, set the saturation and brightness to 1, and display the hue H starting from 0°. Substituting into the conversion formula (1) yields: At this time, the corresponding color is red. According to the conversion formula (2), the duty cycle of the control terminal is (1-R / 255)*100%. The processor controls the duty cycle of RED to 0%, and the duty cycle of GREEN and BLUE pins to 100%. SS2: Create a streamer effect, adjust the parameters of the HSV color space, keep the saturation and brightness at 1, and step the hue by 10 degrees, that is, H = 0 + 10°, S = 1, V = 1; SS3: Convert the adjusted parameters of the HSV color space to the RGB color space and substitute them into the conversion formula (1) to obtain: SS4: According to the calculation result of the above conversion formula (3), the processor needs to control the duty cycle of the RED pin to (1-255 / 255)*100%=0, the duty cycle of the GREEN pin PWM to (1-43 / 255)*100%=83%, and the duty cycle of the BLUE pin to (1-0 / 255)*100%=100%, so that 36 different colors of streamer gradient effects can be evenly transitioned within one streamer cycle.
3. A control method for improving the color change transition effect of RGB light emitting diodes according to claim 2, characterized in that: If the color tone in SS2 steps by 1 degree, 360 different colors of streamer gradient effects can be presented in one streamer cycle.
4. A control method for improving the color change transition effect of RGB light emitting diodes according to claim 2, characterized in that: If the hue H is kept unchanged in the SS2 and the brightness is changed continuously from 0 to 1, a breathing effect of maintaining a certain color and presenting a gradual brightness change under the color is obtained.
