1712 views|1 replies

9702

Posts

24

Resources
The OP
 

bluenrg-1 True random numbers to achieve holiday lighting effects [Copy link]

 

Use the true random number function of the RNG of bluenrg-1 to generate random colors, and then display them through the WS2812B colored lights. If you use a light strip and shorten the update delay, the effect will be better. Generate the code for random numbers, wait for the data to be ready before reading the data. The RNG module can read 16 bits of data at a time.
  1. uint8_t rng_read(void) { uint8_t random; /* Loop until the RNG Data Ready is SET */ while (RNG_GetFlagStatus() != SET); random = (uint8_t)(RNG_GetValue() % 255); return random; }
复制代码
WS2812B uses 24 bits, so read 8 bits each time, and read 3 times in succession to fill an LED lamp bead.
  1. void ws2812b_display(void) { uint16_t i; uint32_t colors[WS2812B_COUNT]; RTC_DateTimeType RTC_DateTime; rtc_get_time(&RTC_DateTime); //Clear source data, draw scale for(i=0;i<ws2812b_count;i++) 16="" 8="" <<="" colors[i]="rng_read()" if(index="" rng_read()="" rng_read();="" {="" |="" }="">= 24 || RTC_DateTime.Second == 0)index = 0; //Display after filling a column of 8 points IntColorsToWS2812BBytes(ws2812b_buffer,colors,WS2812B_COUNT); DMASpi_Sending((uint32_t)ws2812b_buffer,WS2812B_COUNT * 9); }
复制代码
https://training.eeworld.com.cn/course/4063/learn?preview=1#lesson/17835 https://training.eeworld.com.cn/course/4063/learn?preview=1#lesson/17836 Project Files
游客,如果您要查看本帖隐藏内容请回复


This post is from ST - Low Power RF

Latest reply

Awesome, no time to do it  Details Published on 2019-1-29 23:02
Personal signature虾扯蛋,蛋扯虾,虾扯蛋扯虾
 
 

30

Posts

0

Resources
2
 
Awesome, no time to do it
This post is from ST - Low Power RF
 
 
 

Just looking around
Find a datasheet?

EEWorld Datasheet Technical Support

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews

Room 1530, Zhongguancun MOOC Times Building, Block B, 18 Zhongguancun Street, Haidian District, Beijing 100190, China Tel:(010)82350740 Postcode:100190

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京B2-20211791 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号
快速回复 返回顶部 Return list