Hardware/Software Details
Blynk library version: 0.6.1
IDE: Arduino
IDE version: 1.8.12
Board type: Arduino Pro Mini
Additional modules: HC-05
App Version: 2.27.14
Platform: Android
Steps to reproduce
- Create app with a joystick and a slider (vertical or horizontal)
- Set slider “Send on release” to ON
- Set joystick “Write interval” to a large value (1sec)
- Print something in joystick BLYNK_WRITE to know when it’s being called
- Start app and move joystick to confirm print is happening at 1sec interval
- Move the slider to new value
- Now move the joystick again after changing the slider
Expected Result
Joystick BLYNK_WRITE should always be called at 1sec interval.
Actual Result
Joystick BLYNK_WRITE is being called at 100ms when the write interval setting is still set to 1sec after adjusting the slider.
Notes
Stopping the app and changing the slider “Send on release” to OFF and re-running does not change the result after it is in this state. You must change the “Send on release” to OFF in the slider settings and then close/reopen the app for the joystick write interval to fix itself.
This line in the documentation leads to some confusion, as it mentions enabling “Send on release” when there is only a write interval in the joystick settings. I believe the interval was implemented later and it just wasn’t updated:
For example, when you move joystick widget, commands are streamed to the hardware, during a single joystick move you can send dozens of commands. There are use-cases where it’s needed, however creating such a load may lead to hardware overload and reset. Send On Release is a recommended setting for majority of applications. This is also a default setting.
Related Issues
These issues were just a few that I found mentioning something similar:
Code
My setup is a little unorthodox as it’s a bluetooth module wired straight to Serial in direct connect mode (through an accompanying voltage divider/capacitor and a transistor to invert the HC-05 state pin for auto reset). This allows me to wireless program the arduino pro mini over the same serial device since it does not have usb (hence the 57600 baud rate set in the code and also in the HC-05 AT settings). However that doesn’t seem to be related to this issue, and is instead an app UI issue. I can provide a schematic for anyone who is interested, as this was an awesome little hack that works great. The limitations are: 1) No blynk debug without a seperate software serial, which is why I’m using terminal.print() instead of Serial.print() here. 2) The slower baud rate limits how complex your app is and the number of widgets and relies heavily on intervals and timers to not overflow/flood the buffer, which is why a joystick spamming at 100ms is undesirable.
#define BLYNK_USE_DIRECT_CONNECT
#include <BlynkSimpleSerialBLE.h>
#define SerialBLE Serial
#define VPIN_TERMINAL V0
#define VPIN_JOYSTICK V1
#define VPIN_VSLIDER V2
char auth[] = "*****"
WidgetTerminal terminal(VPIN_TERMINAL);
BLYNK_WRITE(VPIN_JOYSTICK)
{
terminal.print(F("X:" ));
terminal.print(param[0].asInt());
terminal.print(F(" Y:"));
terminal.print(param[1].asInt());
terminal.print(F(" t:"));
terminal.println(millis());
terminal.flush();
}
BLYNK_WRITE(VPIN_VSLIDER)
{
terminal.print(F("S:"));
terminal.print(param[0].asInt());
terminal.print(F(" t:"));
terminal.println(millis());
terminal.flush();
}
void setup() {
SerialBLE.begin(57600);
Blynk.begin(SerialBLE, auth);
terminal.clear();
terminal.println(F("Blynk v" BLYNK_VERSION));
terminal.flush();
}
void loop() {
Blynk.run();
}