diff --git a/app/Models/DeviceModel.php b/app/Models/DeviceModel.php index c9de2af..c5f3d31 100644 --- a/app/Models/DeviceModel.php +++ b/app/Models/DeviceModel.php @@ -24,4 +24,13 @@ final class DeviceModel extends Model 'offset_y' => 'integer', 'published_at' => 'datetime', ]; + + public function getColorDepthAttribute(): ?string + { + if (! $this->bit_depth){ + return null; + } + + return $this->bit_depth . 'bit'; + } } diff --git a/app/Models/Plugin.php b/app/Models/Plugin.php index 40b3383..375921b 100644 --- a/app/Models/Plugin.php +++ b/app/Models/Plugin.php @@ -278,7 +278,7 @@ class Plugin extends Model * * @throws LiquidException */ - public function render(string $size = 'full', bool $standalone = true): string + public function render(string $size = 'full', bool $standalone = true, ?Device $device = null): string { if ($this->render_markup) { $renderedContent = ''; @@ -344,6 +344,7 @@ class Plugin extends Model if ($standalone) { return view('trmnl-layouts.single', [ + 'colorDepth' => $device?->deviceModel?->color_depth, 'slot' => $renderedContent, ])->render(); } @@ -354,6 +355,7 @@ class Plugin extends Model if ($this->render_markup_view) { if ($standalone) { return view('trmnl-layouts.single', [ + 'colorDepth' => $device?->deviceModel?->color_depth, 'slot' => view($this->render_markup_view, [ 'size' => $size, 'data' => $this->data_payload, diff --git a/composer.json b/composer.json index 0ae1e49..8417cc6 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "php": "^8.2", "ext-imagick": "*", "ext-zip": "*", - "bnussbau/laravel-trmnl-blade": "1.2.*", + "bnussbau/laravel-trmnl-blade": "2.0.*", "intervention/image": "^3.11", "keepsuit/laravel-liquid": "^0.5.2", "laravel/framework": "^12.1", diff --git a/composer.lock b/composer.lock index d382489..5cbc926 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "ecbc891180c22676e2d03b6c8a02b6e3", + "content-hash": "349a46b94103f479caae00ca7e6a99c2", "packages": [ { "name": "aws/aws-crt-php", @@ -159,16 +159,16 @@ }, { "name": "bnussbau/laravel-trmnl-blade", - "version": "1.2.1", + "version": "2.0.0", "source": { "type": "git", "url": "https://github.com/bnussbau/laravel-trmnl-blade.git", - "reference": "fe11d1d7d896d6f0ea44664c1c6b5f00f1bdab36" + "reference": "3b60522bea8ae5dbca94834706247339e1e53582" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/bnussbau/laravel-trmnl-blade/zipball/fe11d1d7d896d6f0ea44664c1c6b5f00f1bdab36", - "reference": "fe11d1d7d896d6f0ea44664c1c6b5f00f1bdab36", + "url": "https://api.github.com/repos/bnussbau/laravel-trmnl-blade/zipball/3b60522bea8ae5dbca94834706247339e1e53582", + "reference": "3b60522bea8ae5dbca94834706247339e1e53582", "shasum": "" }, "require": { @@ -223,7 +223,7 @@ ], "support": { "issues": "https://github.com/bnussbau/laravel-trmnl-blade/issues", - "source": "https://github.com/bnussbau/laravel-trmnl-blade/tree/1.2.1" + "source": "https://github.com/bnussbau/laravel-trmnl-blade/tree/2.0.0" }, "funding": [ { @@ -239,7 +239,7 @@ "type": "github" } ], - "time": "2025-08-11T16:14:12+00:00" + "time": "2025-09-14T07:54:31+00:00" }, { "name": "brick/math", diff --git a/resources/views/trmnl-layouts/single.blade.php b/resources/views/trmnl-layouts/single.blade.php index ec073e5..741ddbd 100644 --- a/resources/views/trmnl-layouts/single.blade.php +++ b/resources/views/trmnl-layouts/single.blade.php @@ -1,3 +1,7 @@ - +@props([ + 'colorDepth' => '1bit', +]) + + {!! $slot !!} diff --git a/resources/views/vendor/trmnl/components/screen.blade.php b/resources/views/vendor/trmnl/components/screen.blade.php index 99aa147..b5e570f 100644 --- a/resources/views/vendor/trmnl/components/screen.blade.php +++ b/resources/views/vendor/trmnl/components/screen.blade.php @@ -3,7 +3,7 @@ 'darkMode' => false, 'deviceVariant' => 'og', 'deviceOrientation' => null, - 'colorDepth' => '2bit', + 'colorDepth' => '1bit', 'scaleLevel' => null, ]) diff --git a/routes/api.php b/routes/api.php index 36c7aa0..578fe7d 100644 --- a/routes/api.php +++ b/routes/api.php @@ -85,7 +85,7 @@ Route::get('/display', function (Request $request) { // Check and update stale data if needed if ($plugin->isDataStale() || $plugin->current_image === null) { $plugin->updateDataPayload(); - $markup = $plugin->render(); + $markup = $plugin->render(device: $device); GenerateScreenJob::dispatchSync($device->id, $plugin->id, $markup); }