kai — Raspberry Pi 5 simulation

An interactive Raspberry Pi 5 circuit simulation you can run free in your browser on Velxio, by tingop12345.

Components

Sketch code

import csv
import os
from datetime import datetime

# ==============================
# ข้อมูลนักเรียน
# ==============================

STUDENTS = {
    "1234": {
        "id": "67001",
        "name": "Student 1"
    },
    "5678": {
        "id": "67002",
        "name": "Student 2"
    },
    "9999": {
        "id": "67003",
        "name": "Student 3"
    }
}

# ==============================
# ไฟล์บันทึกการเช็คชื่อ
# ==============================

ATTENDANCE_FILE = "attendance.csv"

# ==============================
# จำลองหน้าจอ TFT
# ==============================

def tft_display(message):

    print()
    print("+--------------------------------+")
    print("|          TFT DISPLAY           |")
    print("+--------------------------------+")

    for line in message.split("\n"):
        print("| " + line[:30].ljust(30) + " |")

    print("+--------------------------------+")
    print()

# ==============================
# บันทึกข้อมูลการเช็คชื่อ
# ==============================

def save_attendance(student_id, name):

    now = datetime.now()

    date = now.strftime("%Y-%m-%d")
    time = now.strftime("%H:%M:%S")

    file_exists = os.path.exists(ATTENDANCE_FILE)

    with open(
        ATTENDANCE_FILE,
        "a",
        newline="",
        encoding="utf-8"
    ) as file:

        writer = csv.writer(file)

        if not file_exists:

            writer.writerow([
                "Student ID",
                "Name",
                "Date",
                "Time",
                "Status"
            ])

        writer.writerow([
            student_id,
            name,
            date,
            time,
            "เช็คชื่อสำเร็จ"
        ])

    print()
    print("บันทึกข้อมูลเรียบร้อย")
    print("ไฟล์:", ATTENDANCE_FILE)

# ==============================
# จำลองการตรวจจับใบหน้า
# ==============================

def camera_detection():

    print()
    print("Camera: กำลังตรวจสอบใบหน้า...")
    print()

    while True:

        answer = input(
            "พบใบหน้าหรือไม่? (y/n): "
        ).strip().lower()

        if answer == "y":

            print("Camera: พบใบหน้า")
            return True

        elif answer == "n":

            print("Camera: ไม่พบใบหน้า")

            tft_display(
                "NO FACE\n"
                "PLEASE TRY AGAIN"
            )

            return False

        else:

            print(
                "กรุณาพิมพ์ y หรือ n"
            )

# ==============================
# จำลอง Keypad
# ==============================

def keypad_input():

    print()
    print("================================")
    print("             Keypad")
    print("================================")
    print("ใส่รหัสผ่าน เช่น 1234#")
    print("* = ล้างรหัส")
    print("# = ยืนยัน")
    print()

    while True:

        password = input(
            "กดปุ่ม: "
        ).strip()

        if password == "":
            continue

        # กด * เพื่อล้าง
        if password == "*":

            tft_display(