Update example web miner.php to use new API commands
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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
diff --git a/miner.php b/miner.php
index 763c022..8ba2b4e 100644
--- a/miner.php
+++ b/miner.php
@@ -18,6 +18,7 @@ td.sta { color:green; font-family:verdana,arial,sans; font-size:14pt; }
<script type='text/javascript'>
function pr(a,m){if(m!=null){if(!confirm(m+'?'))return}window.location="<? echo $here ?>"+a}
function prs(a){var c=a.substr(3);var z=c.split('|',2);var m=z[0].substr(0,1).toUpperCase()+z[0].substr(1)+' GPU '+z[1];pr('?arg='+a,m)}
+function prs2(a,n){var v=document.getElementById('gi'+n).value;var c=a.substr(3);var z=c.split('|',2);var m='Set GPU '+z[1]+' '+z[0].substr(0,1).toUpperCase()+z[0].substr(1)+' to '+v;pr('?arg='+a+','+v,m)}
</script>
<table width=100% height=100% border=0 cellpadding=0 cellspacing=0 summary='Mine'>
<tr><td align=center valign=top>
@@ -156,6 +157,9 @@ function fmt($section, $name, $value)
switch ($section.'.'.$name)
{
+ case 'GPU0.Last Share Time':
+ return date('H:i:s', $value);
+ break;
case 'SUMMARY.Elapsed':
$s = $value % 60;
$value -= $s;
@@ -258,33 +262,69 @@ function details($list)
echo $te;
}
#
-function gpubuttons($count)
+global $devs;
+$devs = null;
+#
+function gpubuttons($count, $info)
{
+ global $devs;
+
+ $basic = array( 'GPU', 'Enable', 'Disable', 'Restart' );
+
+ $options = array( 'intensity' => 'Intensity',
+ 'fan' => 'Fan Percent',
+ 'engine' => 'GPU Clock',
+ 'mem' => 'Memory Clock',
+ 'vddc' => 'GPU Voltage' );
+
$tb = '<tr><td><table border=1 cellpadding=5 cellspacing=0>';
$te = '</table></td></tr>';
echo $tb.'<tr>';
- for ($i = 0; $i < 4; $i++)
- {
- echo '<td>';
+ foreach ($basic as $head)
+ echo "<td>$head</td>";
- if ($i == 0)
- echo 'GPU';
- else
- echo ' ';
-
- echo '</td>';
- }
+ foreach ($options as $name => $des)
+ echo "<td nowrap>$des</td>";
+ $n = 0;
for ($c = 0; $c < $count; $c++)
{
echo '</tr><tr>';
- echo "<td>$c</td>";
- echo "<td><input type=button value='Enable $c' onclick='prs(\"gpuenable|$c\")'></td>";
- echo "<td><input type=button value='Disable $c' onclick='prs(\"gpudisable|$c\")'></td>";
- echo "<td><input type=button value='Restart $c' onclick='prs(\"gpurestart|$c\")'></td>";
+ foreach ($basic as $name)
+ {
+ echo '<td>';
+
+ if ($name == 'GPU')
+ echo $c;
+ else
+ {
+ echo "<input type=button value='$name $c' onclick='prs(\"gpu";
+ echo strtolower($name);
+ echo "|$c\")'>";
+ }
+
+ echo '</td>';
+ }
+
+ foreach ($options as $name => $des)
+ {
+ echo '<td>';
+ if (!isset($devs["GPU$c"][$des]))
+ echo ' ';
+ else
+ {
+ $value = $devs["GPU$c"][$des];
+ echo "<input type=button value='Set $c:' onclick='prs2(\"gpu$name|$c\",$n)'>";
+ echo "<input size=7 type=text name=gi$n value='$value' id=gi$n>";
+ $n++;
+ }
+
+ echo '</td>';
+ }
+
}
echo '</tr>'.$te;
@@ -315,7 +355,7 @@ function processgpus($rd, $ro)
#
function process($cmds, $rd, $ro)
{
- global $error;
+ global $error, $devs;
foreach ($cmds as $cmd => $des)
{
@@ -331,6 +371,8 @@ function process($cmds, $rd, $ro)
{
details($process);
echo '<tr><td><br><br></td></tr>';
+ if ($cmd == 'devs')
+ $devs = $process;
}
}
}
@@ -356,7 +398,8 @@ function display()
$cmds = array( 'devs' => 'device list',
'summary' => 'summary information',
- 'pools' => 'pool list');
+ 'pools' => 'pool list',
+ 'config' => 'cgminer config');
process($cmds, $rd, $ro);