Epaper | Php Script
/** * Create a blank image buffer */ public function createBlankImage() $image = imagecreatetruecolor($this->width, $this->height); // Set white background $white = imagecolorallocate($image, 255, 255, 255); imagefill($image, 0, 0, $white); return $image;
public function __construct() $this->display = new EPaperDisplay(800, 480, EPaperDisplay::COLOR_BW); epaper php script
try: fb = open('/dev/fb0', 'rb') fcntl.ioctl(fb, FBIO_REFRESH, struct.pack('I', 0)) fb.close() except Exception as e: print(f"Refresh failed: e", file=sys.stderr) sys.exit(1) <?php // api.php - REST API for e-paper display header('Content-Type: application/json'); $display = new EPaperDisplay(800, 480); /** * Create a blank image buffer */
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; basename($_FILES['image']['name']); $targetPath = $uploadDir
?> # Update e-paper display every hour with weather data 0 * * * * php /var/www/epaper/fetch_weather.php Update with RSS feed every 30 minutes */30 * * * * php /var/www/epaper/fetch_rss.php Usage Examples // Basic usage $display = new EPaperDisplay(800, 480); $display->displayText("Hello E-Paper!", 48); // Display image $image = $display->loadImage('photo.jpg'); $display->display($image);
public function handleRequest() if ($_SERVER['REQUEST_METHOD'] === 'POST') if (isset($_FILES['image'])) $this->handleImageUpload(); elseif (isset($_POST['text'])) $this->handleTextDisplay(); $this->renderInterface();