yarf 0.1
Yet Another RepRap Firmware
|
Implementation of g-code commands. More...
#include <stdio.h>
#include <stdbool.h>
Go to the source code of this file.
Data Structures | |
struct | cmd_response_t |
Data structure representing a response to a command. More... | |
Enumerations | |
enum | cmd_status { OK, INVALID, FAULT } |
Enumeration representing the status of response to a command. More... | |
Functions | |
void | cmd_init (void) |
Initializes the command component. | |
void | cmd_controlled_move (cmd_response_t *r, float x, float y, float z, float e, float f) |
G1: Controlled move (buffered) | |
void | cmd_set_units_inches (cmd_response_t *r) |
G20: Set Units to Inches. | |
void | cmd_set_units_millimeters (cmd_response_t *r) |
G21: Set Units to Millimeters. | |
void | cmd_move_to_origin (cmd_response_t *r, bool x, bool y, bool z) |
G28: Move to Origin (buffered) | |
void | cmd_set_absolute_positioning (cmd_response_t *r) |
G90: Set to absolute positioning (unbuffered) | |
void | cmd_set_relative_positioning (cmd_response_t *r) |
G91: Set to relative positioning (unbuffered) | |
void | cmd_set_position (cmd_response_t *r, float x, float y, float z, float e) |
G92: Set Position. | |
void | cmd_stop_idle_hold (cmd_response_t *r) |
M84: Stop idle hold (unbuffered) | |
void | cmd_set_extruder_temp_async (cmd_response_t *r, float c) |
M104: Set nozzle temperature (non-blocking) | |
void | cmd_read_nozzle_and_printbed_temp (cmd_response_t *r) |
M105: Read extruder and printbed temperature. | |
void | cmd_set_extruder_temp_sync (cmd_response_t *r, float c) |
M109: Set nozzle temperature (blocking) | |
void | cmd_set_extruder_pwm (cmd_response_t *r, float s) |
M113: Set extruder PWM. | |
void | cmd_get_position (cmd_response_t *r) |
M114: Get current position. | |
void | cmd_wait (cmd_response_t *r) |
M116: Wait. | |
void | cmd_set_printbed_temp_async (cmd_response_t *r, float c) |
M140: Set print bed temperature (non-blocking) | |
void | cmd_select_tool (cmd_response_t *r, int tool) |
T: Select tool. |
enum cmd_status |
Enumeration representing the status of response to a command.
OK |
The command was executed successfully. |
INVALID |
The request was invalid. |
FAULT |
A hardware fault took place while trying to execute the command. |
Definition at line 38 of file commands.h.
void cmd_controlled_move | ( | cmd_response_t * | r, |
float | x, | ||
float | y, | ||
float | z, | ||
float | e, | ||
float | f | ||
) |
G1: Controlled move (buffered)
r | pointer to a cmd_response_t structure to write the response in |
x | determines the x coordinate of the destination position |
y | determines the y coordinate of the destination position |
z | determines the z coordinate of the destination position |
e | determines the e coordinate of the destination position |
f | the maximum speed of the movement in mm/min |
Go in a straight line from the current position to the specified position, with a maximum feed rate of f. The x, y, z and e values are interpreted as absolute or relative coordinates, depending on whether G90 or G91 was executed.
Definition at line 153 of file commands.c.
void cmd_get_position | ( | cmd_response_t * | r | ) |
M114: Get current position.
r | pointer to a cmd_response_t structure to write the response in |
Sends the current virtual x, y, z and e coordinates to the host.
Definition at line 301 of file commands.c.
void cmd_move_to_origin | ( | cmd_response_t * | r, |
bool | x, | ||
bool | y, | ||
bool | z | ||
) |
G28: Move to Origin (buffered)
r | pointer to a cmd_response_t structure to write the response in |
x | whether to move the x axis to its origin |
y | whether to move the y axis to its origin |
z | whether to move the z axis to its origin |
This causes the machine to move one or more of its axes to its origin.
Definition at line 194 of file commands.c.
void cmd_read_nozzle_and_printbed_temp | ( | cmd_response_t * | r | ) |
M105: Read extruder and printbed temperature.
r | pointer to a cmd_response_t structure to write the response in |
Reads the current temperature of the nozzle and the print bed in degrees celsius and sends them to the host.
Definition at line 271 of file commands.c.
void cmd_select_tool | ( | cmd_response_t * | r, |
int | tool | ||
) |
T: Select tool.
r | pointer to a cmd_response_t structure to write the response in |
tool | 0-based index of the tool to select |
Selects the extruder to build with. Yarf only supports a single extruder, so this command will send an 'invalid' response when called with any tool index other than 0.
Definition at line 369 of file commands.c.
void cmd_set_absolute_positioning | ( | cmd_response_t * | r | ) |
G90: Set to absolute positioning (unbuffered)
r | pointer to a cmd_response_t structure to write the response in |
Definition at line 209 of file commands.c.
void cmd_set_extruder_pwm | ( | cmd_response_t * | r, |
float | s | ||
) |
M113: Set extruder PWM.
r | pointer to a cmd_response_t structure to write the response in |
s | pwm value to which to set the extruder motor |
This command is not supported because yarf only supports stepper motors, which do not require a PWM to be set. An 'invalid' response will be sent back to the host if the s value is anything but NAN.
Definition at line 288 of file commands.c.
void cmd_set_extruder_temp_async | ( | cmd_response_t * | r, |
float | c | ||
) |
M104: Set nozzle temperature (non-blocking)
r | pointer to a cmd_response_t structure to write the response in |
c | temperature in degrees celcius to which to set the nozzle |
Sets the temperature of the nozzle to the specified number of degrees and returns control to the host immediately (i.e. before that temperature has been reached by the extruder).
Definition at line 259 of file commands.c.
void cmd_set_extruder_temp_sync | ( | cmd_response_t * | r, |
float | c | ||
) |
M109: Set nozzle temperature (blocking)
r | pointer to a cmd_response_t structure to write the response in |
c | temperature in degrees celcius to which to set the nozzle |
Sets the temperature of the nozzle to the specified number of degrees and waits for it to reach that temperature before sending a response back to the host.
Definition at line 278 of file commands.c.
void cmd_set_position | ( | cmd_response_t * | r, |
float | x, | ||
float | y, | ||
float | z, | ||
float | e | ||
) |
G92: Set Position.
r | pointer to a cmd_response_t structure to write the response in |
x | determines the x coordinate of the position |
y | determines the y coordinate of the position |
z | determines the z coordinate of the position |
e | determines the e coordinate of the position |
Sets the current virtual position to the specified position. The x, y, z and e values are interpreted as absolute or relative coordinates, depending on whether G90 or G91 was executed.
Definition at line 225 of file commands.c.
void cmd_set_printbed_temp_async | ( | cmd_response_t * | r, |
float | c | ||
) |
M140: Set print bed temperature (non-blocking)
r | pointer to a cmd_response_t structure to write the response in |
c | temperature in degrees celcius to which to set the print bed |
Sets the temperature of the print bed to the specified number of degrees and returns control to the host immediately (i.e. before that temperature has been reached by the extruder).
Definition at line 357 of file commands.c.
void cmd_set_relative_positioning | ( | cmd_response_t * | r | ) |
G91: Set to relative positioning (unbuffered)
r | pointer to a cmd_response_t structure to write the response in |
Definition at line 217 of file commands.c.
void cmd_set_units_inches | ( | cmd_response_t * | r | ) |
G20: Set Units to Inches.
r | pointer to a cmd_response_t structure to write the response in |
This command is not supported and will send an 'invalid' response when executed.
Definition at line 179 of file commands.c.
void cmd_set_units_millimeters | ( | cmd_response_t * | r | ) |
G21: Set Units to Millimeters.
r | pointer to a cmd_response_t structure to write the response in |
Units from now on are in millimeters.
Definition at line 186 of file commands.c.
void cmd_stop_idle_hold | ( | cmd_response_t * | r | ) |
M84: Stop idle hold (unbuffered)
r | pointer to a cmd_response_t structure to write the response in |
Stops the idle hold on all axes (including the extruder) by disabling their stepper motors.
Definition at line 245 of file commands.c.
void cmd_wait | ( | cmd_response_t * | r | ) |
M116: Wait.
r | pointer to a cmd_response_t structure to write the response in |
Waits for the nozzle and print bed temperatures to reach their set values.
Definition at line 339 of file commands.c.