【AB32VG1开发板测评】非判别处理的色彩变换处理
本帖最后由 jinglixixi 于 2021-8-16 09:18 编辑<p style="text-align:justify"><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:"微软雅黑","sans-serif""><span style="color:#444444"><span style="letter-spacing:.75pt">前面介绍一种在RGB_LED的色彩变换程序,它是通过条件判别语句来实现的,这里介绍一种无需判别处理的方法,其程序内容如下:</span></span></span></span></span></p>
<pre>
<code class="language-cpp">int main(void)
{
uint32_t cnt = 0;
uint8_t n;
uint8_t LED_R = rt_pin_get("PE.1");
uint8_t LED_G = rt_pin_get("PE.4");
uint8_t LED_B = rt_pin_get("PA.1");
// 设置引脚为输出方式
rt_pin_mode(LED_R, PIN_MODE_OUTPUT);
rt_pin_mode(LED_G, PIN_MODE_OUTPUT);
rt_pin_mode(LED_B, PIN_MODE_OUTPUT);
while (1)
{
n=cnt%8;
rt_pin_write(LED_G, (n&0x01));
rt_pin_write(LED_R, (n&0x02));
rt_pin_write(LED_B, (n&0x04));
cnt++;
rt_thread_mdelay(1000);
}
return 0;
}</code></pre>
<p> </p>
<p> </p>
<p><span style="font-size:10.5pt"><span style="font-family:Calibri,sans-serif"><span style="font-family:"微软雅黑","sans-serif""><span style="color:#444444"><span style="letter-spacing:.75pt">它是用3位2进制数的每一位来对应RGB_LED的相应彩色来控制变换,由于RGB_LED是由低电平点亮的,故在色彩变换的顺序上是有所变化的。</span></span></span></span></span></p>
<p> </p>
<p> </p>
<p>挺好,多种思考方式:)</p>
<p>RGB_LED的相应彩色来控制变换这个有用,收藏</p>
soso 发表于 2021-8-16 10:03
挺好,多种思考方式:)
<p>哈哈,还是坛友的提议好。</p>
<p>没太看懂呢</p>
页:
[1]