Ok, so i've been working my through some JS tutorials to try and get my head around this all. I think I understand the solution from @Gordon. And I think it would be adequate for my task. But I understand the potential issues that could be caused if a command is sent before the previous one has completed. So I really want to learn the method submitted by @allObjects that handles this event. I understand that the idea is create a "queue" of what I want to send and then add to that queue.
Currently I'm having trouble understanding what we are doing here:
, type: function(s) { // feeding the FIFO w/ string to write
this.string += s; // add string to FIFO w/ simple concat
if (this.string.length == s.length) { // length are the same
Line one is defining a function called hidKBD.type with the parameter s
Line two is hidKBD.string = hidKBD.string + s
Then Line three if the length hidKBD.string is the same as s.....
What I'm not sure about is the parameter "s", where are we assigning it some data?
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Ok, so i've been working my through some JS tutorials to try and get my head around this all. I think I understand the solution from @Gordon. And I think it would be adequate for my task. But I understand the potential issues that could be caused if a command is sent before the previous one has completed. So I really want to learn the method submitted by @allObjects that handles this event. I understand that the idea is create a "queue" of what I want to send and then add to that queue.
Currently I'm having trouble understanding what we are doing here:
Line one is defining a function called hidKBD.type with the parameter s
Line two is hidKBD.string = hidKBD.string + s
Then Line three if the length hidKBD.string is the same as s.....
What I'm not sure about is the parameter "s", where are we assigning it some data?
Thanks