走马观花

【RA】Fantasy Light Cube

 
Overview

demand analysis

1. A 4x4 matrix composed of three-color LED lights, distributed on the 6 faces of the cube.
2. LED lights are connected in series.
3. The lights on each side are connected in series through connectors.
4. Serial communication through Renesas MCU SPI pin.
5. The color of the lamp can change gradually.

Schematic design instructions

LED matrix serial connection
jWBsbPWs8kn6rrwBXLLzNDmAkeP8H7mbe8JP2gOh.png
Inter-board interconnect connector
snap_screen_20220509153853.png
Renesas MCU
snap_screen_20220509154046.png

Software description

Code block:

#define FACE_NUM            6   //共6个面
#define PIXEL_NUM_OF_FACE   16  //一个面16个灯
#define BIT_OF_PIXEL        24  //一个灯有24bit数据
#define PIXEL_NUM           96  //共96个灯
#define LED_BIT             (PIXEL_NUM * BIT_OF_PIXEL)        //LED灯共这些bit数据

uint8_t Pixel_Buffer[FACE_NUM][PIXEL_NUM_OF_FACE][BIT_OF_PIXEL];
uint8_t color_face_1[6][3] = {{128 ,  0 ,  0},{64 , 64 ,  0},{ 0 , 128 ,  0},{ 0 , 64 ,  64},{ 0 , 0 ,  128},{  64 ,0 ,  64}};
uint8_t Color_Buffer_of_Face[PIXEL_NUM_OF_FACE][3] = {
    {128 ,  0 ,  0},{104 , 24 ,  0},{ 80 , 48 ,  0},{ 56 , 72 ,  0},
    { 32 , 96 ,  0},{  8 ,120 ,  0},{  0 ,112 , 16},{  0 , 88 , 40},
    {  0 , 64 , 64},{  0 , 40 , 88},{  0 , 16 ,112},{  8 ,  0 ,120},
    { 32 ,  0 , 96},{ 56 ,  0 , 72},{ 80 ,  0 , 48},{104 ,  0 , 24},
};
void LED_Set_Color(uint8_t color,uint8_t *position)
{
    uint8_t zero    = 0x30; //00110000
    uint8_t one     = 0xF8; //11111000
    uint8_t k       = 0;
    uint8_t mask    = 0x80;

    for(k=0;k<8;k++)
    {
        position[k]   = ((color & mask) ? one : zero);
        mask >>= 1;
    }
}
        for(cnt_f=0;cnt_f<FACE_NUM;cnt_f++)     //6个面
        {
            for(cnt_p=0;cnt_p<PIXEL_NUM_OF_FACE;cnt_p++)        //16个像素
            {
                for(cnt_b=0;cnt_b<3;cnt_b++)        //每个像素3种颜色
                {
                    LED_Set_Color(color_face_1[cnt_f][cnt_b],&Pixel_Buffer[cnt_f][cnt_p][cnt_b*8]);
                }
            }
        }
        for(cnt_p=0;cnt_p<FACE_NUM;cnt_p++)        //16个像素颜色变换
        {
            if((color_face_1[cnt_p][0] != 0) && (color_face_1[cnt_p][2] == 0))
            {
                color_face_1[cnt_p][0]--;
                color_face_1[cnt_p][1]++;
            }
            else if((color_face_1[cnt_p][0] == 0) && (color_face_1[cnt_p][1] != 0))
            {
                color_face_1[cnt_p][1]--;
                color_face_1[cnt_p][2]++;
            }
            else if((color_face_1[cnt_p][1] == 0) && (color_face_1[cnt_p][2] != 0))
            {
                color_face_1[cnt_p][2]--;
                color_face_1[cnt_p][0]++;
            }
        }

        err = R_SPI_Write(&g_spi0_ctrl, Pixel_Buffer, LED_BIT, SPI_BIT_WIDTH_8_BITS);
        assert(FSP_SUCCESS == err);
        R_BSP_SoftwareDelay(5, BSP_DELAY_UNITS_MILLISECONDS); // NOLINT100->160

Physical display instructions

Cube plot.png
Lighting effect, you can watch the video attachment to see the complete effect

references

The hardware design of this project is a replica of the "KeG Stack" work. The main design has basically remained unchanged. The main control MCU has been replaced with R7FA2L1AB2DFL#AA0.
The link is as follows:
https://www.bilibili.com/video/BV1ev411k7mh?spm_id_from=333.999.0.0

Code design reference:
https://blog.csdn.net/geek_liyang/article/details/89208507?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_title~default-0-89208507-blog-84638967 .pc_relevant_paycolumn_v3&spm=1001.2101.3001.4242.1&utm_relevant_index=3

Optimization suggestions

1. In order to connect the 6-sided lights in series in the design, PCBs with two wiring directions need to be spliced. I think the connector connection method can be optimized here, and a PCB board can be used to realize the series connection of 6 surface lights.

Demo video and engineering code

see attached

参考设计图片
×
 
 
Search Datasheet?

Supported by EEWorld Datasheet

Forum More
Update:2025-05-06 03:40:19

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
community

Robot
development
community

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号