From 56822cf17e5d8b3c43d48f7800dd06aec93849c9 Mon Sep 17 00:00:00 2001 From: FrYakaTKoP Date: Mon, 9 Oct 2017 22:13:09 +0200 Subject: [PATCH] added value cap to laser and motorValues --- esp8266-laser.ino | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/esp8266-laser.ino b/esp8266-laser.ino index ba7f5ec..cd37a61 100644 --- a/esp8266-laser.ino +++ b/esp8266-laser.ino @@ -119,7 +119,14 @@ void handleFileList() { void handleLaser(String uri) { String laserValue = uri.substring(7); - lmValues[0] = laserValue.toInt(); + if(laserValue.toInt() > 128) { + lmValues[0] = 128; + laserValue = "128"; + } + else + { + lmValues[0] = laserValue.toInt(); + } String msg = "AT SLV "; msg += laserValue; @@ -138,9 +145,15 @@ void handleLaser(String uri) void handleMotor(String uri) { String motorNr = uri.substring(7, 8); - String motorValue = uri.substring(9); - lmValues[motorNr.toInt()] = motorValue.toInt(); - + String motorValue = uri.substring(9); + if(motorValue.toInt() > 128) { + lmValues[motorNr.toInt()] = 128; + motorValue = "128"; + } + else + { + lmValues[motorNr.toInt()] = motorValue.toInt(); + } String msg = "AT SMS "; msg += motorNr; msg += " ";