Current position boxes added to web interface, and polled along with temperatures.
This commit is contained in:
parent
4f703d86ec
commit
0c7e13a73e
5 changed files with 58 additions and 24 deletions
11
GCodes.cpp
11
GCodes.cpp
|
@ -448,15 +448,10 @@ bool GCodes::GetProbeCoordinates(int count, float& x, float& y, float& z)
|
|||
|
||||
char* GCodes::GetCurrentCoordinates()
|
||||
{
|
||||
if(fileBeingPrinted != NULL)
|
||||
{
|
||||
return "Can't request coordinates while printing a G Code file"; // FIXME
|
||||
}
|
||||
float liveCoordinates[DRIVES+1];
|
||||
reprap.GetMove()->LiveCoordinates(liveCoordinates);
|
||||
|
||||
if(!AllMovesAreFinishedAndMoveBufferIsLoaded())
|
||||
return 0;
|
||||
|
||||
sprintf(scratchString, "X:%f Y:%f Z:%f E:%f", moveBuffer[X_AXIS], moveBuffer[Y_AXIS], moveBuffer[Z_AXIS], moveBuffer[DRIVES]);
|
||||
sprintf(scratchString, "X:%f Y:%f Z:%f E:%f", liveCoordinates[X_AXIS], liveCoordinates[Y_AXIS], liveCoordinates[Z_AXIS], liveCoordinates[AXES]);
|
||||
return scratchString;
|
||||
}
|
||||
|
||||
|
|
10
Move.cpp
10
Move.cpp
|
@ -82,16 +82,21 @@ void Move::Init()
|
|||
lookAheadRingCount = 0;
|
||||
|
||||
addNoMoreMoves = false;
|
||||
|
||||
|
||||
// Put the origin on the lookahead ring with default velocity in the previous
|
||||
// position to the first one that will be used.
|
||||
|
||||
lastMove = lookAheadRingAddPointer->Previous();
|
||||
|
||||
for(i = 0; i < DRIVES; i++)
|
||||
{
|
||||
ep[i] = 0;
|
||||
liveCoordinates[i] = 0.0;
|
||||
}
|
||||
|
||||
lastMove->Init(ep, platform->HomeFeedRate(Z_AXIS), platform->InstantDv(Z_AXIS), false, zMove); // Typically Z is the slowest Axis
|
||||
lastMove->Release();
|
||||
liveCoordinates[DRIVES] = platform->HomeFeedRate(Z_AXIS);
|
||||
|
||||
checkEndStopsOnNextMove = false;
|
||||
|
||||
|
@ -1010,6 +1015,9 @@ void DDA::Step(bool noTest)
|
|||
|
||||
if(!active && noTest)
|
||||
{
|
||||
for(int8_t drive = 0; drive < DRIVES; drive++)
|
||||
move->liveCoordinates[drive] = myLookAheadEntry->MachineToEndPoint(drive);
|
||||
move->liveCoordinates[DRIVES] = myLookAheadEntry->FeedRate();
|
||||
myLookAheadEntry->Release();
|
||||
platform->SetInterrupt(STANDBY_INTERRUPT_RATE);
|
||||
}
|
||||
|
|
13
Move.h
13
Move.h
|
@ -149,7 +149,8 @@ class Move
|
|||
void Init();
|
||||
void Spin();
|
||||
void Exit();
|
||||
bool GetCurrentState(float m[]);
|
||||
bool GetCurrentState(float m[]); // takes account of all the reings and delays
|
||||
void LiveCoordinates(float m[]); // Just gives the last point at the end of the last DDA
|
||||
void Interrupt();
|
||||
void InterruptTime();
|
||||
bool AllMovesAreFinished();
|
||||
|
@ -168,6 +169,9 @@ class Move
|
|||
float ComputeCurrentCoordinate(int8_t drive, LookAhead* la, DDA* runningDDA);
|
||||
|
||||
friend class DDA;
|
||||
|
||||
protected:
|
||||
float liveCoordinates[DRIVES + 1];
|
||||
|
||||
private:
|
||||
|
||||
|
@ -361,6 +365,13 @@ inline void Move::ReleaseDDARingLock()
|
|||
ddaRingLocked = false;
|
||||
}
|
||||
|
||||
inline void Move::LiveCoordinates(float m[])
|
||||
{
|
||||
for(int8_t drive = 0; drive <= DRIVES; drive++)
|
||||
m[drive] = liveCoordinates[drive];
|
||||
InverseTransform(m);
|
||||
}
|
||||
|
||||
// To wait until all the current moves in the buffers are
|
||||
// complete, call this function repeatedly and wait for it to
|
||||
// return true. Then do whatever you wanted to do after all
|
||||
|
|
|
@ -116,7 +116,7 @@ function heatRowHTML(heater, hNumber)
|
|||
var result = "";
|
||||
|
||||
result += "<td>" + heater + "</td>";
|
||||
result += "<td>" + '<span data-bind="text: temps().temps[' + hNumber + ']"></span>' + "<sup>o</sup>C" + "</td>";
|
||||
result += "<td>" + '<span data-bind="text: poll().poll[' + hNumber + ']"></span>' + "<sup>o</sup>C" + "</td>";
|
||||
result += '<td>' +
|
||||
'<form data-bind="submit: function(data, event) { setTemperature(' + hNumber + ', data, event) }">' +
|
||||
'<button type="submit">set to -></button><input type="text" size="4" data-bind="value: setTemp" />' + '</form>' +
|
||||
|
@ -220,6 +220,20 @@ function heatRowHTML(heater, hNumber)
|
|||
|
||||
</div></table>
|
||||
|
||||
<br><br>
|
||||
|
||||
<table border="1"><div align="center">
|
||||
<tr>
|
||||
<th colspan="8">Current position (mm)</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> X: </td><td><span data-bind="text: poll().poll[2]"></span></td>
|
||||
<td> Y: </td><td><span data-bind="text: poll().poll[3]"></span></td>
|
||||
<td> Z: </td><td><span data-bind="text: poll().poll[4]"></span></td>
|
||||
<td> E: </td><td><span data-bind="text: poll().poll[5]"></span></td>
|
||||
</tr>
|
||||
</div></table>
|
||||
|
||||
<br><br>
|
||||
|
||||
<table border="1"><div align="center">
|
||||
|
@ -327,7 +341,7 @@ function viewModel()
|
|||
self.gcode = ko.observable();
|
||||
self.files = ko.observable(JSON.parse('{"files":[""]}'));
|
||||
self.files().files = ko.observableArray([""]);
|
||||
self.temps = ko.observable(JSON.parse('{"temps":["0.0","0.0"]}'));
|
||||
self.poll = ko.observable(JSON.parse('{"poll":["0.0","0.0","0.0","0.0","0.0","0.0"]}'));
|
||||
self.axisLengths = ko.observable(JSON.parse('{"axes":["140.0", "140.0", "100.0"]}'));
|
||||
self.setTemp = ko.observable();
|
||||
self.dummy = ko.observable();
|
||||
|
@ -339,10 +353,10 @@ function viewModel()
|
|||
$.get('/rr_files', {}, self.files);
|
||||
};
|
||||
|
||||
self.getTemps = function()
|
||||
self.getPoll = function()
|
||||
{
|
||||
if(onControlPage)
|
||||
$.get('/rr_temps', {}, self.temps);
|
||||
$.get('/rr_poll', {}, self.poll);
|
||||
};
|
||||
|
||||
self.getAxes = function()
|
||||
|
@ -547,7 +561,7 @@ function viewModel()
|
|||
|
||||
onControlPage = false;
|
||||
self.getName();
|
||||
//self.getTemps();
|
||||
//self.getPoll();
|
||||
setTimeout(function() {
|
||||
onControlPage = false;
|
||||
}, 300);
|
||||
|
@ -567,7 +581,7 @@ function poll()
|
|||
{
|
||||
setTimeout(function()
|
||||
{
|
||||
vm.getTemps();
|
||||
vm.getPoll();
|
||||
poll();
|
||||
}, 3000)
|
||||
}
|
||||
|
|
|
@ -306,20 +306,26 @@ void Webserver::GetJsonResponse(char* request)
|
|||
jsonPointer = 0;
|
||||
writing = true;
|
||||
|
||||
if(StringStartsWith(request, "temps"))
|
||||
if(StringStartsWith(request, "poll"))
|
||||
{
|
||||
strcpy(jsonResponse, "{\"temps\":[");
|
||||
strcpy(jsonResponse, "{\"poll\":[");
|
||||
for(int8_t heater = 0; heater < HEATERS; heater++)
|
||||
{
|
||||
strcat(jsonResponse, "\"");
|
||||
strcat(jsonResponse, ftoa(0, reprap.GetHeat()->GetTemperature(heater), 1));
|
||||
//sprintf(scratchString, "%d", (int)reprap.GetHeat()->GetTemperature(heater));
|
||||
//strcat(jsonResponse, scratchString);
|
||||
if(heater < HEATERS-1)
|
||||
strcat(jsonResponse, "\",");
|
||||
else
|
||||
strcat(jsonResponse, "\"");
|
||||
strcat(jsonResponse, "\",");
|
||||
}
|
||||
float liveCoordinates[DRIVES+1];
|
||||
reprap.GetMove()->LiveCoordinates(liveCoordinates);
|
||||
for(int8_t drive = 0; drive < AXES; drive++)
|
||||
{
|
||||
strcat(jsonResponse, "\"");
|
||||
strcat(jsonResponse, ftoa(0, liveCoordinates[drive], 2));
|
||||
strcat(jsonResponse, "\",");
|
||||
}
|
||||
strcat(jsonResponse, "\"");
|
||||
strcat(jsonResponse, ftoa(0, liveCoordinates[AXES], 4));
|
||||
strcat(jsonResponse, "\"");
|
||||
strcat(jsonResponse, "]}");
|
||||
JsonReport(true, request);
|
||||
return;
|
||||
|
|
Reference in a new issue