Printing data on numpad key press, first version. Settings page for mapping key to actions.

This commit is contained in:
kplaczek
2018-05-06 21:03:42 +02:00
parent 283c5b905e
commit e5f44b92e4
12 changed files with 535 additions and 61 deletions

View File

@@ -0,0 +1,93 @@
<?php
/**
* Created by PhpStorm.
* User: k
* Date: 10.02.2017
* Time: 20:10
*/
namespace App\Http\Controllers;
set_time_limit(-1);
use App\Paper\Airly;
use App\Paper\Paper;
use Illuminate\Http\Request;
class AirlyController extends Controller
{
private $paper = null;
public function __construct()
{
$this->paper = new Paper();
}
/**
* get:/airly_all
* @return \Illuminate\Http\RedirectResponse
*/
public function airly_all()
{
$airly = new Airly();
$this->paper->sendImagePrint($airly->icon);
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
$airly->setStations(config('paper.airly.stations'));
foreach ($airly->getStations() as $stationId) {
$stationInfo = $airly->getStationInfo($stationId);
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
$dataText = $airly->getInformationText($stationId);
$this->paper->sendPrint('', $dataText);
}
return back();
}
public function airly_rzeczypospolitej()
{
$airly = new Airly();
$this->paper->sendImagePrint($airly->icon);
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
$airly->setStations([config('paper.airly.rzeczypospolitej')]);
foreach ($airly->getStations() as $stationId) {
$stationInfo = $airly->getStationInfo($stationId);
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
$dataText = $airly->getInformationText($stationId);
$this->paper->sendPrint('', $dataText);
}
return back();
}
public function airly_grunwaldzka()
{
$airly = new Airly();
$this->paper->sendImagePrint($airly->icon);
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
$airly->setStations([config('paper.airly.grunwaldzka')]);
foreach ($airly->getStations() as $stationId) {
$stationInfo = $airly->getStationInfo($stationId);
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
$dataText = $airly->getInformationText($stationId);
$this->paper->sendPrint('', $dataText);
}
return back();
}
public function airly_sowinskiego()
{
$airly = new Airly();
$this->paper->sendImagePrint($airly->icon);
$this->paper->sendHeaderPrint('Jakość powietrza:' . PHP_EOL . date('H:i d-m-Y'));
$airly->setStations([config('paper.airly.sowinskiego')]);
foreach ($airly->getStations() as $stationId) {
$stationInfo = $airly->getStationInfo($stationId);
$this->paper->sendHeaderPrint($stationInfo['address']['locality'] . ' ' . $stationInfo['address']['route']);
$dataText = $airly->getInformationText($stationId);
$this->paper->sendPrint('', $dataText);
}
return back();
}
}