HSC2011/Software/Frontend/Application development: Unterschied zwischen den Versionen
Chrysn (Diskussion | Beiträge) moved from Frontend documentation |
Chrysn (Diskussion | Beiträge) updated to last upload |
||
Zeile 17: | Zeile 17: | ||
by simply overwriting the <tt>display</tt> function. | by simply overwriting the <tt>display</tt> function. | ||
If you set up interval callbacks, make sure you remove them when <tt>Edubuzzer.stop_application</tt> is called. | |||
=== general infrastructure === | |||
Throughout the games, the [http://api.jquery.com/jQuery.getJSON/ jQuery] library is used. In order to display buzzers, fill the <tt>$("#buzzers")</tt> area, additional user interface can be shown in <tt>$("#post-buzzers")</tt>. | |||
</ | |||
=== talking to buzzers === | |||
The | The <tt>global.js</tt> library implements most of the buzzer communication you'll need. For example, in order to turn on all the four LEDs on a buzzer called <tt>dst</tt>, do this: | ||
in | |||
Edubuzzer.send_package(dst, 'S', 's', 'n n yyyy 00 00', function() {}); | |||
<tt>'S'</tt> is the package type to send (as described in [[HSC2011/Communication/Serial protocol|the serial documentation]]), <tt>'s'</tt> the type of the acknowledgement that is expected, <tt>'n n …'</tt> the payload (as described there as well), and the function will get called once the command is acknowledged by the buzzer. | |||
< | Be aware that while the [[HSC2011/Software/Ygor|underlying middleware]] handles all requests in sequence, you can't rely on the browser to deliver multiple <tt>send_package</tt> calls in sequence. | ||
</ | |||
Events other than acknowledgements you can receive by implementing the hook <tt>Edubuzzer.new_event(event)</tt>. Event will be an object with members <tt>src</tt>, <tt>type</tt> and <tt>payload</tt>, with <tt>type</tt> typically being <tt>"E"</tt>. The payload is typically <tt>"b0001"</tt> for the first button going down etc. (again, see, the serial documentation). | |||
=== instruction list === | === instruction list === |