Files
rt-thread/components/drivers/graphic/logo/SConscript
T
GuEe-GUI 27eb7c4f72
ToolsCI / Tools (push) Has been cancelled
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
doc_doxygen / doxygen_doc generate (push) Has been cancelled
doc_doxygen / deploy (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
utest_auto_run / A9 :components/dfs.cfg (push) Has been cancelled
utest_auto_run / A9 :components/lwip.cfg (push) Has been cancelled
utest_auto_run / A9 :components/netdev.cfg (push) Has been cancelled
utest_auto_run / A9 :components/sal.cfg (push) Has been cancelled
utest_auto_run / A9 :cpp11/cpp11.cfg (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/mem.cfg (push) Has been cancelled
Weekly CI Scheduler / Trigger and Monitor CIs (push) Has been cancelled
Weekly CI Scheduler / Create Discussion Report (push) Has been cancelled
[dm][graphic] add new drivers and logo
1. Generic GPIO based backlight driver
2. Generic PWM based backlight driver
3. Simple framebuffer support
4. Standard 224-color RT-Thread logo
5. Standard 224-color RT-Thread white logo

Signed-off-by: GuEe-GUI <2991707448@qq.com>
2025-12-15 16:54:23 +08:00

91 lines
2.5 KiB
Python

from building import *
import os, re
group = []
if not GetDepend(['RT_GRAPHIC_LOGO']):
Return('group')
cwd = GetCurrentDir()
CPPPATH = [cwd + '/../../include']
CPPDEFINES = []
src = ['logo.c']
logo_path = None
logo_width = 0
logo_height = 0
logo_max_val = 0
if GetDepend(['RT_GRAPHIC_LOGO_RT_THREAD_CLUT224']):
logo_path = cwd + '/logo-rt-thread-clut224.ppm'
if GetDepend(['RT_GRAPHIC_LOGO_RT_THREAD_WHITE_CLUT224']):
logo_path = cwd + '/logo-rt-thread-white-clut224.ppm'
if logo_path == None:
# Find in BSP
paths = None
for key in BuildOptions.keys():
if re.match(r'RT_GRAPHIC_LOGO_.*_PATH', key):
paths = BuildOptions[key]
break
if paths != None and len(paths) > 0:
logo_path = Dir('#').abspath + '/' + paths[1:-1]
if not os.path.exists(logo_path):
print("Logo file '{}' not found!".format(logo_path))
exit(-1)
if logo_path != None:
with open(logo_path, 'rb') as ppm:
data = ppm.read().split(b'\n')
# PPM: <magic number>
magic = data[0].decode('utf-8')
# PPM: <comment>
offset = 1
while True:
comment = str(data[offset].decode('utf-8'))
if comment[0] != '#':
break
offset += 1
# PPM: <width> <height>
logo_width, logo_height = map(int, data[offset].split())
# PPM: <max pixel value>
logo_max_val = int(data[offset + 1])
# PPM: <data>
ppm.seek(0)
pixels = b''.join(ppm.readlines()[offset + 2:])
ppm.close()
if magic == 'P1' or magic == 'P2' or magic == 'P3':
# ASCII
pixels = re.sub(b'\\s+', b'\n', pixels.strip()).decode('utf-8').split('\n')
logo = open(cwd + '/logo.inc', "w")
for dy in range(logo_height):
for dx in range(logo_width):
index = (dy * logo_width + dx) * 3
# Red
logo.write(str(pixels[index]).rjust(4) + ",")
# Green
logo.write(str(pixels[index + 1]).rjust(4) + ",")
# Blue
logo.write(str(pixels[index + 2]).rjust(4) + ",")
logo.write("\n")
logo.close()
CPPDEFINES += ['__STARTUP_LOGO_WIDTH__=' + str(logo_width)]
CPPDEFINES += ['__STARTUP_LOGO_HEIGHT__=' + str(logo_height)]
CPPDEFINES += ['__STARTUP_LOGO_COLOR_MAX__=' + str(logo_max_val)]
group = DefineGroup('DeviceDrivers', src, depend = [''], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES)
Return('group')