本帖最后由 jasonZJR 于 2026-4-9 13:45 编辑
LED屏幕信息:
共16x16组灯珠,每组灯珠3个灯,1颗绿色,2颗红色(同时亮灭)
屏幕划分为4x4组灯珠为一个块,一共16个块,块顺序为左上角为第1块,从上到下的顺序是1~4
每一个块由一个uint16_t数据显示,块内4x4,第一列(从上到下,后同)为bit0~3,第二列为bit4~7,第三列为bit8~11,第四列为bit12~15
----------------------------------------------------------
知道了以上信息,就写了个坐标转换,可以像写LCD一样,给一个xy坐标和对应颜色,屏幕就能正确显示,以下是显示效果
----------------------------------------------------------
----------------------------------------------------------
以下是核心驱动部分,需要在主循环里边循环调用PLED_Flush来刷新屏幕,我在RTOS里边单独创建了一个任务来刷屏,其他还有十来个任务,目前没看出闪烁或者卡顿
内容滚动的部分,我不打算开源,大伙自己实现吧
画点的核心代码
[C] 纯文本查看 复制代码 void PLED_DrawPoint(uint16_t x, uint16_t y, uint16_t color)
{
if((x < PLED_X_SIZE) && (y < PLED_Y_SIZE))
{
uint16_t pled_4x4_index = 0;
uint16_t bits = 0;
#if(PLED_DIR == 0)
uint16_t pled_index = y / PLED_1_XY_SIZE; //屏幕索引--对应的显存索引
y %= PLED_1_XY_SIZE; //限制y在一个屏幕内
#else
uint16_t pled_index = x / PLED_1_XY_SIZE; //屏幕索引--对应的显存索引
x %= PLED_1_XY_SIZE; //限制x在一个屏幕内
#endif
pled_4x4_index = ((x >> 2) << 2) + (y >> 2); //块索引
bits = (y % 4) + ((x << 2) % PLED_1_XY_SIZE); //点索引
if(color == 0)
{
pled_g_buf[pled_index][pled_4x4_index] |= 1 << bits;
}
else if(color == 1)
{
pled_r_buf[pled_index][pled_4x4_index] |= 1 << bits;
}
else
{
pled_g_buf[pled_index][pled_4x4_index] &= ~(1 << bits);
pled_r_buf[pled_index][pled_4x4_index] &= ~(1 << bits);
}
}
}
pled.zip
(2.42 KB, 下载次数: 0)
|