Documentation ¶
Overview ¶
Copyright (c) 2021 Dave Marsh. See LICENSE.
Index ¶
- Constants
- Variables
- type BuildInfo
- type Connector
- type Controller
- func (gctl *Controller) Apply(viewName, key string, vals map[string][]string) (updated []*forms.Updated, err error)
- func (gctl *Controller) Descriptor() string
- func (gctl *Controller) Edit(w io.Writer, viewName, key string) (err error)
- func (gctl *Controller) FormatResponseList(list []string) (r []string)
- func (gctl *Controller) Query(view string, key string) (err error)
- func (gctl *Controller) Update(form *forms.Form) (err error)
- func (gctl *Controller) Upload(w io.Writer, files []string) (err error)
- func (gctl *Controller) View(w io.Writer, viewName string) (err error)
- func (gctl *Controller) ViewForms(viewName string) (view forms.Forms, err error)
- func (gctl *Controller) Views() (vs []*monitor.View)
- type EditData
- type GCode
- type GCodeParameters
- type GrblCommands
- type GrblSettings
- type Group
- type Profile
- type Version
- type Versions
Constants ¶
View Source
const ( Ok uint = 0 ExpectedCommandLetter uint = 1 BadNumberFormat uint = 2 InvalidStatement uint = 3 NegativeValue uint = 4 SettingDisabled uint = 5 SettingStepPulseMin uint = 6 SettingReadFail uint = 7 IdleError uint = 8 SystemGcLock uint = 9 SoftLimitError uint = 10 Overflow uint = 11 MaxStepRateExceeded uint = 12 CheckDoor uint = 13 LineLengthExceeded uint = 14 TravelExceeded uint = 15 InvalidJogCommand uint = 16 SettingDisabledLaser uint = 17 HomingNoCycles uint = 18 GcodeUnsupportedCommand uint = 20 GcodeModalGroupViolation uint = 21 GcodeUndefinedFeedRate uint = 22 GcodeCommandValueNotInteger uint = 23 GcodeAxisCommandConflict uint = 24 GcodeWordRepeated uint = 25 GcodeNoAxisWords uint = 26 GcodeInvalidLineNumber uint = 27 GcodeValueWordMissing uint = 28 GcodeUnsupportedCoordSys uint = 29 GcodeG53InvalidMotionMode uint = 30 GcodeAxisWordsExist uint = 31 GcodeNoAxisWordsInPlane uint = 32 GcodeInvalidTarget uint = 33 GcodeArcRadiusError uint = 34 GcodeNoOffsetsInPlane uint = 35 GcodeUnusedWords uint = 36 GcodeG43DynamicAxisError uint = 37 GcodeMaxValueExceeded uint = 38 PParamMaxExceeded uint = 39 FsFailedMount uint = 60 // SD Failed to mount FsFailedRead uint = 61 // SD Failed to read file FsFailedOpenDir uint = 62 // SD card failed to open directory FsDirNotFound uint = 63 // SD Card directory not found FsFileEmpty uint = 64 // SD Card file empty FsFileNotFound uint = 65 // SD Card file not found FsFailedOpenFile uint = 66 // SD card failed to open file FsFailedBusy uint = 67 // SD card is busy FsFailedDelDir uint = 68 FsFailedDelFile uint = 69 BtFailBegin uint = 70 // Bluetooth failed to start WifiFailBegin uint = 71 // WiFi failed to start NumberRange uint = 80 // Setting number range problem InvalidValue uint = 81 // Setting string problem MessageFailed uint = 90 NvsSetFailed uint = 100 NvsGetStatsFailed uint = 101 AuthenticationFailed uint = 110 Eol uint = 111 AnotherInterfaceBusy uint = 120 JogCancelled uint = 130 )
View Source
const ( Parameters forms.WebId = iota Motion PlaneSelection Diameter DistanceMode FeedRateMode Units CutterRadiusCompensation ToolLengthOffset ReturnModeInCannedCycles CoordinateSystemSelection Stopping ToolChange SpindleTurning Coolant OverrideSwitches FlowControl NonModal )
View Source
const ( VER = "VER:" OPT = "OPT:" MAC = "MAC=" IP = "IP=" ID = "ID=" WIFI_STATUS = "Status=" ESP32_VERSION = "1.3a.20210424" ATMEGA328P_VERSION = "1.1h.20190825" ESP32 = "ESP32" ATMEGA328P = "ATMEGA328P" )
Variables ¶
View Source
var GCodes = map[string]*GCode{ "G0": { Group: Groups[Motion], Code: "G0", Label: "Rapid positioning", Notes: "Switch to rapid linear motion mode (seek). Used to get the tool somewhere quickly without cutting --- moves the machine as quickly as possible along each axis --- an axis which needs less movement will finish before the others, so one cannot count on the movement being a straight line.", }, "G1": { Group: Groups[Motion], Code: "G1", Label: "Linear interpolation", Notes: "Switch to linear motion at the current feed rate. Used to cut a straight line --- the interpreter will determine the acceleration needed along each axis to ensure direct movement from the original to the destination point at no more than the current Feed rate (F see below).", }, "G2": { Group: Groups[Motion], Code: "G2", Label: "Circular interpolation, clockwise", Notes: "Switch to clockwise arc mode. The interpreter will cut an arc or circle from the current position to the destination using the specified radius (R) or center (IJK location) at the current Feed rate (F see below) in the plane selected by G17/18/19.", }, "G3": { Group: Groups[Motion], Code: "G3", Label: "Circular interpolation, counterclockwise", Notes: "Switch to anti-clockwise arc mode. Corollary to G2 above.", }, "G4": { Group: Groups[Motion], Code: "G4", Label: "Dwell", Notes: "This should probably be calculated to be only one or two spindle rotations for best efficiency. Dwell time is expressed using a parameter (may be X, U, or P) which determines the time unit (seconds, milliseconds, &c.) P, for seconds, is supported and used by Grbl, typically X and U express the duration in milliseconds.", }, "G38.2": { Group: Groups[Motion], Code: "G38.2", Label: "Straight Probe", Notes: "Probe toward workpiece, stop on contact, signal error if failure.", }, "G38.3": { Group: Groups[Motion], Code: "G38.3", Label: "Probe", Notes: "Probe toward workpiece, stop on contact.", }, "G38.4": { Group: Groups[Motion], Code: "G38.4", Label: "Probe", Notes: "Probe away workpiece, stop on contact, signal error if failure.", }, "G38.5": { Group: Groups[Motion], Code: "G38.5", Label: "Probe", Notes: "Probe away workpiece, stop on contact.", }, "G80": { Group: Groups[Motion], Code: "G80", Label: "Motion mode cancel", Notes: "Canned cycle", }, "G54": { Group: Groups[CoordinateSystemSelection], Code: "G54", Label: "Fixture offset 1", Notes: "Fixture offset 1--6. CF G10 and G92.[21] Note that G54 is reserved by Carbide Motion, and will be reset by the software.[22]", }, "G55": { Group: Groups[CoordinateSystemSelection], Code: "G55", Label: "Fixture offset 2", }, "G56": { Group: Groups[CoordinateSystemSelection], Code: "G56", Label: "Fixture offset 3", }, "G57": { Group: Groups[CoordinateSystemSelection], Code: "G57", Label: "Fixture offset 4", }, "G58": { Group: Groups[CoordinateSystemSelection], Code: "G58", Label: "Fixture offset 5", }, "G59": { Group: Groups[CoordinateSystemSelection], Code: "G59", Label: "Fixture offset 6", }, "G17": { Group: Groups[PlaneSelection], Code: "G17", Label: "Select the XY plane (for arcs)", Notes: "Use I and J", }, "G18": { Group: Groups[PlaneSelection], Code: "G18", Label: "Select the XZ plane (for arcs)", Notes: "Use I and K", }, "G19": { Group: Groups[PlaneSelection], Code: "G19", Label: "Select the YZ plane (for arcs)", Notes: "Use J and K", }, "G90": { Group: Groups[DistanceMode], Code: "G90", Label: "Switch to absolute distance mode", Notes: "Coordinates are now relative to the origin of the currently active coordinate system, as opposed to the current position. G0 X-10 Y5 will move to the position 10 units to the left and 5 above the origin X0,Y0. cf. G91 below.", }, "G91": { Group: Groups[DistanceMode], Code: "G91", Label: "Switch to incremental distance mode", Notes: "Coordinates are now relative to the current position, with no consideration for machine origin. G0 X-10 Y5 will move to the position 10 units to the left and 5 above the current position. cf. G90 above.", }, "G93": { Group: Groups[FeedRateMode], Code: "G93", Label: "Set inverse time feed rate mode", Notes: "An F word is interpreted to mean that the move should be completed in (one divided by the F number) minutes. For example, if F is 2, the move should be completed in half a minute.", }, "G94": { Group: Groups[FeedRateMode], Code: "G94", Label: "Set units per minute feed rate mode", Notes: "An F Word is interpreted to mean the controlled point should move at a certain number of units (or degrees) per minute.", }, "G20": { Group: Groups[Units], Code: "G20", Label: "Units will be in inches", Notes: "Best practice: do this at the start of a program and nowhere else. The usual minimum increment in G20 is one ten-thousandth of an inch (0.0001\").", }, "G21": { Group: Groups[Units], Code: "G21", Label: "Units will be in mm", Notes: "Best practice: do this at the start of a program and nowhere else. The usual minimum increment in G21 (one thousandth of a millimeter, .001 mm, that is, one micrometre).", }, "M3": { Group: Groups[SpindleTurning], Code: "M3", Label: "Spindle direction clockwise", Notes: "Starts or restarts the spindle spinning clockwise, if the system is wired up to start/stop the spindle.", }, "M4": { Group: Groups[SpindleTurning], Code: "M4", Label: "Spindle direction counter-clockwise", Notes: "Used to enable laser mode movement in Grbl 1.0 and later.", }, "M5": { Group: Groups[SpindleTurning], Code: "M5", Label: "Spindle direction clockwise", Notes: "Starts or restarts the spindle spinning clockwise, if the system is wired up to start/stop the spindle.", }, "M7": { Group: Groups[Coolant], Code: "M7", Label: "Mist", Notes: "Coolant control", }, "M8": { Group: Groups[Coolant], Code: "M8", Label: "Flood coolant on", Notes: "Coolant control", }, "M9": { Group: Groups[Coolant], Code: "M9", Label: "All coolant off.", Notes: "Coolant control", }, "M6": { Group: Groups[ToolChange], Code: "M6", Label: "Tool Change", Notes: "Coolant control", }, "T?": { Group: Groups[Parameters], Code: "T?", Label: "Tool Number", }, "F?": { Group: Groups[Parameters], Code: "F?", Label: "Feed Rate", }, "S?": { Group: Groups[Parameters], Code: "S?", Label: "Spindle Speed", }, "X?": { Group: Groups[Parameters], Code: "X?", Label: "X Axis Position", Notes: "", }, "Y?": { Group: Groups[Parameters], Code: "Y?", Label: "Y Axis Position", Notes: "", }, "Z?": { Group: Groups[Parameters], Code: "Z?", Label: "Z Axis Position", Notes: "", }, "A?": { Group: Groups[Parameters], Code: "A?", Label: "A Axis Position", Notes: "", }, "B?": { Group: Groups[Parameters], Code: "B?", Label: "B Axis Position", Notes: "", }, "C?": { Group: Groups[Parameters], Code: "C?", Label: "C Axis Position", Notes: "", }, "I?": { Group: Groups[Parameters], Code: "I?", Label: "Arc Centre in X Axis ", Notes: "", }, "J?": { Group: Groups[Parameters], Code: "J?", Label: "Arc Centre in Y Axis ", Notes: "", }, "K?": { Group: Groups[Parameters], Code: "K?", Label: "Arc Centre in Z Axis ", Notes: "", }, "R?": { Group: Groups[Parameters], Code: "R?", Label: "Arc Radius Size ", Notes: "", }, "P?": { Group: Groups[Parameters], Code: "P?", Label: "Parameter Address", Notes: "", }, }
View Source
var GrblErrors = map[uint]string{ ExpectedCommandLetter: "Expected command letter G-code words consist of a letter and a value. Letter was not found.", BadNumberFormat: "Bad number format Missing the expected G-code word value or numeric value format is not valid.", InvalidStatement: "Invalid statement Grbl '$' system command was not recognized or supported.", NegativeValue: "Value < 0 Negative value received for an expected positive value.", SettingDisabled: "Setting disabled Homing cycle failure. Homing is not enabled via settings.", SettingStepPulseMin: "Value < 3 usec Minimum step pulse time must be greater than 3usec.", SettingReadFail: "EEPROM read fail. Using defaults An EEPROM read failed. Auto-restoring affected EEPROM to default values.", IdleError: "Not idle Grbl '$' command cannot be used unless Grbl is IDLE. Ensures smooth operation during a job.", SystemGcLock: "G-code lock G-code commands are locked out during alarm or jog state.", SoftLimitError: "Homing not enabled Soft limits cannot be enabled without homing also enabled.", Overflow: "Line overflow Max characters per line exceeded. Received command line was not executed.", MaxStepRateExceeded: "Step rate > 30kHz Grbl '$' setting value cause the step rate to exceed the maximum supported.", CheckDoor: "Check Door Safety door detected as opened and door state initiated.", LineLengthExceeded: "Line length exceeded Build info or startup line exceeded EEPROM line length limit. Line not stored.", TravelExceeded: "Travel exceeded Jog target exceeds machine travel. Jog command has been ignored.", InvalidJogCommand: "Invalid jog command Jog command has no '=' or contains prohibited g-code.", SettingDisabledLaser: "Setting disabled Laser mode requires PWM output.", HomingNoCycles: "Unsupported command Unsupported or invalid g-code command found in block.", GcodeUnsupportedCommand: "Modal group violation More than one g-code command from same modal group found in block.", GcodeUndefinedFeedRate: "Undefined feed rate Feed rate has not yet been set or is undefined.", GcodeCommandValueNotInteger: "Invalid gcode ID:23 G-code command in block requires an integer value.", GcodeAxisCommandConflict: "Invalid gcode ID:24 More than one g-code command that requires axis words found in block.", GcodeWordRepeated: "Invalid gcode ID:25 Repeated g-code word found in block.", GcodeNoAxisWords: "Invalid gcode ID:26 No axis words found in block for g-code command or current modal state which requires them.", GcodeInvalidLineNumber: "Invalid gcode ID:27 Line number value is invalid.", GcodeValueWordMissing: "Invalid gcode ID:28 G-code command is missing a required value word.", GcodeUnsupportedCoordSys: "Invalid gcode ID:29 G59.x work coordinate systems are not supported.", GcodeG53InvalidMotionMode: "Invalid gcode ID:30 G53 only allowed with G0 and G1 motion modes.", GcodeAxisWordsExist: "Invalid gcode ID:31 Axis words found in block when no command or current modal state uses them.", GcodeNoAxisWordsInPlane: "Invalid gcode ID:32 G2 and G3 arcs require at least one in-plane axis word.", GcodeInvalidTarget: "Invalid gcode ID:33 Motion command target is invalid.", GcodeArcRadiusError: "Invalid gcode ID:34 Arc radius value is invalid.", GcodeNoOffsetsInPlane: "Invalid gcode ID:35 G2 and G3 arcs require at least one in-plane offset word.", GcodeUnusedWords: "Invalid gcode ID:36 Unused value words found in block.", GcodeG43DynamicAxisError: "Invalid gcode ID:37 G43.1 dynamic tool length offset is not assigned to configured tool length axis.", GcodeMaxValueExceeded: "Invalid gcode ID:38 Tool number greater than max supported value.", PParamMaxExceeded: "Maximum parameters exceeded.", FsFailedMount: "SD Failed to mount.", FsFailedRead: "SD Failed to read file.", FsFailedOpenDir: "SD card failed to open directory.", FsDirNotFound: "SD Card directory not found.", FsFileEmpty: "SD Card file empty.", FsFileNotFound: "SD Card file not found.", FsFailedOpenFile: "SD card failed to open file.", FsFailedBusy: "SD card is busy.", FsFailedDelDir: "SD card failed to delete directory.", FsFailedDelFile: "SD card failed to delete file.", BtFailBegin: "Bluetooth failed to start.", WifiFailBegin: "WiFi failed to start.", NumberRange: "Setting out of range.", InvalidValue: "Setting invalid", MessageFailed: "Message failed.", NvsSetFailed: "NVS set failed.", NvsGetStatsFailed: "NVS get stats failed.", AuthenticationFailed: "Authentication failed.", Eol: "End of line.", AnotherInterfaceBusy: "Another interface busy", JogCancelled: "Jog cancelled.", }
GrblErrors is based on https://grblminicnc.blogspot.com/2017/04/grbl-error-list.html
View Source
var Groups = map[forms.WebId]*forms.Entry{ Motion: { ID: Motion.String(), Label: "Motion ('Group 1')", }, PlaneSelection: { ID: PlaneSelection.String(), Label: "Plane selection", }, Diameter: { ID: Diameter.String(), Label: "Diameter / Radius for lathes", }, DistanceMode: { ID: DistanceMode.String(), Label: "Distance Mode", }, FeedRateMode: { ID: FeedRateMode.String(), Label: "Feed Rate Mode", }, Units: { ID: Units.String(), Label: "Units", }, CutterRadiusCompensation: { ID: CutterRadiusCompensation.String(), Label: "Cutter Radius Compensation", }, ToolLengthOffset: { ID: ToolLengthOffset.String(), Label: "Tool Length Offset", }, ReturnModeInCannedCycles: { ID: ReturnModeInCannedCycles.String(), Label: "Return Mode in Canned Cycles", }, CoordinateSystemSelection: { ID: CoordinateSystemSelection.String(), Label: "Coordinate System Selection", }, Stopping: { ID: Stopping.String(), Label: "Stopping", }, ToolChange: { ID: ToolChange.String(), Label: "Tool Change", }, SpindleTurning: { ID: SpindleTurning.String(), Label: "Spindle Turning", }, Coolant: { ID: Coolant.String(), Label: "Coolant", }, OverrideSwitches: { ID: OverrideSwitches.String(), Label: "Override Switches", }, FlowControl: { ID: FlowControl.String(), Label: "Flow Control", }, NonModal: { ID: NonModal.String(), Label: "Non-modal codes ('Group 0')", }, }
Functions ¶
This section is empty.
Types ¶
type Connector ¶
type Connector struct { Controllers map[string]*Controller // contains filtered or unexported fields }
func NewConnector ¶
func (*Connector) Add ¶
func (conn *Connector) Add(gctl *Controller)
type Controller ¶
type Controller struct { ID string `json:"id"` Title string `json:"title"` Profile *Profile `json:"profile"` Active bool `json:"active"` Port string `json:"port"` Settings GrblSettings `json:"settings"` Commands GrblCommands `json:"-"` CameraIDs []string `json:"camera-ids"` Cameras camera.Cameras `json:"-"` // contains filtered or unexported fields }
func NewController ¶
func NewController(bus *monitor.Bus, layout *template.Template) (gctl *Controller)
func (*Controller) Descriptor ¶
func (gctl *Controller) Descriptor() string
func (*Controller) Edit ¶
func (gctl *Controller) Edit(w io.Writer, viewName, key string) (err error)
func (*Controller) FormatResponseList ¶
func (gctl *Controller) FormatResponseList(list []string) (r []string)
func (*Controller) ViewForms ¶
func (gctl *Controller) ViewForms(viewName string) (view forms.Forms, err error)
func (*Controller) Views ¶
func (gctl *Controller) Views() (vs []*monitor.View)
type GCodeParameters ¶
type GrblCommands ¶
type GrblCommands struct { Settings []string `json:"settings"` Parameters []string `json:"parameters"` ParserState []string `json:"parserState"` BuildInfo []string `json:"buildInfo"` StartupBlocks []string `json:"startupBlocks"` CodeMode []string `json:"codeMode"` KillAlarm []string `json:"killAlarm"` RunHomingCycle []string `json:"runHomingCycle"` RunJoggingCycle []string `json:"runJoggingCycle"` EraseRestore []string `json:"eraseRestore"` EraseZero []string `json:"eraseZero"` ClearRestore []string `json:"clearRestore"` }
type GrblSettings ¶
type GrblSettings struct { StepPulse uint `json:"stepPulse"` StepIdleDelay uint `json:"stepIdleDelay"` StepPortInvertMask uint `json:"stepPortInvertMask"` DirPortInvertMask uint `json:"dirPortInvertMask"` StepEnableInvert bool `json:"stepEnableInvert"` LimitPinsInvert bool `json:"limitPinsInvert"` ProbePinInvert bool `json:"probePinInvert"` StatusReportMask uint `json:"statusReportMask"` JunctionDeviation float32 `json:"junctionDeviation"` ArcTolerance float32 `json:"arcTolerance"` ReportInches bool `json:"reportInches"` SoftLimits bool `json:"softLimits"` HardLimits bool `json:"hardLimits"` HomingCycle bool `json:"homingCycle"` HomingDirInvert uint `json:"homingDirInvert"` HomingFeed float32 `json:"homingFeed"` HomingSeek float32 `json:"homingSeek"` HomingDebounce uint `json:"homingDebounce"` HomingPulloff float32 `json:"homingPulloff"` MaxSpindleSpeed float32 `json:"maxSpindleSpeed"` MinSpindleSpeed float32 `json:"minSpindleSpeed"` LaserMode bool `json:"laserMode"` StepsX float32 `json:"stepsX"` StepsY float32 `json:"stepsY"` StepsZ float32 `json:"stepsZ"` StepsA float32 `json:"stepsA"` StepsB float32 `json:"stepsB"` StepsC float32 `json:"stepsC"` MaxRateX float32 `json:"maxRateX"` MaxRateY float32 `json:"maxRateY"` MaxRateZ float32 `json:"maxRateZ"` MaxRateA float32 `json:"maxRateA"` MaxRateB float32 `json:"maxRateB"` MaxRateC float32 `json:"maxRateC"` AccelX float32 `json:"accelX"` AccelY float32 `json:"accelY"` AccelZ float32 `json:"accelZ"` AccelA float32 `json:"accelA"` AccelB float32 `json:"accelB"` AccelC float32 `json:"accelC"` MaxTravelX float32 `json:"maxTravelX"` MaxTravelY float32 `json:"maxTravelY"` MaxTravelZ float32 `json:"maxTravelZ"` MaxTravelA float32 `json:"maxTravelA"` MaxTravelB float32 `json:"maxTravelB"` MaxTravelC float32 `json:"maxTravelC"` }
GrblSettings as defined by grbl
type Profile ¶
type Profile struct { ID string `json:"id"` Version string `json:"version"` Options string `json:"options"` AxisCount int `json:"axisCount"` IP string `json:"ip"` Status string `json:"status"` }
func CheckProfile ¶
func (*Profile) IsMEGA328P ¶
Click to show internal directories.
Click to hide internal directories.