mirror of
https://github.com/grblHAL/core.git
synced 2026-02-05 16:50:16 +08:00
See changelog for details.
This commit is contained in:
@@ -11,7 +11,7 @@ It has been written to complement grblHAL and has features such as proper keyboa
|
||||
|
||||
---
|
||||
|
||||
Latest build date is 20211122, see the [changelog](changelog.md) for details.
|
||||
Latest build date is 20211128, see the [changelog](changelog.md) for details.
|
||||
__NOTE:__ A settings reset will be performed on an update for versions earlier than 20211122. Backup and restore of settings is recommended.
|
||||
__IMPORTANT!__ A new setting has been introduced for ganged axes motors in version 20211121.
|
||||
I have only bench tested this for a couple of drivers, correct function should be verified after updating by those who have more than three motors configured.
|
||||
@@ -83,4 +83,4 @@ List of Supported G-Codes:
|
||||
Some [plugins](https://github.com/grblHAL/plugins) implements additional M-codes.
|
||||
|
||||
---
|
||||
2021-11-22
|
||||
2021-11-28
|
||||
|
||||
44
alarms.c
44
alarms.c
@@ -27,23 +27,23 @@
|
||||
#include "core_handlers.h"
|
||||
|
||||
PROGMEM static const alarm_detail_t alarm_detail[] = {
|
||||
{ Alarm_HardLimit, "Hard limit", "Hard limit has been triggered. Machine position is likely lost due to sudden halt. Re-homing is highly recommended." },
|
||||
{ Alarm_SoftLimit, "Soft limit", "Soft limit alarm. G-code motion target exceeds machine travel. Machine position retained. Alarm may be safely unlocked." },
|
||||
{ Alarm_AbortCycle, "Abort during cycle", "Reset while in motion. Machine position is likely lost due to sudden halt. Re-homing is highly recommended." },
|
||||
{ Alarm_ProbeFailInitial, "Probe fail", "Probe fail. Probe is not in the expected initial state before starting probe cycle when G38.2 and G38.3 is not triggered and G38.4 and G38.5 is triggered." },
|
||||
{ Alarm_ProbeFailContact, "Probe fail", "Probe fail. Probe did not contact the workpiece within the programmed travel for G38.2 and G38.4." },
|
||||
{ Alarm_HomingFailReset, "Homing fail", "Homing fail. The active homing cycle was reset." },
|
||||
{ Alarm_HomingFailDoor, "Homing fail", "Homing fail. Safety door was opened during homing cycle." },
|
||||
{ Alarm_FailPulloff, "Homing fail", "Homing fail. Pull off travel failed to clear limit switch. Try increasing pull-off setting or check wiring." },
|
||||
{ Alarm_HomingFailApproach, "Homing fail", "Homing fail. Could not find limit switch within search distances. Try increasing max travel, decreasing pull-off distance, or check wiring." },
|
||||
{ Alarm_EStop, "EStop", "EStop asserted. Clear and reset" },
|
||||
{ Alarm_HomingRequried, "Homing required", "Homing required. Execute homing command ($H) to continue." },
|
||||
{ Alarm_LimitsEngaged, "Limit switch engaged", "Limit switch engaged. Clear before continuing." },
|
||||
{ Alarm_ProbeProtect, "Probe protection triggered", "Probe protection triggered. Clear before continuing." },
|
||||
{ Alarm_Spindle, "Spindle at speed timeout", "Spindle at speed timeout. Clear before continuing." },
|
||||
{ Alarm_HomingFailAutoSquaringApproach, "Homing fail", "Homing fail. Could not find second limit switch for auto squared axis within search distances. Try increasing max travel, decreasing pull-off distance, or check wiring." },
|
||||
{ Alarm_SelftestFailed, "Selftest failed", "Power on selftest (POS) failed." },
|
||||
{ Alarm_MotorFault, "Motor fault", "Motor fault." }
|
||||
{ Alarm_HardLimit, "Hard limit has been triggered. Machine position is likely lost due to sudden halt. Re-homing is highly recommended." },
|
||||
{ Alarm_SoftLimit, "Soft limit alarm. G-code motion target exceeds machine travel. Machine position retained. Alarm may be safely unlocked." },
|
||||
{ Alarm_AbortCycle, "Reset while in motion. Machine position is likely lost due to sudden halt. Re-homing is highly recommended." },
|
||||
{ Alarm_ProbeFailInitial, "Probe fail. Probe is not in the expected initial state before starting probe cycle when G38.2 and G38.3 is not triggered and G38.4 and G38.5 is triggered." },
|
||||
{ Alarm_ProbeFailContact, "Probe fail. Probe did not contact the workpiece within the programmed travel for G38.2 and G38.4." },
|
||||
{ Alarm_HomingFailReset, "Homing fail. The active homing cycle was reset." },
|
||||
{ Alarm_HomingFailDoor, "Homing fail. Safety door was opened during homing cycle." },
|
||||
{ Alarm_FailPulloff, "Homing fail. Pull off travel failed to clear limit switch. Try increasing pull-off setting or check wiring." },
|
||||
{ Alarm_HomingFailApproach, "Homing fail. Could not find limit switch within search distances. Try increasing max travel, decreasing pull-off distance, or check wiring." },
|
||||
{ Alarm_EStop, "EStop asserted. Clear and reset" },
|
||||
{ Alarm_HomingRequried, "Homing required. Execute homing command ($H) to continue." },
|
||||
{ Alarm_LimitsEngaged, "Limit switch engaged. Clear before continuing." },
|
||||
{ Alarm_ProbeProtect, "Probe protection triggered. Clear before continuing." },
|
||||
{ Alarm_Spindle, "Spindle at speed timeout. Clear before continuing." },
|
||||
{ Alarm_HomingFailAutoSquaringApproach, "Homing fail. Could not find second limit switch for auto squared axis within search distances. Try increasing max travel, decreasing pull-off distance, or check wiring." },
|
||||
{ Alarm_SelftestFailed, "Power on selftest (POS) failed." },
|
||||
{ Alarm_MotorFault, "Motor fault." }
|
||||
};
|
||||
|
||||
static alarm_details_t details = {
|
||||
@@ -51,9 +51,15 @@ static alarm_details_t details = {
|
||||
.n_alarms = sizeof(alarm_detail) / sizeof(alarm_detail_t)
|
||||
};
|
||||
|
||||
static alarm_details_t *alarms = &details;
|
||||
|
||||
void alarms_register (alarm_details_t *details)
|
||||
{
|
||||
alarms->next = details;
|
||||
alarms = details;
|
||||
}
|
||||
|
||||
alarm_details_t *alarms_get_details (void)
|
||||
{
|
||||
details.on_get_alarms = grbl.on_get_alarms;
|
||||
|
||||
return &details;
|
||||
}
|
||||
|
||||
5
alarms.h
5
alarms.h
@@ -49,19 +49,18 @@ typedef enum {
|
||||
|
||||
typedef struct {
|
||||
alarm_code_t id;
|
||||
const char *name;
|
||||
const char *description;
|
||||
} alarm_detail_t;
|
||||
|
||||
typedef struct alarm_details {
|
||||
const uint16_t n_alarms;
|
||||
const alarm_detail_t *alarms;
|
||||
struct alarm_details *(*on_get_alarms)(void);
|
||||
struct alarm_details *next;
|
||||
} alarm_details_t;
|
||||
|
||||
// NOTE: this must match the signature of on_get_alarms in the alarm_details_t struct above!
|
||||
typedef alarm_details_t *(*on_get_alarms_ptr)(void);
|
||||
|
||||
void alarms_register (alarm_details_t *details);
|
||||
alarm_details_t *alarms_get_details (void);
|
||||
|
||||
#endif
|
||||
|
||||
28
changelog.md
28
changelog.md
@@ -1,10 +1,34 @@
|
||||
## grblHAL changelog
|
||||
|
||||
Build 20211128:
|
||||
|
||||
Core:
|
||||
|
||||
* Added functionality for serial stream registration and enumeration, allows plugins to claim stream(s) from free pool.
|
||||
* Simplified registration of settings, alarms and error codes from driver and plugin code.
|
||||
* Fixed `$$` settings report, it reported some configuration dependent settings when not available.
|
||||
* Added pin id definitions for soft UART pins \(used by Trinamic TMC2209\) driver code.
|
||||
|
||||
Plugins, templates and drivers:
|
||||
|
||||
* Updated for core changes above.
|
||||
|
||||
Drivers:
|
||||
|
||||
* ESP32 driver: updated for ESP-IDF 4.3 API call change that prevented WiFi AP mode initialization. Rewrite of wifi code that used deprecated library calls.
|
||||
* STM32F4xx driver: added tentative support for Trinamic stepper drivers for BTT SKR Pro 1.1 \(and 1.2 that can use the same map\) board. _Not tested!_
|
||||
|
||||
Plugins:
|
||||
|
||||
* Motors plugin: bug fixes for handling of ganged motors with Trinamic drivers. Added optional callbacks to low level driver code pre and post configuration \(per driver\).
|
||||
|
||||
---
|
||||
|
||||
Build 20211122:
|
||||
|
||||
Core:
|
||||
|
||||
* Fixed silly typedef mistake in setting struct, added settings $392 and $393 for spindle and coolant startup delays on safety door open.
|
||||
* Fixed silly typedef mistake in setting struct, added settings `$392` and `$393` for spindle and coolant startup delays on safety door open.
|
||||
* Removed Grbl v0.9 error messages.
|
||||
|
||||
Drivers:
|
||||
@@ -12,6 +36,8 @@ Drivers:
|
||||
* Added setting $308 for FTP port to use for networking capable drivers. Defaults to 21.
|
||||
* Fixed WebUI processor clock speed report in ESP32 driver, added FTP port, board name and driver version to same.
|
||||
|
||||
---
|
||||
|
||||
Build 20211121:
|
||||
|
||||
Core:
|
||||
|
||||
213
crossbar.h
213
crossbar.h
@@ -129,7 +129,13 @@ typedef enum {
|
||||
Output_Aux6,
|
||||
Output_Aux7,
|
||||
Bidirectional,
|
||||
Bidirectional_SDA = Bidirectional
|
||||
Bidirectional_SDA = Bidirectional,
|
||||
Bidirectional_MotorUARTX,
|
||||
Bidirectional_MotorUARTY,
|
||||
Bidirectional_MotorUARTZ,
|
||||
Bidirectional_MotorUARTM3,
|
||||
Bidirectional_MotorUARTM4,
|
||||
Bidirectional_MotorUARTM5
|
||||
} pin_function_t;
|
||||
|
||||
#define PIN_ISINPUT(pin) (pin < Outputs)
|
||||
@@ -142,105 +148,111 @@ typedef struct {
|
||||
} pin_name_t;
|
||||
|
||||
PROGMEM static const pin_name_t pin_names[] = {
|
||||
{ .function = Input_Probe, .name = "Probe" },
|
||||
{ .function = Input_Reset, .name = "Reset" },
|
||||
{ .function = Input_FeedHold, .name = "Feed hold" },
|
||||
{ .function = Input_CycleStart, .name = "Cycle start" },
|
||||
{ .function = Input_SafetyDoor, .name = "Safety door" },
|
||||
{ .function = Input_LimitsOverride, .name = "Limits override" },
|
||||
{ .function = Input_EStop, .name = "Emergency stop" },
|
||||
{ .function = Input_ModeSelect, .name = "MPG mode select" },
|
||||
{ .function = Input_LimitX, .name = "X limit min" },
|
||||
{ .function = Input_LimitX_2, .name = "X limit min 2" },
|
||||
{ .function = Input_LimitX_Max, .name = "X limit max" },
|
||||
{ .function = Input_LimitY, .name = "Y limit min" },
|
||||
{ .function = Input_LimitY_2, .name = "Y limit min 2" },
|
||||
{ .function = Input_LimitY_Max, .name = "Y limit max" },
|
||||
{ .function = Input_LimitZ, .name = "Z limit min" },
|
||||
{ .function = Input_LimitZ_2, .name = "Z limit min 2" },
|
||||
{ .function = Input_LimitZ_Max, .name = "Z limit max" },
|
||||
{ .function = Input_LimitA, .name = "A limit min" },
|
||||
{ .function = Input_LimitA_Max, .name = "A limit max" },
|
||||
{ .function = Input_LimitB, .name = "B limit min" },
|
||||
{ .function = Input_LimitB_Max, .name = "B limit max" },
|
||||
{ .function = Input_LimitC, .name = "C limit min" },
|
||||
{ .function = Input_LimitC_Max, .name = "C limit max" },
|
||||
{ .function = Input_LimitU, .name = "U limit min" },
|
||||
{ .function = Input_LimitU_Max, .name = "U limit max" },
|
||||
{ .function = Input_LimitV, .name = "V limit min" },
|
||||
{ .function = Input_LimitV_Max, .name = "V limit max" },
|
||||
{ .function = Input_MISO, .name = "MISO" },
|
||||
{ .function = Input_RX, .name = "RX" },
|
||||
{ .function = Input_KeypadStrobe, .name = "Keypad strobe" },
|
||||
{ .function = Input_I2CStrobe, .name = "I2C strobe" },
|
||||
{ .function = Input_QEI_A, .name = "QEI A" },
|
||||
{ .function = Input_QEI_B, .name = "QEI B" },
|
||||
{ .function = Input_QEI_Select, .name = "QEI select" },
|
||||
{ .function = Input_QEI_Index, .name = "QEI index" },
|
||||
{ .function = Input_SpindleIndex, .name = "Spindle index" },
|
||||
{ .function = Input_MotorWarning, .name = "Motor warning" },
|
||||
{ .function = Input_MotorFault, .name = "Motor fault" },
|
||||
{ .function = Input_Aux0, .name = "Aux input 0" },
|
||||
{ .function = Input_Aux1, .name = "Aux input 1" },
|
||||
{ .function = Input_Aux2, .name = "Aux input 2" },
|
||||
{ .function = Input_Aux3, .name = "Aux input 3" },
|
||||
{ .function = Input_Aux4, .name = "Aux input 4" },
|
||||
{ .function = Input_Aux5, .name = "Aux input 5" },
|
||||
{ .function = Input_Aux6, .name = "Aux input 6" },
|
||||
{ .function = Input_Aux7, .name = "Aux input 7" },
|
||||
{ .function = Output_StepX, .name = "X step" },
|
||||
{ .function = Output_StepX_2, .name = "X2 step" },
|
||||
{ .function = Output_StepY, .name = "Y step" },
|
||||
{ .function = Output_StepY_2, .name = "Y2 step" },
|
||||
{ .function = Output_StepZ, .name = "Z step" },
|
||||
{ .function = Output_StepZ_2, .name = "Z2 step" },
|
||||
{ .function = Output_StepA, .name = "A step" },
|
||||
{ .function = Output_StepB, .name = "B step" },
|
||||
{ .function = Output_StepC, .name = "C step" },
|
||||
{ .function = Output_DirX, .name = "X dir" },
|
||||
{ .function = Output_DirX_2, .name = "X2 dir" },
|
||||
{ .function = Output_DirY, .name = "Y dir" },
|
||||
{ .function = Output_DirY_2, .name = "Y2 dir" },
|
||||
{ .function = Output_DirZ, .name = "Z dir" },
|
||||
{ .function = Output_DirZ_2, .name = "Z2 dir" },
|
||||
{ .function = Output_DirA, .name = "A dir" },
|
||||
{ .function = Output_DirB, .name = "B dir" },
|
||||
{ .function = Output_DirC, .name = "C dir" },
|
||||
{ .function = Output_StepperPower, .name = "Stepper power" },
|
||||
{ .function = Output_StepperEnable, .name = "Steppers enable" },
|
||||
{ .function = Output_StepperEnableX, .name = "X enable" },
|
||||
{ .function = Output_StepperEnableY, .name = "Y enable" },
|
||||
{ .function = Output_StepperEnableZ, .name = "Z enable" },
|
||||
{ .function = Output_StepperEnableA, .name = "A enable" },
|
||||
{ .function = Output_StepperEnableB, .name = "B enable" },
|
||||
{ .function = Output_StepperEnableC, .name = "C enable" },
|
||||
{ .function = Output_StepperEnableXY, .name = "XY enable" },
|
||||
{ .function = Output_StepperEnableAB, .name = "AB enable" },
|
||||
{ .function = Output_MotorChipSelect, .name = "Motor CS" },
|
||||
{ .function = Output_MotorChipSelectX, .name = "Motor CSX" },
|
||||
{ .function = Output_MotorChipSelectY, .name = "Motor CSY" },
|
||||
{ .function = Output_MotorChipSelectZ, .name = "Motor CSZ" },
|
||||
{ .function = Output_MotorChipSelectM3, .name = "Motor CSM3" },
|
||||
{ .function = Output_MotorChipSelectM4, .name = "Motor CSM4" },
|
||||
{ .function = Output_MotorChipSelectM5, .name = "Motor CSM5" },
|
||||
{ .function = Output_SpindleOn, .name = "Spindle on" },
|
||||
{ .function = Output_SpindleDir, .name = "Spindle direction" },
|
||||
{ .function = Output_SpindlePWM, .name = "Spindle PWM" },
|
||||
{ .function = Output_CoolantMist, .name = "Mist" },
|
||||
{ .function = Output_CoolantFlood, .name = "Flood" },
|
||||
{ .function = Output_TX, .name = "TX" },
|
||||
{ .function = Output_SCK, .name = "SCK" },
|
||||
{ .function = Output_MOSI, .name = "MOSI" },
|
||||
{ .function = Output_SdCardCS, .name = "SD card CS" },
|
||||
{ .function = Output_Aux0, .name = "Aux out 0" },
|
||||
{ .function = Output_Aux1, .name = "Aux out 1" },
|
||||
{ .function = Output_Aux2, .name = "Aux out 2" },
|
||||
{ .function = Output_Aux3, .name = "Aux out 3" },
|
||||
{ .function = Output_Aux4, .name = "Aux out 4" },
|
||||
{ .function = Output_Aux5, .name = "Aux out 5" },
|
||||
{ .function = Output_Aux6, .name = "Aux out 6" },
|
||||
{ .function = Output_Aux7, .name = "Aux out 7" },
|
||||
{ .function = Bidirectional_SDA, .name = "SDA" }
|
||||
{ .function = Input_Probe, .name = "Probe" },
|
||||
{ .function = Input_Reset, .name = "Reset" },
|
||||
{ .function = Input_FeedHold, .name = "Feed hold" },
|
||||
{ .function = Input_CycleStart, .name = "Cycle start" },
|
||||
{ .function = Input_SafetyDoor, .name = "Safety door" },
|
||||
{ .function = Input_LimitsOverride, .name = "Limits override" },
|
||||
{ .function = Input_EStop, .name = "Emergency stop" },
|
||||
{ .function = Input_ModeSelect, .name = "MPG mode select" },
|
||||
{ .function = Input_LimitX, .name = "X limit min" },
|
||||
{ .function = Input_LimitX_2, .name = "X limit min 2" },
|
||||
{ .function = Input_LimitX_Max, .name = "X limit max" },
|
||||
{ .function = Input_LimitY, .name = "Y limit min" },
|
||||
{ .function = Input_LimitY_2, .name = "Y limit min 2" },
|
||||
{ .function = Input_LimitY_Max, .name = "Y limit max" },
|
||||
{ .function = Input_LimitZ, .name = "Z limit min" },
|
||||
{ .function = Input_LimitZ_2, .name = "Z limit min 2" },
|
||||
{ .function = Input_LimitZ_Max, .name = "Z limit max" },
|
||||
{ .function = Input_LimitA, .name = "A limit min" },
|
||||
{ .function = Input_LimitA_Max, .name = "A limit max" },
|
||||
{ .function = Input_LimitB, .name = "B limit min" },
|
||||
{ .function = Input_LimitB_Max, .name = "B limit max" },
|
||||
{ .function = Input_LimitC, .name = "C limit min" },
|
||||
{ .function = Input_LimitC_Max, .name = "C limit max" },
|
||||
{ .function = Input_LimitU, .name = "U limit min" },
|
||||
{ .function = Input_LimitU_Max, .name = "U limit max" },
|
||||
{ .function = Input_LimitV, .name = "V limit min" },
|
||||
{ .function = Input_LimitV_Max, .name = "V limit max" },
|
||||
{ .function = Input_MISO, .name = "MISO" },
|
||||
{ .function = Input_RX, .name = "RX" },
|
||||
{ .function = Input_KeypadStrobe, .name = "Keypad strobe" },
|
||||
{ .function = Input_I2CStrobe, .name = "I2C strobe" },
|
||||
{ .function = Input_QEI_A, .name = "QEI A" },
|
||||
{ .function = Input_QEI_B, .name = "QEI B" },
|
||||
{ .function = Input_QEI_Select, .name = "QEI select" },
|
||||
{ .function = Input_QEI_Index, .name = "QEI index" },
|
||||
{ .function = Input_SpindleIndex, .name = "Spindle index" },
|
||||
{ .function = Input_MotorWarning, .name = "Motor warning" },
|
||||
{ .function = Input_MotorFault, .name = "Motor fault" },
|
||||
{ .function = Input_Aux0, .name = "Aux input 0" },
|
||||
{ .function = Input_Aux1, .name = "Aux input 1" },
|
||||
{ .function = Input_Aux2, .name = "Aux input 2" },
|
||||
{ .function = Input_Aux3, .name = "Aux input 3" },
|
||||
{ .function = Input_Aux4, .name = "Aux input 4" },
|
||||
{ .function = Input_Aux5, .name = "Aux input 5" },
|
||||
{ .function = Input_Aux6, .name = "Aux input 6" },
|
||||
{ .function = Input_Aux7, .name = "Aux input 7" },
|
||||
{ .function = Output_StepX, .name = "X step" },
|
||||
{ .function = Output_StepX_2, .name = "X2 step" },
|
||||
{ .function = Output_StepY, .name = "Y step" },
|
||||
{ .function = Output_StepY_2, .name = "Y2 step" },
|
||||
{ .function = Output_StepZ, .name = "Z step" },
|
||||
{ .function = Output_StepZ_2, .name = "Z2 step" },
|
||||
{ .function = Output_StepA, .name = "A step" },
|
||||
{ .function = Output_StepB, .name = "B step" },
|
||||
{ .function = Output_StepC, .name = "C step" },
|
||||
{ .function = Output_DirX, .name = "X dir" },
|
||||
{ .function = Output_DirX_2, .name = "X2 dir" },
|
||||
{ .function = Output_DirY, .name = "Y dir" },
|
||||
{ .function = Output_DirY_2, .name = "Y2 dir" },
|
||||
{ .function = Output_DirZ, .name = "Z dir" },
|
||||
{ .function = Output_DirZ_2, .name = "Z2 dir" },
|
||||
{ .function = Output_DirA, .name = "A dir" },
|
||||
{ .function = Output_DirB, .name = "B dir" },
|
||||
{ .function = Output_DirC, .name = "C dir" },
|
||||
{ .function = Output_StepperPower, .name = "Stepper power" },
|
||||
{ .function = Output_StepperEnable, .name = "Steppers enable" },
|
||||
{ .function = Output_StepperEnableX, .name = "X enable" },
|
||||
{ .function = Output_StepperEnableY, .name = "Y enable" },
|
||||
{ .function = Output_StepperEnableZ, .name = "Z enable" },
|
||||
{ .function = Output_StepperEnableA, .name = "A enable" },
|
||||
{ .function = Output_StepperEnableB, .name = "B enable" },
|
||||
{ .function = Output_StepperEnableC, .name = "C enable" },
|
||||
{ .function = Output_StepperEnableXY, .name = "XY enable" },
|
||||
{ .function = Output_StepperEnableAB, .name = "AB enable" },
|
||||
{ .function = Output_MotorChipSelect, .name = "Motor CS" },
|
||||
{ .function = Output_MotorChipSelectX, .name = "Motor CSX" },
|
||||
{ .function = Output_MotorChipSelectY, .name = "Motor CSY" },
|
||||
{ .function = Output_MotorChipSelectZ, .name = "Motor CSZ" },
|
||||
{ .function = Output_MotorChipSelectM3, .name = "Motor CSM3" },
|
||||
{ .function = Output_MotorChipSelectM4, .name = "Motor CSM4" },
|
||||
{ .function = Output_MotorChipSelectM5, .name = "Motor CSM5" },
|
||||
{ .function = Output_SpindleOn, .name = "Spindle on" },
|
||||
{ .function = Output_SpindleDir, .name = "Spindle direction" },
|
||||
{ .function = Output_SpindlePWM, .name = "Spindle PWM" },
|
||||
{ .function = Output_CoolantMist, .name = "Mist" },
|
||||
{ .function = Output_CoolantFlood, .name = "Flood" },
|
||||
{ .function = Output_TX, .name = "TX" },
|
||||
{ .function = Output_SCK, .name = "SCK" },
|
||||
{ .function = Output_MOSI, .name = "MOSI" },
|
||||
{ .function = Output_SdCardCS, .name = "SD card CS" },
|
||||
{ .function = Output_Aux0, .name = "Aux out 0" },
|
||||
{ .function = Output_Aux1, .name = "Aux out 1" },
|
||||
{ .function = Output_Aux2, .name = "Aux out 2" },
|
||||
{ .function = Output_Aux3, .name = "Aux out 3" },
|
||||
{ .function = Output_Aux4, .name = "Aux out 4" },
|
||||
{ .function = Output_Aux5, .name = "Aux out 5" },
|
||||
{ .function = Output_Aux6, .name = "Aux out 6" },
|
||||
{ .function = Output_Aux7, .name = "Aux out 7" },
|
||||
{ .function = Bidirectional_SDA, .name = "SDA" },
|
||||
{ .function = Bidirectional_MotorUARTX, .name = "UART X" },
|
||||
{ .function = Bidirectional_MotorUARTY, .name = "UART Y" },
|
||||
{ .function = Bidirectional_MotorUARTZ, .name = "UART Z" },
|
||||
{ .function = Bidirectional_MotorUARTM3, .name = "UART M3" },
|
||||
{ .function = Bidirectional_MotorUARTM4, .name = "UART M4" },
|
||||
{ .function = Bidirectional_MotorUARTM5, .name = "UART M5" }
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
@@ -256,6 +268,7 @@ typedef enum {
|
||||
PinGroup_AuxOutput,
|
||||
PinGroup_SdCard,
|
||||
PinGroup_MotorChipSelect,
|
||||
PinGroup_MotorUART,
|
||||
PinGroup_I2C,
|
||||
PinGroup_SPI,
|
||||
PinGroup_UART,
|
||||
|
||||
@@ -102,8 +102,19 @@
|
||||
#ifndef SPINDLE_SYNC_ENABLE
|
||||
#define SPINDLE_SYNC_ENABLE 0
|
||||
#endif
|
||||
|
||||
#ifndef TRINAMIC_ENABLE
|
||||
#define TRINAMIC_ENABLE 0
|
||||
#define TRINAMIC_ENABLE 0
|
||||
#endif
|
||||
#if TRINAMIC_ENABLE == 2209
|
||||
#define TRINAMIC_UART_ENABLE 1
|
||||
#else
|
||||
#define TRINAMIC_UART_ENABLE 0
|
||||
#endif
|
||||
#if TRINAMIC_ENABLE == 2130 || TRINAMIC_ENABLE == 5160
|
||||
#define TRINAMIC_SPI_ENABLE 1
|
||||
#else
|
||||
#define TRINAMIC_SPI_ENABLE 0
|
||||
#endif
|
||||
#ifndef TRINAMIC_I2C
|
||||
#define TRINAMIC_I2C 0
|
||||
@@ -116,6 +127,7 @@
|
||||
#ifndef TRINAMIC_DEV
|
||||
#define TRINAMIC_DEV 0
|
||||
#endif
|
||||
|
||||
#ifndef PWM_RAMPED
|
||||
#define PWM_RAMPED 0
|
||||
#endif
|
||||
|
||||
10
errors.c
10
errors.c
@@ -97,9 +97,15 @@ static error_details_t details = {
|
||||
.n_errors = sizeof(status_detail) / sizeof(status_detail_t)
|
||||
};
|
||||
|
||||
static error_details_t *errors = &details;
|
||||
|
||||
void errors_register (error_details_t *details)
|
||||
{
|
||||
errors->next = details;
|
||||
errors = details;
|
||||
}
|
||||
|
||||
error_details_t *errors_get_details (void)
|
||||
{
|
||||
details.on_get_errors = grbl.on_get_errors;
|
||||
|
||||
return &details;
|
||||
}
|
||||
|
||||
4
errors.h
4
errors.h
@@ -114,12 +114,12 @@ typedef struct {
|
||||
typedef struct error_details {
|
||||
const uint16_t n_errors;
|
||||
const status_detail_t *errors;
|
||||
struct error_details *(*on_get_errors)(void);
|
||||
struct error_details *next;
|
||||
} error_details_t;
|
||||
|
||||
// NOTE: this must match the signature of on_get_alarms in the on_get_statuses struct above!
|
||||
typedef error_details_t *(*on_get_errors_ptr)(void);
|
||||
|
||||
error_details_t *errors_get_details (void);
|
||||
void errors_register (error_details_t *details);
|
||||
|
||||
#endif
|
||||
|
||||
2
grbl.h
2
grbl.h
@@ -34,7 +34,7 @@
|
||||
#else
|
||||
#define GRBL_VERSION "1.1f"
|
||||
#endif
|
||||
#define GRBL_BUILD 20211122
|
||||
#define GRBL_BUILD 20211125
|
||||
|
||||
// The following symbols are set here if not already set by the compiler or in config.h
|
||||
// Do NOT change here!
|
||||
|
||||
@@ -134,6 +134,9 @@ int grbl_enter (void)
|
||||
grbl.enqueue_realtime_command = stream_enqueue_realtime_command;
|
||||
grbl.on_report_options = dummy_bool_handler;
|
||||
grbl.on_report_command_help = system_command_help;
|
||||
grbl.on_get_alarms = alarms_get_details;
|
||||
grbl.on_get_errors = errors_get_details;
|
||||
grbl.on_get_settings = settings_get_details;
|
||||
|
||||
// Clear all and set some HAL function pointers
|
||||
memset(&hal, 0, sizeof(grbl_hal_t));
|
||||
|
||||
@@ -106,10 +106,14 @@ bool ioport_claim (io_port_type_t type, io_port_direction_t dir, uint8_t *port,
|
||||
} while(n_ports && !ok);
|
||||
|
||||
} else if((ok = n_ports > 0)) {
|
||||
|
||||
if(type == Port_Digital)
|
||||
*port = dir == Port_Input ? --hal.port.num_digital_in : --hal.port.num_digital_out;
|
||||
else
|
||||
*port = dir == Port_Input ? --hal.port.num_analog_in : --hal.port.num_analog_out;
|
||||
|
||||
if(hal.port.set_pin_description)
|
||||
hal.port.set_pin_description(type, dir, *port, description);
|
||||
}
|
||||
|
||||
return ok;
|
||||
|
||||
@@ -28,11 +28,23 @@
|
||||
trinamic_init();
|
||||
#endif
|
||||
|
||||
#if MODBUS_ENABLE
|
||||
extern void modbus_init (void);
|
||||
modbus_init();
|
||||
#endif
|
||||
|
||||
#if HUANYANG_ENABLE
|
||||
extern void huanyang_init (void);
|
||||
huanyang_init();
|
||||
#endif
|
||||
|
||||
#ifndef GRBL_ESP32 // ESP32 has its own bluetooth_init
|
||||
#if BLUETOOTH_ENABLE
|
||||
extern void bluetooth_init (void);
|
||||
bluetooth_init();
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if KEYPAD_ENABLE
|
||||
extern bool keypad_init (void);
|
||||
keypad_init();
|
||||
|
||||
50
protocol.c
50
protocol.c
@@ -80,6 +80,47 @@ bool protocol_enqueue_gcode (char *gcode)
|
||||
return ok;
|
||||
}
|
||||
|
||||
static bool recheck_line (char *line, line_flags_t *flags)
|
||||
{
|
||||
bool keep_rt_commands = false, first_char = true;
|
||||
|
||||
flags->value = 0;
|
||||
|
||||
if(*line != '\0') do {
|
||||
|
||||
switch(*line) {
|
||||
|
||||
case '$':
|
||||
case '[':
|
||||
if(first_char)
|
||||
keep_rt_commands = true;
|
||||
break;
|
||||
|
||||
case '(':
|
||||
if(!keep_rt_commands && (flags->comment_parentheses = !flags->comment_semicolon))
|
||||
keep_rt_commands = !hal.driver_cap.no_gcode_message_handling; // Suspend real-time processing of printable command characters.
|
||||
break;
|
||||
|
||||
case ')':
|
||||
if(!flags->comment_semicolon)
|
||||
flags->comment_parentheses = keep_rt_commands = false;
|
||||
break;
|
||||
|
||||
case ';':
|
||||
if(!flags->comment_parentheses) {
|
||||
keep_rt_commands = false;
|
||||
flags->comment_semicolon = On;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
first_char = false;
|
||||
|
||||
} while(*++line != '\0');
|
||||
|
||||
return keep_rt_commands;
|
||||
}
|
||||
|
||||
/*
|
||||
GRBL PRIMARY LOOP:
|
||||
*/
|
||||
@@ -259,6 +300,13 @@ bool protocol_main_loop (void)
|
||||
line_flags.comment_semicolon = On;
|
||||
}
|
||||
break;
|
||||
|
||||
case ASCII_DEL:
|
||||
if(char_counter) {
|
||||
line[--char_counter] = '\0';
|
||||
keep_rt_commands = recheck_line(line, &line_flags);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(!(line_flags.overflow = char_counter >= (LINE_BUFFER_SIZE - 1)))
|
||||
line[char_counter++] = c;
|
||||
@@ -816,7 +864,7 @@ ISR_CODE bool protocol_enqueue_realtime_command (char c)
|
||||
break;
|
||||
|
||||
default:
|
||||
if(c < ' ' || (c >= 0x7F && c <= 0xBF))
|
||||
if(c < ' ' || (c > ASCII_DEL && c <= 0xBF))
|
||||
drop = grbl.on_unknown_realtime_cmd == NULL || grbl.on_unknown_realtime_cmd(c);
|
||||
break;
|
||||
}
|
||||
|
||||
348
report.c
348
report.c
@@ -416,17 +416,10 @@ status_code_t report_help (char *args)
|
||||
|
||||
found = report_group_settings(settings_info->groups, settings_info->n_groups, args);
|
||||
|
||||
if(!found && grbl.on_get_settings) {
|
||||
|
||||
on_get_settings_ptr on_get_settings = grbl.on_get_settings;
|
||||
|
||||
while(on_get_settings) {
|
||||
settings_info = on_get_settings();
|
||||
if(settings_info->groups && (found = report_group_settings(settings_info->groups, settings_info->n_groups, args)))
|
||||
break;
|
||||
on_get_settings = settings_info->on_get_settings;
|
||||
}
|
||||
}
|
||||
if(!found && (settings_info = settings_info->next)) do {
|
||||
if(settings_info->groups && (found = report_group_settings(settings_info->groups, settings_info->n_groups, args)))
|
||||
break;
|
||||
} while((settings_info = settings_info->next));
|
||||
|
||||
if(!found)
|
||||
hal.stream.write( ASCII_EOL "N/A" ASCII_EOL);
|
||||
@@ -488,25 +481,22 @@ static bool print_setting (const setting_detail_t *setting, uint_fast16_t offset
|
||||
|
||||
void report_grbl_settings (bool all, void *data)
|
||||
{
|
||||
setting_details_t *details = settings_get_details();
|
||||
uint16_t n_settings = details->n_settings;
|
||||
uint_fast16_t idx, n_settings = 0;
|
||||
const setting_detail_t *setting;
|
||||
|
||||
while(details->on_get_settings) {
|
||||
details = details->on_get_settings();
|
||||
n_settings += details->n_settings;
|
||||
}
|
||||
|
||||
setting_detail_t **all_settings, **psetting;
|
||||
setting_details_t *details = settings_get_details();
|
||||
|
||||
if((all_settings = calloc(n_settings, sizeof(setting_detail_t *)))) {
|
||||
do {
|
||||
n_settings += details->n_settings;
|
||||
} while((details = details->next));
|
||||
|
||||
uint_fast16_t idx;
|
||||
details = settings_get_details();
|
||||
|
||||
if((all_settings = psetting = calloc(n_settings, sizeof(setting_detail_t *)))) {
|
||||
|
||||
details = settings_get_details();
|
||||
psetting = all_settings;
|
||||
n_settings = 0;
|
||||
|
||||
// Report core settings
|
||||
for(idx = 0; idx < details->n_settings; idx++) {
|
||||
setting = &details->settings[idx];
|
||||
if((all || setting->type == Setting_IsLegacy || setting->type == Setting_IsLegacyFn) &&
|
||||
@@ -516,8 +506,8 @@ void report_grbl_settings (bool all, void *data)
|
||||
}
|
||||
}
|
||||
|
||||
if(all) while(details->on_get_settings) {
|
||||
details = details->on_get_settings();
|
||||
// Report driver and plugin settings
|
||||
if(all && (details = details->next)) do {
|
||||
for(idx = 0; idx < details->n_settings; idx++) {
|
||||
setting = &details->settings[idx];
|
||||
if(setting->is_available == NULL ||setting->is_available(setting)) {
|
||||
@@ -525,7 +515,7 @@ void report_grbl_settings (bool all, void *data)
|
||||
n_settings++;
|
||||
}
|
||||
}
|
||||
}
|
||||
} while((details = details->next));
|
||||
|
||||
qsort(all_settings, n_settings, sizeof(setting_detail_t *), cmp_settings);
|
||||
|
||||
@@ -533,7 +523,11 @@ void report_grbl_settings (bool all, void *data)
|
||||
settings_iterator(all_settings[idx], print_setting, data);
|
||||
|
||||
free(all_settings);
|
||||
}
|
||||
|
||||
} else do {
|
||||
for(idx = 0; idx < n_settings; idx++)
|
||||
settings_iterator(&details->settings[idx], print_setting, data);
|
||||
} while((details = details->next));
|
||||
}
|
||||
|
||||
|
||||
@@ -1684,72 +1678,6 @@ static bool print_sorted (const setting_detail_t *setting, uint_fast16_t offset,
|
||||
return true;
|
||||
}
|
||||
|
||||
static status_code_t sort_settings_details (settings_format_t format, setting_group_t group)
|
||||
{
|
||||
bool reported = group == Group_All;
|
||||
|
||||
setting_details_t *details = settings_get_details();
|
||||
uint16_t n_settings = details->n_settings;
|
||||
const setting_detail_t *setting;
|
||||
report_args_t args;
|
||||
|
||||
args.group = settings_normalize_group(group);
|
||||
args.offset = group - args.group;
|
||||
args.format = format;
|
||||
|
||||
while(details->on_get_settings) {
|
||||
details = details->on_get_settings();
|
||||
n_settings += details->n_settings;
|
||||
}
|
||||
|
||||
setting_detail_t **all_settings, **psetting;
|
||||
|
||||
if((all_settings = calloc(n_settings, sizeof(setting_detail_t *)))) {
|
||||
|
||||
uint_fast16_t idx;
|
||||
|
||||
details = settings_get_details();
|
||||
|
||||
psetting = all_settings;
|
||||
n_settings = 0;
|
||||
|
||||
for(idx = 0; idx < details->n_settings; idx++) {
|
||||
setting = &details->settings[idx];
|
||||
if((group == Group_All || setting->group == args.group) && (setting->is_available == NULL ||setting->is_available(setting))) {
|
||||
*psetting++ = (setting_detail_t *)setting;
|
||||
n_settings++;
|
||||
}
|
||||
}
|
||||
|
||||
while(details->on_get_settings) {
|
||||
details = details->on_get_settings();
|
||||
for(idx = 0; idx < details->n_settings; idx++) {
|
||||
setting = &details->settings[idx];
|
||||
if((group == Group_All || setting->group == args.group) && (setting->is_available == NULL ||setting->is_available(setting))) {
|
||||
*psetting++ = (setting_detail_t *)setting;
|
||||
n_settings++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
qsort(all_settings, n_settings, sizeof(setting_detail_t *), cmp_settings);
|
||||
|
||||
if(format == SettingsFormat_Grbl)
|
||||
hal.stream.write("\"$-Code\",\" Setting\",\" Units\",\" Setting Description\"" ASCII_EOL);
|
||||
else if(format == SettingsFormat_grblHAL)
|
||||
hal.stream.write("$-Code\tSetting\tUnits\tDatatype\tData format\tSetting Description\tMin\tMax" ASCII_EOL);
|
||||
|
||||
for(idx = 0; idx < n_settings; idx++) {
|
||||
if(settings_iterator(all_settings[idx], print_sorted, &args))
|
||||
reported = true;
|
||||
}
|
||||
|
||||
free(all_settings);
|
||||
}
|
||||
|
||||
return all_settings == NULL ? Status_Unhandled : (reported ? Status_OK : Status_SettingDisabled);
|
||||
}
|
||||
|
||||
static bool print_unsorted (const setting_detail_t *setting, uint_fast16_t offset, void *args)
|
||||
{
|
||||
if(!(((report_args_t *)args)->group == setting->group && ((report_args_t *)args)->offset != offset) &&
|
||||
@@ -1759,43 +1687,70 @@ static bool print_unsorted (const setting_detail_t *setting, uint_fast16_t offse
|
||||
return true;
|
||||
}
|
||||
|
||||
static status_code_t print_settings_details (settings_format_t format, setting_group_t group, uint_fast16_t axis_rpt)
|
||||
static status_code_t print_settings_details (settings_format_t format, setting_group_t group)
|
||||
{
|
||||
status_code_t status;
|
||||
|
||||
if((status = sort_settings_details(format, group)) != Status_Unhandled)
|
||||
return status;
|
||||
|
||||
uint_fast16_t idx, n_settings = 0;
|
||||
bool reported = group == Group_All;
|
||||
uint_fast16_t idx;
|
||||
const setting_detail_t *setting;
|
||||
setting_details_t *settings = settings_get_details();
|
||||
report_args_t args;
|
||||
setting_detail_t **all_settings, **psetting;
|
||||
setting_details_t *details = settings_get_details();
|
||||
|
||||
args.group = settings_normalize_group(group);
|
||||
args.offset = group - args.group;
|
||||
args.format = format;
|
||||
|
||||
do {
|
||||
for(idx = 0; idx < settings->n_settings; idx++) {
|
||||
n_settings += details->n_settings;
|
||||
} while((details = details->next));
|
||||
|
||||
setting = &settings->settings[idx];
|
||||
if(format == SettingsFormat_Grbl)
|
||||
hal.stream.write("\"$-Code\",\" Setting\",\" Units\",\" Setting Description\"" ASCII_EOL);
|
||||
else if(format == SettingsFormat_grblHAL)
|
||||
hal.stream.write("$-Code\tSetting\tUnits\tDatatype\tData format\tSetting Description\tMin\tMax" ASCII_EOL);
|
||||
|
||||
details = settings_get_details();
|
||||
|
||||
if((all_settings = psetting = calloc(n_settings, sizeof(setting_detail_t *)))) {
|
||||
|
||||
n_settings = 0;
|
||||
|
||||
do {
|
||||
for(idx = 0; idx < details->n_settings; idx++) {
|
||||
setting = &details->settings[idx];
|
||||
if((group == Group_All || setting->group == args.group) && (setting->is_available == NULL || setting->is_available(setting))) {
|
||||
*psetting++ = (setting_detail_t *)setting;
|
||||
n_settings++;
|
||||
}
|
||||
}
|
||||
} while((details = details->next));
|
||||
|
||||
qsort(all_settings, n_settings, sizeof(setting_detail_t *), cmp_settings);
|
||||
|
||||
for(idx = 0; idx < n_settings; idx++) {
|
||||
if(settings_iterator(all_settings[idx], print_sorted, &args))
|
||||
reported = true;
|
||||
}
|
||||
|
||||
free(all_settings);
|
||||
|
||||
} else do {
|
||||
for(idx = 0; idx < details->n_settings; idx++) {
|
||||
|
||||
setting = &details->settings[idx];
|
||||
|
||||
if(group == Group_All || setting->group == args.group) {
|
||||
if(settings_iterator(setting, print_unsorted, &args))
|
||||
reported = true;
|
||||
}
|
||||
}
|
||||
settings = settings->on_get_settings ? settings->on_get_settings() : NULL;
|
||||
} while(settings);
|
||||
} while((details = details->next));
|
||||
|
||||
return reported ? Status_OK : Status_SettingDisabled;
|
||||
}
|
||||
|
||||
status_code_t report_settings_details (settings_format_t format, setting_id_t id, setting_group_t group)
|
||||
{
|
||||
uint_fast16_t axis_rpt = 0;
|
||||
|
||||
if(id != Setting_SettingsAll) {
|
||||
status_code_t status = Status_OK;
|
||||
|
||||
@@ -1809,7 +1764,7 @@ status_code_t report_settings_details (settings_format_t format, setting_id_t id
|
||||
return status;
|
||||
}
|
||||
|
||||
return print_settings_details(format, group, axis_rpt);
|
||||
return print_settings_details(format, group);
|
||||
}
|
||||
|
||||
#ifndef NO_SETTINGS_DESCRIPTIONS
|
||||
@@ -1834,76 +1789,122 @@ status_code_t report_setting_description (settings_format_t format, setting_id_t
|
||||
|
||||
#endif
|
||||
|
||||
static int cmp_alarms (const void *a, const void *b)
|
||||
{
|
||||
return (*(alarm_detail_t **)(a))->id - (*(alarm_detail_t **)(b))->id;
|
||||
}
|
||||
|
||||
static void print_alarm (const alarm_detail_t *alarm, bool grbl_format)
|
||||
{
|
||||
if(grbl_format) {
|
||||
write_quoted(uitoa(alarm->id), ",");
|
||||
write_quoted("N/A", ",");
|
||||
write_quoted(alarm->description ? alarm->description : "", NULL);
|
||||
hal.stream.write(ASCII_EOL);
|
||||
} else {
|
||||
hal.stream.write("[ALARMCODE:");
|
||||
hal.stream.write(uitoa(alarm->id));
|
||||
hal.stream.write(vbar);
|
||||
hal.stream.write(vbar);
|
||||
if(alarm->description)
|
||||
hal.stream.write(alarm->description);
|
||||
hal.stream.write("]" ASCII_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
status_code_t report_alarm_details (bool grbl_format)
|
||||
{
|
||||
uint_fast16_t idx;
|
||||
alarm_details_t *list = alarms_get_details();
|
||||
uint_fast16_t idx, n_alarms = 0;
|
||||
alarm_details_t *details = grbl.on_get_alarms();
|
||||
alarm_detail_t **all_alarms, **palarm;
|
||||
|
||||
if(grbl_format)
|
||||
hal.stream.write("\"Alarm Code in v1.1+\",\" Alarm Message in v1.0-\",\" Alarm Description\"" ASCII_EOL);
|
||||
|
||||
do { // TODO: add sorting?
|
||||
do {
|
||||
n_alarms += details->n_alarms;
|
||||
} while((details = details->next));
|
||||
|
||||
for(idx = 0; idx < list->n_alarms; idx++) {
|
||||
details = grbl.on_get_alarms();
|
||||
|
||||
if(grbl_format) {
|
||||
write_quoted(uitoa(list->alarms[idx].id), ",");
|
||||
write_quoted("N/A", ",");
|
||||
// write_quoted(list->alarms[idx].name, ",");
|
||||
write_quoted(list->alarms[idx].description ? list->alarms[idx].description : "", NULL);
|
||||
hal.stream.write(ASCII_EOL);
|
||||
} else {
|
||||
hal.stream.write("[ALARMCODE:");
|
||||
hal.stream.write(uitoa(list->alarms[idx].id));
|
||||
hal.stream.write(vbar);
|
||||
// hal.stream.write(list->alarms[idx].name);
|
||||
hal.stream.write(vbar);
|
||||
if(list->alarms[idx].description)
|
||||
hal.stream.write(list->alarms[idx].description);
|
||||
hal.stream.write("]" ASCII_EOL);
|
||||
}
|
||||
}
|
||||
if((all_alarms = palarm = calloc(n_alarms, sizeof(alarm_detail_t *)))) {
|
||||
|
||||
list = list->on_get_alarms ? list->on_get_alarms() : NULL;
|
||||
do {
|
||||
for(idx = 0; idx < details->n_alarms; idx++)
|
||||
*palarm++ = (alarm_detail_t *)&(details->alarms[idx]);
|
||||
} while((details = details->next));
|
||||
|
||||
} while(list);
|
||||
qsort(all_alarms, n_alarms, sizeof(alarm_detail_t *), cmp_alarms);
|
||||
|
||||
for(idx = 0; idx < n_alarms; idx++)
|
||||
print_alarm(all_alarms[idx], grbl_format);
|
||||
|
||||
free(all_alarms);
|
||||
|
||||
} else do {
|
||||
for(idx = 0; idx < details->n_alarms; idx++)
|
||||
print_alarm(&details->alarms[idx], grbl_format);
|
||||
} while((details = details->next));
|
||||
|
||||
return Status_OK;
|
||||
}
|
||||
|
||||
static int cmp_errors (const void *a, const void *b)
|
||||
{
|
||||
return (*(status_detail_t **)(a))->id - (*(status_detail_t **)(b))->id;
|
||||
}
|
||||
|
||||
static void print_error (const status_detail_t *error, bool grbl_format)
|
||||
{
|
||||
if(grbl_format) {
|
||||
write_quoted(uitoa(error->id), ",");
|
||||
write_quoted("N/A", ",");
|
||||
write_quoted(error->description ? error->description : "", NULL);
|
||||
hal.stream.write(ASCII_EOL);
|
||||
} else {
|
||||
hal.stream.write("[ERRORCODE:");
|
||||
hal.stream.write(uitoa(error->id));
|
||||
hal.stream.write(vbar);
|
||||
hal.stream.write(vbar);
|
||||
if(error->description)
|
||||
hal.stream.write(error->description);
|
||||
hal.stream.write("]" ASCII_EOL);
|
||||
}
|
||||
}
|
||||
|
||||
status_code_t report_error_details (bool grbl_format)
|
||||
{
|
||||
uint_fast16_t idx;
|
||||
error_details_t *list = errors_get_details();
|
||||
uint_fast16_t idx, n_errors = 0;
|
||||
error_details_t *details = grbl.on_get_errors();
|
||||
status_detail_t **all_errors, **perror;
|
||||
|
||||
if(grbl_format)
|
||||
hal.stream.write("\"Error Code in v1.1+\",\"Error Message in v1.0-\",\"Error Description\"" ASCII_EOL);
|
||||
|
||||
do { // TODO: add sorting?
|
||||
do {
|
||||
n_errors += details->n_errors;
|
||||
} while((details = details->next));
|
||||
|
||||
for(idx = 0; idx < list->n_errors; idx++) {
|
||||
details = grbl.on_get_errors();
|
||||
|
||||
if(grbl_format) {
|
||||
write_quoted(uitoa(list->errors[idx].id), ",");
|
||||
write_quoted("N/A", ",");
|
||||
// write_quoted(list->errors[idx].name, ",");
|
||||
write_quoted(list->errors[idx].description ? list->errors[idx].description : "", NULL);
|
||||
hal.stream.write(ASCII_EOL);
|
||||
} else {
|
||||
hal.stream.write("[ERRORCODE:");
|
||||
hal.stream.write(uitoa(list->errors[idx].id));
|
||||
hal.stream.write(vbar);
|
||||
// hal.stream.write(list->errors[idx].name);
|
||||
hal.stream.write(vbar);
|
||||
if(list->errors[idx].description)
|
||||
hal.stream.write(list->errors[idx].description);
|
||||
hal.stream.write("]" ASCII_EOL);
|
||||
}
|
||||
}
|
||||
if((all_errors = perror = calloc(n_errors, sizeof(status_detail_t *)))) {
|
||||
|
||||
list = list->on_get_errors ? list->on_get_errors() : NULL;
|
||||
do {
|
||||
for(idx = 0; idx < details->n_errors; idx++)
|
||||
*perror++ = (status_detail_t *)&(details->errors[idx]);
|
||||
} while((details = details->next));
|
||||
|
||||
} while(list);
|
||||
qsort(all_errors, n_errors, sizeof(status_detail_t *), cmp_errors);
|
||||
|
||||
for(idx = 0; idx < n_errors; idx++)
|
||||
print_error(all_errors[idx], grbl_format);
|
||||
|
||||
free(all_errors);
|
||||
|
||||
} else do {
|
||||
for(idx = 0; idx < details->n_errors; idx++)
|
||||
print_error(&details->errors[idx], grbl_format);
|
||||
} while((details = details->next));
|
||||
|
||||
return Status_OK;
|
||||
}
|
||||
@@ -1937,30 +1938,28 @@ static int cmp_setting_group_name (const void *a, const void *b)
|
||||
return strcmp((*(setting_detail_t **)(a))->name, (*(setting_detail_t **)(b))->name);
|
||||
}
|
||||
|
||||
static status_code_t sort_setting_group_details (bool by_id, char *prefix)
|
||||
status_code_t report_setting_group_details (bool by_id, char *prefix)
|
||||
{
|
||||
uint_fast16_t idx, n_groups = 0;
|
||||
setting_details_t *details = settings_get_details();
|
||||
uint8_t n_groups = details->n_groups;
|
||||
|
||||
while(details->on_get_settings) {
|
||||
details = details->on_get_settings();
|
||||
n_groups += details->n_groups;
|
||||
}
|
||||
|
||||
setting_group_detail_t **all_groups, **group;
|
||||
|
||||
if((all_groups = calloc(n_groups, sizeof(setting_group_detail_t *)))) {
|
||||
do {
|
||||
n_groups += details->n_groups;
|
||||
} while((details = details->next));
|
||||
|
||||
details = settings_get_details();
|
||||
|
||||
if((all_groups = group = calloc(n_groups, sizeof(setting_group_detail_t *)))) {
|
||||
|
||||
uint_fast16_t idx;
|
||||
|
||||
group = all_groups;
|
||||
details = settings_get_details();
|
||||
|
||||
do {
|
||||
for(idx = 0; idx < details->n_groups; idx++)
|
||||
*group++ = (setting_group_detail_t *)&details->groups[idx];
|
||||
details = details->on_get_settings ? details->on_get_settings() : NULL;
|
||||
} while(details);
|
||||
} while((details = details->next));
|
||||
|
||||
qsort(all_groups, n_groups, sizeof(setting_group_detail_t *), by_id ? cmp_setting_group_id : cmp_setting_group_name);
|
||||
|
||||
@@ -1968,24 +1967,11 @@ static status_code_t sort_setting_group_details (bool by_id, char *prefix)
|
||||
print_setting_group(all_groups[idx], prefix);
|
||||
|
||||
free(all_groups);
|
||||
}
|
||||
|
||||
return all_groups == NULL ? Status_Unhandled : Status_OK;
|
||||
}
|
||||
|
||||
status_code_t report_setting_group_details (bool by_id, char *prefix)
|
||||
{
|
||||
if(sort_setting_group_details(by_id, prefix) != Status_Unhandled)
|
||||
return Status_OK;
|
||||
|
||||
uint_fast16_t idx;
|
||||
setting_details_t *details = settings_get_details();
|
||||
|
||||
do {
|
||||
} else do {
|
||||
for(idx = 0; idx < details->n_groups; idx++)
|
||||
print_setting_group(&details->groups[idx], prefix);
|
||||
details = details->on_get_settings ? details->on_get_settings() : NULL;
|
||||
} while(details);
|
||||
} while((details = details->next));
|
||||
|
||||
return Status_OK;
|
||||
}
|
||||
|
||||
87
settings.c
87
settings.c
@@ -387,10 +387,10 @@ PROGMEM static const setting_detail_t setting_detail[] = {
|
||||
#else
|
||||
{ Setting_LimitPinsInvertMask, Group_Limits, "Invert limit pins", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsLegacyFn, set_limits_invert_mask, get_int, NULL },
|
||||
#endif
|
||||
{ Setting_InvertProbePin, Group_Probing, "Invert probe pin", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsLegacyFn, set_probe_invert, get_int, NULL },
|
||||
{ Setting_InvertProbePin, Group_Probing, "Invert probe pin", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsLegacyFn, set_probe_invert, get_int, is_setting_available },
|
||||
{ Setting_SpindlePWMBehaviour, Group_Spindle, "Disable spindle with zero speed", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtended, &settings.spindle.flags.mask, NULL, is_setting_available },
|
||||
// { Setting_SpindlePWMBehaviour, Group_Spindle, "Spindle enable vs. speed behaviour", NULL, Format_RadioButtons, "No action,Disable spindle with zero speed,Enable spindle with all speeds", NULL, NULL, Setting_IsExtended, &settings.spindle.flags.mask, NULL, NULL },
|
||||
{ Setting_GangedDirInvertMask, Group_Stepper, "Ganged axes direction invert", NULL, Format_Bitfield, ganged_axes, NULL, NULL, Setting_IsExtendedFn, set_ganged_dir_invert, get_int, NULL },
|
||||
{ Setting_GangedDirInvertMask, Group_Stepper, "Ganged axes direction invert", NULL, Format_Bitfield, ganged_axes, NULL, NULL, Setting_IsExtendedFn, set_ganged_dir_invert, get_int, is_setting_available },
|
||||
#if COMPATIBILITY_LEVEL <= 1
|
||||
{ Setting_StatusReportMask, Group_General, "Status report options", NULL, Format_Bitfield, "Position in machine coordinate,Buffer state,Line numbers,Feed & speed,Pin state,Work coordinate offset,Overrides,Probe coordinates,Buffer sync on WCO change,Parser state,Alarm substatus,Run substatus", NULL, NULL, Setting_IsExtendedFn, set_report_mask, get_int, NULL },
|
||||
#else
|
||||
@@ -404,7 +404,7 @@ PROGMEM static const setting_detail_t setting_detail[] = {
|
||||
{ Setting_SpindleInvertMask, Group_Spindle, "Invert spindle signals", NULL, Format_Bitfield, spindle_signals, NULL, NULL, Setting_IsExtendedFn, set_spindle_invert, get_int, NULL },
|
||||
{ Setting_ControlPullUpDisableMask, Group_ControlSignals, "Pullup disable control pins", NULL, Format_Bitfield, control_signals, NULL, NULL, Setting_IsExtendedFn, set_control_disable_pullup, get_int, NULL },
|
||||
{ Setting_LimitPullUpDisableMask, Group_Limits, "Pullup disable limit pins", NULL, Format_AxisMask, NULL, NULL, NULL, Setting_IsExtended, &settings.limits.disable_pullup.mask, NULL, NULL },
|
||||
{ Setting_ProbePullUpDisable, Group_Probing, "Pullup disable probe pin", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_probe_disable_pullup, get_int, NULL },
|
||||
{ Setting_ProbePullUpDisable, Group_Probing, "Pullup disable probe pin", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_probe_disable_pullup, get_int, is_setting_available },
|
||||
{ Setting_SoftLimitsEnable, Group_Limits, "Soft limits enable", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsLegacyFn, set_soft_limits_enable, get_int, NULL },
|
||||
#if COMPATIBILITY_LEVEL <= 1
|
||||
{ Setting_HardLimitsEnable, Group_Limits, "Hard limits enable", NULL, Format_XBitfield, "Enable,Strict mode", NULL, NULL, Setting_IsExpandedFn, set_hard_limits_enable, get_int, NULL },
|
||||
@@ -462,22 +462,22 @@ PROGMEM static const setting_detail_t setting_detail[] = {
|
||||
{ Setting_SleepEnable, Group_General, "Sleep enable", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_sleep_enable, get_int, NULL },
|
||||
{ Setting_HoldActions, Group_General, "Feed hold actions", NULL, Format_Bitfield, "Disable laser during hold,Restore spindle and coolant state on resume", NULL, NULL, Setting_IsExtendedFn, set_hold_actions, get_int, NULL },
|
||||
{ Setting_ForceInitAlarm, Group_General, "Force init alarm", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_force_initialization_alarm, get_int, NULL },
|
||||
{ Setting_ProbingFeedOverride, Group_Probing, "Probing feed override", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_probe_allow_feed_override, get_int, NULL },
|
||||
{ Setting_ProbingFeedOverride, Group_Probing, "Probing feed override", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_probe_allow_feed_override, get_int, is_setting_available },
|
||||
#ifdef ENABLE_SPINDLE_LINEARIZATION
|
||||
{ Setting_LinearSpindlePiece1, Group_Spindle, "Spindle linearisation, first point", NULL, Format_String, "x30", NULL, "30", Setting_IsExtendedFn, set_linear_piece, get_linear_piece, NULL },
|
||||
{ Setting_LinearSpindlePiece2, Group_Spindle, "Spindle linearisation, second point", NULL, Format_String, "x30", NULL, "30", Setting_IsExtendedFn, set_linear_piece, get_linear_piece, NULL },
|
||||
{ Setting_LinearSpindlePiece3, Group_Spindle, "Spindle linearisation, third point", NULL, Format_String, "x30", NULL, "30", Setting_IsExtendedFn, set_linear_piece, get_linear_piece, NULL },
|
||||
{ Setting_LinearSpindlePiece4, Group_Spindle, "Spindle linearisation, fourth point", NULL, Format_String, "x30", NULL, "30", Setting_IsExtendedFn, set_linear_piece, get_linear_piece, NULL },
|
||||
#endif
|
||||
{ Setting_SpindlePGain, Group_Spindle_ClosedLoop, "Spindle P-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.spindle.pid.p_gain, NULL, NULL },
|
||||
{ Setting_SpindleIGain, Group_Spindle_ClosedLoop, "Spindle I-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.spindle.pid.i_gain, NULL, NULL },
|
||||
{ Setting_SpindleDGain, Group_Spindle_ClosedLoop, "Spindle D-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.spindle.pid.d_gain, NULL, NULL },
|
||||
{ Setting_SpindleMaxError, Group_Spindle_ClosedLoop, "Spindle PID max error", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.spindle.pid.max_error, NULL, NULL },
|
||||
{ Setting_SpindleIMaxError, Group_Spindle_ClosedLoop, "Spindle PID max I error", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.spindle.pid.i_max_error, NULL, NULL },
|
||||
{ Setting_PositionPGain, Group_Spindle_Sync, "Spindle sync P-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.position.pid.p_gain, NULL, NULL },
|
||||
{ Setting_PositionIGain, Group_Spindle_Sync, "Spindle sync I-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.position.pid.i_gain, NULL, NULL },
|
||||
{ Setting_PositionDGain, Group_Spindle_Sync, "Spindle sync D-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.position.pid.d_gain, NULL, NULL },
|
||||
{ Setting_PositionIMaxError, Group_Spindle_Sync, "Spindle sync PID max I error", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.position.pid.i_max_error, NULL, NULL },
|
||||
{ Setting_SpindlePGain, Group_Spindle_ClosedLoop, "Spindle P-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.spindle.pid.p_gain, NULL, is_setting_available },
|
||||
{ Setting_SpindleIGain, Group_Spindle_ClosedLoop, "Spindle I-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.spindle.pid.i_gain, NULL, is_setting_available },
|
||||
{ Setting_SpindleDGain, Group_Spindle_ClosedLoop, "Spindle D-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.spindle.pid.d_gain, NULL, is_setting_available },
|
||||
{ Setting_SpindleMaxError, Group_Spindle_ClosedLoop, "Spindle PID max error", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.spindle.pid.max_error, NULL, is_setting_available },
|
||||
{ Setting_SpindleIMaxError, Group_Spindle_ClosedLoop, "Spindle PID max I error", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.spindle.pid.i_max_error, NULL, is_setting_available },
|
||||
{ Setting_PositionPGain, Group_Spindle_Sync, "Spindle sync P-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.position.pid.p_gain, NULL, is_setting_available },
|
||||
{ Setting_PositionIGain, Group_Spindle_Sync, "Spindle sync I-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.position.pid.i_gain, NULL, is_setting_available },
|
||||
{ Setting_PositionDGain, Group_Spindle_Sync, "Spindle sync D-gain", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.position.pid.d_gain, NULL, is_setting_available },
|
||||
{ Setting_PositionIMaxError, Group_Spindle_Sync, "Spindle sync PID max I error", NULL, Format_Decimal, "###0.000", NULL, NULL, Setting_IsExtended, &settings.position.pid.i_max_error, NULL, is_setting_available },
|
||||
{ Setting_AxisStepsPerMM, Group_Axis0, "?-axis travel resolution", "step/mm", Format_Decimal, "#####0.000", NULL, NULL, Setting_IsLegacyFn, set_axis_setting, get_float, NULL },
|
||||
{ Setting_AxisMaxRate, Group_Axis0, "?-axis maximum rate", "mm/min", Format_Decimal, "#####0.000", NULL, NULL, Setting_IsLegacyFn, set_axis_setting, get_float, NULL },
|
||||
{ Setting_AxisAcceleration, Group_Axis0, "?-axis acceleration", "mm/sec^2", Format_Decimal, "#####0.000", NULL, NULL, Setting_IsLegacyFn, set_axis_setting, get_float, NULL },
|
||||
@@ -492,9 +492,9 @@ PROGMEM static const setting_detail_t setting_detail[] = {
|
||||
{ Setting_ToolChangeFeedRate, Group_Toolchange, "Tool change locate feed rate", "mm/min", Format_Decimal, "#####0.0", NULL, NULL, Setting_IsExtended, &settings.tool_change.feed_rate, NULL, NULL },
|
||||
{ Setting_ToolChangeSeekRate, Group_Toolchange, "Tool change search seek rate", "mm/min", Format_Decimal, "#####0.0", NULL, NULL, Setting_IsExtended, &settings.tool_change.seek_rate, NULL, NULL },
|
||||
{ Setting_ToolChangePulloffRate, Group_Toolchange, "Tool change probe pull-off rate", "mm/min", Format_Decimal, "#####0.0", NULL, NULL, Setting_IsExtended, &settings.tool_change.pulloff_rate, NULL, NULL },
|
||||
{ Setting_DualAxisLengthFailPercent, Group_Limits_DualAxis, "Dual axis length fail", "percent", Format_Decimal, "##0.0", "0", "100", Setting_IsExtended, &settings.homing.dual_axis.fail_length_percent, NULL, NULL },
|
||||
{ Setting_DualAxisLengthFailMin, Group_Limits_DualAxis, "Dual axis length fail min", "mm", Format_Decimal, "#####0.000", NULL, NULL, Setting_IsExtended, &settings.homing.dual_axis.fail_distance_min, NULL, NULL },
|
||||
{ Setting_DualAxisLengthFailMax, Group_Limits_DualAxis, "Dual axis length fail max", "mm", Format_Decimal, "#####0.000", NULL, NULL, Setting_IsExtended, &settings.homing.dual_axis.fail_distance_max, NULL, NULL },
|
||||
{ Setting_DualAxisLengthFailPercent, Group_Limits_DualAxis, "Dual axis length fail", "percent", Format_Decimal, "##0.0", "0", "100", Setting_IsExtended, &settings.homing.dual_axis.fail_length_percent, NULL, is_setting_available },
|
||||
{ Setting_DualAxisLengthFailMin, Group_Limits_DualAxis, "Dual axis length fail min", "mm", Format_Decimal, "#####0.000", NULL, NULL, Setting_IsExtended, &settings.homing.dual_axis.fail_distance_min, NULL, is_setting_available },
|
||||
{ Setting_DualAxisLengthFailMax, Group_Limits_DualAxis, "Dual axis length fail max", "mm", Format_Decimal, "#####0.000", NULL, NULL, Setting_IsExtended, &settings.homing.dual_axis.fail_distance_max, NULL, is_setting_available },
|
||||
#if COMPATIBILITY_LEVEL <= 1
|
||||
{ Setting_DisableG92Persistence, Group_General, "Disable G92 persistence", NULL, Format_Bool, NULL, NULL, NULL, Setting_IsExtendedFn, set_g92_disable_persistence, get_int, NULL },
|
||||
#endif
|
||||
@@ -650,7 +650,7 @@ PROGMEM static const setting_descr_t setting_descr[] = {
|
||||
|
||||
#endif
|
||||
|
||||
static setting_details_t details = {
|
||||
static setting_details_t setting_details = {
|
||||
.groups = setting_group_detail,
|
||||
.n_groups = sizeof(setting_group_detail) / sizeof(setting_group_detail_t),
|
||||
.settings = setting_detail,
|
||||
@@ -714,11 +714,17 @@ bool settings_override_acceleration (uint8_t axis, float acceleration)
|
||||
|
||||
// ---
|
||||
|
||||
static setting_details_t *settingsd = &setting_details;
|
||||
|
||||
void settings_register (setting_details_t *details)
|
||||
{
|
||||
settingsd->next = details;
|
||||
settingsd = details;
|
||||
}
|
||||
|
||||
setting_details_t *settings_get_details (void)
|
||||
{
|
||||
details.on_get_settings = grbl.on_get_settings;
|
||||
|
||||
return &details;
|
||||
return &setting_details;
|
||||
}
|
||||
|
||||
#if COMPATIBILITY_LEVEL > 1
|
||||
@@ -1386,6 +1392,15 @@ static bool is_setting_available (const setting_detail_t *setting)
|
||||
available = hal.driver_cap.variable_spindle;
|
||||
break;
|
||||
|
||||
case Setting_InvertProbePin:
|
||||
case Setting_ProbePullUpDisable:
|
||||
case Setting_ProbingFeedOverride:
|
||||
// case Setting_ToolChangeProbingDistance:
|
||||
// case Setting_ToolChangeFeedRate:
|
||||
// case Setting_ToolChangeSeekRate:
|
||||
available = hal.probe.get_state != NULL;
|
||||
break;
|
||||
|
||||
case Setting_SpindlePPR:
|
||||
available = hal.driver_cap.spindle_sync || hal.driver_cap.spindle_pid;
|
||||
break;
|
||||
@@ -1403,6 +1418,9 @@ static bool is_setting_available (const setting_detail_t *setting)
|
||||
available = hal.driver_cap.variable_spindle;
|
||||
break;
|
||||
|
||||
case Setting_DualAxisLengthFailPercent:
|
||||
case Setting_DualAxisLengthFailMin:
|
||||
case Setting_DualAxisLengthFailMax:
|
||||
case Setting_AxisAutoSquareOffset:
|
||||
available = hal.stepper.get_ganged && hal.stepper.get_ganged(true).mask != 0;
|
||||
// available = hal.stepper.get_ganged && bit_istrue(hal.stepper.get_ganged(true).mask, setting->id - Setting_AxisAutoSquareOffset);
|
||||
@@ -1599,13 +1617,12 @@ void settings_restore (settings_restore_t restore)
|
||||
settings_write_build_info(BUILD_INFO);
|
||||
}
|
||||
|
||||
setting_details_t *details = settings_get_details();
|
||||
setting_details_t *details = setting_details.next;
|
||||
|
||||
while(details->on_get_settings) {
|
||||
details = details->on_get_settings();
|
||||
if(details) do {
|
||||
if(details->restore)
|
||||
details->restore();
|
||||
};
|
||||
} while((details = details->next));
|
||||
|
||||
nvs_buffer_sync_physical();
|
||||
}
|
||||
@@ -1677,14 +1694,11 @@ bool settings_is_group_available (setting_group_t group)
|
||||
do {
|
||||
if(details->settings) {
|
||||
for(idx = 0; idx < details->n_settings; idx++) {
|
||||
if(details->settings[idx].group == group && is_available(&details->settings[idx])) {
|
||||
available = true;
|
||||
if(details->settings[idx].group == group && (available = is_available(&details->settings[idx])))
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
details = !available && details->on_get_settings ? details->on_get_settings() : NULL;
|
||||
} while(details);
|
||||
} while(!available && (details = details->next));
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -1785,8 +1799,7 @@ const setting_detail_t *setting_get_details (setting_id_t id, setting_details_t
|
||||
return &details->settings[idx];
|
||||
}
|
||||
}
|
||||
details = details->on_get_settings ? details->on_get_settings() : NULL;
|
||||
} while(details);
|
||||
} while((details = details->next));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
@@ -1809,8 +1822,7 @@ const char *setting_get_description (setting_id_t id)
|
||||
description = settings->descriptions[idx].description;
|
||||
} while(idx && description == NULL);
|
||||
}
|
||||
settings = settings->on_get_settings ? settings->on_get_settings() : NULL;
|
||||
} while(settings && description == NULL);
|
||||
} while(description == NULL && (settings = settings->next));
|
||||
|
||||
#endif
|
||||
|
||||
@@ -2155,15 +2167,14 @@ void settings_init (void)
|
||||
if(!hal.driver_cap.mist_control)
|
||||
setting_remove_element(Setting_CoolantInvertMask, 1);
|
||||
|
||||
setting_details_t *details = settings_get_details();
|
||||
setting_details_t *details = setting_details.next;
|
||||
|
||||
while(details->on_get_settings) {
|
||||
details = details->on_get_settings();
|
||||
if(details) do {
|
||||
if(details->load)
|
||||
details->load();
|
||||
if(details->on_changed)
|
||||
details->on_changed(&settings);
|
||||
};
|
||||
} while((details = details->next));
|
||||
|
||||
settings_get_details()->on_changed = hal.settings_changed;
|
||||
setting_details.on_changed = hal.settings_changed;
|
||||
}
|
||||
|
||||
@@ -731,7 +731,8 @@ typedef struct setting_details {
|
||||
const uint16_t n_descriptions;
|
||||
const setting_descr_t *descriptions;
|
||||
#endif
|
||||
struct setting_details *(*on_get_settings)(void);
|
||||
// struct setting_details *(*on_get_settings)(void);
|
||||
struct setting_details *next;
|
||||
settings_changed_ptr on_changed;
|
||||
driver_settings_save_ptr save;
|
||||
driver_settings_load_ptr load;
|
||||
@@ -782,6 +783,7 @@ bool settings_read_tool_data (uint32_t tool, tool_data_t *tool_data);
|
||||
// Temporarily override acceleration, if 0 restore to configured setting value
|
||||
bool settings_override_acceleration (uint8_t axis, float acceleration);
|
||||
|
||||
void settings_register (setting_details_t *details);
|
||||
setting_details_t *settings_get_details (void);
|
||||
bool settings_is_group_available (setting_group_t group);
|
||||
bool settings_iterator (const setting_detail_t *setting, setting_output_ptr callback, void *data);
|
||||
|
||||
27
stream.c
27
stream.c
@@ -34,6 +34,33 @@ typedef struct {
|
||||
} stream_state_t;
|
||||
|
||||
static stream_state_t stream = {0};
|
||||
static io_stream_details_t *streams = NULL;
|
||||
|
||||
void stream_register_streams (io_stream_details_t *details)
|
||||
{
|
||||
details->next = streams;
|
||||
streams = details;
|
||||
}
|
||||
|
||||
bool stream_enumerate_streams (stream_enumerate_callback_ptr callback)
|
||||
{
|
||||
if(streams == NULL || callback == NULL)
|
||||
return false;
|
||||
|
||||
bool claimed = false;
|
||||
io_stream_details_t *details = streams;
|
||||
|
||||
while(details && !claimed) {
|
||||
uint_fast8_t idx;
|
||||
for(idx = 0; idx < details->n_streams; idx++) {
|
||||
if((claimed = callback(&details->streams[idx])))
|
||||
break;
|
||||
}
|
||||
details = details->next;
|
||||
};
|
||||
|
||||
return claimed;
|
||||
}
|
||||
|
||||
// called from stream drivers while tx is blocking, returns false to terminate
|
||||
bool stream_tx_blocking (void)
|
||||
|
||||
33
stream.h
33
stream.h
@@ -193,6 +193,19 @@ for handing feed-holds, overrides, soft resets etc.
|
||||
*/
|
||||
typedef bool (*disable_rx_stream_ptr)(bool disable);
|
||||
|
||||
typedef union {
|
||||
uint8_t value;
|
||||
struct {
|
||||
uint8_t connected :1,
|
||||
claimable :1,
|
||||
claimed :1,
|
||||
can_set_baud :1,
|
||||
rx_only :1,
|
||||
modbus_ready :1,
|
||||
unused :2;
|
||||
};
|
||||
} io_stream_flags_t;
|
||||
|
||||
//! Properties and handlers for stream I/O
|
||||
typedef struct {
|
||||
stream_type_t type; //!< Type of stream.
|
||||
@@ -216,6 +229,22 @@ typedef struct {
|
||||
set_baud_rate_ptr set_baud_rate; //!< Optional handler for setting the stream baud rate. Required for Modbus support, recommended for Bluetooth support.
|
||||
} io_stream_t;
|
||||
|
||||
typedef const io_stream_t *(*stream_claim_ptr)(uint32_t baud_rate);
|
||||
|
||||
typedef struct {
|
||||
stream_type_t type; //!< Type of stream.
|
||||
uint8_t instance; //!< Instance of stream type, starts from 0.
|
||||
io_stream_flags_t flags;
|
||||
stream_claim_ptr claim;
|
||||
} io_stream_properties_t;
|
||||
|
||||
typedef bool (*stream_enumerate_callback_ptr)(io_stream_properties_t const *properties);
|
||||
|
||||
typedef struct io_stream_details {
|
||||
uint8_t n_streams;
|
||||
io_stream_properties_t *streams;
|
||||
struct io_stream_details *next;
|
||||
} io_stream_details_t;
|
||||
|
||||
// The following structures and functions are not referenced in the core code, may be used by drivers
|
||||
|
||||
@@ -282,6 +311,10 @@ bool stream_tx_blocking (void);
|
||||
|
||||
bool stream_enqueue_realtime_command (char c);
|
||||
|
||||
void stream_register_streams (io_stream_details_t *details);
|
||||
|
||||
bool stream_enumerate_streams (stream_enumerate_callback_ptr callback);
|
||||
|
||||
#ifdef DEBUGOUT
|
||||
void debug_write (const char *s);
|
||||
void debug_stream_init (io_stream_t *stream);
|
||||
|
||||
2
system.c
2
system.c
@@ -260,7 +260,7 @@ void system_command_help (void)
|
||||
hal.stream.write("$HELP <topic> - output help for <topic>" ASCII_EOL);
|
||||
hal.stream.write("$RST=* - restore/reset all settings" ASCII_EOL);
|
||||
hal.stream.write("$RST=$ - restore default settings" ASCII_EOL);
|
||||
if(settings_get_details()->on_get_settings)
|
||||
if(settings_get_details()->next)
|
||||
hal.stream.write("$RST=& - restore driver and plugin default settings" ASCII_EOL);
|
||||
#ifdef N_TOOLS
|
||||
hal.stream.write("$RST=# - reset offsets and tool data" ASCII_EOL);
|
||||
|
||||
Reference in New Issue
Block a user