Page 270 - Hacking Roomba
P. 270
Chapter 12 — Going Wireless with Wi-Fi 251
Listing 12-2 Continued
<html>
<head>
<title> Roomba Command </title>
<style> table,td { text-align: center; } </style>
</head>
<body bgcolor=#ddddff>
<h1> Roomba Command </h1>
<form method=GET>
<table border=0>
<tr><td><input type=submit name=”cmd” value=”init”></td>
<td> </td>
<td><input type=submit name=”cmd”
value=”sensors”></td></tr>
<tr><td> </td>
<td><input type=submit name=”cmd” value=”forward”></td>
<td> </td></tr>
<tr><td><input type=submit name=”cmd” value=”spinleft”></td>
<td><input type=submit name=”cmd” value=”stop”></td>
<td><input type=submit name=”cmd”
value=”spinright”></td></tr>
<tr><td> </td>
<td><input type=submit name=”cmd” value=”backward”></td>
<td> </td></tr>
<tr><td> velocity: </td>
<td><input type=text size=5 name=”vel”
value=”<?echo $vel?>”></td>
<td/> </td></tr>
</table>
</form>
<pre>
<?php
if( $cmd ) print “cmd:$cmd\n”;
if( $cmd == ‘init’ ) {
roomba_init();
}
else if( $cmd == ‘stop’ ) {
roomba_stop();
}
else if( $cmd == ‘forward’ ) {
roomba_go_forward( $vel );
}
else if( $cmd == ‘backward’ ) {
roomba_go_backward( $vel );
}
else if( $cmd == ‘spinleft’ ) {
roomba_spin_left( $vel );
Continued