Skip to content

Commit

Permalink
Make requests for reading more dynamic in their timing.
Browse files Browse the repository at this point in the history
  • Loading branch information
easytarget committed Nov 7, 2019
1 parent 6600183 commit d943504
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion index.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,11 +184,15 @@ const char MAIN_page[] PROGMEM = R"=====(
<!-- The scripting -->

<script>

// Master interval (update rate) setting.
updateInterval = 250;
minUpdateInterval = 200; // fastest we can go, even at higher sensor speeds

// Create the recurring interval task to refresh the reading data
setInterval(function() {
getData();
}, 150); // interval in ms.
}, updateInterval); // interval in ms. -- 5 reading requests/second

// make a simple http request and return result. Used to trigger actions from buttons
function httpGet(theUrl)
Expand Down Expand Up @@ -280,6 +284,13 @@ const char MAIN_page[] PROGMEM = R"=====(
setMode(response.Mode);
}

// Adjust update interval based on Intermeasurement period (sensor reading speed).
var lastInterval = response.IntermeasurementPeriod + 50;
if (lastInterval > minUpdateInterval) {
updateInterval = lastInterval;
}


// Detect and enable stepper(lidar) functions
if ((response.HasServo == true) && !haveLidar) { // stepper present but undetected?
haveLidar = true;
Expand Down

0 comments on commit d943504

Please sign in to comment.