File source

<?php
class GarageScreen extends Screen{
  protected 
$id "garage";
  protected 
$garageSource;
  protected 
$iconClosed;
  protected 
$iconOpen;
  protected 
$lastData false;
  protected 
$lastValid false;

  function 
__construct($garageSource){
    
$this->garageSource $garageSource;
    
$this->iconClosed imagecreatefrompng("icons/closed.png");
    
$this->iconOpen imagecreatefrompng("icons/open.png");
    
$this->touchPush("return_btn"0,0,160,160);
  }

  function 
activate($params){
    
$this->lastValid false;
    if(
$params["return"]){
      
$this->returnTo $params["return"];
    }else{
      
$this->returnTo false;
    }
  }

  function 
render(){
    if(
$this->touched("return_btn") && $this->returnTo){
        return 
$this->screen($this->returnTo);
    }

    
$data $this->garageSource->getData();
    if(
$data["closed"] != $this->lastData["closed"] && $this->lastValid && $this->returnTo){
      
$this->lastValid false;
      
$r $this->returnTo;
      
$this->returnTo false;
      return 
$this->screen($r);
    }
    
$img screen();
    if(
$data["closed"]){
      
pasteCenter($img$this->iconClosed160/2160/2);
    }else{
      
pasteCenter($img$this->iconOpen160/2160/2);
    }
    
$this->lastData $data;
    
$this->lastValid true;
    return 
$this->image($img);
  }

}