If your following this, I had a fault that was causing random pin functions to change from output to input, strange but true turns out it was a faulty serial to usb adapter, swapped it out and the buttons became stable only tried this because I had disconnected every other sensor and div board and it was the only thing left, anyway the following is my working code to switch all 16 outputs on a mcp23017 designated mcp0 in the config file, without calling any python macros, unlike buttons controlled via the restapi / ajax Post and Get it appears work fine via port forwarding, of coarse you need to be fully aware of the risks of port forwarding before you go down this route .
If you want to try this note the following.
There is a section that sets the function of all 16 pins on the mcp0 to OUTPUT 's the section can be deleted if you set the functions to OUTPUT in your script.py file.
Also the button styles are for use with chrome I didn't try them with other browsers, if you find it a problem just replace the 2 lines = background-image: bla bla to background-color: Red; Blue or whatever.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content = "height = device-height, width = 420, user-scalable = yes" />
<title>mcp0</title>
<script type="text/javascript" src="/webiopi.js"></script>
<script type="text/javascript">
webiopi().ready(function() {
var content, button;
content = $("#content");
button = webiopi().createButton("macro0", "mcp0 0 Off", callMacro_tog_mcp0_0);
$("#leftTop").append(button); // append button to left div
button = webiopi().createButton("macro1", "mcp0 1 Off", callMacro_tog_mcp0_1);
$("#left").append(button); // append button to left div
button = webiopi().createButton("macro2", "mcp0 2 Off", callMacro_tog_mcp0_2);
$("#rightTop").append(button); // append button to left div
button = webiopi().createButton("macro3", "mcp0 3 Off", callMacro_tog_mcp0_3);
$("#right").append(button); // append button to left div
button = webiopi().createButton("macro4", "mcp0 4 Off", callMacro_tog_mcp0_4);
$("#leftTop").append(button); // append button to right div
button = webiopi().createButton("macro5", "mcp0 5 Off", callMacro_tog_mcp0_5);
$("#left").append(button); // append button to right div
button = webiopi().createButton("macro6", "mcp0 6 Off", callMacro_tog_mcp0_6);
$("#rightTop").append(button); // append button to right div
button = webiopi().createButton("macro7", "mcp0 7 Off", callMacro_tog_mcp0_7);
$("#right").append(button); // append button to right div
button = webiopi().createButton("macro8", "mcp0 8 Off", callMacro_tog_mcp0_8);
$("#leftTop").append(button); // append button to left div
button = webiopi().createButton("macro9", "mcp0 9 Off", callMacro_tog_mcp0_9);
$("#left").append(button); // append button to left div
button = webiopi().createButton("macro10", "mcp0 10 Off", callMacro_tog_mcp0_10);
$("#rightTop").append(button); // append button to left div
button = webiopi().createButton("macro11", "mcp0 11 Off", callMacro_tog_mcp0_11);
$("#right").append(button); // append button to left div
button = webiopi().createButton("macro12", "mcp0 12 Off", callMacro_tog_mcp0_12);
$("#leftTop").append(button); // append button to right div
button = webiopi().createButton("macro13", "mcp0 13 Off", callMacro_tog_mcp0_13);
$("#left").append(button); // append button to right div
button = webiopi().createButton("macro14", "mcp0 14 Off", callMacro_tog_mcp0_14);
$("#rightTop").append(button); // append button to right div
button = webiopi().createButton("macro15", "mcp0 15 Off", callMacro_tog_mcp0_15);
$("#right").append(button); // append button to right div
webiopi().refreshGPIO(true);
});
//************************************** i2c Buttons mcp0 pins 0 - 15 ***********************************************
window.onload = function(){
macro_set_mcp0(); // Call only once to set up functions on mcp0 (see * note below)
macro_mcp0_callback();
}
//*******************************************************************************************************************
// Set all 16 pins on mcp0 to function type "OUTPUT" ( * only needed if you are not using script.py to set up functions)
function macro_set_mcp0(){