I am wondering what is the best approach for updating a motor PWM over web bluetooth from the joystick or other device. In the past pre-espruino implementations I would just send data frame and commands would be just fired periodically (or on event) on the control board. With espruino you can send a whole command over BLE like:
mot.dcMotorControl(mot.dir.FWD,0.05);
I have a feeling if I do that with too hight update rate by moving a knob in my web joystick that would cause problems. It would be fine for toggling lights but not for continuously updated value. Do I just have to setInterval on the controller side or I could listen for an event from BLE? I think listening for an event would be best. Maybe with some mechanism for discarding uncaught events so they dont queue. Is there a best practice here?
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.
I am wondering what is the best approach for updating a motor PWM over web bluetooth from the joystick or other device. In the past pre-espruino implementations I would just send data frame and commands would be just fired periodically (or on event) on the control board. With espruino you can send a whole command over BLE like:
I have a feeling if I do that with too hight update rate by moving a knob in my web joystick that would cause problems. It would be fine for toggling lights but not for continuously updated value. Do I just have to setInterval on the controller side or I could listen for an event from BLE? I think listening for an event would be best. Maybe with some mechanism for discarding uncaught events so they dont queue. Is there a best practice here?