This example demonstrates how a Raspberry Pi board can be controlled from the browser.
It tracks the switches state and allows the user to turn on and off the 8 leds.
The toggle buttons are based on this jQuery plugin: http://simontabor.com/labs/toggles/
The server code is quite simple. All the active connections are stored in a Map. This map is used to notify all connections about the switches events:
Sub HandleSwitch(index As Int, State As Boolean) 'notify all active connections about the switch state change. For Each wsm As WebSocketModule In connections.Keys CallSubDelayed3(wsm, "SwitchStateChanged", index, State) Next End Sub
Public Sub Led_Toggle(Params As Map) Dim id As String = Params.Get("id") 'id will be ledx Dim active As Boolean = Params.Get("active") Main.pface.GetLED(id.SubString(3)).State = active End Sub
See this link for more information about jPi4J library: http://www.basic4ppc.com/android/forum/threads/jpi4j-raspberry-pi-gpio-controller.37493/#content
6 KB Views: 994