-
Notifications
You must be signed in to change notification settings - Fork 2
/
handler.php
executable file
·57 lines (42 loc) · 1.5 KB
/
handler.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/php
<?php
$display_width = 480;
$display_height = 320;
$output = "/run/uctronics-35inch-lcd.png";
$cache = "/run/uctronics-35inch-lcd.json";
$print = dirname(dirname(__FILE__))."/utils/framebuffer/line.py";
$fbcopy = dirname(dirname(__FILE__))."/utils/framebuffer/copy.sh";
// -1 - clear all display
// -2 - dynamic line, use one from command line
// 0-9 - static line, use one from the table
$events = array (
"shutdown" => array(-1, ""),
"ready" => array(0, "ready"),
"target_ready" => array(0, "target ready"),
"target_disconnected" => array(0, "ready"),
"media_device_detected" => array(9, "syncing media"),
"media_device_processed" => array(9, "done"),
"operation_started" => array(-2, "syncing data"),
"operation_finished" => array(-2, "done"),
);
function execute($exec) {
$out = shell_exec($exec);
if (!empty($out))
echo trim($out)." [$exec]\n";
}
if ($argc < 3)
die("usage: $argv[0] <event> <line>\n");
$event = $argv[1];
if (!isset($events[$event]))
die("error: unknown event \"$event\"\n");
$details = $events[$event];
$line = $details[0];
$text = $details[1];
if ($line == -1) {
unlink($cache);
$line = 0;
$text = "";
} else if ($line == -2)
$line = intval($argv[2]);
execute("$print $cache $output $display_width $display_height $line \"$text\"");
execute("$fbcopy $output");