private function handleImageUpload() $uploadDir = __DIR__ . '/uploads/'; if (!is_dir($uploadDir)) mkdir($uploadDir, 0755, true); $filename = uniqid() . '_' . basename($_FILES['image']['name']); $targetPath = $uploadDir . $filename; if (move_uploaded_file($_FILES['image']['tmp_name'], $targetPath)) try $image = $this->display->loadImage($targetPath); $this->display->display($image); imagedestroy($image); $message = "Image displayed successfully!"; catch (Exception $e) $message = "Error: " . $e->getMessage(); unlink($targetPath); else $message = "Failed to upload image"; $_SESSION['message'] = $message;
$method = $_SERVER['REQUEST_METHOD']; $path = $_GET['path'] ?? ''; epaper php script
// Run the web interface $webInterface = new EPaperWebInterface(); $webInterface->handleRequest(); ?> # Install required PHP packages sudo apt-get install php-gd php-imagick Set permissions for framebuffer sudo chmod 666 /dev/fb0 Create required directories mkdir -p uploads fonts Download a font wget -O fonts/FreeSans.ttf https://github.com/google/fonts/raw/main/apache/opensans/OpenSans-Regular.ttf System Integration Script # /usr/local/bin/epaper_refresh.py #!/usr/bin/env python3 import sys import fcntl import struct import os E-Paper refresh IOCTL command (vendor specific) FBIO_REFRESH = 0x4600 private function handleImageUpload() $uploadDir = __DIR__
// Slideshow $images = ['img1.jpg', 'img2.jpg', 'img3.jpg']; $display->displaySlideshow($images, 10); basename($_FILES['image']['name']); $targetPath = $uploadDir
/** * Create text display */ public function displayText($text, $fontSize = 24, $fontFile = null) $image = $this->createBlankImage(); // Default font if none specified if (!$fontFile) $fontFile = __DIR__ . '/fonts/FreeSans.ttf'; $black = imagecolorallocate($image, 0, 0, 0); // Calculate text position (center) $bbox = imagettfbbox($fontSize, 0, $fontFile, $text); $textWidth = $bbox[2] - $bbox[0]; $textHeight = $bbox[1] - $bbox[7]; $x = ($this->width - $textWidth) / 2; $y = ($this->height + $textHeight) / 2; imagettftext($image, $fontSize, 0, $x, $y, $black, $fontFile, $text); return $this->display($image);