Welcome to mirror list, hosted at ThFree Co, Russian Federation.

RestorePoint.cpp « GCodes « src - github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: f197b25d097b5ba7da2b79b62f2737ff2f9d7109 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*
 * RestorePoint.cpp
 *
 *  Created on: 14 Jun 2017
 *      Author: David
 */

#include "RestorePoint.h"
#include <Platform/RepRap.h>
#include <GCodes/GCodes.h>

#if SUPPORT_OBJECT_MODEL

// Object model table and functions
// Note: if using GCC version 7.3.1 20180622 and lambda functions are used in this table, you must compile this file with option -std=gnu++17.
// Otherwise the table will be allocate in RAM instead of flash, which wastes too much RAM.

// Macro to build a standard lambda function that includes the necessary type conversions
#define OBJECT_MODEL_FUNC(...) OBJECT_MODEL_FUNC_BODY(RestorePoint, __VA_ARGS__)
#define OBJECT_MODEL_FUNC_IF(_condition,...) OBJECT_MODEL_FUNC_IF_BODY(RestorePoint, _condition,__VA_ARGS__)

constexpr ObjectModelArrayDescriptor RestorePoint::coordinatesArrayDescriptor =
{
	nullptr,
	[] (const ObjectModel *self, const ObjectExplorationContext&) noexcept -> size_t { return reprap.GetGCodes().GetVisibleAxes(); },
	[] (const ObjectModel *self, ObjectExplorationContext& context) noexcept -> ExpressionValue
																			{ return ExpressionValue(((const RestorePoint*)self)->moveCoords[context.GetLastIndex()], 3); }
};

constexpr ObjectModelTableEntry RestorePoint::objectModelTable[] =
{
	// Within each group, these entries must be in alphabetical order
	// 0. LaserFilamentMonitor members
	{ "coords", 			OBJECT_MODEL_FUNC_NOSELF(&coordinatesArrayDescriptor), 								ObjectModelEntryFlags::none },
	{ "extruderPos",		OBJECT_MODEL_FUNC(self->virtualExtruderPosition, 1),	 							ObjectModelEntryFlags::none },
	{ "fanPwm", 			OBJECT_MODEL_FUNC(self->fanSpeed, 2), 												ObjectModelEntryFlags::none },
	{ "feedRate", 			OBJECT_MODEL_FUNC(InverseConvertSpeedToMmPerSec(self->feedRate), 1), 				ObjectModelEntryFlags::none },
#if SUPPORT_IOBITS
	{ "ioBits",				OBJECT_MODEL_FUNC_IF(reprap.GetGCodes().GetMachineType() != MachineType::laser,
													(int32_t)self->laserPwmOrIoBits.ioBits),					ObjectModelEntryFlags::none },
#endif
#if SUPPORT_LASER
	{ "laserPwm",			OBJECT_MODEL_FUNC_IF(reprap.GetGCodes().GetMachineType() == MachineType::laser,
													(float)self->laserPwmOrIoBits.laserPwm/65535.0, 2),			ObjectModelEntryFlags::none },
#endif
	{ "toolNumber",			OBJECT_MODEL_FUNC((int32_t)self->toolNumber),										ObjectModelEntryFlags::none },
};

constexpr uint8_t RestorePoint::objectModelTableDescriptor[] = { 1, 5 + SUPPORT_LASER + SUPPORT_IOBITS };

DEFINE_GET_OBJECT_MODEL_TABLE(RestorePoint)

#endif

RestorePoint::RestorePoint() noexcept
{
	Init();
}

void RestorePoint::Init() noexcept
{
	for (size_t i = 0; i < MaxAxes; ++i)
	{
		moveCoords[i] = 0.0;
	}

	feedRate = ConvertSpeedFromMmPerMin(DefaultFeedRate);
	virtualExtruderPosition = 0.0;
	filePos = noFilePosition;
	proportionDone = 0.0;
	initialUserC0 = initialUserC1 = 0.0;
	toolNumber = -1;
	fanSpeed = 0.0;

#if SUPPORT_LASER || SUPPORT_IOBITS
	laserPwmOrIoBits.Clear();
#endif
}

// End