<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/db.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/touch_report.php"; header('Content-Type: application/json'); $tr = new touch_report(); $last_object = $tr->most_recent_object(); if (!$last_object) { echo json_encode(false); exit; } echo json_encode($tr->object_information()); exit;
<?php require_once $_SERVER['DOCUMENT_ROOT'] . "/db.php"; if (isset($_GET['touch_report_print'])) { $tr = new touch_report(); $tr->print_report(); } class touch_report { private $output; private $most_recent_object = false; private $orientation_in_radians = false; private $orientation_quadrent = false; //__construct public function __construct() { $db = new db(); $this->most_recent_object = false; $result = $db->query("select * from touch order by ID desc limit 100"); $output = ""; $output .= "<table border='1'>"; $output .= "<tr><th>ID</th><th>X</th><th>Y</th><th>TYPE</th><th>DATE</th></tr>"; $downs = array(); $downs_index = 0; while ($row = $db->fetch_array($result)) { $output .= "<tr "; if ($row['type_percent'] == 1) { //type_percent 1 is "down" (as opposed to up or move which could be detected as well in the future) //collect the last 3 if ($downs_index <= 2 && !$this->down_already_exists($downs, $row['x_percent'], $row['y_percent'])) { $downs[$downs_index] = new stdClass();
<?php /* * Graph's the previous object's pose on the screen. For testing purposes. */ require_once $_SERVER['DOCUMENT_ROOT'] . "/db.php"; require_once $_SERVER['DOCUMENT_ROOT'] . "/touch_report.php"; $tr = new touch_report(); $last_object = $tr->most_recent_object(); if (!$last_object) { echo "last object is false..."; exit; } ?> <html> <head> <script type="text/javascript" src="https://www.google.com/jsapi"></script> <script type="text/javascript"> google.load("visualization", "1.1", {packages:["corechart"]}); google.setOnLoadCallback(drawChart); function drawChart() { var data = google.visualization.arrayToDataTable ([['X', 'Y'], <?php $first = true; foreach ($last_object as $point) { if (!$first) { echo ",\n"; } $first = false; echo "[" . $point->x . "," . $point->y . "]";