Home→Forums→MonoBrick EV3 Firmware→Webserver→Reply To: Webserver
December 30, 2014 at 12:03
#5155
Jacek S
Participant
Hi
The starting time is the next thing that I don’t like.
Yes I’m sure, I did many tests yesterday. My test program is configured to send ajax posts with 250ms breaks (when the position of joystick is changed). This means that Nancy on the brick have problem with handling 4 requests per second.
handler code:
Post["/joypos"] = x =>
{
JoyPos pos = this.Bind();
LcdConsole.WriteLine("X:{0} Y:{1}",pos.X,pos.Y);
var speed = (sbyte) (pos.Y > 100 ? 100 : pos.Y < -100 ? 100 : pos.Y);
if (speed == 0)
motor.Off();
else
motor.SetSpeed(speed);
return Response.AsJson(pos);
};
poster code:
var timer = $.timer(function () {
if (Math.abs(x - lastx) > 5 || Math.abs(y - lasty) > 5) {
lastx = x;
lasty = y;
$.post("/truck/joypos", { X: x, Y: y});
}
});
timer.set({ time: 250, autostart: true });
- This reply was modified 9 years, 8 months ago by Jacek S.
Follow