File tree Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Expand file tree Collapse file tree 3 files changed +36
-3
lines changed Original file line number Diff line number Diff line change @@ -3107,6 +3107,9 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply)
3107
3107
Tool* const tool = reprap.GetTool (tNumber);
3108
3108
if (tool != nullptr )
3109
3109
{
3110
+ if (gb.Seen (' S' )) {
3111
+ tool->SetCanExceedMixSumOf1 (gb.GetIValue () == 0 );
3112
+ }
3110
3113
if (gb.Seen (extrudeLetter))
3111
3114
{
3112
3115
float eVals[MaxExtruders];
@@ -3118,7 +3121,9 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply)
3118
3121
}
3119
3122
else
3120
3123
{
3121
- tool->DefineMix (eVals);
3124
+ if (!tool->DefineMix (eVals)) {
3125
+ reply.printf (" Setting mix ratios - sum of ratios > 1.0. Disable this check with M567 P%d S0" , tNumber);
3126
+ }
3122
3127
}
3123
3128
}
3124
3129
else
@@ -3130,6 +3135,7 @@ bool GCodes::HandleMcode(GCodeBuffer& gb, const StringRef& reply)
3130
3135
reply.catf (" %c%.3f" , sep, (double )tool->GetMix ()[drive]);
3131
3136
sep = ' :' ;
3132
3137
}
3138
+ reply.printf (" . Mix ratio sum of 1.0 can be exceeded: %s" , tool->GetCanExceedMixSumOf1 () ? " true" : " false" );
3133
3139
}
3134
3140
}
3135
3141
}
Original file line number Diff line number Diff line change @@ -116,6 +116,7 @@ Tool * Tool::freelist = nullptr;
116
116
t->heaterFault = false ;
117
117
t->axisOffsetsProbed = 0 ;
118
118
t->displayColdExtrudeWarning = false ;
119
+ t->canExceedMixSumOf1 = false ;
119
120
120
121
for (size_t axis = 0 ; axis < MaxAxes; axis++)
121
122
{
@@ -356,12 +357,33 @@ bool Tool::DisplayColdExtrudeWarning()
356
357
return result;
357
358
}
358
359
359
- void Tool::DefineMix (const float m[])
360
+ bool Tool::DefineMix (const float m[])
360
361
{
362
+ if (this ->CheckExceedsMixSumOf1 (m)) {
363
+ return false ;
364
+ }
361
365
for (size_t drive = 0 ; drive < driveCount; drive++)
362
366
{
363
367
mix[drive] = m[drive];
364
368
}
369
+ return true ;
370
+ }
371
+
372
+ bool Tool::CheckExceedsMixSumOf1 (const float m[]) const {
373
+ // We don't need to check if this is true
374
+ if (this ->canExceedMixSumOf1 ) {
375
+ return false ;
376
+ }
377
+
378
+ float sum = 0.0 ;
379
+ // Only check for the amount of configured drives
380
+ for (size_t drive = 0 ; drive < driveCount; drive++) {
381
+ sum += m[drive];
382
+ if (sum > 1.0 ) {
383
+ return true ;
384
+ }
385
+ }
386
+ return false ;
365
387
}
366
388
367
389
// Write the tool's settings to file returning true if successful
Original file line number Diff line number Diff line change @@ -58,7 +58,9 @@ class Tool
58
58
int Heater (size_t heaterNumber) const ;
59
59
const char *GetName () const ;
60
60
int Number () const ;
61
- void DefineMix (const float m[]);
61
+ bool DefineMix (const float m[]);
62
+ void SetCanExceedMixSumOf1 (const bool m) { canExceedMixSumOf1 = m; }
63
+ bool GetCanExceedMixSumOf1 () const { return canExceedMixSumOf1; }
62
64
const float * GetMix () const ;
63
65
float MaxFeedrate () const ;
64
66
void Print (const StringRef& reply) const ;
@@ -94,11 +96,14 @@ class Tool
94
96
void ResetTemperatureFault (int8_t wasDudHeater);
95
97
bool AllHeatersAtHighTemperature (bool forExtrusion) const ;
96
98
99
+ bool CheckExceedsMixSumOf1 (const float m[]) const ;
100
+
97
101
Tool* next;
98
102
Filament *filament;
99
103
char *name;
100
104
float offset[MaxAxes];
101
105
float mix[MaxExtruders];
106
+ bool canExceedMixSumOf1;
102
107
float activeTemperatures[Heaters];
103
108
float standbyTemperatures[Heaters];
104
109
size_t driveCount;
You can’t perform that action at this time.
0 commit comments