Skip to content

Commit 5ec2742

Browse files
committed
fix(UI): request data for up to 10 axes
1 parent 4ae71ed commit 5ec2742

File tree

12 files changed

+39
-9
lines changed

12 files changed

+39
-9
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Multiple methods are available to connect the Duet3D screen to a mainboard. The
5656
2. In the GUI, select the USB connection method.
5757

5858
> [!NOTE]
59-
> When the Duet3D screen detects a USB connection to a Duet3D mainboard, it will automatically send `M575 P0 S0` to configure the mainboard for USB communication.
59+
> When the Duet3D screen detects a USB connection to a Duet3D mainboard, it will automatically send `M575 P0 S4` to configure the mainboard for USB communication.
6060

6161
### WiFi
6262
> [!NOTE]
@@ -79,7 +79,7 @@ Multiple methods are available to connect the Duet3D screen to a mainboard. The
7979
1. Connect the Duet3D screen to the mainboard using a UART cable.
8080
- Use connector `UART Duet` on the screen.
8181
2. In the GUI, select the UART connection method.
82-
3. Set the baud rate on the mainboard to `115200`. use `M575 P1 S1 B115200` in config.g, this is similar to connecting a PanelDue, other than the default baud rate is 115200
82+
3. Set the baud rate on the mainboard to `115200`. use `M575 P1 S4 B115200` in config.g, this is similar to connecting a PanelDue, other than the default baud rate is 115200
8383

8484
#### Wiring
8585
For a Duet3 IO0 port for UART is as follows:

src/Comm/Commands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace Comm
2929
rcvSeqsHeat,
3030
rcvSeqsInputs,
3131
rcvSeqsJob,
32+
rcvSeqsLimits,
3233
rcvSeqsMove,
3334
rcvSeqsNetwork,
3435
rcvSeqsReply,

src/Comm/Communication.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ namespace Comm
152152
}
153153
}
154154

155+
LOG_WARN("Received key '{:s}' does not match any known seq", key);
155156
return nullptr;
156157
}
157158

src/Comm/JsonDecoder.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -174,6 +174,7 @@ namespace Comm
174174
m_fieldPrefix.Clear();
175175
m_fieldId.Clear();
176176
m_fieldVal.Clear();
177+
m_key.Clear();
177178
m_state = jsBegin;
178179
m_lastState = jsBegin;
179180
m_serialIoErrors = 0;
@@ -208,6 +209,8 @@ namespace Comm
208209
m_seq = nullptr;
209210
}
210211

212+
m_key.Clear();
213+
211214
responseType = ResponseType::unknown;
212215
responseData = nullptr;
213216
}
@@ -216,7 +219,7 @@ namespace Comm
216219
void JsonDecoder::ProcessReceivedValue(StringRef id, const char data[], const size_t indices[])
217220
{
218221
ZoneScoped;
219-
LOG_VERBOSE("{:s} (indices [{:d}|{:d}|{:d}|{:d}]) = '{:s}'",
222+
LOG_VERBOSE("'{:s}' (indices [{:d}|{:d}|{:d}|{:d}]) = '{:s}'",
220223
id.c_str(),
221224
indices[0],
222225
indices[1],
@@ -233,9 +236,9 @@ namespace Comm
233236
// modifier)
234237

235238
id.Erase(0, 6);
236-
if (m_seq != nullptr && strcasecmp(m_seq->key, "") != 0)
239+
if (!m_key.IsEmpty())
237240
{
238-
id.Prepend(m_seq->key);
241+
id.Prepend(m_key.c_str());
239242
}
240243
else
241244
{
@@ -269,6 +272,8 @@ namespace Comm
269272
{
270273
m_seq = FindSeqByKey(data);
271274
}
275+
m_key.copy(data);
276+
m_key.ReplaceAll('.', ':');
272277
break;
273278
}
274279

@@ -358,15 +363,15 @@ namespace Comm
358363
void JsonDecoder::RemoveLastId()
359364
{
360365
ZoneScoped;
361-
// LOG_VERBOSE("{:s}, len: {:d}", m_fieldId.c_str(), m_fieldId.strlen());
366+
LOG_VERBOSE("{:s}, len: {:d}", m_fieldId.c_str(), m_fieldId.strlen());
362367
size_t index = m_fieldId.strlen();
363368
while (index != 0 && m_fieldId[index - 1] != '^' && m_fieldId[index - 1] != ':')
364369
{
365370
--index;
366371
}
367372
m_fieldId.Truncate(index);
368373

369-
// LOG_VERBOSE("{:s}, len: {:d}", m_fieldId.c_str(), m_fieldId.strlen());
374+
LOG_VERBOSE("{:s}, len: {:d}", m_fieldId.c_str(), m_fieldId.strlen());
370375
}
371376

372377
void JsonDecoder::RemoveLastIdChar()

src/Comm/JsonDecoder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ namespace Comm
108108
size_t m_arrayIndices[MAX_ARRAY_NESTING];
109109
size_t m_arrayDepth;
110110
Seq* m_seq = nullptr;
111+
String<50> m_key; // for OM responses
111112
};
112113
} // namespace Comm
113114
#endif /* JNI_COMM_JSONDECODER_H_ */

src/Configuration.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ constexpr unsigned int MAX_HEATERS = 32;
8989
constexpr unsigned int MAX_SENSORS = 32;
9090
constexpr unsigned int MAX_ENDSTOPS = 20;
9191
constexpr size_t MAX_TRACKED_OBJECTS = 40;
92+
constexpr size_t MAX_REPORTED_AXES =
93+
5; // RRF only reports 5 axes in the `move` object, need to request `move.axes` to get the rest
9294

9395
/* Console */
9496
constexpr unsigned int MAX_COMMAND_LENGTH = 50;

src/Subscribers/MoveSubscribers.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "Debug.h"
22

3+
#include "Hardware/Duet.h"
34
#include "MoveSubscribers.h"
45
#include "ObjectModel/Axis.h"
56
#include "ObjectModel/Heightmap.h"
@@ -340,6 +341,19 @@ bool MoveSubscribers::axesArrayEnd(Comm::JsonDecoder* decoder, const size_t indi
340341
{
341342
ZoneScoped;
342343
UNUSED(decoder);
344+
const Comm::Seq* seq = decoder->GetSeq();
345+
if (seq && seq->seqid == Comm::rcvSeqsMove && indices[0] >= MAX_REPORTED_AXES)
346+
{
347+
/**
348+
* There might be more axes available
349+
*
350+
* TODO: this won't handle the case where the single `move.axes` request still doesn't return all axes but it
351+
* can handle 10 currently. Will need to check the `next` field in the response to handle more than that.
352+
* Likely I will postpone handling that until the Duet comms are reworked to handle request/response IDs (#69)
353+
*/
354+
Comm::DUET.RequestModel("move.axes", "vna0");
355+
return true;
356+
}
343357
OM::Move::RemoveAxis(indices[0], true);
344358
Model::get().post<EventType::AxesData>();
345359
return true;

src/UI/Screens/Move/MoveView.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ namespace UI
6262
m_messageBox.cancelVisible(true);
6363

6464
/* Axis Control */
65+
m_axisControlCont.setFlag(LV_OBJ_FLAG_SCROLLABLE, false);
6566
m_axisControlCont.setHeight(LV_PCT(100));
6667
m_axisControlCont.setFlexGrow(1);
6768
m_axisControlCont.setFlexFlow(LV_FLEX_FLOW_ROW);
@@ -173,10 +174,11 @@ namespace UI
173174
m_zControl.setLabelCallback([this](char axis_letter, float position)
174175
{ configureNumberpadForAxis(axis_letter, position); });
175176

177+
m_genericAxisControls.setFlexGrow(1);
176178
m_genericAxisControls.setSize(LV_SIZE_CONTENT, LV_PCT(100));
177179
m_genericAxisControls.setListSize(LV_SIZE_CONTENT, LV_PCT(100));
178180
// m_genericAxisControls.setFlexGrow(1);
179-
m_genericAxisControls.setMaxWidth(LV_PCT(60));
181+
m_genericAxisControls.setMaxWidth(LV_SIZE_CONTENT);
180182
m_genericAxisControls.setListFlow(LV_FLEX_FLOW_ROW);
181183
m_genericAxisControls.addStyle(Themes::getLvglStyles().no_border);
182184
m_genericAxisControls.addStyle(Themes::getLvglStyles().pad_zero);
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"key":"move.axes","flags":"vna0","result":[{"acceleration":2000.0,"babystep":0,"backlash":0,"current":1300,"drivers":["0.4"],"homed":true,"jerk":600.0,"letter":"X","machinePosition":0,"max":355.00,"maxProbed":false,"microstepping":{"interpolated":true,"value":16},"min":0,"minProbed":false,"percentCurrent":100,"percentStstCurrent":71,"phaseStep":false,"printingJerk":600.0,"reducedAcceleration":1000.0,"speed":33000.0,"stepPos":0,"stepsPerMm":43.61,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]},{"acceleration":2000.0,"babystep":0,"backlash":0,"current":1300,"drivers":["0.5"],"homed":true,"jerk":600.0,"letter":"Y","machinePosition":0,"max":355.00,"maxProbed":false,"microstepping":{"interpolated":true,"value":16},"min":0,"minProbed":false,"percentCurrent":100,"percentStstCurrent":71,"phaseStep":false,"printingJerk":600.0,"reducedAcceleration":1000.0,"speed":33000.0,"stepPos":0,"stepsPerMm":43.61,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]},{"acceleration":300.0,"babystep":0,"backlash":0,"current":1400,"drivers":["0.2","0.1","0.0"],"homed":true,"jerk":40.0,"letter":"Z","machinePosition":0,"max":315.00,"maxProbed":false,"microstepping":{"interpolated":true,"value":16},"min":0,"minProbed":false,"percentCurrent":100,"percentStstCurrent":71,"phaseStep":false,"printingJerk":40.0,"reducedAcceleration":200.0,"speed":2500.0,"stepPos":0,"stepsPerMm":426.67,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]},{"acceleration":1000.0,"babystep":0,"backlash":0,"current":0,"drivers":["1.6"],"homed":true,"jerk":900.0,"letter":"U","machinePosition":0,"max":200.00,"maxProbed":false,"microstepping":{"interpolated":true,"value":16},"min":0,"minProbed":false,"percentCurrent":100,"percentStstCurrent":71,"phaseStep":false,"printingJerk":900.0,"reducedAcceleration":1000.0,"speed":6000.0,"stepPos":0,"stepsPerMm":80.00,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]},{"acceleration":1000.0,"babystep":0,"backlash":0,"current":0,"drivers":["1.4"],"homed":true,"jerk":900.0,"letter":"V","machinePosition":0,"max":200.00,"maxProbed":false,"microstepping":{"interpolated":true,"value":16},"min":0,"minProbed":false,"percentCurrent":100,"percentStstCurrent":71,"phaseStep":false,"printingJerk":900.0,"reducedAcceleration":1000.0,"speed":6000.0,"stepPos":0,"stepsPerMm":80.00,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]},{"acceleration":1000.0,"babystep":0,"backlash":0,"current":0,"drivers":["1.3"],"homed":false,"jerk":900.0,"letter":"D","machinePosition":0,"max":200.00,"maxProbed":false,"microstepping":{"interpolated":true,"value":16},"min":0,"minProbed":false,"percentCurrent":100,"percentStstCurrent":71,"phaseStep":false,"printingJerk":900.0,"reducedAcceleration":1000.0,"speed":6000.0,"stepPos":0,"stepsPerMm":80.00,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]},{"acceleration":1000.0,"babystep":0,"backlash":0,"current":0,"drivers":["1.0"],"homed":false,"jerk":900.0,"letter":"A","machinePosition":0,"max":200.00,"maxProbed":false,"microstepping":{"interpolated":true,"value":16},"min":0,"minProbed":false,"percentCurrent":100,"percentStstCurrent":71,"phaseStep":false,"printingJerk":900.0,"reducedAcceleration":1000.0,"speed":6000.0,"stepPos":0,"stepsPerMm":80.00,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]},{"acceleration":1000.0,"babystep":0,"backlash":0,"current":0,"drivers":["1.1"],"homed":false,"jerk":900.0,"letter":"B","machinePosition":0,"max":200.00,"maxProbed":false,"microstepping":{"interpolated":true,"value":16},"min":0,"minProbed":false,"percentCurrent":100,"percentStstCurrent":71,"phaseStep":false,"printingJerk":900.0,"reducedAcceleration":1000.0,"speed":6000.0,"stepPos":0,"stepsPerMm":80.00,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]},{"acceleration":1000.0,"babystep":0,"backlash":0,"current":0,"drivers":["1.2"],"homed":false,"jerk":900.0,"letter":"C","machinePosition":0,"max":200.00,"maxProbed":false,"microstepping":{"interpolated":true,"value":16},"min":0,"minProbed":false,"percentCurrent":100,"percentStstCurrent":71,"phaseStep":false,"printingJerk":900.0,"reducedAcceleration":1000.0,"speed":6000.0,"stepPos":0,"stepsPerMm":80.00,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]},{"acceleration":1000.0,"babystep":0,"backlash":0,"current":0,"drivers":["1.1"],"homed":false,"jerk":900.0,"letter":"b","machinePosition":0,"max":200.00,"maxProbed":false,"microstepping":{"interpolated":true,"value":16},"min":0,"minProbed":false,"percentCurrent":100,"percentStstCurrent":71,"phaseStep":false,"printingJerk":900.0,"reducedAcceleration":1000.0,"speed":6000.0,"stepPos":0,"stepsPerMm":80.00,"userPosition":0,"visible":true,"workplaceOffsets":[0,0,0,0,0,0,0,0,0]}],"next":10}
68.2 KB
Loading

0 commit comments

Comments
 (0)