芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

飞芯科技-芯片解密|单片机解密|IC解密|芯片破解|芯片复制| PCB抄板|软件开发

WS2812B渐变色流水算法IC解密

IC解密STM32,到定时器与DMA章节,正巧手头有先前买的WS2812B模块,查找相关资料,于是成功点亮了,
又按照自己想法和思路写了一个渐变色算法,和渐变色流水功能,

可自定义灯的数量和渐变色的深度

渐变色原理:
假如红蓝两色变换
红(亮度):10   8   6   4   2   0
蓝(亮度):0     2   4   6   8   10


IC解密这样就形成两种颜色的过度
加大其分辨率,两颜色之间颜色差越小,生成颜色数据越多


在流水过程中,颜色取到数组末尾时,要将数组首端的数据加在末尾,使其颜色无差别连接

控制代码:

生成三种颜色数据数组

  1. /**
  2. * color_length 每种颜色渐变最大长度,总颜色长度:color_length * 3
  3. * return 颜色数据总长度
  4. */
  5. uint32_t set_Color_Loop(uint8_t color_length)
  6. {
  7.     RGB = (uint32_t*)malloc(color_length*3*sizeof(uint32_t));//分配数组大小,(所有渐变色颜色长度)
  8.     color_length -= 1;
  9.     for(uint8_t i=0;i<=color_length;i++)
  10.     {
  11.         RGB[i] = (((0xff/color_length)*i)<<8)|((0xff/color_length)*(color_length-i));                                       //蓝到绿
  12.         RGB[color_length + 1 +i] = (((0xff/color_length)*i)<<16)|((0xff/color_length)*(color_length-i))<<8; //绿到红
  13.         RGB[((color_length+1)*2) +i] = ((0xff/color_length)*i)|((0xff/color_length)*(color_length-i))<<16;   //红到蓝
  14.     }
  15.     return color_length*3;
  16. }


  17. 无间断位移获取8位颜色数据
  18. /**
  19. * colorwidth 每次获取多少位
  20. */

  21. void out_RGB(uint16_t data_Max_Length,uint16_t colorwidth)
  22. {
  23.     static uint32_t rgb_position = 0;
  24.     for(uint32_t i = 0;i < colorwidth; i++){
  25.         uint16_t c = (rgb_position + i) % data_Max_Length;//末尾颜色数据结束时将首位的收据填充到数组
  26.         send_Data(RGB[c]);
  27.     }
  28.     rgb_position ++;
  29.     rgb_position %= data_Max_Leng



联系方式

地址:石家庄市新华区民族路77号华强广场D座2009
电话:0311-88816616/87087811
手机:13315190088
传真:0311-67901001
联系人:张工
网址:www.feixindz.com
邮箱:feixindz@163.com
微信:xinpianjiemi
QQ:527263666/568069805

在线客服
热线电话

企业微信