# Generated by Django 5.2.8 on 2025-12-06 15:03

import django.db.models.deletion
from django.db import migrations, models


class Migration(migrations.Migration):

    initial = True

    dependencies = []

    operations = [
        migrations.CreateModel(
            name="DeviceScreen",
            fields=[
                (
                    "id",
                    models.BigAutoField(
                        auto_created=True,
                        primary_key=True,
                        serialize=False,
                        verbose_name="ID",
                    ),
                ),
                ("is_seed_data", models.BooleanField(default=False, editable=False)),
                ("is_user_data", models.BooleanField(default=False, editable=False)),
                ("is_deleted", models.BooleanField(default=False, editable=False)),
                ("slug", models.SlugField(max_length=64, unique=True)),
                ("name", models.CharField(max_length=100)),
                (
                    "category",
                    models.CharField(
                        choices=[
                            ("lcd", "LCD"),
                            ("led", "LED"),
                            ("touch", "Touch"),
                            ("pixel", "Pixel matrix"),
                            ("other", "Other"),
                        ],
                        default="other",
                        help_text="Broad hardware category for the screen.",
                        max_length=32,
                    ),
                ),
                (
                    "skin",
                    models.CharField(
                        help_text="Skin, SKU or shell identifier for the device.",
                        max_length=100,
                    ),
                ),
                (
                    "columns",
                    models.PositiveSmallIntegerField(
                        default=0,
                        help_text="Text columns for character displays or pixel width for matrix screens.",
                    ),
                ),
                (
                    "rows",
                    models.PositiveSmallIntegerField(
                        default=0,
                        help_text="Text rows for character displays or pixel height for matrix screens.",
                    ),
                ),
                (
                    "resolution_width",
                    models.PositiveIntegerField(
                        blank=True,
                        help_text="Pixel width for graphical displays when the resolution differs from columns.",
                        null=True,
                    ),
                ),
                (
                    "resolution_height",
                    models.PositiveIntegerField(
                        blank=True,
                        help_text="Pixel height for graphical displays when the resolution differs from rows.",
                        null=True,
                    ),
                ),
                (
                    "min_refresh_ms",
                    models.PositiveIntegerField(
                        default=50,
                        help_text="Minimum delay in milliseconds before accepting the next frame.",
                    ),
                ),
                (
                    "last_bitmap",
                    models.JSONField(
                        blank=True,
                        default=list,
                        editable=False,
                        help_text="Last bitmap payload received by the screen.",
                    ),
                ),
                (
                    "last_refresh_at",
                    models.DateTimeField(blank=True, editable=False, null=True),
                ),
            ],
            options={
                "verbose_name": "Device Screen",
                "verbose_name_plural": "Device Screens",
                "ordering": ["name"],
            },
        ),
        migrations.CreateModel(
            name="PyxelViewport",
            fields=[
                (
                    "devicescreen_ptr",
                    models.OneToOneField(
                        auto_created=True,
                        on_delete=django.db.models.deletion.CASCADE,
                        parent_link=True,
                        primary_key=True,
                        serialize=False,
                        to="screens.devicescreen",
                    ),
                ),
                (
                    "pyxel_script",
                    models.TextField(
                        help_text="Python code executed with a `pyxel` variable available. Define a `draw()` function (and optional `update()`) to populate the viewport."
                    ),
                ),
                (
                    "pyxel_fps",
                    models.PositiveSmallIntegerField(
                        default=20,
                        help_text="Frame rate passed to Pyxel when rendering this viewport.",
                    ),
                ),
            ],
            options={
                "verbose_name": "Pyxel viewport",
                "verbose_name_plural": "Pyxel viewports",
            },
            bases=("screens.devicescreen",),
        ),
    ]
