-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmachine.h
More file actions
137 lines (111 loc) · 4.78 KB
/
machine.h
File metadata and controls
137 lines (111 loc) · 4.78 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
/*
* machine.h
*
* Created on: Dec 6, 2012
* Author: cyberwizzard
*/
#ifndef MACHINE_H_
#define MACHINE_H_
#include "main.h" // Also contains the machine boundaries
#include "mesh_builder.h"
#include <ncurses.h>
#define TOKENPASTE(x, y) x ## y
#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
//#define SAFETY_LIMIT_TEST(axis, value, result) if(value < TOKENPASTE(MIN_,axis) || value > TOKENPASTE(MAX_,axis)) { result = -1; printf("Axis position out of bounds: " axis "=%.3f\n", value); }
#define SAFETY_LIMIT_TEST(axis, value, result) { if(value < TOKENPASTE2(MIN_,axis) || value > TOKENPASTE2(MAX_,axis)) { \
result = -1; \
printf("Axis position out of bounds: " #axis "=%.3f\n", value); \
}}
#define ASSERT(x) {int _return_code = x; if(_return_code!=0) { printf("Command assert failed in " __FILE__":%i with code %i\n", __LINE__, _return_code); return _return_code; }}
/**
* Position the head of the machine in 3 dimensional space and with a given speed.
* Note that only changed parameters are sent to the printer to reduce traffic over
* the serial port when changes_only is true.
* @param xval X coordinate
* @param yval Y coordinate
* @param zval Z coordinate
* @param relative Marks the given coordinates as a relative move instead of an absolute one
* @param speed for the move, always absolute
* @return 0 for OK or a negative error code otherwise
*/
int set_position(float xval, float yval, float zval, int relative, float speed, bool changes_only = true);
// Wrapper functions around set_position for ease of use
int home_x();
int set_x(float val);
int set_x(float val, int relative);
int set_x(float val, int relative, float speedval);
float get_x();
int home_y();
int set_y(float val);
int set_y(float val, int relative);
int set_y(float val, int relative, float speedval);
float get_y();
int home_z();
int set_z(float val);
int set_z(float val, int relative);
int set_z(float val, int relative, float speedval);
float get_z();
int home_xy();
int home_xyz();
int get_pos();
int set_speed(float val);
/**
* Load the UBL mesh points from a specific EEPROM save slot (or the currently loaded mesh)
* @param slot Set to -1 to load the current mesh points and not load a mesh from EEPROM
* @param mesh Pointer to the mesh memory to load with the mesh points from the printer
*/
int mesh_download(int slot = -1, ty_meshpoint mesh[MESH_SIZE_Y][MESH_SIZE_X] = NULL, WINDOW* wnd = NULL);
/**
* Upload the UBL mesh points into a specific EEPROM save slot (or the currently loaded mesh)
* @param slot Set to -1 to only load the mesh into the printer RAM (and not EEPROM)
* @param mesh Pointer to the mesh memory to upload with the mesh points for the printer
* @param wnd Window handle from ncurses to print debug info into (when NULL no debug info is generated)
*/
int mesh_upload(int slot, ty_meshpoint mesh[MESH_SIZE_Y][MESH_SIZE_X], WINDOW* wnd);
/**
* Tell the machine to dwell for a number of microseconds. This is an unbuffered command
* which can also be used as a barrier to wait for the command queue to flush between moves.
* @param timeout in microseconds (1000 is one second)
* @return 0 when OK or an error code otherwise
*/
int set_dwell(int timeout);
/**
* Adjust the alignment of the Z axis by overriding the position of the head. This allows us to
* move beyond the built-in boundaries; for example this can be used to home the Z axis into the
* opt-flag and then lower it towards the bed (through the opto-flag barrier).
* WARNING: Overriding the position of the toolhead can result in serious damage as the machine
* will blindly accept the new coordinates!
* @param val The value for the Z axis
* @return 0 when OK or an error code otherwise
*/
int override_zpos(float val);
int disable_motor_hold();
int enable_soft_endstops(bool on);
int mesh_disable();
int enable_fan(bool on);
/**
* Get the printer temperatures
* Firmware: Marlin
*
* @param hotend_temp pointer to a double to store the hotend temperature in
* @param bed_temp pointer to a double to store the bed temperature in
*/
int get_temperature(double *hotend_temp, double* bed_temp);
/**
* Set the hotend temperature - this command does not wait until the target temperature is reached
*
* Note: Teacup allows setting the bed temperature using ID 1
* @param temp The temperature to set the printer bed to
* @param heaterid Hotend ID to set the temperature on - if the machine only has one hotend, its usually ID 0
*/
int set_hotend_temperature(double temp = 0, const unsigned char heaterid = 0);
/**
* Set the bed temperature - this command does not wait until the target temperature is reached
* @param temp The temperature to set the printer bed to
*/
int set_bed_temperature(const double temp = 0);
int set_pid_p(const double p);
int set_pid_i(const int i);
int set_pid_d(const int d);
int print_pid();
#endif /* MACHINE_H_ */