Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <HTML>
- <HEAD>
- <TITLE>Hello World</TITLE>
- <SCRIPT type="text/javascript" src="../../Sources/yocto_api.js"></SCRIPT>
- <SCRIPT type="text/javascript" src="../../Sources/yocto_led.js"></SCRIPT>
- <SCRIPT language='javascript1.5' type='text/JavaScript'>
- <!--
- // Use explicit error handling rather than exceptions
- yDisableExceptions();
- // Setup the API to use the VirtualHub on local machine
- if(yRegisterHub('http://127.0.0.1:4444/') != YAPI_SUCCESS) {
- alert("Cannot contact VirtualHub on 127.0.0.1");
- }
- var led;
- function refresh()
- {
- var serial = document.getElementById('serial').value;
- if(serial == '') {
- // Detect any conected module suitable for the demo
- led = yFirstLed();
- if(led) {
- serial = led.module().get_serialNumber();
- document.getElementById('serial').value = serial;
- }
- }
- led = yFindLed(serial+".led");
- if(led.isOnline()) {
- document.getElementById('msg').value = '';
- } else {
- document.getElementById('msg').value = 'Module not connected';
- }
- setTimeout('refresh()',500);
- }
- function switchIt(state)
- {
- if (state) led.set_power(Y_POWER_ON);
- else led.set_power(Y_POWER_OFF);
- }
- -->
- </SCRIPT>
- </HEAD>
- <BODY onload='refresh();'>
- Module to use: <input id='serial'>
- <input id='msg' style='color:red;border:none;' readonly><br>
- <a href='javascript:switchIt(true);'>ON</a><br>
- <a href='javascript:switchIt(false);'>OFF</a>
- </BODY>
- </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement