MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / Adjust_AlterHelper

Method Adjust_AlterHelper

src/Display/ValueMenuItem.cpp:308–388  ·  view source on GitHub ↗

Adjust the value of this item by 'clicks' click of the encoder. 'clicks' is nonzero. Return true if we have finished adjusting it.

Source from the content-addressed store, hash-verified

306// Adjust the value of this item by 'clicks' click of the encoder. 'clicks' is nonzero.
307// Return true if we have finished adjusting it.
308bool ValueMenuItem::Adjust_AlterHelper(int clicks) noexcept
309{
310 itemChanged = true; // we will probably change the value, so it will need to be re-displayed
311 const unsigned int itemNumber = GetReferencedToolNumber();
312
313 switch (valIndex/100)
314 {
315 case 1: // heater active temperature
316 case 2: // heater standby temperature
317 if (itemNumber < 80) // Tool heaters
318 {
319 // If we're decreasing, make any value smaller than 95 go to 0
320 // If we're increasing, make any value between 0 and 95 jump directly to 95
321 // Also cap the maximum
322 if (0 > clicks) // decrementing
323 {
324 currentValue.fVal += (float)clicks;
325 if (95.0 > currentValue.fVal)
326 {
327 currentValue.fVal = 0.0;
328 }
329 }
330 else // incrementing
331 {
332 if (0.0 == currentValue.fVal)
333 {
334 currentValue.fVal = 95.0 - 1.0;
335 }
336 currentValue.fVal = min<float>(currentValue.fVal + (float)clicks, reprap.GetHeat().GetHighestTemperatureLimit(Tool::GetLockedTool(itemNumber)->GetHeater(0)));
337 }
338 }
339 else
340 {
341 currentValue.fVal += (float)clicks;
342 }
343 break;
344
345 case 3: // fan %
346 currentValue.fVal = constrain<float>(currentValue.fVal + (float)clicks, 0.0, 100.0);
347 break;
348
349 case 5: // misc.
350 switch (itemNumber)
351 {
352 case 0: // 500 Feed Rate
353 currentValue.fVal = constrain<float>(currentValue.fVal + (float)clicks, 10.0, 500.0);
354 break;
355
356 case 20: // 520 Tool Selection
357 currentValue.iVal = constrain<int>((int)currentValue.iVal + clicks, -1, 255);
358 break;
359
360 case 21: // 521 baby stepping
361 {
362 String<ShortGCodeLength> cmd;
363 cmd.printf("M290 Z%.2f", (double)(0.02 * clicks));
364 (void) reprap.GetGCodes().ProcessCommandFromLcd(cmd.c_str());
365 adjusting = AdjustMode::liveAdjusting;

Callers

nothing calls this directly

Calls 4

GetHeaterMethod · 0.80
ProcessCommandFromLcdMethod · 0.80
printfMethod · 0.45

Tested by

no test coverage detected