fluidcanvas_r2pi:tft_boot_splash_and_status_display_guide
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| fluidcanvas_r2pi:tft_boot_splash_and_status_display_guide [2026/03/21 23:25] – hyjeong | fluidcanvas_r2pi:tft_boot_splash_and_status_display_guide [2026/03/21 23:28] (current) – hyjeong | ||
|---|---|---|---|
| Line 50: | Line 50: | ||
| ## 4. 상태 화면 스크립트(~/ | ## 4. 상태 화면 스크립트(~/ | ||
| + | ```` | ||
| + | # | ||
| + | from PIL import Image, ImageDraw, ImageFont | ||
| + | import subprocess | ||
| + | from pathlib import Path | ||
| + | W, H = 480, 320 | ||
| + | OUT = Path("/ | ||
| + | |||
| + | FONT_BOLD = "/ | ||
| + | FONT_REG | ||
| + | |||
| + | def run_cmd(cmd): | ||
| + | try: | ||
| + | result = subprocess.run( | ||
| + | cmd, shell=True, capture_output=True, | ||
| + | ) | ||
| + | return result.stdout.strip() | ||
| + | except Exception: | ||
| + | return "" | ||
| + | |||
| + | def get_status(): | ||
| + | hostname = run_cmd(" | ||
| + | time_str = run_cmd(" | ||
| + | ip_str = run_cmd(" | ||
| + | if not ip_str: | ||
| + | ip_str = "no network" | ||
| + | |||
| + | cpu_load = run_cmd(" | ||
| + | cpu_temp = run_cmd(" | ||
| + | mem = run_cmd(" | ||
| + | |||
| + | return { | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | " | ||
| + | } | ||
| + | |||
| + | def render(status): | ||
| + | img = Image.new(" | ||
| + | draw = ImageDraw.Draw(img) | ||
| + | |||
| + | font_title = ImageFont.truetype(FONT_BOLD, | ||
| + | font_label = ImageFont.truetype(FONT_BOLD, | ||
| + | font_text | ||
| + | |||
| + | # 제목 | ||
| + | draw.text((W // 2, 18), " | ||
| + | draw.line((20, | ||
| + | |||
| + | items = [ | ||
| + | (" | ||
| + | (" | ||
| + | (" | ||
| + | (" | ||
| + | (" | ||
| + | (" | ||
| + | ] | ||
| + | |||
| + | y = 70 | ||
| + | for label, value in items: | ||
| + | draw.text((24, | ||
| + | draw.text((110, | ||
| + | y += 36 | ||
| + | |||
| + | draw.line((20, | ||
| + | draw.text((W // 2, H - 28), " | ||
| + | |||
| + | img.save(OUT) | ||
| + | |||
| + | def show(): | ||
| + | subprocess.run( | ||
| + | [" | ||
| + | check=False | ||
| + | ) | ||
| + | |||
| + | def main(): | ||
| + | status = get_status() | ||
| + | render(status) | ||
| + | show() | ||
| + | |||
| + | if __name__ == " | ||
| + | main() | ||
| + | ```` | ||
| --- | --- | ||
fluidcanvas_r2pi/tft_boot_splash_and_status_display_guide.txt · Last modified: by hyjeong
