#include <math.h>
#include <string.h>
#include "hal.h"
#include "motion_control.h"
#include "protocol.h"
#include "tool_change.h"
#include "state_machine.h"
#include "machine_limits.h"
#include "nvs_buffer.h"
Functions | |
void | system_init_switches (void) |
ISR_CODE void ISR_FUNC() | control_interrupt_handler (control_signals_t signals) |
Pin change interrupt handler for pin-out commands, i.e. cycle start, feed hold, reset etc. Mainly sets the realtime command execute variable to have the main program execute these when its ready. This works exactly like the character-based realtime commands when picked off directly from the incoming data stream. More... | |
void | system_execute_startup (void) |
Executes user startup scripts, if stored. More... | |
const char * | help_rst (const char *cmd) |
const char * | help_rtc (const char *cmd) |
const char * | help_spindle (const char *cmd) |
const char * | help_pins (const char *cmd) |
const char * | help_pin_state (const char *cmd) |
const char * | help_switches (const char *cmd) |
const char * | help_homing (const char *cmd) |
void | system_register_commands (sys_commands_t *commands) |
void | _system_output_help (sys_commands_t *commands, bool traverse) |
void | system_output_help (const sys_command_t *commands, uint32_t num_commands) |
void | system_command_help (void) |
status_code_t | system_execute_line (char *line) |
Directs and executes one line of input from protocol_process. More... | |
void | system_clear_tlo_reference (axes_signals_t homing_cycle) |
Called on homing state changes. More... | |
void | system_flag_wco_change (void) |
Called on a work coordinate (WCO) changes. More... | |
void | system_convert_array_steps_to_mpos (float *position, int32_t *steps) |
Sets machine position. Must be sent a 'step' array. More... | |
bool | system_xy_at_fixture (coord_system_id_t id, float tolerance) |
Checks if XY position is within coordinate system XY with given tolerance. More... | |
void | system_raise_alarm (alarm_code_t alarm) |
Raise and report a system alarm. More... | |
report_tracking_flags_t | system_get_rt_report_flags (void) |
Get the active realtime report addon flags for the next report. More... | |
void | system_add_rt_report (report_tracking_t report) |
Set(s) or clear all active realtime report addon flag(s) for the next report. More... | |
void _system_output_help | ( | sys_commands_t * | commands, |
bool | traverse | ||
) |
ISR_CODE void ISR_FUNC() control_interrupt_handler | ( | control_signals_t | signals | ) |
Pin change interrupt handler for pin-out commands, i.e. cycle start, feed hold, reset etc. Mainly sets the realtime command execute variable to have the main program execute these when its ready. This works exactly like the character-based realtime commands when picked off directly from the incoming data stream.
signals | a control_signals_t union holding status of the signals. |
const char* help_homing | ( | const char * | cmd | ) |
const char* help_pin_state | ( | const char * | cmd | ) |
const char* help_pins | ( | const char * | cmd | ) |
const char* help_rst | ( | const char * | cmd | ) |
const char* help_rtc | ( | const char * | cmd | ) |
const char* help_spindle | ( | const char * | cmd | ) |
const char* help_switches | ( | const char * | cmd | ) |
void system_add_rt_report | ( | report_tracking_t | report | ) |
Set(s) or clear all active realtime report addon flag(s) for the next report.
Fires the grbl.on_rt_reports_added event.
report | a report_tracking_t enum containing the flag(s) to set or clear. |
void system_clear_tlo_reference | ( | axes_signals_t | homing_cycle | ) |
Called on homing state changes.
Clears the tool length offset (TLO) when linear axis or X- or Z-axis is homed in lathe mode. Typically called on the grbl.on_homing complete event.
id | a axes_signals_t holding the axis flags that homed status was changed for. |
void system_command_help | ( | void | ) |
void system_convert_array_steps_to_mpos | ( | float * | position, |
int32_t * | steps | ||
) |
Sets machine position. Must be sent a 'step' array.
NOTE: If motor steps and machine position are not in the same coordinate frame, this function serves as a central place to compute the transformation.
position | pointer to the target float array for the machine position. |
steps | pointer to the source step count array to transform. |
status_code_t system_execute_line | ( | char * | line | ) |
Directs and executes one line of input from protocol_process.
While mostly incoming streaming g-code blocks, this also executes grblHAL internal commands, such as settings, initiating the homing cycle, and toggling switch states. This differs from the realtime command module by being susceptible to when grblHAL is ready to execute the next line during a cycle, so for switches like block delete, the switch only effects the lines that are processed afterward, not necessarily real-time during a cycle, since there are motions already stored in the buffer. However, this 'lag' should not be an issue, since these commands are not typically used during a cycle. If the command is not known to the core a grbl.on_unknown_sys_command event is raised so that plugin code can check if it is a command it supports.
NOTE: Code calling this function needs to provide the command in a writable buffer since the first part of the command (up to the first = character) is changed to uppercase and having spaces removed.
line | pointer to the command string. |
void system_execute_startup | ( | void | ) |
Executes user startup scripts, if stored.
void system_flag_wco_change | ( | void | ) |
Called on a work coordinate (WCO) changes.
If configured waits for the planner buffer to empty then fires the grbl.on_wco_changed event and sets the Report_WCO flag to add the WCO report element to the next status report.
report_tracking_flags_t system_get_rt_report_flags | ( | void | ) |
Get the active realtime report addon flags for the next report.
void system_init_switches | ( | void | ) |
void system_output_help | ( | const sys_command_t * | commands, |
uint32_t | num_commands | ||
) |
void system_raise_alarm | ( | alarm_code_t | alarm | ) |
Raise and report a system alarm.
a | alarm_code_t enum representing the alarm code. |
void system_register_commands | ( | sys_commands_t * | commands | ) |
bool system_xy_at_fixture | ( | coord_system_id_t | id, |
float | tolerance | ||
) |
Checks if XY position is within coordinate system XY with given tolerance.
id | a coord_system_id_t, typically CoordinateSystem_G59_3. |
tolerance | as the allowed radius the current position has to be within. |