├── EXTENTIONS.md ├── Hardware └── GrblCnc3040 │ ├── GrblCnc3040-cache.lib │ ├── GrblCnc3040.dcm │ ├── GrblCnc3040.jpg │ ├── GrblCnc3040.kicad_pcb │ ├── GrblCnc3040.lib │ ├── GrblCnc3040.net │ ├── GrblCnc3040.pretty │ ├── 182-025-213.STEP │ ├── BluePill_STM32F103C.kicad_mod │ ├── DSUB-25_Female_Horizontal_P2.77x2.84mm_EdgePinOffset4.94mm_Housed_MountingHolesOffset7.48mm.kicad_mod │ └── YAAJ_BluePill.STEP │ ├── GrblCnc3040.pro │ ├── GrblCnc3040.sch │ ├── GrblCnc3040_back.jpg │ ├── STM32-Pin-Details_0.png │ ├── fp-lib-table │ ├── gerbers_cnc3040 │ ├── GrblCnc3040-B.Cu.gbr │ ├── GrblCnc3040-B.Mask.gbr │ ├── GrblCnc3040-B.SilkS.gbr │ ├── GrblCnc3040-Edge.Cuts.gbr │ ├── GrblCnc3040-F.Cu.gbr │ ├── GrblCnc3040-F.Mask.gbr │ ├── GrblCnc3040-F.SilkS.gbr │ ├── GrblCnc3040-NPTH.drl │ └── GrblCnc3040-PTH.drl │ └── sym-lib-table ├── LICENSE.md ├── Media ├── GrblCnc3040.jpg ├── GrblCnc3040_back.jpg ├── Pinout.svg ├── STM32F103C8T8_Bluepill.pptx ├── grblcnc1.png └── pindiag.png ├── PROGRESS.md ├── README.md ├── Release └── V0.01 │ ├── GRBL Driver STM32F103C8 V20200503.bin │ ├── GrblCNC.exe │ ├── OpenTK.GLControl.dll │ ├── OpenTK.dll │ └── gerbers_cnc3040_2Layer.zip ├── Software ├── GrblCNC.sln └── GrblCNC │ ├── App.config │ ├── CncTool.cs │ ├── Controls │ ├── AlarmViewer.Designer.cs │ ├── AlarmViewer.cs │ ├── AlarmViewer.resx │ ├── BigNumViewer.Designer.cs │ ├── BigNumViewer.cs │ ├── BigNumViewer.resx │ ├── DualProgressTool.cs │ ├── ErrorView.Designer.cs │ ├── ErrorView.cs │ ├── ErrorView.resx │ ├── FormAbout.Designer.cs │ ├── FormAbout.cs │ ├── FormAbout.resx │ ├── FormChangeTool.Designer.cs │ ├── FormChangeTool.cs │ ├── FormChangeTool.resx │ ├── FormConfirmation.Designer.cs │ ├── FormConfirmation.cs │ ├── FormConfirmation.resx │ ├── FormGoto.Designer.cs │ ├── FormGoto.cs │ ├── FormGoto.resx │ ├── FormOffset.Designer.cs │ ├── FormOffset.cs │ ├── FormOffset.resx │ ├── FormProbe.Designer.cs │ ├── FormProbe.cs │ ├── FormProbe.resx │ ├── FormSelectToolNum.Designer.cs │ ├── FormSelectToolNum.cs │ ├── FormSelectToolNum.resx │ ├── GStateViewer.Designer.cs │ ├── GStateViewer.cs │ ├── GStateViewer.resx │ ├── GcodeParamViewer.Designer.cs │ ├── GcodeParamViewer.cs │ ├── GcodeParamViewer.resx │ ├── GcodeViewer.Designer.cs │ ├── GcodeViewer.cs │ ├── GcodeViewer.resx │ ├── HorizTab.Designer.cs │ ├── HorizTab.cs │ ├── JogButton.Designer.cs │ ├── JogButton.cs │ ├── ManualControl.Designer.cs │ ├── ManualControl.cs │ ├── ManualControl.resx │ ├── MdiControl.Designer.cs │ ├── MdiControl.cs │ ├── MdiControl.resx │ ├── MultiSelect.Designer.cs │ ├── MultiSelect.cs │ ├── MultiSelect.resx │ ├── ParameterControl.cs │ ├── ParameterViewer.Designer.cs │ ├── ParameterViewer.cs │ ├── ParameterViewer.resx │ ├── ParametersEdit.Designer.cs │ ├── ParametersEdit.cs │ ├── ParametersEdit.resx │ ├── StatusViewer.Designer.cs │ ├── StatusViewer.cs │ ├── StatusViewer.resx │ ├── ToolTableEdit.Designer.cs │ ├── ToolTableEdit.cs │ ├── ToolTableEdit.resx │ ├── ValueSlider.Designer.cs │ ├── ValueSlider.cs │ └── ValueSlider.resx │ ├── ErrorDisplayHandler.cs │ ├── FontManager.cs │ ├── FormPopWindow.Designer.cs │ ├── FormPopWindow.cs │ ├── FormPopWindow.resx │ ├── GCodeConfig.cs │ ├── GCodeDimensions.cs │ ├── GcodeInterp.cs │ ├── Global.cs │ ├── Glutils │ ├── Camera.cs │ ├── ColoredQuad.cs │ ├── Line3D.cs │ ├── Obj3DText.cs │ ├── Object3D.cs │ ├── Overlay.cs │ ├── Shader.cs │ ├── Text3D.cs │ ├── Texture.cs │ ├── Utils.cs │ └── Wire3D.cs │ ├── GrblCNC.csproj │ ├── GrblCNC.csproj.user │ ├── GrblComm.cs │ ├── GrblCommDevice.cs │ ├── GrblCommSerial.cs │ ├── GrblCommTelnet.cs │ ├── GrblConfig.cs │ ├── GrblProbber.cs │ ├── GrblStatus.cs │ ├── GrblUtils.cs │ ├── MainForm.Designer.cs │ ├── MainForm.cs │ ├── MainForm.resx │ ├── MillHead3D.cs │ ├── Obj3DFloor.cs │ ├── Program.cs │ ├── Properties │ ├── AssemblyInfo.cs │ ├── Resources.Designer.cs │ ├── Resources.resx │ ├── Settings.Designer.cs │ └── Settings.settings │ ├── Resources │ ├── AboutPicSmall.png │ ├── AlarmErrorIcon.png │ ├── AlarmIcon.png │ ├── ConfGrblButt.png │ ├── ConfSenderButt.png │ ├── ErrorIcon.png │ ├── FragShaderColor.txt │ ├── FragShaderFlat.txt │ ├── FragShaderLine.txt │ ├── FragShaderNorm.txt │ ├── FragShaderText.txt │ ├── FragShaderWire.txt │ ├── GotoIcon.png │ ├── GrblAlarmCodes.txt │ ├── GrblErrorCodes.txt │ ├── GrblLogo_ngc.txt │ ├── GrblParamDescription.txt │ ├── GridCenter.png │ ├── GridEmpty.png │ ├── GridRuler.png │ ├── HomeIcon.png │ ├── HomeIconFull.png │ ├── HomedIcon.png │ ├── JetBrainsMono-Medium.ttf │ ├── JogButtHover.png │ ├── JogButtNorm.png │ ├── JogButtPress.png │ ├── MacroAddButt.png │ ├── MacroF1Buttt.png │ ├── MacroF2Buttt.png │ ├── MacroF3Buttt.png │ ├── MacroF4Buttt.png │ ├── MacroF5Buttt.png │ ├── MacroF6Buttt.png │ ├── MacroF7Buttt.png │ ├── MacroF8Buttt.png │ ├── MacroF9Buttt.png │ ├── OpenButt.png │ ├── ProbeHoleIcon.png │ ├── ProbeIcon.png │ ├── ReloaButt.png │ ├── SliderThumb.png │ ├── SpinLeftIcon.png │ ├── SpinRightIcon.png │ ├── StepButt.png │ ├── StopIcon.png │ ├── ToolTableButt.png │ ├── TouchGIcon.png │ ├── TouchTIcon.png │ ├── VertShader2DColor.txt │ ├── VertShader2DFlat.txt │ ├── VertShader2DText.txt │ ├── VertShader3DFlat.txt │ ├── VertShader3DLine.txt │ ├── VertShader3DNorm.txt │ ├── VertShader3DText.txt │ ├── VertShader3DWire.txt │ ├── WifiButt.png │ ├── aboutButt.png │ ├── checkedButt.png │ ├── estop.png │ ├── grblIcon.png │ ├── pauseButt.png │ ├── playButt.png │ ├── powerButt.png │ └── stopButt.png │ ├── ToolButton.cs │ ├── ToolTable.cs │ ├── VisualizerOverlay.cs │ ├── VisualizerWin.Designer.cs │ ├── VisualizerWin.cs │ ├── lib │ ├── OpenTK.GLControl.dll │ ├── OpenTK.dll │ └── OpenTK.dll.config │ └── mDns │ ├── LICENSE │ ├── mDNS.cs │ └── packet.cs └── TODO.md /EXTENTIONS.md: -------------------------------------------------------------------------------- 1 | ## GRBL for Chinese CNC3040-like machines. WIP. 2 | ### Extensions to the original Grbl 3 | 4 | #### Command Extentions: 5 | * $H\ : When auto home is not enabled, this command can reset the current axis position to 0. 6 | Similar to pressing Home on this axis in LinuxCNC. For example, to reset X axis position: $HX 7 | 8 | #### Report Extentions: 9 | * '|Hs:\' : This reports the current bitmask home state of each axis. When the axis is homed, 10 | the coresponding bit will be 1. For example Hs:5 means Axis X and Z were homed. 11 | * '|GC:\<.../>' : Usually returned by the $G command. But now, whenever there is a gcode parser change, 12 | this report will be sent automatically 13 | 14 | -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/GrblCnc3040.dcm: -------------------------------------------------------------------------------- 1 | EESchema-DOCLIB Version 2.0 2 | # 3 | #End Doc Library 4 | -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/GrblCnc3040.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Hardware/GrblCnc3040/GrblCnc3040.jpg -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/GrblCnc3040.lib: -------------------------------------------------------------------------------- 1 | EESchema-LIBRARY Version 2.4 2 | #encoding utf-8 3 | # 4 | # BluePillF 5 | # 6 | DEF BluePillF U 0 40 Y Y 1 F N 7 | F0 "U" -500 900 60 H V C CNN 8 | F1 "BluePillF" 400 -950 60 H V C CNN 9 | F2 "" -100 750 60 H I C CNN 10 | F3 "" -100 750 60 H I C CNN 11 | DRAW 12 | S -550 850 550 -850 0 1 0 N 13 | X Vbat 1 -150 1050 200 D 50 50 1 1 W 14 | X PA5 10 -750 0 200 R 50 50 1 1 B 15 | X PA6 11 -750 -100 200 R 50 50 1 1 B 16 | X PA7 12 -750 -200 200 R 50 50 1 1 B 17 | X PB0 13 -750 -300 200 R 50 50 1 1 B 18 | X PB1 14 -750 -400 200 R 50 50 1 1 B 19 | X PB10 15 -750 -500 200 R 50 50 1 1 B 20 | X PB11 16 -750 -600 200 R 50 50 1 1 B 21 | X RESET 17 -750 -800 200 R 50 50 1 1 I 22 | X 3.3V 18 100 1050 200 D 50 50 1 1 I 23 | X GND 19 -150 -1050 200 U 50 50 1 1 I 24 | X PC13 2 -750 800 200 R 50 50 1 1 B 25 | X GND 20 -50 -1050 200 U 50 50 1 1 I 26 | X PB12 21 750 -800 200 L 50 50 1 1 B 27 | X PB13 22 750 -700 200 L 50 50 1 1 B 28 | X PB14 23 750 -600 200 L 50 50 1 1 B 29 | X PB15 24 750 -500 200 L 50 50 1 1 B 30 | X PA8 25 750 -400 200 L 50 50 1 1 B 31 | X PA9 26 750 -300 200 L 50 50 1 1 B 32 | X PA10 27 750 -200 200 L 50 50 1 1 B 33 | X PA11 28 750 -100 200 L 50 50 1 1 B 34 | X PA12 29 750 0 200 L 50 50 1 1 B 35 | X PC14 3 -750 700 200 R 50 50 1 1 B 36 | X PA15 30 750 100 200 L 50 50 1 1 B 37 | X PB3 31 750 200 200 L 50 50 1 1 B 38 | X PB4 32 750 300 200 L 50 50 1 1 B 39 | X PB5 33 750 400 200 L 50 50 1 1 B 40 | X PB6 34 750 500 200 L 50 50 1 1 B 41 | X PB7 35 750 600 200 L 50 50 1 1 B 42 | X PB8 36 750 700 200 L 50 50 1 1 B 43 | X PB9 37 750 800 200 L 50 50 1 1 B 44 | X 5V 38 250 1050 200 D 50 50 1 1 w 45 | X GND 39 150 -1050 200 U 50 50 1 1 w 46 | X PC15 4 -750 600 200 R 50 50 1 1 B 47 | X 3.3V 40 0 1050 200 D 50 50 1 1 w 48 | X PA0 5 -750 500 200 R 50 50 1 1 B 49 | X PA1 6 -750 400 200 R 50 50 1 1 B 50 | X PA2 7 -750 300 200 R 50 50 1 1 B 51 | X PA3 8 -750 200 200 R 50 50 1 1 B 52 | X PA4 9 -750 100 200 R 50 50 1 1 B 53 | ENDDRAW 54 | ENDDEF 55 | # 56 | #End Library 57 | -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/GrblCnc3040.pretty/YAAJ_BluePill.STEP: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Hardware/GrblCnc3040/GrblCnc3040.pretty/YAAJ_BluePill.STEP -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/GrblCnc3040.pro: -------------------------------------------------------------------------------- 1 | update=22/05/2015 07:44:53 2 | version=1 3 | last_client=kicad 4 | [general] 5 | version=1 6 | RootSch= 7 | BoardNm= 8 | [pcbnew] 9 | version=1 10 | LastNetListRead= 11 | UseCmpFile=1 12 | PadDrill=0.600000000000 13 | PadDrillOvalY=0.600000000000 14 | PadSizeH=1.500000000000 15 | PadSizeV=1.500000000000 16 | PcbTextSizeV=1.500000000000 17 | PcbTextSizeH=1.500000000000 18 | PcbTextThickness=0.300000000000 19 | ModuleTextSizeV=1.000000000000 20 | ModuleTextSizeH=1.000000000000 21 | ModuleTextSizeThickness=0.150000000000 22 | SolderMaskClearance=0.000000000000 23 | SolderMaskMinWidth=0.000000000000 24 | DrawSegmentWidth=0.200000000000 25 | BoardOutlineThickness=0.100000000000 26 | ModuleOutlineThickness=0.150000000000 27 | [cvpcb] 28 | version=1 29 | NetIExt=net 30 | [eeschema] 31 | version=1 32 | LibDir= 33 | [eeschema/libraries] 34 | -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/GrblCnc3040_back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Hardware/GrblCnc3040/GrblCnc3040_back.jpg -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/STM32-Pin-Details_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Hardware/GrblCnc3040/STM32-Pin-Details_0.png -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/fp-lib-table: -------------------------------------------------------------------------------- 1 | (fp_lib_table 2 | (lib (name GrblCnc3040)(type KiCad)(uri ${KIPRJMOD}/GrblCnc3040.pretty)(options "")(descr "Local library")) 3 | ) 4 | -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/gerbers_cnc3040/GrblCnc3040-Edge.Cuts.gbr: -------------------------------------------------------------------------------- 1 | G04 #@! TF.GenerationSoftware,KiCad,Pcbnew,(5.0.2)-1* 2 | G04 #@! TF.CreationDate,2020-05-04T12:03:43+03:00* 3 | G04 #@! TF.ProjectId,GrblCnc3040,4772626c-436e-4633-9330-34302e6b6963,rev?* 4 | G04 #@! TF.SameCoordinates,Original* 5 | G04 #@! TF.FileFunction,Profile,NP* 6 | %FSLAX46Y46*% 7 | G04 Gerber Fmt 4.6, Leading zero omitted, Abs format (unit mm)* 8 | G04 Created by KiCad (PCBNEW (5.0.2)-1) date 04/05/2020 12:03:43* 9 | %MOMM*% 10 | %LPD*% 11 | G01* 12 | G04 APERTURE LIST* 13 | %ADD10C,0.150000*% 14 | G04 APERTURE END LIST* 15 | D10* 16 | X175500000Y-102500000D02* 17 | X227500000Y-102500000D01* 18 | X227500000Y-47500000D02* 19 | X175500000Y-47500000D01* 20 | X230000000Y-100000000D02* 21 | G75* 22 | G02X227500000Y-102500000I-2500000J0D01* 23 | G01* 24 | X227500000Y-47500000D02* 25 | G75* 26 | G02X230000000Y-50000000I0J-2500000D01* 27 | G01* 28 | X175500000Y-102500000D02* 29 | X175500000Y-47500000D01* 30 | X230000000Y-97500000D02* 31 | X230000000Y-100000000D01* 32 | X230000000Y-50000000D02* 33 | X230000000Y-97500000D01* 34 | M02* 35 | -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/gerbers_cnc3040/GrblCnc3040-NPTH.drl: -------------------------------------------------------------------------------- 1 | M48 2 | ;DRILL file {KiCad (5.0.2)-1} date 04/05/2020 12:03:51 3 | ;FORMAT={-:-/ absolute / inch / decimal} 4 | FMAT,2 5 | INCH,TZ 6 | % 7 | G90 8 | G05 9 | T0 10 | M30 11 | -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/gerbers_cnc3040/GrblCnc3040-PTH.drl: -------------------------------------------------------------------------------- 1 | M48 2 | ;DRILL file {KiCad (5.0.2)-1} date 04/05/2020 12:03:51 3 | ;FORMAT={-:-/ absolute / inch / decimal} 4 | FMAT,2 5 | INCH,TZ 6 | T1C0.0157 7 | T2C0.0394 8 | T3C0.0400 9 | T4C0.1260 10 | % 11 | G90 12 | G05 13 | T1 14 | X8.0591Y-2.5512 15 | X8.063Y-2.6535 16 | X8.063Y-3.0512 17 | X8.063Y-3.1496 18 | X8.063Y-3.252 19 | X8.063Y-3.5551 20 | X8.0669Y-3.4488 21 | X8.0709Y-2.8504 22 | X8.0748Y-2.248 23 | X8.0748Y-2.9528 24 | X8.0787Y-2.752 25 | X8.0945Y-2.3307 26 | X8.1154Y-2.2973 27 | X8.1155Y-2.4514 28 | X8.1325Y-2.7612 29 | X8.1693Y-2.3976 30 | X8.1969Y-2.5157 31 | T2 32 | X8.2677Y-2.126 33 | X8.2677Y-2.226 34 | X8.2677Y-2.326 35 | X8.2677Y-2.426 36 | X8.2677Y-2.526 37 | X8.2677Y-2.626 38 | X8.2677Y-2.726 39 | X8.2677Y-2.826 40 | X8.2677Y-2.926 41 | X8.2677Y-3.026 42 | X8.2677Y-3.126 43 | X8.2677Y-3.226 44 | X8.2677Y-3.326 45 | X8.2677Y-3.426 46 | X8.2677Y-3.526 47 | X8.2677Y-3.626 48 | X8.2677Y-3.726 49 | X8.525Y-2.125 50 | X8.525Y-2.225 51 | X8.525Y-2.325 52 | X8.525Y-2.425 53 | X8.525Y-2.525 54 | X8.525Y-2.625 55 | X8.525Y-2.725 56 | X8.525Y-2.825 57 | X8.525Y-2.925 58 | X8.525Y-3.025 59 | X8.525Y-3.125 60 | X8.525Y-3.225 61 | X8.525Y-3.325 62 | X8.525Y-3.425 63 | X8.525Y-3.525 64 | X8.525Y-3.625 65 | X8.525Y-3.725 66 | X8.7362Y-2.2992 67 | X8.7362Y-2.4083 68 | X8.7362Y-2.5173 69 | X8.7362Y-2.6264 70 | X8.7362Y-2.7354 71 | X8.7362Y-2.8445 72 | X8.7362Y-2.9535 73 | X8.7362Y-3.0626 74 | X8.7362Y-3.1717 75 | X8.7362Y-3.2807 76 | X8.7362Y-3.3898 77 | X8.7362Y-3.4988 78 | X8.7362Y-3.6079 79 | X8.848Y-2.3537 80 | X8.848Y-2.4628 81 | X8.848Y-2.5719 82 | X8.848Y-2.6809 83 | X8.848Y-2.79 84 | X8.848Y-2.899 85 | X8.848Y-3.0081 86 | X8.848Y-3.1171 87 | X8.848Y-3.2262 88 | X8.848Y-3.3352 89 | X8.848Y-3.4443 90 | X8.848Y-3.5533 91 | X7.925Y-2. 92 | X7.925Y-2.1 93 | X7.925Y-2.2 94 | X7.925Y-2.3 95 | X7.925Y-2.4 96 | X7.925Y-2.5 97 | X7.925Y-2.6 98 | X7.925Y-2.7 99 | X7.925Y-2.8 100 | X7.925Y-2.9 101 | X7.925Y-3. 102 | X7.925Y-3.1 103 | X7.925Y-3.2 104 | X7.925Y-3.3 105 | X7.925Y-3.4 106 | X7.925Y-3.5 107 | X7.925Y-3.6 108 | X7.925Y-3.7 109 | X7.925Y-3.8 110 | X7.925Y-3.9 111 | X8.025Y-2. 112 | X8.025Y-2.1 113 | X8.025Y-2.2 114 | X8.025Y-2.3 115 | X8.025Y-2.4 116 | X8.025Y-2.5 117 | X8.025Y-2.6 118 | X8.025Y-2.7 119 | X8.025Y-2.8 120 | X8.025Y-2.9 121 | X8.025Y-3. 122 | X8.025Y-3.1 123 | X8.025Y-3.2 124 | X8.025Y-3.3 125 | X8.025Y-3.4 126 | X8.025Y-3.5 127 | X8.025Y-3.6 128 | X8.025Y-3.7 129 | X8.025Y-3.8 130 | X8.025Y-3.9 131 | T3 132 | X7.075Y-1.998 133 | X7.075Y-2.098 134 | X7.075Y-2.198 135 | X7.075Y-2.298 136 | X7.075Y-2.398 137 | X7.075Y-2.498 138 | X7.075Y-2.598 139 | X7.075Y-2.698 140 | X7.075Y-2.798 141 | X7.075Y-2.898 142 | X7.075Y-2.998 143 | X7.075Y-3.098 144 | X7.075Y-3.198 145 | X7.075Y-3.298 146 | X7.075Y-3.398 147 | X7.075Y-3.498 148 | X7.075Y-3.598 149 | X7.075Y-3.698 150 | X7.075Y-3.798 151 | X7.075Y-3.898 152 | X7.3254Y-2.148 153 | X7.4254Y-2.148 154 | X7.675Y-1.996 155 | X7.675Y-2.098 156 | X7.675Y-2.198 157 | X7.675Y-2.298 158 | X7.675Y-2.398 159 | X7.675Y-2.498 160 | X7.675Y-2.598 161 | X7.675Y-2.698 162 | X7.675Y-2.798 163 | X7.675Y-2.898 164 | X7.675Y-2.998 165 | X7.675Y-3.098 166 | X7.675Y-3.198 167 | X7.675Y-3.298 168 | X7.675Y-3.398 169 | X7.675Y-3.498 170 | X7.675Y-3.598 171 | X7.675Y-3.698 172 | X7.675Y-3.798 173 | X7.675Y-3.898 174 | T4 175 | X8.748Y-2.0264 176 | X8.748Y-3.8807 177 | T0 178 | M30 179 | -------------------------------------------------------------------------------- /Hardware/GrblCnc3040/sym-lib-table: -------------------------------------------------------------------------------- 1 | (sym_lib_table 2 | (lib (name GrblCnc3040)(type Legacy)(uri ${KIPRJMOD}/GrblCnc3040.lib)(options "")(descr "")) 3 | ) 4 | -------------------------------------------------------------------------------- /Media/GrblCnc3040.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Media/GrblCnc3040.jpg -------------------------------------------------------------------------------- /Media/GrblCnc3040_back.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Media/GrblCnc3040_back.jpg -------------------------------------------------------------------------------- /Media/STM32F103C8T8_Bluepill.pptx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Media/STM32F103C8T8_Bluepill.pptx -------------------------------------------------------------------------------- /Media/grblcnc1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Media/grblcnc1.png -------------------------------------------------------------------------------- /Media/pindiag.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Media/pindiag.png -------------------------------------------------------------------------------- /PROGRESS.md: -------------------------------------------------------------------------------- 1 | ## GRBL for Chinese CNC3040-like machines. WIP. 2 | ### Project progress: 3 | 4 | * 04 May 2020: First release 5 | * 18 Apr 2020: Manual Tool change and start of tool table implemented 6 | * 06 Apr 2020: Support of g54-59 offsets 7 | * Display gcode parser state 8 | * Working coordinate display on main 3D window 9 | * Coordinate touch off and tool probing 10 | * Error display similar to LinuxCNC 11 | * 28 Mar 2020: Basic Sender program available 12 | * move to grblHal as the grbl driver for its more comprehensive gcode support 13 | * 18 Mar 2020: Migration to STM32CubeIDE 14 | * 05 Mar 2020: A and B axis basic functionality added 15 | * Add option to manualy home each axis (similar to LinuxCNC) 16 | * 04 Mar 2020: Complete PCB editing of dongle. 17 | * 02 Mar 2020: Fix some initial bugs related to using 8bit vars for 16bit ports. 18 | * 01 Mar 2020: Reorder pin assignments. 19 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # GrblCNC 2 | A C# Clone to LinuxCNC that works with GRBL CNC driver 3 | #### This project is done in parallel with a compatible Grbl driver firmware 4 | * [Click here for project page](https://github.com/shaise/grblHAL_CNC3040) 5 | ```diff 6 | - This is a work in progress, only basic stuff are operational 7 | ``` 8 | ## Software 9 | ### Screen preview 10 | ![GrblCNC interface](Media/grblcnc1.png?raw=true) 11 | 12 | ## Hardware 13 | * [Click here for firmware project page](https://github.com/shaise/grblHAL_CNC3040) 14 | * [Click here for project progress](PROGRESS.md) 15 | * [Click here for list of added capabilities](EXTENTIONS.md) 16 | ### GRBL for Chinese CNC3040-like machines. WIP. 17 | ### Based on STM32F103C8T6 "Bluepill" boards with customized grblHAL firmware 18 | #### Project goals: 19 | * Develop simple open hardware plug to replace the vanishing parallel port 20 | - Support configurable pin assignments 21 | - Support extra controls not available on CNC3040 such as mist, flood, spindle RPM reader 22 | * Add support for more axis. (at least add A axis) 23 | * Support other features that LinuxCNC have 24 | 25 | ## Development Environment 26 | | | | 27 | |----------------------|--------------------------| 28 | | **IDE** | STM32CubeIDE v1.2.0 | 29 | | **Controller board** | STM32F103C8T6 (Bluepill) | 30 | 31 | ## Reference 32 | - GRBL CNC controller ported to STM32 controller (and others) 33 | ```https://github.com/terjeio/grblHAL``` 34 | - GRBL CNC controller 35 | ```https://github.com/gnea/grbl``` 36 | 37 | ## Pin Diagram 38 | 39 | ![STM32 Pin Diagram](Media/pindiag.png?raw=true) 40 | 41 | ## GRBL dongle for CNC3040 concept art: 42 | ![Concept PCB](Media/GrblCnc3040.jpg?raw=true) 43 | ### Back side 44 | ![Concept PCB_back](Media/GrblCnc3040_back.jpg?raw=true) 45 | 46 | -------------------------------------------------------------------------------- /Release/V0.01/GRBL Driver STM32F103C8 V20200503.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Release/V0.01/GRBL Driver STM32F103C8 V20200503.bin -------------------------------------------------------------------------------- /Release/V0.01/GrblCNC.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Release/V0.01/GrblCNC.exe -------------------------------------------------------------------------------- /Release/V0.01/OpenTK.GLControl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Release/V0.01/OpenTK.GLControl.dll -------------------------------------------------------------------------------- /Release/V0.01/OpenTK.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Release/V0.01/OpenTK.dll -------------------------------------------------------------------------------- /Release/V0.01/gerbers_cnc3040_2Layer.zip: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Release/V0.01/gerbers_cnc3040_2Layer.zip -------------------------------------------------------------------------------- /Software/GrblCNC.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.34112.143 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GrblCNC", "GrblCNC\GrblCNC.csproj", "{ECD5DC3A-C407-4678-A707-58572B891971}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {ECD5DC3A-C407-4678-A707-58572B891971}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {ECD5DC3A-C407-4678-A707-58572B891971}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {ECD5DC3A-C407-4678-A707-58572B891971}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {ECD5DC3A-C407-4678-A707-58572B891971}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {BCDC694E-5841-481F-9548-DA5A34F43CA1} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /Software/GrblCNC/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/AlarmViewer.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC 2 | { 3 | partial class AlarmViewer 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // BigNumViewer 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.Name = "BigNumViewer"; 38 | this.Size = new System.Drawing.Size(212, 88); 39 | this.ResumeLayout(false); 40 | 41 | } 42 | 43 | #endregion 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/BigNumViewer.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC 2 | { 3 | partial class BigNumViewer 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // BigNumViewer 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.Name = "BigNumViewer"; 38 | this.Size = new System.Drawing.Size(212, 88); 39 | this.ResumeLayout(false); 40 | 41 | } 42 | 43 | #endregion 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/DualProgressTool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace GrblCNC.Controls 12 | { 13 | public partial class DualProgressTool : ToolStripItem 14 | { 15 | int value1 = 0; 16 | int maximum1 = 100; 17 | int value2 = 0; 18 | int maximum2 = 100; 19 | Color color1 = Color.Blue; 20 | Color color2 = Color.Blue; 21 | public DualProgressTool() 22 | { 23 | } 24 | 25 | public int Maximum1 26 | { 27 | get { return maximum1; } 28 | set 29 | { 30 | maximum1 = value; 31 | if (maximum1 < 1) 32 | maximum1 = 1; 33 | if (maximum1 < value1) 34 | value1 = maximum1; 35 | Invalidate(); 36 | } 37 | } 38 | 39 | public int Value1 40 | { 41 | get { return value1; } 42 | set 43 | { 44 | value1 = value; 45 | if (value1 < 0) 46 | value1 = 0; 47 | if (value1 > maximum1) 48 | maximum1 = value1; 49 | Invalidate(); 50 | } 51 | } 52 | 53 | public Color Color1 54 | { 55 | get { return color1; } 56 | set 57 | { 58 | color1 = value; 59 | Invalidate(); 60 | } 61 | } 62 | 63 | public int Maximum2 64 | { 65 | get { return maximum2; } 66 | set 67 | { 68 | maximum2 = value; 69 | if (maximum2 < 1) 70 | maximum2 = 1; 71 | if (maximum2 < value2) 72 | value2 = maximum2; 73 | Invalidate(); 74 | } 75 | } 76 | 77 | 78 | public int Value2 79 | { 80 | get { return value2; } 81 | set 82 | { 83 | value2 = value; 84 | if (value2 < 0) 85 | value2 = 0; 86 | if (value2 > maximum2) 87 | maximum2 = value2; 88 | Invalidate(); 89 | } 90 | } 91 | 92 | public Color Color2 93 | { 94 | get { return color2; } 95 | set 96 | { 97 | color2 = value; 98 | Invalidate(); 99 | } 100 | } 101 | 102 | void DrawBar(Graphics g, Color c, Rectangle rect, int val, int max) 103 | { 104 | Brush b = new SolidBrush(Color.FromArgb(64, c)); 105 | g.FillRectangle(b, rect); 106 | rect.Width = (val * rect.Width) / max; 107 | b = new SolidBrush(c); 108 | g.FillRectangle(b, rect); 109 | } 110 | 111 | protected override void OnPaint(PaintEventArgs e) 112 | { 113 | //base.OnPaint(e); 114 | Rectangle rectangle = e.ClipRectangle; 115 | rectangle.Height -= 2; 116 | ProgressBarRenderer.DrawHorizontalBar(e.Graphics, rectangle); 117 | rectangle.Width = rectangle.Width - 4; 118 | rectangle.Height = (Height - 4) / 2 - 2; 119 | rectangle.X = 2; 120 | rectangle.Y = 2; 121 | DrawBar(e.Graphics, color1, rectangle, value1, maximum1); 122 | rectangle.Y += rectangle.Height + 2; 123 | DrawBar(e.Graphics, color2, rectangle, value2, maximum2); 124 | } 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/ErrorView.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC.Controls 2 | { 3 | partial class ErrorView 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.components = new System.ComponentModel.Container(); 32 | this.labelError = new System.Windows.Forms.Label(); 33 | this.pictureBox1 = new System.Windows.Forms.PictureBox(); 34 | this.toolTip1 = new System.Windows.Forms.ToolTip(this.components); 35 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit(); 36 | this.SuspendLayout(); 37 | // 38 | // labelError 39 | // 40 | this.labelError.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); 41 | this.labelError.Location = new System.Drawing.Point(42, 5); 42 | this.labelError.Name = "labelError"; 43 | this.labelError.Size = new System.Drawing.Size(194, 80); 44 | this.labelError.TabIndex = 0; 45 | this.labelError.Text = "Error\r\n1\r\n2\r\n3"; 46 | this.labelError.Click += new System.EventHandler(this.labelError_Click); 47 | // 48 | // pictureBox1 49 | // 50 | this.pictureBox1.Image = global::GrblCNC.Properties.Resources.ErrorIcon; 51 | this.pictureBox1.Location = new System.Drawing.Point(3, 7); 52 | this.pictureBox1.Name = "pictureBox1"; 53 | this.pictureBox1.Size = new System.Drawing.Size(33, 77); 54 | this.pictureBox1.TabIndex = 1; 55 | this.pictureBox1.TabStop = false; 56 | this.pictureBox1.Click += new System.EventHandler(this.pictureBox1_Click); 57 | // 58 | // ErrorView 59 | // 60 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 61 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 62 | this.Controls.Add(this.pictureBox1); 63 | this.Controls.Add(this.labelError); 64 | this.Name = "ErrorView"; 65 | this.Size = new System.Drawing.Size(260, 90); 66 | ((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).EndInit(); 67 | this.ResumeLayout(false); 68 | 69 | } 70 | 71 | #endregion 72 | 73 | private System.Windows.Forms.Label labelError; 74 | private System.Windows.Forms.PictureBox pictureBox1; 75 | private System.Windows.Forms.ToolTip toolTip1; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/ErrorView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using GrblCNC.Properties; 11 | 12 | namespace GrblCNC.Controls 13 | { 14 | public partial class ErrorView : UserControl 15 | { 16 | int id; 17 | const float xSize = 10; 18 | const float borderWidth = 2; 19 | float gap1; 20 | float gap2; 21 | bool isOverX; 22 | 23 | public enum ErrorType 24 | { 25 | Alarm, 26 | Error 27 | } 28 | 29 | public ErrorView() 30 | { 31 | InitializeComponent(); 32 | gap1 = borderWidth + 2 + xSize; 33 | gap2 = borderWidth + 2; 34 | } 35 | 36 | public override string Text 37 | { 38 | get 39 | { 40 | return labelError.Text; 41 | } 42 | set 43 | { 44 | labelError.Text = value; 45 | toolTip1.SetToolTip(labelError, MakeMultiline(value, 30)); 46 | } 47 | } 48 | 49 | public int Id 50 | { 51 | get { return id; } 52 | set { id = value; } 53 | } 54 | 55 | public void SetErrorType(ErrorType typ) 56 | { 57 | if (typ == ErrorType.Alarm) 58 | pictureBox1.Image = Resources.AlarmErrorIcon; 59 | else 60 | pictureBox1.Image = Resources.ErrorIcon; 61 | } 62 | 63 | protected override void OnPaint(PaintEventArgs e) 64 | { 65 | Graphics g = e.Graphics; 66 | Pen pOutline = new Pen(Color.DarkRed, borderWidth); 67 | float bw2 = borderWidth / 2; 68 | g.DrawRectangle(pOutline, bw2, bw2, Width - borderWidth, Height - borderWidth); 69 | if (isOverX) 70 | g.FillRectangle(Brushes.LightBlue, Width - gap1, gap2, xSize, xSize); 71 | Pen pX = new Pen(ForeColor, 2); 72 | g.DrawLine(pX, Width - gap1, gap2, Width - gap2, gap1); 73 | g.DrawLine(pX, Width - gap2, gap2, Width - gap1, gap1); 74 | base.OnPaint(e); 75 | } 76 | 77 | string MakeMultiline(string line, int maxCharsPerLine) 78 | { 79 | string[] words = line.Split(' '); 80 | StringBuilder sb = new StringBuilder(); 81 | int len = 0; 82 | foreach (string word in words) 83 | { 84 | if (len + word.Length > maxCharsPerLine) 85 | { 86 | sb.Append("\r\n"); 87 | len = 0; 88 | } 89 | sb.Append(word); 90 | sb.Append(" "); 91 | len += word.Length + 1; 92 | } 93 | return sb.ToString(); 94 | } 95 | 96 | protected override void OnMouseMove(MouseEventArgs e) 97 | { 98 | bool oldState = isOverX; 99 | isOverX = e.X >= (Width - gap1) && e.X <= (Width - gap2) && e.Y >= gap2 && e.Y <= gap1; 100 | if (oldState != isOverX) 101 | { 102 | oldState = isOverX; 103 | Invalidate(); 104 | } 105 | base.OnMouseMove(e); 106 | } 107 | 108 | private void labelError_Click(object sender, EventArgs e) 109 | { 110 | InvokeOnClick(this, e); 111 | } 112 | 113 | private void pictureBox1_Click(object sender, EventArgs e) 114 | { 115 | InvokeOnClick(this, e); 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/FormAbout.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace GrblCNC.Controls 12 | { 13 | public partial class FormAbout : Form 14 | { 15 | public FormAbout() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | private void linkDevel_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 21 | { 22 | System.Diagnostics.Process.Start("https://github.com/shaise/GrblCNC"); 23 | } 24 | 25 | private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) 26 | { 27 | System.Diagnostics.Process.Start("https://github.com/terjeio/grblHAL"); 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/FormChangeTool.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC.Controls 2 | { 3 | partial class FormChangeTool 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.buttResume = new System.Windows.Forms.Button(); 32 | this.labelTool = new System.Windows.Forms.Label(); 33 | this.buttPause = new System.Windows.Forms.Button(); 34 | this.label2 = new System.Windows.Forms.Label(); 35 | this.label3 = new System.Windows.Forms.Label(); 36 | this.SuspendLayout(); 37 | // 38 | // buttResume 39 | // 40 | this.buttResume.Location = new System.Drawing.Point(17, 178); 41 | this.buttResume.Margin = new System.Windows.Forms.Padding(6); 42 | this.buttResume.Name = "buttResume"; 43 | this.buttResume.Size = new System.Drawing.Size(106, 44); 44 | this.buttResume.TabIndex = 0; 45 | this.buttResume.Text = "Continue"; 46 | this.buttResume.UseVisualStyleBackColor = true; 47 | this.buttResume.Click += new System.EventHandler(this.buttResume_Click); 48 | // 49 | // labelTool 50 | // 51 | this.labelTool.AutoSize = true; 52 | this.labelTool.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); 53 | this.labelTool.ForeColor = System.Drawing.Color.Maroon; 54 | this.labelTool.Location = new System.Drawing.Point(73, 22); 55 | this.labelTool.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); 56 | this.labelTool.Name = "labelTool"; 57 | this.labelTool.Size = new System.Drawing.Size(184, 37); 58 | this.labelTool.TabIndex = 1; 59 | this.labelTool.Text = "Insert Tool #"; 60 | // 61 | // buttPause 62 | // 63 | this.buttPause.Location = new System.Drawing.Point(268, 178); 64 | this.buttPause.Margin = new System.Windows.Forms.Padding(6); 65 | this.buttPause.Name = "buttPause"; 66 | this.buttPause.Size = new System.Drawing.Size(106, 44); 67 | this.buttPause.TabIndex = 2; 68 | this.buttPause.Text = "Pause"; 69 | this.buttPause.UseVisualStyleBackColor = true; 70 | this.buttPause.Click += new System.EventHandler(this.buttPause_Click); 71 | // 72 | // label2 73 | // 74 | this.label2.AutoSize = true; 75 | this.label2.Location = new System.Drawing.Point(12, 68); 76 | this.label2.Name = "label2"; 77 | this.label2.Size = new System.Drawing.Size(303, 25); 78 | this.label2.TabIndex = 3; 79 | this.label2.Text = "Press Continue when finished."; 80 | // 81 | // label3 82 | // 83 | this.label3.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); 84 | this.label3.Location = new System.Drawing.Point(12, 101); 85 | this.label3.Name = "label3"; 86 | this.label3.Size = new System.Drawing.Size(362, 68); 87 | this.label3.TabIndex = 4; 88 | this.label3.Text = "If you need to adjust head location or probe the new tool, press Pause, make the " + 89 | "adjustments, then press the Play button to continue."; 90 | // 91 | // FormChangeTool 92 | // 93 | this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F); 94 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 95 | this.ClientSize = new System.Drawing.Size(392, 240); 96 | this.Controls.Add(this.label3); 97 | this.Controls.Add(this.label2); 98 | this.Controls.Add(this.buttPause); 99 | this.Controls.Add(this.labelTool); 100 | this.Controls.Add(this.buttResume); 101 | this.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); 102 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 103 | this.Margin = new System.Windows.Forms.Padding(6); 104 | this.Name = "FormChangeTool"; 105 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 106 | this.Text = "Change Tool"; 107 | this.ResumeLayout(false); 108 | this.PerformLayout(); 109 | 110 | } 111 | 112 | #endregion 113 | 114 | private System.Windows.Forms.Button buttResume; 115 | private System.Windows.Forms.Label labelTool; 116 | private System.Windows.Forms.Button buttPause; 117 | private System.Windows.Forms.Label label2; 118 | private System.Windows.Forms.Label label3; 119 | } 120 | } -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/FormChangeTool.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace GrblCNC.Controls 12 | { 13 | public partial class FormChangeTool : Form 14 | { 15 | public FormChangeTool() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | public void SetToolNumber(int toolno) 21 | { 22 | labelTool.Text = "Insert Tool #" + toolno.ToString(); 23 | } 24 | 25 | private void buttResume_Click(object sender, EventArgs e) 26 | { 27 | DialogResult = System.Windows.Forms.DialogResult.OK; 28 | Close(); 29 | } 30 | 31 | private void buttPause_Click(object sender, EventArgs e) 32 | { 33 | DialogResult = System.Windows.Forms.DialogResult.Cancel; 34 | Close(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/FormConfirmation.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC.Controls 2 | { 3 | partial class FormConfirmation 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.buttConfirm = new System.Windows.Forms.Button(); 32 | this.labelTool = new System.Windows.Forms.Label(); 33 | this.buttCancel = new System.Windows.Forms.Button(); 34 | this.labelMessage = new System.Windows.Forms.Label(); 35 | this.SuspendLayout(); 36 | // 37 | // buttConfirm 38 | // 39 | this.buttConfirm.Location = new System.Drawing.Point(17, 153); 40 | this.buttConfirm.Margin = new System.Windows.Forms.Padding(6); 41 | this.buttConfirm.Name = "buttConfirm"; 42 | this.buttConfirm.Size = new System.Drawing.Size(106, 44); 43 | this.buttConfirm.TabIndex = 0; 44 | this.buttConfirm.Text = "Confirm"; 45 | this.buttConfirm.UseVisualStyleBackColor = true; 46 | this.buttConfirm.Click += new System.EventHandler(this.buttConfirm_Click); 47 | // 48 | // labelTool 49 | // 50 | this.labelTool.AutoSize = true; 51 | this.labelTool.Font = new System.Drawing.Font("Microsoft Sans Serif", 24F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); 52 | this.labelTool.ForeColor = System.Drawing.Color.Maroon; 53 | this.labelTool.Location = new System.Drawing.Point(73, 22); 54 | this.labelTool.Margin = new System.Windows.Forms.Padding(6, 0, 6, 0); 55 | this.labelTool.Name = "labelTool"; 56 | this.labelTool.Size = new System.Drawing.Size(215, 37); 57 | this.labelTool.TabIndex = 1; 58 | this.labelTool.Text = "Are you sure?"; 59 | // 60 | // buttCancel 61 | // 62 | this.buttCancel.Location = new System.Drawing.Point(269, 153); 63 | this.buttCancel.Margin = new System.Windows.Forms.Padding(6); 64 | this.buttCancel.Name = "buttCancel"; 65 | this.buttCancel.Size = new System.Drawing.Size(106, 44); 66 | this.buttCancel.TabIndex = 2; 67 | this.buttCancel.Text = "Cancel"; 68 | this.buttCancel.UseVisualStyleBackColor = true; 69 | this.buttCancel.Click += new System.EventHandler(this.buttCancel_Click); 70 | // 71 | // labelMessage 72 | // 73 | this.labelMessage.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); 74 | this.labelMessage.Location = new System.Drawing.Point(13, 68); 75 | this.labelMessage.Name = "labelMessage"; 76 | this.labelMessage.Size = new System.Drawing.Size(362, 68); 77 | this.labelMessage.TabIndex = 4; 78 | this.labelMessage.Text = "This will reset the Grbl CNC driver. After that, location will be lost and the CN" + 79 | "C must be rehomed"; 80 | // 81 | // FormConfirmation 82 | // 83 | this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F); 84 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 85 | this.ClientSize = new System.Drawing.Size(392, 213); 86 | this.Controls.Add(this.labelMessage); 87 | this.Controls.Add(this.buttCancel); 88 | this.Controls.Add(this.labelTool); 89 | this.Controls.Add(this.buttConfirm); 90 | this.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); 91 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 92 | this.Margin = new System.Windows.Forms.Padding(6); 93 | this.Name = "FormConfirmation"; 94 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 95 | this.Text = "Please confirm"; 96 | this.ResumeLayout(false); 97 | this.PerformLayout(); 98 | 99 | } 100 | 101 | #endregion 102 | 103 | private System.Windows.Forms.Button buttConfirm; 104 | private System.Windows.Forms.Label labelTool; 105 | private System.Windows.Forms.Button buttCancel; 106 | private System.Windows.Forms.Label labelMessage; 107 | } 108 | } -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/FormConfirmation.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace GrblCNC.Controls 12 | { 13 | public partial class FormConfirmation : Form 14 | { 15 | public FormConfirmation() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | public void SetMessage(string Message) 21 | { 22 | labelMessage.Text = Message; 23 | } 24 | 25 | private void buttConfirm_Click(object sender, EventArgs e) 26 | { 27 | DialogResult = System.Windows.Forms.DialogResult.OK; 28 | Close(); 29 | } 30 | 31 | private void buttCancel_Click(object sender, EventArgs e) 32 | { 33 | DialogResult = System.Windows.Forms.DialogResult.Cancel; 34 | Close(); 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/FormGoto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using GrblCNC.Glutils; 11 | using static GrblCNC.Controls.ManualControl; 12 | 13 | namespace GrblCNC.Controls 14 | { 15 | public partial class FormGoto : Form 16 | { 17 | public delegate void GotoActionPressedDelegate(object sender, GoToAction action); 18 | public event GotoActionPressedDelegate GotoActionPressed; 19 | 20 | public FormGoto() 21 | { 22 | InitializeComponent(); 23 | comboCoord.Items.Add("Current"); 24 | comboCoord.Items.AddRange(GrblUtils.GetCoordSystemRange()); 25 | comboCoord.SelectedIndex = 0; 26 | Global.NumAxesChanged += Global_NumAxesChanged; 27 | } 28 | 29 | private void Global_NumAxesChanged() 30 | { 31 | if (InvokeRequired) 32 | { 33 | BeginInvoke(new MethodInvoker(() => { Global_NumAxesChanged(); })); 34 | return; 35 | } 36 | multiSelAxis.SelectionTexts = Global.GetAxesString(); 37 | UpdateVisibility(); 38 | } 39 | 40 | private void UpdateVisibility() 41 | { 42 | numA.Visible = Global.NumAxes > 3; 43 | numB.Visible = Global.NumAxes > 4; 44 | int selstate = multiSelAxis.SelectedValue; 45 | numX.Enabled = (selstate & 1) != 0; 46 | numY.Enabled = (selstate & 2) != 0; 47 | numZ.Enabled = (selstate & 4) != 0; 48 | numA.Enabled = (selstate & 8) != 0; 49 | numB.Enabled = (selstate & 16) != 0; 50 | } 51 | 52 | public int CoordSystem 53 | { 54 | get 55 | { 56 | return comboCoord.SelectedIndex - 1; 57 | } 58 | set 59 | { 60 | if (value >= -1 && value < (comboCoord.Items.Count - 1)) 61 | comboCoord.SelectedIndex = value + 1; 62 | } 63 | } 64 | 65 | public int Axis 66 | { 67 | get { return multiSelAxis.SelectedValue; } 68 | set { 69 | multiSelAxis.SelectedValue = value; 70 | UpdateVisibility(); 71 | } 72 | } 73 | 74 | 75 | private void buttGO_Click(object sender, EventArgs e) 76 | { 77 | if (GotoActionPressed == null) 78 | return; 79 | GoToAction action = new GoToAction(); 80 | action.pos = new double[Global.MAX_AXES]; 81 | action.pos[0] = (double)numX.Value; 82 | action.pos[1] = (double)numY.Value; 83 | action.pos[2] = (double)numZ.Value; 84 | action.pos[3] = (double)numA.Value; 85 | action.pos[4] = (double)numB.Value; 86 | action.coordSystem = CoordSystem; 87 | action.axisMask = multiSelAxis.SelectedValue; 88 | GotoActionPressed(this, action); 89 | } 90 | 91 | 92 | private void multiSelAxis_SelectionChanged(object obj, int newSelection) 93 | { 94 | UpdateVisibility(); 95 | } 96 | 97 | private void buttClose_Click(object sender, EventArgs e) 98 | { 99 | DialogResult = System.Windows.Forms.DialogResult.OK; 100 | Close(); 101 | } 102 | 103 | private void buttClear_Click(object sender, EventArgs e) 104 | { 105 | numX.Value = 0; 106 | numY.Value = 0; 107 | numZ.Value = 0; 108 | numA.Value = 0; 109 | numB.Value = 0; 110 | comboCoord.SelectedIndex = 0; 111 | } 112 | 113 | private void numX_ValueChanged(object sender, EventArgs e) 114 | { 115 | 116 | } 117 | } 118 | public class GoToAction 119 | { 120 | public double [] pos; 121 | public int coordSystem; 122 | public int axisMask; 123 | } 124 | } 125 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/FormOffset.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace GrblCNC.Controls 12 | { 13 | public partial class FormOffset : Form 14 | { 15 | public FormOffset() 16 | { 17 | InitializeComponent(); 18 | comboCoord.Items.AddRange(GrblUtils.GetCoordSystemRange()); 19 | comboCoord.SelectedIndex = 0; 20 | } 21 | 22 | public float Offset 23 | { 24 | get { return (float)numericOffset.Value; } 25 | set { numericOffset.Value = (decimal)value; } 26 | } 27 | 28 | protected override void OnVisibleChanged(EventArgs e) 29 | { 30 | if (Visible) 31 | numericOffset.Select(); 32 | base.OnVisibleChanged(e); 33 | } 34 | 35 | 36 | 37 | public int CoordSystem 38 | { 39 | get 40 | { 41 | if (comboCoord.Enabled) 42 | return comboCoord.SelectedIndex; 43 | else 44 | return -1; 45 | } 46 | set 47 | { 48 | if (value >= 0 && value < comboCoord.Items.Count) 49 | { 50 | comboCoord.SelectedIndex = value; 51 | comboCoord.Enabled = true; 52 | } 53 | else 54 | comboCoord.Enabled = false; 55 | } 56 | } 57 | 58 | private void buttOK_Click(object sender, EventArgs e) 59 | { 60 | DialogResult = System.Windows.Forms.DialogResult.OK; 61 | Close(); 62 | } 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/FormProbe.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using GrblCNC.Glutils; 11 | 12 | namespace GrblCNC.Controls 13 | { 14 | public partial class FormProbe : Form 15 | { 16 | int tool; 17 | public bool IsProbe = false; 18 | public enum Mode 19 | { 20 | Tool, 21 | Axis 22 | } 23 | 24 | decimal [] offsPerAxis; 25 | int lastAxisSel; 26 | public FormProbe() 27 | { 28 | InitializeComponent(); 29 | comboCoord.Items.AddRange(GrblUtils.GetCoordSystemRange()); 30 | comboCoord.SelectedIndex = 0; 31 | comboTool.Items.Add("No Tool"); 32 | Global.NumAxesChanged += Global_NumAxesChanged; 33 | offsPerAxis = new decimal[8]; 34 | for (int i = 0; i < 8; i++) 35 | { 36 | offsPerAxis[i] = numericOffset.Value; 37 | } 38 | lastAxisSel = multiSelAxis.SelectedValue; 39 | } 40 | 41 | private void Global_NumAxesChanged() 42 | { 43 | if (InvokeRequired) 44 | { 45 | BeginInvoke(new MethodInvoker(() => { Global_NumAxesChanged(); })); 46 | return; 47 | } 48 | multiSelAxis.SelectionTexts = Global.GetAxesString(); 49 | } 50 | 51 | public float Offset 52 | { 53 | get { return (float)numericOffset.Value; } 54 | set { numericOffset.Value = (decimal)value; } 55 | } 56 | 57 | protected override void OnVisibleChanged(EventArgs e) 58 | { 59 | if (Visible) 60 | numericOffset.Select(); 61 | base.OnVisibleChanged(e); 62 | } 63 | 64 | public int Axis 65 | { 66 | get { return multiSelAxis.SelectedValue; } 67 | set { multiSelAxis.SelectedValue = value; } 68 | } 69 | 70 | int FindTool(int toolnum) 71 | { 72 | for (int i = 1; i < comboTool.Items.Count; i++) 73 | { 74 | string[] vars = comboTool.Items[i].ToString().Split(':'); 75 | if (toolnum == int.Parse(vars[0])) 76 | return i; 77 | } 78 | return 0; 79 | } 80 | 81 | public void SetMode(Mode mode) 82 | { 83 | comboTool.Visible = (mode == Mode.Tool); 84 | comboCoord.Visible = (mode == Mode.Axis); 85 | } 86 | 87 | public int Tool 88 | { 89 | get { return tool; } 90 | set 91 | { 92 | int toolix = FindTool(value); 93 | comboTool.SelectedIndex = toolix; 94 | labelCoord.Text = "Tool:"; 95 | UpdateToolFromSelection(); 96 | } 97 | } 98 | 99 | public int CoordSystem 100 | { 101 | get 102 | { 103 | if (comboCoord.Enabled) 104 | return comboCoord.SelectedIndex; 105 | else 106 | return -1; 107 | } 108 | set 109 | { 110 | if (value >= 0 && value < comboCoord.Items.Count) 111 | { 112 | comboCoord.SelectedIndex = value; 113 | comboCoord.Enabled = true; 114 | } 115 | else 116 | comboCoord.Enabled = false; 117 | labelCoord.Text = "Coordinates:"; 118 | } 119 | } 120 | 121 | void UpdateToolFromSelection() 122 | { 123 | if (comboTool.SelectedIndex == 0) 124 | tool = 0; 125 | else 126 | { 127 | string[] vars = comboTool.SelectedItem.ToString().Split(':'); 128 | tool = int.Parse(vars[0]); 129 | } 130 | } 131 | 132 | 133 | 134 | public void UpdateTools() 135 | { 136 | comboTool.Items.Clear(); 137 | comboTool.Items.Add("No Tool"); 138 | foreach (CncTool tool in Global.toolTable.Tools) 139 | { 140 | if (tool.description.Length > 0) 141 | comboTool.Items.Add(string.Format("{0}: {1}", tool.toolNum, tool.description)); 142 | else 143 | comboTool.Items.Add(tool.toolNum.ToString()); 144 | } 145 | } 146 | 147 | public float Direction 148 | { 149 | get { return multiSelDir.SelectedValue == 0 ? -1 : 1; } 150 | set { multiSelDir.SelectedValue = value < 0 ? 0 : 1; } 151 | } 152 | 153 | private void buttOK_Click(object sender, EventArgs e) 154 | { 155 | IsProbe = false; 156 | DialogResult = System.Windows.Forms.DialogResult.OK; 157 | Close(); 158 | } 159 | 160 | private void comboTool_SelectedIndexChanged(object sender, EventArgs e) 161 | { 162 | UpdateToolFromSelection(); 163 | } 164 | 165 | private void buttProbe_Click(object sender, EventArgs e) 166 | { 167 | IsProbe = true; 168 | DialogResult = System.Windows.Forms.DialogResult.OK; 169 | Close(); 170 | } 171 | 172 | private void multiSelAxis_SelectionChanged(object obj, int newSelection) 173 | { 174 | if (lastAxisSel < offsPerAxis.Length) 175 | offsPerAxis[lastAxisSel] = numericOffset.Value; 176 | numericOffset.Value = offsPerAxis[newSelection]; 177 | lastAxisSel = newSelection; 178 | } 179 | } 180 | } 181 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/FormSelectToolNum.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC.Controls 2 | { 3 | partial class FormSelectToolNum 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.label1 = new System.Windows.Forms.Label(); 32 | this.numericTool = new System.Windows.Forms.NumericUpDown(); 33 | this.buttOK = new System.Windows.Forms.Button(); 34 | this.buttCancel = new System.Windows.Forms.Button(); 35 | ((System.ComponentModel.ISupportInitialize)(this.numericTool)).BeginInit(); 36 | this.SuspendLayout(); 37 | // 38 | // label1 39 | // 40 | this.label1.AutoSize = true; 41 | this.label1.Location = new System.Drawing.Point(35, 14); 42 | this.label1.Name = "label1"; 43 | this.label1.Size = new System.Drawing.Size(78, 25); 44 | this.label1.TabIndex = 0; 45 | this.label1.Text = "Tool #:"; 46 | // 47 | // numericTool 48 | // 49 | this.numericTool.Location = new System.Drawing.Point(119, 12); 50 | this.numericTool.Minimum = new decimal(new int[] { 51 | 1, 52 | 0, 53 | 0, 54 | 0}); 55 | this.numericTool.Name = "numericTool"; 56 | this.numericTool.Size = new System.Drawing.Size(120, 31); 57 | this.numericTool.TabIndex = 1; 58 | this.numericTool.Value = new decimal(new int[] { 59 | 1, 60 | 0, 61 | 0, 62 | 0}); 63 | // 64 | // buttOK 65 | // 66 | this.buttOK.Location = new System.Drawing.Point(15, 61); 67 | this.buttOK.Margin = new System.Windows.Forms.Padding(6); 68 | this.buttOK.Name = "buttOK"; 69 | this.buttOK.Size = new System.Drawing.Size(118, 44); 70 | this.buttOK.TabIndex = 3; 71 | this.buttOK.Text = "OK"; 72 | this.buttOK.UseVisualStyleBackColor = true; 73 | this.buttOK.Click += new System.EventHandler(this.buttOK_Click); 74 | // 75 | // buttCancel 76 | // 77 | this.buttCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel; 78 | this.buttCancel.Location = new System.Drawing.Point(170, 61); 79 | this.buttCancel.Margin = new System.Windows.Forms.Padding(6); 80 | this.buttCancel.Name = "buttCancel"; 81 | this.buttCancel.Size = new System.Drawing.Size(118, 44); 82 | this.buttCancel.TabIndex = 4; 83 | this.buttCancel.Text = "Cancel"; 84 | this.buttCancel.UseVisualStyleBackColor = true; 85 | this.buttCancel.Click += new System.EventHandler(this.buttCancel_Click); 86 | // 87 | // FormSelectToolNum 88 | // 89 | this.AutoScaleDimensions = new System.Drawing.SizeF(12F, 25F); 90 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 91 | this.ClientSize = new System.Drawing.Size(305, 126); 92 | this.Controls.Add(this.buttCancel); 93 | this.Controls.Add(this.buttOK); 94 | this.Controls.Add(this.numericTool); 95 | this.Controls.Add(this.label1); 96 | this.Font = new System.Drawing.Font("Microsoft Sans Serif", 15.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(177))); 97 | this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedToolWindow; 98 | this.Margin = new System.Windows.Forms.Padding(6, 6, 6, 6); 99 | this.MaximizeBox = false; 100 | this.MinimizeBox = false; 101 | this.Name = "FormSelectToolNum"; 102 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 103 | this.Text = "Select Tool Number"; 104 | ((System.ComponentModel.ISupportInitialize)(this.numericTool)).EndInit(); 105 | this.ResumeLayout(false); 106 | this.PerformLayout(); 107 | 108 | } 109 | 110 | #endregion 111 | 112 | private System.Windows.Forms.Label label1; 113 | private System.Windows.Forms.NumericUpDown numericTool; 114 | private System.Windows.Forms.Button buttOK; 115 | private System.Windows.Forms.Button buttCancel; 116 | } 117 | } -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/FormSelectToolNum.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace GrblCNC.Controls 12 | { 13 | public partial class FormSelectToolNum : Form 14 | { 15 | 16 | public FormSelectToolNum() 17 | { 18 | InitializeComponent(); 19 | } 20 | 21 | private void buttOK_Click(object sender, EventArgs e) 22 | { 23 | DialogResult = System.Windows.Forms.DialogResult.OK; 24 | Close(); 25 | } 26 | 27 | private void buttCancel_Click(object sender, EventArgs e) 28 | { 29 | DialogResult = System.Windows.Forms.DialogResult.Cancel; 30 | Close(); 31 | } 32 | 33 | protected override void OnShown(EventArgs e) 34 | { 35 | numericTool.Focus(); 36 | numericTool.Select(0, numericTool.Text.Length); 37 | base.OnShown(e); 38 | } 39 | 40 | public int Value 41 | { 42 | get { return (int)numericTool.Value; } 43 | set { numericTool.Value = value; } 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/GStateViewer.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC.Controls 2 | { 3 | partial class GStateViewer 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // GStateViewer 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.Name = "GStateViewer"; 38 | this.Size = new System.Drawing.Size(244, 89); 39 | this.ResumeLayout(false); 40 | 41 | } 42 | 43 | #endregion 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/GStateViewer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace GrblCNC.Controls 12 | { 13 | public partial class GStateViewer : UserControl 14 | { 15 | string[] gstates; 16 | Font selFont; 17 | //int nCellsX = 6 18 | int nCellsY = 2; 19 | public GStateViewer() 20 | { 21 | DoubleBuffered = true; 22 | InitializeComponent(); 23 | //gstates = new string[] { "G54", "T1" }; 24 | } 25 | 26 | void UpdateFont() 27 | { 28 | if (Height < 1) 29 | return; 30 | selFont = new Font(Font.FontFamily, (float)Height * 0.25f); 31 | } 32 | 33 | public string[] GStates 34 | { 35 | get { return gstates; } 36 | set 37 | { 38 | gstates = value; 39 | Invalidate(); 40 | } 41 | } 42 | 43 | protected override void OnLoad(EventArgs e) 44 | { 45 | UpdateFont(); 46 | base.OnLoad(e); 47 | } 48 | 49 | protected override void OnResize(EventArgs e) 50 | { 51 | UpdateFont(); 52 | Invalidate(); 53 | base.OnResize(e); 54 | } 55 | 56 | protected override void OnPaint(PaintEventArgs e) 57 | { 58 | if (gstates == null || gstates.Length == 0) 59 | return; 60 | Graphics g = e.Graphics; 61 | int cellh = Height / nCellsY; 62 | Brush bf = new SolidBrush(ForeColor); 63 | Brush bb = new SolidBrush(Color.FromArgb(255,BackColor)); 64 | int px = 0; 65 | int py = 0; 66 | for (int i = 0; i < gstates.Length; i++ ) 67 | { 68 | SizeF sz = g.MeasureString(gstates[i], selFont); 69 | int w = (int)sz.Width + 6; 70 | if ((px + w) > Width) 71 | { 72 | px = 0; 73 | py += cellh; 74 | } 75 | g.FillRectangle(bf, px + 1, py + 1, w - 2, cellh - 2); 76 | g.DrawString(gstates[i], selFont, bb, px + (w - sz.Width) / 2, py + (cellh - sz.Height) / 2); 77 | px += w; 78 | } 79 | base.OnPaint(e); 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/GcodeViewer.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC 2 | { 3 | partial class GcodeViewer 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.vScroll = new System.Windows.Forms.VScrollBar(); 32 | this.SuspendLayout(); 33 | // 34 | // vScroll 35 | // 36 | this.vScroll.Dock = System.Windows.Forms.DockStyle.Right; 37 | this.vScroll.Location = new System.Drawing.Point(133, 0); 38 | this.vScroll.Name = "vScroll"; 39 | this.vScroll.Size = new System.Drawing.Size(17, 150); 40 | this.vScroll.TabIndex = 0; 41 | this.vScroll.Scroll += new System.Windows.Forms.ScrollEventHandler(this.vScroll_Scroll); 42 | // 43 | // GcodeViewer 44 | // 45 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 46 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 47 | this.Controls.Add(this.vScroll); 48 | this.Name = "GcodeViewer"; 49 | this.MouseClick += new System.Windows.Forms.MouseEventHandler(this.GcodeViewer_MouseClick); 50 | this.ResumeLayout(false); 51 | 52 | } 53 | 54 | #endregion 55 | 56 | private System.Windows.Forms.VScrollBar vScroll; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/HorizTab.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC.Controls 2 | { 3 | partial class HorizTab 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | components = new System.ComponentModel.Container(); 32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 33 | } 34 | 35 | #endregion 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/JogButton.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC.Controls 2 | { 3 | partial class JogButton 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | components = new System.ComponentModel.Container(); 32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 33 | } 34 | 35 | #endregion 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/MdiControl.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC.Controls 2 | { 3 | partial class MdiControl 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.textGcodeLine = new System.Windows.Forms.TextBox(); 32 | this.buttSendGcodeLine = new System.Windows.Forms.Button(); 33 | this.gStateView = new GrblCNC.Controls.GStateViewer(); 34 | this.gcodeViewMDI = new GrblCNC.GcodeViewer(); 35 | this.SuspendLayout(); 36 | // 37 | // textGcodeLine 38 | // 39 | this.textGcodeLine.Location = new System.Drawing.Point(6, 319); 40 | this.textGcodeLine.Name = "textGcodeLine"; 41 | this.textGcodeLine.Size = new System.Drawing.Size(175, 20); 42 | this.textGcodeLine.TabIndex = 3; 43 | this.textGcodeLine.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textGcodeLine_KeyDown); 44 | this.textGcodeLine.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textGcodeLine_KeyPress); 45 | // 46 | // buttSendGcodeLine 47 | // 48 | this.buttSendGcodeLine.Location = new System.Drawing.Point(187, 319); 49 | this.buttSendGcodeLine.Name = "buttSendGcodeLine"; 50 | this.buttSendGcodeLine.Size = new System.Drawing.Size(55, 23); 51 | this.buttSendGcodeLine.TabIndex = 4; 52 | this.buttSendGcodeLine.Text = "Send"; 53 | this.buttSendGcodeLine.UseVisualStyleBackColor = true; 54 | this.buttSendGcodeLine.Click += new System.EventHandler(this.buttSendGcodeLine_Click); 55 | // 56 | // gStateView 57 | // 58 | this.gStateView.ForeColor = System.Drawing.Color.Sienna; 59 | this.gStateView.GStates = null; 60 | this.gStateView.Location = new System.Drawing.Point(6, 349); 61 | this.gStateView.Name = "gStateView"; 62 | this.gStateView.Size = new System.Drawing.Size(236, 34); 63 | this.gStateView.TabIndex = 5; 64 | // 65 | // gcodeViewMDI 66 | // 67 | this.gcodeViewMDI.BorderStyle = System.Windows.Forms.BorderStyle.Fixed3D; 68 | this.gcodeViewMDI.Location = new System.Drawing.Point(6, 6); 69 | this.gcodeViewMDI.Name = "gcodeViewMDI"; 70 | this.gcodeViewMDI.ShowLineNumbers = false; 71 | this.gcodeViewMDI.Size = new System.Drawing.Size(234, 307); 72 | this.gcodeViewMDI.TabIndex = 1; 73 | this.gcodeViewMDI.TabStop = false; 74 | // 75 | // MdiControl 76 | // 77 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 78 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 79 | this.Controls.Add(this.gStateView); 80 | this.Controls.Add(this.buttSendGcodeLine); 81 | this.Controls.Add(this.textGcodeLine); 82 | this.Controls.Add(this.gcodeViewMDI); 83 | this.Name = "MdiControl"; 84 | this.Size = new System.Drawing.Size(273, 392); 85 | this.ResumeLayout(false); 86 | this.PerformLayout(); 87 | 88 | } 89 | 90 | #endregion 91 | 92 | private GcodeViewer gcodeViewMDI; 93 | private System.Windows.Forms.TextBox textGcodeLine; 94 | private System.Windows.Forms.Button buttSendGcodeLine; 95 | private GStateViewer gStateView; 96 | } 97 | } 98 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/MdiControl.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | using System.Linq.Expressions; 11 | 12 | namespace GrblCNC.Controls 13 | { 14 | public partial class MdiControl : UserControl 15 | { 16 | List mdiLines; 17 | int curMdiLine; 18 | public MdiControl() 19 | { 20 | InitializeComponent(); 21 | mdiLines = new List(); 22 | curMdiLine = 0; 23 | Global.GrblConnectionChanged += Global_GrblConnectionChanged; 24 | } 25 | 26 | void Global_GrblConnectionChanged(bool isConnected) 27 | { 28 | buttSendGcodeLine.Enabled = isConnected; 29 | textGcodeLine.Enabled = isConnected; 30 | } 31 | 32 | private void buttSendGcodeLine_Click(object sender, EventArgs e) 33 | { 34 | if (Global.grblComm == null) 35 | return; 36 | string line = textGcodeLine.Text; 37 | if (line.Length == 0) 38 | return; 39 | if (line[0] == '`') 40 | { 41 | try 42 | { 43 | byte code; 44 | if (line[1] == 'x') 45 | code = (byte)int.Parse(line.Substring(2), System.Globalization.NumberStyles.HexNumber); 46 | else 47 | code = (byte)int.Parse(line.Substring(1)); 48 | Global.grblComm.SendByte(code); 49 | mdiLines.Add(string.Format("<0x{0:X}>", code)); 50 | } 51 | catch { } 52 | } 53 | else 54 | { 55 | //gcodeViewMDI.AddLine(line); 56 | Global.grblComm.PostLine(line); 57 | mdiLines.Add(line); 58 | } 59 | curMdiLine = mdiLines.Count; 60 | textGcodeLine.Text = ""; 61 | } 62 | 63 | private void textGcodeLine_KeyDown(object sender, KeyEventArgs e) 64 | { 65 | switch (e.KeyCode) 66 | { 67 | case Keys.Up: 68 | if (curMdiLine > 0) 69 | { 70 | curMdiLine--; 71 | textGcodeLine.Text = mdiLines[curMdiLine]; 72 | //textGcodeLine.c 73 | e.Handled = true; 74 | } 75 | break; 76 | 77 | case Keys.Down: 78 | if (curMdiLine < (mdiLines.Count - 1)) 79 | { 80 | curMdiLine++; 81 | textGcodeLine.Text = mdiLines[curMdiLine]; 82 | e.Handled = true; 83 | } 84 | break; 85 | } 86 | } 87 | 88 | private void textGcodeLine_KeyPress(object sender, KeyPressEventArgs e) 89 | { 90 | if (e.KeyChar == (char)Keys.Enter) 91 | { 92 | e.Handled = true; 93 | buttSendGcodeLine.PerformClick(); 94 | } 95 | } 96 | 97 | void UpdateControlLocations() 98 | { 99 | // scale internal controls 100 | gStateView.Location = new Point(6, Height - 40); 101 | gStateView.Width = Width - 6; 102 | textGcodeLine.Location = new Point(6, gStateView.Location.Y - 25); 103 | textGcodeLine.Width = Width - 73; 104 | buttSendGcodeLine.Location = new Point(Width - 61, gStateView.Location.Y - 26); 105 | gcodeViewMDI.Width = Width - 14; 106 | gcodeViewMDI.Height = gStateView.Location.Y - 38; 107 | } 108 | 109 | protected override void OnSizeChanged(EventArgs e) 110 | { 111 | UpdateControlLocations(); 112 | base.OnSizeChanged(e); 113 | } 114 | protected override void OnLoad(EventArgs e) 115 | { 116 | buttSendGcodeLine.Enabled = Global.GrblConnected; 117 | UpdateControlLocations(); 118 | base.OnLoad(e); 119 | } 120 | 121 | public void AddLine(string line) 122 | { 123 | if (InvokeRequired) 124 | { 125 | try 126 | { 127 | if (!Global.AppClosing) 128 | Invoke(new MethodInvoker(() => { AddLine(line); })); 129 | } 130 | catch { } 131 | return; 132 | } 133 | gcodeViewMDI.AddLine(line); 134 | } 135 | 136 | public void SetGcodeParserStatus(string [] stat) 137 | { 138 | gStateView.GStates = stat; 139 | } 140 | 141 | //private void gcodeViewMDI_Enter(object sender, EventArgs e) 142 | //{ 143 | // textGcodeLine.Select(); 144 | //} 145 | } 146 | } 147 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/MultiSelect.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC.Controls 2 | { 3 | partial class MultiSelect 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // MultiSelect 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.Name = "MultiSelect"; 38 | this.Size = new System.Drawing.Size(227, 37); 39 | this.ResumeLayout(false); 40 | 41 | } 42 | 43 | #endregion 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/MultiSelect.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace GrblCNC.Controls 12 | { 13 | public partial class MultiSelect : UserControl 14 | { 15 | string selTextJoined; 16 | int depth = 2; 17 | Color highlightColor = Color.White, shadowColor = Color.Gray; 18 | int selectedValue = 0; 19 | bool multiMode = false; 20 | Font selFont = null; 21 | int nsels = 0; 22 | float cellw; 23 | public delegate void SelectionChangedDelegate(object obj, int newSelection); 24 | public event SelectionChangedDelegate SelectionChanged; 25 | public MultiSelect() 26 | { 27 | DoubleBuffered = true; 28 | InitializeComponent(); 29 | } 30 | 31 | public string SelectionTexts 32 | { 33 | get { return selTextJoined; } 34 | set 35 | { 36 | selTextJoined = value; 37 | Invalidate(); 38 | } 39 | } 40 | 41 | public void SetSelectionTexts(string [] texts) 42 | { 43 | SelectionTexts = string.Join("|", texts); 44 | } 45 | 46 | public int SelectedValue 47 | { 48 | get { return selectedValue; } 49 | set 50 | { 51 | bool ischange = (selectedValue != value); 52 | selectedValue = value; 53 | if (ischange) 54 | { 55 | if (SelectionChanged != null) 56 | SelectionChanged(this, selectedValue); 57 | } 58 | Invalidate(); 59 | } 60 | } 61 | 62 | public bool MultiSelectionMode 63 | { 64 | get { return multiMode; } 65 | set 66 | { 67 | multiMode = value; 68 | SelectedValue = 0; 69 | } 70 | } 71 | 72 | void UpdateFont() 73 | { 74 | if (Height < 1) 75 | return; 76 | selFont = new Font(Font.FontFamily, (float)Height * 0.5f); 77 | } 78 | 79 | protected override void OnLoad(EventArgs e) 80 | { 81 | // UpdateFont(); 82 | base.OnLoad(e); 83 | } 84 | 85 | protected override void OnPaint(PaintEventArgs e) 86 | { 87 | Graphics g = e.Graphics; 88 | Pen ps = new Pen(shadowColor); 89 | Pen ph = new Pen(highlightColor); 90 | int h = Height - 1; 91 | int w = Width - 1; 92 | for (int i = 0; i < depth; i++) 93 | { 94 | g.DrawLine(ps, i, i, w - i, i); 95 | g.DrawLine(ps, i, i, i, h - i); 96 | g.DrawLine(ph, i, h - i, w - i, h - i); 97 | g.DrawLine(ph, w - i, i, w - i, h - i); 98 | } 99 | if (selTextJoined == null) 100 | return; 101 | string[] selTexts = selTextJoined.Split('|'); 102 | nsels = selTexts.Length; 103 | if (nsels == 0) 104 | return; 105 | //h = Height - 2 * depth; 106 | //w = Width - 2 * depth; 107 | cellw = ((float)Width - 2 * depth) / nsels; 108 | Brush bf = Enabled ? new SolidBrush(ForeColor) : new SolidBrush(Color.FromArgb(64, ForeColor)); 109 | Brush bb = new SolidBrush(BackColor); 110 | 111 | for (int i = 0; i < nsels; i++) 112 | { 113 | int sp = (int)(i * cellw + depth); 114 | if (i > 0) 115 | { 116 | g.DrawLine(ph, sp - 1, depth, sp - 1, h - depth); 117 | g.DrawLine(ps, sp, depth, sp, h - depth); 118 | } 119 | SizeF sz = g.MeasureString(selTexts[i], selFont); 120 | float offsx = (cellw - sz.Width) / 2; 121 | float offsy = (Height - sz.Height) / 2; 122 | bool isSelectedCell = false; 123 | if (multiMode) 124 | isSelectedCell = (selectedValue & (1 << i)) != 0; 125 | else 126 | isSelectedCell = i == selectedValue; 127 | if (isSelectedCell) 128 | { 129 | g.FillRectangle(bf, sp + 2, depth + 1, cellw - 3, Height - 2 * depth - 2); 130 | g.DrawString(selTexts[i], selFont, bb, sp + offsx, offsy); 131 | } 132 | else 133 | g.DrawString(selTexts[i], selFont, bf, sp + offsx, offsy); 134 | 135 | } 136 | base.OnPaint(e); 137 | } 138 | 139 | protected override void OnSizeChanged(EventArgs e) 140 | { 141 | UpdateFont(); 142 | base.OnSizeChanged(e); 143 | } 144 | 145 | protected override void OnMouseClick(MouseEventArgs e) 146 | { 147 | if (cellw == 0) 148 | return; 149 | if (e.Button == System.Windows.Forms.MouseButtons.Left) 150 | { 151 | int newsel = (int)((e.X - depth) / cellw); 152 | if (multiMode) 153 | newsel = selectedValue ^ (1 << newsel); 154 | if (newsel != selectedValue) 155 | { 156 | SelectedValue = newsel; 157 | Invalidate(); 158 | } 159 | } 160 | base.OnMouseClick(e); 161 | } 162 | } 163 | } 164 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/StatusViewer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Drawing; 5 | using System.Data; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace GrblCNC 12 | { 13 | public partial class StatusViewer : UserControl 14 | { 15 | int spacingX = 6; 16 | int spacingY = 4; 17 | float desiredRatio = 160f / 36; 18 | List numViewers = null; 19 | int homestate = -1; 20 | 21 | public StatusViewer() 22 | { 23 | InitializeComponent(); 24 | // Fixme: hard coded now, but which data to show should be configurable 25 | numViewers = new List(); 26 | numViewers.Add(bigNumX); 27 | numViewers.Add(bigNumY); 28 | numViewers.Add(bigNumZ); 29 | numViewers.Add(bigNumA); 30 | numViewers.Add(bigNumB); 31 | numViewers.Add(alarmView); 32 | numViewers.Add(bigNumF); 33 | numViewers.Add(bigNumS); 34 | Global.NumAxesChanged += Global_NumAxesChanged; 35 | ApplyColors(); 36 | } 37 | 38 | 39 | 40 | private void Global_NumAxesChanged() 41 | { 42 | if (InvokeRequired) 43 | { 44 | BeginInvoke(new MethodInvoker(() => { Global_NumAxesChanged(); })); 45 | return; 46 | } 47 | UpdateNumAxes(); 48 | } 49 | 50 | public void UpdateNumAxes() 51 | { 52 | bigNumA.Enabled = Global.NumAxes > 3; 53 | bigNumB.Enabled = Global.NumAxes > 4; 54 | } 55 | 56 | void ApplyColors() 57 | { 58 | foreach (UserControl ctrl in numViewers) 59 | { 60 | // Fixme: maybe AlarmViewer and BigNumViewer inherit from same control? 61 | if (ctrl is BigNumViewer) 62 | { 63 | BigNumViewer bignum = (BigNumViewer)ctrl; 64 | bignum.ForeColor = Color.Indigo; 65 | bignum.TitleForeColor = Color.Indigo; 66 | bignum.BackColor = Color.Thistle; 67 | bignum.TitleBackColor = Color.MediumPurple; 68 | } 69 | else if (ctrl is AlarmViewer) 70 | { 71 | AlarmViewer alarmView = (AlarmViewer)ctrl; 72 | alarmView.ForeColor = Color.Indigo; 73 | alarmView.TitleForeColor = Color.Indigo; 74 | alarmView.BackColor = Color.Thistle; 75 | alarmView.TitleBackColor = Color.MediumPurple; 76 | } 77 | } 78 | } 79 | 80 | protected override void OnSizeChanged(EventArgs e) 81 | { 82 | if (numViewers == null) 83 | return; 84 | int w3 = Width / 3; 85 | int h2 = Height / 3; 86 | float ratio = (float)w3 / h2; 87 | if (ratio > desiredRatio) 88 | w3 = (int)(desiredRatio * h2); 89 | else 90 | h2 = (int)((float)w3 / desiredRatio); 91 | int sx = w3 - spacingX * 2; 92 | int sy = h2 - spacingY; 93 | for (int i = 0; i < numViewers.Count; i++) 94 | { 95 | numViewers[i].Location = new Point((i % 3) * w3 + spacingX, (i / 3) * h2 + spacingY); 96 | numViewers[i].Width = sx; 97 | numViewers[i].Height = sy; 98 | } 99 | base.OnSizeChanged(e); 100 | } 101 | 102 | public void SetAxisValues(float [] axVals) 103 | { 104 | int naxis = axVals.Length < 5 ? axVals.Length : 5; 105 | for (int i = 0; i < naxis; i++) 106 | ((BigNumViewer)numViewers[i]).Value = axVals[i]; 107 | } 108 | 109 | public void SetAlarms(string alarms) 110 | { 111 | alarmView.Alarms = alarms; 112 | } 113 | 114 | public void SetFeedSpindle(float feed, float spindle) 115 | { 116 | bigNumF.Value = feed; 117 | bigNumS.Value = spindle; 118 | } 119 | 120 | public void SetHomeState(int homeState) 121 | { 122 | if (homestate == homeState) 123 | return; 124 | homestate = homeState; 125 | for (int i = 0; i < 5; i++) 126 | ((BigNumViewer)numViewers[i]).Homed = (homeState & (1 << i)) != 0; 127 | } 128 | } 129 | } 130 | -------------------------------------------------------------------------------- /Software/GrblCNC/Controls/ValueSlider.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC.Controls 2 | { 3 | partial class ValueSlider 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.labelTitle = new System.Windows.Forms.Label(); 32 | this.labelData = new System.Windows.Forms.Label(); 33 | this.SuspendLayout(); 34 | // 35 | // labelTitle 36 | // 37 | this.labelTitle.AutoSize = true; 38 | this.labelTitle.Location = new System.Drawing.Point(3, 4); 39 | this.labelTitle.Name = "labelTitle"; 40 | this.labelTitle.Size = new System.Drawing.Size(27, 13); 41 | this.labelTitle.TabIndex = 0; 42 | this.labelTitle.Text = "Title"; 43 | // 44 | // labelData 45 | // 46 | this.labelData.AutoSize = true; 47 | this.labelData.Location = new System.Drawing.Point(132, 3); 48 | this.labelData.Name = "labelData"; 49 | this.labelData.Size = new System.Drawing.Size(30, 13); 50 | this.labelData.TabIndex = 1; 51 | this.labelData.Text = "Data"; 52 | // 53 | // ValueSlider 54 | // 55 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 56 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 57 | this.Controls.Add(this.labelData); 58 | this.Controls.Add(this.labelTitle); 59 | this.Name = "ValueSlider"; 60 | this.Size = new System.Drawing.Size(395, 60); 61 | this.ResumeLayout(false); 62 | this.PerformLayout(); 63 | 64 | } 65 | 66 | #endregion 67 | 68 | private System.Windows.Forms.Label labelTitle; 69 | private System.Windows.Forms.Label labelData; 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Software/GrblCNC/ErrorDisplayHandler.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | using System.Drawing; 8 | using GrblCNC.Controls; 9 | 10 | namespace GrblCNC 11 | { 12 | public class ErrorDisplayHandler 13 | { 14 | Form mForm; 15 | List displayedViews; 16 | List hiddenViews; 17 | const int MAX_ERR_VIEWS = 12; 18 | int posX, posY, offset; 19 | int evWidth, evHeight; 20 | int maxVisibleErrors; 21 | public ErrorDisplayHandler(Form frm) 22 | { 23 | mForm = frm; 24 | displayedViews = new List(); 25 | hiddenViews = new List(); 26 | for (int i = 0; i MAX_ERR_VIEWS) 70 | maxVisibleErrors = MAX_ERR_VIEWS; 71 | // remove out of frame messages 72 | while (displayedViews.Count > maxVisibleErrors) 73 | CloseError(displayedViews[0], false); 74 | UpdateLocations(); 75 | } 76 | 77 | void UpdateLocations(int from = 0) 78 | { 79 | // fix other's location 80 | for (int i = from; i < displayedViews.Count; i++) 81 | displayedViews[i].Location = new Point(posX, posY - i * offset); 82 | } 83 | 84 | public void AddError(string errMessage, bool isAlarm = false) 85 | { 86 | if (displayedViews.Count >= maxVisibleErrors) 87 | CloseError(displayedViews[0]); 88 | ErrorView v = hiddenViews[0]; 89 | hiddenViews.RemoveAt(0); 90 | v.Location = new Point(posX, posY - displayedViews.Count * offset); 91 | displayedViews.Add(v); 92 | v.Text = errMessage; 93 | v.SetErrorType(isAlarm ? ErrorView.ErrorType.Alarm : ErrorView.ErrorType.Error); 94 | v.BringToFront(); 95 | v.Visible = true; 96 | } 97 | 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /Software/GrblCNC/FontManager.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Drawing; 7 | using System.Drawing.Text; 8 | using GrblCNC.Properties; 9 | 10 | namespace GrblCNC 11 | { 12 | class FontManager 13 | { 14 | static PrivateFontCollection pfc = new PrivateFontCollection(); 15 | static FontFamily familyFixed = null; 16 | static Font gcodeFont = null; 17 | static Bitmap bitmapFont; 18 | 19 | public static FontFamily GetResourcefont(byte[] fontfile) 20 | { 21 | int len = pfc.Families.Length; 22 | unsafe 23 | { 24 | fixed (byte* pFontData = fontfile) 25 | { 26 | pfc.AddMemoryFont((System.IntPtr)pFontData, fontfile.Length); 27 | } 28 | } 29 | return pfc.Families[len]; 30 | } 31 | 32 | public static FontFamily FamilyFixed 33 | { 34 | get 35 | { 36 | if (familyFixed == null) 37 | familyFixed = GetResourcefont(Resources.JetBrainsMono_Medium); 38 | return familyFixed; 39 | } 40 | } 41 | 42 | public static Font GcodeFont 43 | { 44 | get 45 | { 46 | if (gcodeFont == null) 47 | gcodeFont = new Font(FamilyFixed, 10); 48 | return gcodeFont; 49 | } 50 | } 51 | 52 | public static Bitmap BitmapFont 53 | { 54 | get 55 | { 56 | if (bitmapFont != null) 57 | return bitmapFont; 58 | bitmapFont = new Bitmap(512, 512, System.Drawing.Imaging.PixelFormat.Format32bppArgb); 59 | int fontSize = 40; 60 | int sx = BitmapFont.Width / 16; 61 | int sy = sx * 2; 62 | using (Graphics g = Graphics.FromImage(bitmapFont)) 63 | { 64 | g.TextRenderingHint = TextRenderingHint.AntiAliasGridFit; 65 | g.Clear(Color.Transparent); 66 | Font fnt = new Font(FamilyFixed, fontSize); 67 | SizeF charSize = g.MeasureString("W", fnt); 68 | int offs = (sx - (int)charSize.Width) / 2; 69 | for (int i = 0; i < 96; i++) 70 | { 71 | string stchar = ((char)(i + 32)).ToString(); 72 | int x = (i % 16) * sx + offs; 73 | int y = (i / 16) * sy; 74 | g.DrawString(stchar, fnt, Brushes.White, x, y); 75 | } 76 | } 77 | //bitmapFont.Save("bmpFont.png", System.Drawing.Imaging.ImageFormat.Png); 78 | return bitmapFont; 79 | } 80 | } 81 | } 82 | } 83 | -------------------------------------------------------------------------------- /Software/GrblCNC/FormPopWindow.Designer.cs: -------------------------------------------------------------------------------- 1 | namespace GrblCNC 2 | { 3 | partial class FormPopWindow 4 | { 5 | /// 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Windows Form Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | this.SuspendLayout(); 32 | // 33 | // FormPopWindow 34 | // 35 | this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 36 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 37 | this.ClientSize = new System.Drawing.Size(474, 370); 38 | this.MaximizeBox = false; 39 | this.MinimizeBox = false; 40 | this.Name = "FormPopWindow"; 41 | this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 42 | this.ResumeLayout(false); 43 | 44 | } 45 | 46 | #endregion 47 | 48 | } 49 | } -------------------------------------------------------------------------------- /Software/GrblCNC/FormPopWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.ComponentModel; 4 | using System.Data; 5 | using System.Drawing; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | using System.Windows.Forms; 10 | 11 | namespace GrblCNC 12 | { 13 | public partial class FormPopWindow : Form 14 | { 15 | public FormPopWindow() 16 | { 17 | InitializeComponent(); 18 | } 19 | 20 | public DialogResult ShowControl(UserControl control, string title) 21 | { 22 | Text = title; 23 | Controls.Clear(); 24 | ClientSize = new System.Drawing.Size(control.Width, control.Height); 25 | Controls.Add(control); 26 | return ShowDialog(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Software/GrblCNC/GCodeConfig.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using GrblCNC.Properties; 7 | using GrblCNC.Glutils; 8 | 9 | namespace GrblCNC 10 | { 11 | public class GCodeConfig 12 | { 13 | public class GCodeParam 14 | { 15 | public string code; 16 | //public float [] floatVal; 17 | public string [] strVal; 18 | 19 | public GCodeParam(string parcode, string [] parvals) 20 | { 21 | code = parcode; 22 | strVal = new string[Global.NumAxes]; 23 | for (int i = 0; i < Global.NumAxes; i++) 24 | strVal[i] = "0.000"; 25 | SetVals(parvals); 26 | } 27 | 28 | public void SetVals(string [] vals) 29 | { 30 | for (int i = 0; i < Global.NumAxes && i < vals.Length; i++) 31 | strVal[i] = vals[i]; 32 | } 33 | 34 | // validate a parameter value, return it formated if valid, or null if not 35 | public string ValidateValue(string val) 36 | { 37 | string result = null; 38 | try 39 | { 40 | float tfloat = Utils.ParseFloatInvariant(val); 41 | result = Utils.ToInvariantString(tfloat, "0.000"); 42 | } 43 | catch { } 44 | return result; 45 | } 46 | } 47 | 48 | List parameters; 49 | public static string[] validParams = new string[] { 50 | "G54", "G55", "G56", "G57", "G58", "G59", "G59.1", "G59.2", "G59.3", "G28", "G30", "G92", "TLO" 51 | }; 52 | 53 | public GCodeConfig() 54 | { 55 | parameters = new List(); 56 | } 57 | 58 | public List GetParams() 59 | { 60 | return parameters; 61 | } 62 | 63 | GCodeParam GetParam(string parcode) 64 | { 65 | foreach (GCodeParam par in parameters) 66 | { 67 | if (par.code == parcode) 68 | return par; 69 | } 70 | return null; 71 | } 72 | 73 | public bool ParseParam(string parcode, string stparam) 74 | { 75 | if (!validParams.Contains(parcode)) 76 | return false; 77 | 78 | // split all axis vals 79 | string [] vars = stparam.Split(new char[] { ' ', ',' }, StringSplitOptions.RemoveEmptyEntries); 80 | // see if we already have this param 81 | GCodeParam par = GetParam(parcode); 82 | if (par == null) 83 | { 84 | par = new GCodeParam(parcode, vars); 85 | parameters.Add(par); 86 | } 87 | else 88 | par.SetVals(vars); 89 | return true; 90 | } 91 | 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /Software/GrblCNC/GCodeDimensions.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using GrblCNC.Glutils; 7 | 8 | namespace GrblCNC 9 | { 10 | class GCodeDimensions 11 | { 12 | Line3D lines; 13 | Text3D texts; 14 | 15 | const int XColor = 0x20C020; 16 | const int YColor = 0xC02020; 17 | const int ZColor = 0x2020C0; 18 | 19 | public float fontsize = 2; // mm 20 | 21 | public GCodeDimensions() 22 | { 23 | lines = new Line3D(); 24 | texts = new Text3D(FontManager.BitmapFont); 25 | } 26 | 27 | public void Clear() 28 | { 29 | lines.Clear(); 30 | texts.Clear(); 31 | } 32 | 33 | string CalcPosition(float minVal, float maxVal, out float pos) 34 | { 35 | float len = maxVal - minVal; 36 | string stlen = len.ToString("0.00"); 37 | float stdim = fontsize * stlen.Length; 38 | pos = (len - stdim) / 2; 39 | return stlen; 40 | } 41 | 42 | public void Init(float minX, float minY, float minZ, float maxX, float maxY, float maxZ) 43 | { 44 | float pos; 45 | string stlen; 46 | Clear(); 47 | 48 | // X lines 49 | lines.AddLine(minX, minY - 1, minZ, minX, minY - 5, minZ, XColor); 50 | lines.AddLine(maxX, minY - 1, minZ, maxX, minY - 5, minZ, XColor); 51 | lines.AddLine(minX, minY - 3, minZ, maxX, minY - 3, minZ, XColor); 52 | stlen = CalcPosition(minX, maxX, out pos); 53 | texts.AddText(stlen, Obj3DText.TextPlane.XY, fontsize, minX + pos, minY - 3, minZ, 0, XColor.ToString("X")); 54 | 55 | // Y lines 56 | lines.AddLine(minX - 1, minY, minZ, minX - 5, minY, minZ, YColor); 57 | lines.AddLine(minX - 1, maxY, minZ, minX - 5, maxY, minZ, YColor); 58 | lines.AddLine(minX - 3, minY, minZ, minX - 3, maxY, minZ, YColor); 59 | stlen = CalcPosition(minY, maxY, out pos); 60 | texts.AddText(stlen, Obj3DText.TextPlane.XY, fontsize, minX - 3, maxY - pos, minZ, 90, YColor.ToString("X")); 61 | 62 | // Z lines 63 | lines.AddLine(minX - 1, minY, minZ, minX - 5, minY, minZ, ZColor); 64 | lines.AddLine(minX - 1, minY, maxZ, minX - 5, minY, maxZ, ZColor); 65 | lines.AddLine(minX - 3, minY, minZ, minX - 3, minY, maxZ, ZColor); 66 | stlen = CalcPosition(minZ, maxZ, out pos); 67 | texts.AddText(stlen, Obj3DText.TextPlane.XZ, fontsize, minX - 3, minY, maxZ - pos, 90, ZColor.ToString("X")); 68 | 69 | lines.Init(); 70 | } 71 | 72 | public void Render() 73 | { 74 | lines.Render(); 75 | texts.Render(); 76 | } 77 | 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Software/GrblCNC/Global.cs: -------------------------------------------------------------------------------- 1 | // Global static class to be shared by all components 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | using GrblCNC.Controls; 8 | 9 | namespace GrblCNC 10 | { 11 | public static class Global 12 | { 13 | static bool grblConnected; 14 | public delegate void GrblConnectionChangedDelegate(bool isConnected); 15 | public static event GrblConnectionChangedDelegate GrblConnectionChanged; 16 | 17 | public static GrblComm grblComm; 18 | public static MdiControl mdiControl; 19 | public static GcodeInterp ginterp; 20 | public static VisualizerWin visualizeWindow; 21 | public static GrblStatus grblStatus; 22 | public static GrblConfig grblConfig; 23 | public static ParametersEdit grblParameterEditor; 24 | public static ToolTableEdit toolTableEdit; 25 | public static ToolTable toolTable; 26 | public static ErrorDisplayHandler errHandler; 27 | 28 | public static string SettingsPath; 29 | public static string ToolTableFile; 30 | 31 | public const int MAX_AXES = 5; 32 | private static int numAxes = MAX_AXES; 33 | 34 | public delegate void NumAxesChangedDelegate(); 35 | public static event NumAxesChangedDelegate NumAxesChanged; 36 | 37 | public static bool AppClosing = false; 38 | 39 | 40 | public static int NumAxes 41 | { 42 | get { return numAxes; } 43 | set 44 | { 45 | if (numAxes != value) 46 | { 47 | numAxes = value; 48 | NumAxesChanged?.Invoke(); 49 | } 50 | } 51 | } 52 | 53 | public static string GetAxesString() 54 | { 55 | if (numAxes > 4) 56 | return "X|Y|Z|A|B"; 57 | else if (numAxes > 3) 58 | return "X|Y|Z|A"; 59 | 60 | return "X|Y|Z"; 61 | } 62 | 63 | public static bool GrblConnected 64 | { 65 | get { return grblConnected; } 66 | set 67 | { 68 | bool lastState = grblConnected; 69 | grblConnected = value; 70 | if (lastState != grblConnected && GrblConnectionChanged != null) 71 | GrblConnectionChanged(grblConnected); 72 | } 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /Software/GrblCNC/Glutils/Camera.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using OpenTK; 3 | 4 | namespace GrblCNC.Glutils 5 | { 6 | public class Camera 7 | { 8 | Vector3 target, eye; 9 | float distance, angleHoriz, angleVert; 10 | Vector3 forward; 11 | Vector3 right; 12 | float screenAspect; 13 | Matrix4 camera; 14 | 15 | public Camera(float aspectRatio) 16 | { 17 | screenAspect = aspectRatio; 18 | SetCameraPosition(new Vector3(18, -10, 10.0f), 40, 250, 22); 19 | } 20 | 21 | void SetCameraPosition(Vector3 target, float distance, float horizAngle, float vertAngle) 22 | { 23 | this.target = target; 24 | this.distance = distance; 25 | angleHoriz = horizAngle; 26 | angleVert = vertAngle; 27 | UpdateCamera(); 28 | } 29 | 30 | void UpdateCamera() 31 | { 32 | if (angleVert > 90) 33 | angleVert = 90; 34 | if (angleVert < -90) 35 | angleVert = -90; 36 | if (angleHoriz >= 360) 37 | angleHoriz -= 360; 38 | if (angleHoriz < 0) 39 | angleHoriz += 360; 40 | if (distance < 5) 41 | distance = 5; 42 | double angvertrad = MathHelper.DegreesToRadians(angleVert); 43 | double anghorrad = MathHelper.DegreesToRadians(angleHoriz); 44 | float distH = (float)(distance * Math.Cos(angvertrad)); 45 | float sinAngHor = (float)Math.Sin(anghorrad); 46 | float cosAngHor = (float)Math.Cos(anghorrad); 47 | forward = new Vector3(-cosAngHor, -sinAngHor, 0); 48 | right = new Vector3(-sinAngHor, cosAngHor, 0); 49 | float z = (float)(distance * Math.Sin(angvertrad)); 50 | float x = (float)(distH * cosAngHor); 51 | float y = (float)(distH * sinAngHor); 52 | eye = new Vector3(x,y,z); 53 | Vector3 camTop = Vector3.Cross(eye, right); 54 | camTop.Normalize(); 55 | eye += target; 56 | camera = Matrix4.LookAt(eye, target, camTop); 57 | //Matrix4 trans = Matrix4.CreateTranslation(xshift, 0, 0); 58 | //cam = cam * trans; 59 | Shader.SetMatrix4All("view", camera); 60 | UpdateProjection(screenAspect); 61 | } 62 | 63 | public void UpdateProjection(float aspect) 64 | { 65 | screenAspect = aspect; 66 | Matrix4 projection = Matrix4.CreatePerspectiveFieldOfView(MathHelper.DegreesToRadians(45f), aspect, 0.1f, 1000.0f); 67 | Shader.SetMatrix4All("projection", projection); 68 | } 69 | 70 | public void Rotate(float anglehor, float anglevert) 71 | { 72 | angleHoriz += anglehor; 73 | angleVert += anglevert; 74 | UpdateCamera(); 75 | } 76 | 77 | public void Zoom(float dist) 78 | { 79 | distance -= dist; 80 | UpdateCamera(); 81 | } 82 | 83 | public void MoveTarget(float moveright, float moveforward, float moveup) 84 | { 85 | if (moveright != 0) 86 | target += moveright * right; 87 | if (moveforward != 0) 88 | target += moveforward * forward; 89 | if (moveup != 0) 90 | target.Z += moveup; 91 | UpdateCamera(); 92 | } 93 | 94 | 95 | } 96 | } -------------------------------------------------------------------------------- /Software/GrblCNC/Glutils/ColoredQuad.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace GrblCNC.Glutils 8 | { 9 | class ColoredQuad : Object3D 10 | { 11 | public ColoredQuad(string colTL, string colTR, string colBL, string colBR) 12 | { 13 | float[] verts = {-1, 1, 0, 0, 0, 0, 14 | 1, 1, 0, 0, 0, 0, 15 | -1, -1, 0, 0, 0, 0, 16 | 1, -1, 0, 0, 0, 0}; 17 | uint [] inds = { 0, 1, 2, 2, 1, 3 }; 18 | Utils.SetColor3(colTL, verts, 3); 19 | Utils.SetColor3(colTR, verts, 9); 20 | Utils.SetColor3(colBL, verts, 15); 21 | Utils.SetColor3(colBR, verts, 21); 22 | Init(Shader.ShadingType.MultiColor2D, verts, inds); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /Software/GrblCNC/Glutils/Line3D.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using OpenTK; 7 | using OpenTK.Graphics.OpenGL4; 8 | using GrblCNC.Properties; 9 | 10 | namespace GrblCNC.Glutils 11 | { 12 | class Line3D 13 | { 14 | protected Shader shader; 15 | 16 | int vertexBufferObject = -1; 17 | int vertexArrayObject = -1; 18 | int nVerts = 0; 19 | public Matrix4 objPos; 20 | public float lineThickness; 21 | List lines; 22 | 23 | const int sizeofLine = 8 * sizeof(float); 24 | const int sizeofVertex = 4 * sizeof(float); 25 | public struct LineVerts 26 | { 27 | public float x1, y1, z1; 28 | public float col1; // Fixme: using floats as I cant find a way to pass ints 29 | public float x2, y2, z2; 30 | public float col2; 31 | public LineVerts(float _x1, float _y1, float _z1, float _x2, float _y2, float _z2, int col) 32 | { 33 | x1 = _x1; 34 | y1 = _y1; 35 | z1 = _z1; 36 | x2 = _x2; 37 | y2 = _y2; 38 | z2 = _z2; 39 | col1 = col2 = col; 40 | } 41 | } 42 | 43 | public Line3D() 44 | { 45 | lines = new List(); 46 | } 47 | 48 | public void Clear() 49 | { 50 | lines.Clear(); 51 | } 52 | 53 | public void AddLine(float x1, float y1, float z1, float x2, float y2, float z2, int col) 54 | { 55 | lines.Add(new LineVerts(x1, y1, z1, x2, y2, z2, col)); 56 | } 57 | 58 | public void Init() 59 | { 60 | CleanObject(); 61 | LineVerts[] lv = lines.ToArray(); 62 | shader = Shader.GetShader(Shader.ShadingType.Line3D); 63 | objPos = Matrix4.Identity; 64 | lineThickness = 2; 65 | nVerts = lv.Length * 2; 66 | vertexBufferObject = GL.GenBuffer(); 67 | 68 | // VAO 69 | vertexArrayObject = GL.GenVertexArray(); 70 | GL.BindVertexArray(vertexArrayObject); 71 | 72 | // VBO 73 | GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBufferObject); 74 | GL.BufferData(BufferTarget.ArrayBuffer, lv.Length * sizeofLine, lv, BufferUsageHint.StaticDraw); 75 | //GL.BufferData(BufferTarget.ArrayBuffer, fverts.Length * sizeof(float), fverts, BufferUsageHint.StaticDraw); 76 | // set data strides 77 | GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeofVertex, 0); 78 | GL.EnableVertexAttribArray(0); 79 | GL.VertexAttribPointer(1, 1, VertexAttribPointerType.Float, false, sizeofVertex, 3 * sizeof(float)); 80 | GL.EnableVertexAttribArray(1); 81 | } 82 | 83 | public void Render() 84 | { 85 | if (lines.Count == 0) 86 | return; 87 | shader.Use(); 88 | shader.SetMatrix4("model", objPos); 89 | GL.LineWidth(lineThickness); 90 | GL.BindVertexArray(vertexArrayObject); 91 | GL.DrawArrays(PrimitiveType.Lines, 0, nVerts); 92 | } 93 | 94 | void CleanObject() 95 | { 96 | if (vertexBufferObject >= 0) 97 | { 98 | GL.BindBuffer(BufferTarget.ArrayBuffer, 0); 99 | GL.DeleteBuffer(vertexBufferObject); 100 | vertexBufferObject = -1; 101 | } 102 | if (vertexArrayObject >= 0) 103 | { 104 | GL.BindVertexArray(0); 105 | GL.DeleteVertexArray(vertexArrayObject); 106 | vertexArrayObject = -1; 107 | } 108 | } 109 | 110 | public void Dispose() 111 | { 112 | CleanObject(); 113 | } 114 | } 115 | } 116 | -------------------------------------------------------------------------------- /Software/GrblCNC/Glutils/Obj3DText.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using OpenTK; 7 | using OpenTK.Graphics; 8 | 9 | namespace GrblCNC.Glutils 10 | { 11 | class Obj3DText : Object3D 12 | { 13 | public enum TextPlane 14 | { 15 | XY, 16 | XZ, 17 | ZY 18 | } 19 | 20 | Vector2 ApplyMatrix(Matrix2 rotMat, Vector2 vec) 21 | { 22 | return new OpenTK.Vector2(vec.X * rotMat.M11 + vec.Y * rotMat.M12, vec.X * rotMat.M21 + vec.Y * rotMat.M22); 23 | } 24 | 25 | Vector3 GetTranslatedPoint(float posx, float posy, float posz, float scale, int cornerx, int cornery, Matrix2 rotMat, TextPlane plane) 26 | { 27 | Vector3 vres = new OpenTK.Vector3(); 28 | Vector2 vcorner = new OpenTK.Vector2(cornerx * scale, cornery * scale * 2); 29 | Vector2 tcorner = ApplyMatrix(rotMat, vcorner); 30 | switch (plane) 31 | { 32 | case TextPlane.XY: vres.X = posx + tcorner.X; vres.Y = posy + tcorner.Y; vres.Z = posz; break; 33 | case TextPlane.XZ: vres.X = posx + tcorner.X; vres.Y = posy; vres.Z = posz + tcorner.Y; break; 34 | case TextPlane.ZY: vres.X = posx; vres.Y = posy + tcorner.Y; vres.Z = posz + tcorner.X; break; 35 | } 36 | return vres; 37 | } 38 | 39 | Vector2 GetTextureCorner(char ch, int cornerx, int cornery) 40 | { 41 | int c = (int)ch - 32; 42 | if (c < 0 || c >= 96) 43 | c = 0; // unknown chard display as space 44 | float x = ((c % 16) + cornerx) * 0.0625f; 45 | float y = ((c / 16) + cornery) * 0.125f; 46 | return new Vector2(x, y); 47 | } 48 | 49 | void SetVertex(float [] verts, int vert, Vector3 v3p, Vector2 vtp) 50 | { 51 | int vp = vert * 5; 52 | verts[vp++] = v3p.X; 53 | verts[vp++] = v3p.Y; 54 | verts[vp++] = v3p.Z; 55 | verts[vp++] = vtp.X; 56 | verts[vp++] = vtp.Y; 57 | } 58 | 59 | public Obj3DText(string txt, TextPlane plane, float size, float posX, float posY, float posZ, float dirAngle, string color, Texture fontTex) 60 | { 61 | Matrix2 rotMat = Matrix2.CreateRotation(MathHelper.DegreesToRadians(dirAngle)); 62 | float [] verts = new float[txt.Length * 4 * 5]; 63 | uint [] inds = new uint[txt.Length * 6]; 64 | int vp = 0; 65 | int ip = 0; 66 | for (int i=0; i 0) 66 | { 67 | GL.VertexAttribPointer(1, size1, VertexAttribPointerType.Float, false, stride * sizeof(float), 3 * sizeof(float)); 68 | GL.EnableVertexAttribArray(1); 69 | } 70 | 71 | if (useIndices) 72 | { 73 | // EBO 74 | GL.BindBuffer(BufferTarget.ElementArrayBuffer, elementBufferObject); 75 | GL.BufferData(BufferTarget.ElementArrayBuffer, indices.Length * sizeof(uint), indices, BufferUsageHint.StaticDraw); 76 | } 77 | 78 | if (usetexture) 79 | this.texture = texture; 80 | } 81 | 82 | public void Init(Shader.ShadingType type, float[] verts, uint[] indices = null, string textureName = "") 83 | { 84 | Texture tex = null; 85 | // texture 86 | if (textureName != null && textureName.Length > 0) 87 | tex = Texture.From(textureName); 88 | Init(type, verts, indices, tex); 89 | } 90 | 91 | public void SetColor(string color) 92 | { 93 | tintColor = Utils.ColorToVector(color); 94 | } 95 | 96 | public virtual void Render() 97 | { 98 | shader.Use(); 99 | if (tintVar != null) 100 | shader.SetVector4(tintVar, tintColor); 101 | if (is3D) 102 | shader.SetMatrix4("model", objPos); 103 | if (usetexture) 104 | texture.Use(); 105 | GL.BindVertexArray(vertexArrayObject); 106 | if (useIndices) 107 | GL.DrawElements(PrimitiveType.Triangles, nTriangles, DrawElementsType.UnsignedInt, 0); 108 | else 109 | GL.DrawArrays(PrimitiveType.Triangles, 0, nTriangles); 110 | } 111 | 112 | void CleanObject() 113 | { 114 | usetexture = false; 115 | if (vertexBufferObject >= 0) 116 | { 117 | GL.BindBuffer(BufferTarget.ArrayBuffer, 0); 118 | GL.DeleteBuffer(vertexBufferObject); 119 | vertexBufferObject = -1; 120 | } 121 | if (vertexArrayObject >= 0) 122 | { 123 | GL.BindVertexArray(0); 124 | GL.DeleteVertexArray(vertexArrayObject); 125 | vertexArrayObject = -1; 126 | } 127 | if (elementBufferObject >= 0) 128 | { 129 | GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); 130 | GL.DeleteBuffer(elementBufferObject); 131 | elementBufferObject = -1; 132 | } 133 | } 134 | 135 | public void Dispose() 136 | { 137 | CleanObject(); 138 | } 139 | } 140 | } 141 | -------------------------------------------------------------------------------- /Software/GrblCNC/Glutils/Overlay.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Drawing; 7 | using OpenTK; 8 | using OpenTK.Graphics.OpenGL4; 9 | 10 | namespace GrblCNC.Glutils 11 | { 12 | class Overlay 13 | { 14 | Shader shader; 15 | Texture texture; 16 | public Bitmap bitmap; 17 | int vertexBufferObject = -1; 18 | int vertexArrayObject = -1; 19 | float [] verts; 20 | 21 | public void Init(int x, int y) 22 | { 23 | CleanObject(); 24 | bitmap = new Bitmap(x, y, System.Drawing.Imaging.PixelFormat.Format32bppArgb); 25 | using (Graphics g = Graphics.FromImage(bitmap)) 26 | { 27 | g.FillRectangle(Brushes.Beige, 20, 20, 20, 20); 28 | } 29 | texture = new Texture(bitmap); 30 | shader = Shader.GetShader(Shader.ShadingType.Textured2D); 31 | vertexBufferObject = GL.GenBuffer(); 32 | 33 | verts = new float[] { 34 | -1, 1, 0, 0, 0, // top left 35 | -1, -1, 0, 0, 1, // bottom left 36 | 1, 1, 0, 1, 0, // top right 37 | 1, 1, 0, 1, 0, // top right 38 | -1, -1, 0, 0, 1, // bottom left 39 | 1, -1, 0, 1, 1, // bottom right 40 | }; 41 | 42 | // VAO 43 | vertexArrayObject = GL.GenVertexArray(); 44 | GL.BindVertexArray(vertexArrayObject); 45 | 46 | // VBO 47 | GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBufferObject); 48 | GL.BufferData(BufferTarget.ArrayBuffer, verts.Length * sizeof(float), verts, BufferUsageHint.DynamicDraw); 49 | GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 5 * sizeof(float), 0); 50 | GL.EnableVertexAttribArray(0); 51 | GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, 5 * sizeof(float), 3 * sizeof(float)); 52 | GL.EnableVertexAttribArray(1); 53 | } 54 | 55 | 56 | public void UpdateVerts(int width, int height) 57 | { 58 | float maxx = (float)bitmap.Width * 2 / width - 1; 59 | float maxy = 1 - (float)bitmap.Height * 2 / height; 60 | verts[6] = verts[21] = verts[26] = maxy; 61 | verts[10] = verts[15] = verts[25] = maxx; 62 | GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBufferObject); 63 | GL.BufferSubData(BufferTarget.ArrayBuffer, (IntPtr)0, verts.Length * sizeof(float), verts); 64 | } 65 | 66 | public void Render() 67 | { 68 | shader.Use(); 69 | //if (tintVar != null) 70 | shader.SetVector4("tintColor", Utils.ColorToVector("ffffffff")); 71 | texture.Use(); 72 | GL.BindVertexArray(vertexArrayObject); 73 | GL.DrawArrays(PrimitiveType.Triangles, 0, 6); 74 | } 75 | 76 | public Graphics GetOverlayGraphics() 77 | { 78 | return Graphics.FromImage(bitmap); 79 | } 80 | 81 | public void UpdateOverlay() 82 | { 83 | texture.UpdateImage(bitmap); 84 | } 85 | 86 | void CleanObject() 87 | { 88 | if (vertexBufferObject >= 0) 89 | { 90 | GL.BindBuffer(BufferTarget.ArrayBuffer, 0); 91 | GL.DeleteBuffer(vertexBufferObject); 92 | vertexBufferObject = -1; 93 | } 94 | if (vertexArrayObject >= 0) 95 | { 96 | GL.BindVertexArray(0); 97 | GL.DeleteVertexArray(vertexArrayObject); 98 | vertexArrayObject = -1; 99 | } 100 | } 101 | 102 | public void Dispose() 103 | { 104 | CleanObject(); 105 | } 106 | 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Software/GrblCNC/Glutils/Text3D.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Drawing; 7 | using OpenTK; 8 | using OpenTK.Graphics; 9 | 10 | namespace GrblCNC.Glutils 11 | { 12 | class Text3D 13 | { 14 | List texts; 15 | Texture texture; 16 | 17 | public Text3D(Bitmap bmpFont) 18 | { 19 | texture = new Texture(bmpFont); 20 | texts = new List(); 21 | } 22 | 23 | public void AddText(string txt, Obj3DText.TextPlane plane, float size, float posX, float posY, float posZ, float dirAngle, string color) 24 | { 25 | texts.Add(new Obj3DText(txt, plane, size, posX, posY, posZ, dirAngle, color, texture)); 26 | } 27 | 28 | public void Clear() 29 | { 30 | texts.Clear(); 31 | } 32 | 33 | public void Render() 34 | { 35 | foreach (Obj3DText otxt in texts) 36 | otxt.Render(); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Software/GrblCNC/Glutils/Utils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Drawing; 7 | using System.Drawing.Text; 8 | using System.Windows.Forms; 9 | using System.IO; 10 | using GrblCNC.Properties; 11 | using OpenTK; 12 | using System.Drawing.Imaging; 13 | using System.Globalization; 14 | namespace GrblCNC.Glutils 15 | { 16 | class Utils 17 | { 18 | public static void SetColor(string webColor, float [] buff, int offs = 0, bool isAlpha = true) 19 | { 20 | if (webColor == null || webColor.Length < 2) 21 | return; 22 | float [] c = new float [4]; 23 | int i; 24 | for (i = 0; i < 4; i ++) 25 | { 26 | if (webColor.Length < (i + 1) * 2) 27 | break; 28 | buff[offs + i] = (float)(int.Parse(webColor.Substring(i * 2, 2), System.Globalization.NumberStyles.AllowHexSpecifier)) / 255f; 29 | } 30 | if (i < 3) 31 | { 32 | // mono color 33 | if (isAlpha) 34 | buff[offs + 3] = i > 1 ? buff[offs + 1] : 1f; 35 | buff[offs + 1] = buff[offs + 2] = buff[offs]; 36 | } 37 | else if (i < 4 && isAlpha) 38 | buff[offs + 3] = 1f; 39 | } 40 | 41 | public static void SetColor3(string webColor, float [] buff, int offs = 0) 42 | { 43 | SetColor(webColor, buff, offs, false); 44 | } 45 | 46 | public static Vector4 ColorToVector(string webColor) 47 | { 48 | float[] fcol = new float[4]; 49 | Utils.SetColor(webColor, fcol); 50 | return new Vector4(fcol[0], fcol[1], fcol[2], fcol[3]); 51 | } 52 | 53 | public static Vector3 ColorToVector3(string webColor) 54 | { 55 | float[] fcol = new float[4]; 56 | Utils.SetColor(webColor, fcol); 57 | return new Vector3(fcol[0], fcol[1], fcol[2]); 58 | } 59 | 60 | public static float GetFontAccent(Font font) 61 | { 62 | float ascent = font.FontFamily.GetCellAscent(FontStyle.Regular); 63 | float ascentPixel = font.Height * ascent / font.FontFamily.GetEmHeight(FontStyle.Regular); 64 | return ascentPixel; 65 | } 66 | 67 | public static Bitmap ColorizeBitmap(Bitmap srcbmp, Color col) 68 | { 69 | if (srcbmp == null) 70 | return null; 71 | Bitmap cbmp = new Bitmap(srcbmp.Width, srcbmp.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb); 72 | using (Graphics g = Graphics.FromImage(cbmp)) 73 | { 74 | ColorMatrix matrix = new ColorMatrix(); 75 | matrix.Matrix00 = (float)col.R / 255; 76 | matrix.Matrix11 = (float)col.G / 255; 77 | matrix.Matrix22 = (float)col.B / 255; 78 | matrix.Matrix33 = (float)col.A / 255; 79 | ImageAttributes attributes = new ImageAttributes(); 80 | attributes.SetColorMatrix(matrix, ColorMatrixFlag.Default, ColorAdjustType.Bitmap); 81 | g.DrawImage(srcbmp, new Rectangle(0, 0, cbmp.Width, cbmp.Height), 82 | 0, 0, srcbmp.Width, srcbmp.Height, GraphicsUnit.Pixel, attributes); 83 | } 84 | return cbmp; 85 | } 86 | 87 | public static string ToInvariantString(double value, string format) 88 | { 89 | return value.ToString(format, CultureInfo.InvariantCulture); 90 | } 91 | 92 | // convert float to string with 3 decimal digits 93 | public static string F3(double value) 94 | { 95 | return ToInvariantString(value, "0.000"); 96 | } 97 | 98 | public static float ParseFloatInvariant(string floatNum) 99 | { 100 | return float.Parse(floatNum, CultureInfo.InvariantCulture); 101 | } 102 | 103 | static int TuneColorElement(int cElement, float tune) 104 | { 105 | int res = (int)((float)cElement * tune); 106 | if (res < 0) 107 | res = 0; 108 | if (res > 255) 109 | res = 255; 110 | return res; 111 | } 112 | 113 | public static Color TuneColor(Color baseColor, float tune) 114 | { 115 | int r = TuneColorElement(baseColor.R, tune); 116 | int g = TuneColorElement(baseColor.G, tune); 117 | int b = TuneColorElement(baseColor.B, tune); 118 | return Color.FromArgb(baseColor.A, r, g, b); 119 | } 120 | 121 | public static void ErrorBox(string message, string title = "Error") 122 | { 123 | MessageBox.Show(message, title, MessageBoxButtons.OK, MessageBoxIcon.Error); 124 | } 125 | 126 | public static string SettingPath(string fileName) 127 | { 128 | return Global.SettingsPath + Path.DirectorySeparatorChar + fileName; 129 | } 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /Software/GrblCNC/Glutils/Wire3D.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using OpenTK; 7 | using OpenTK.Graphics.OpenGL4; 8 | using GrblCNC.Properties; 9 | 10 | namespace GrblCNC.Glutils 11 | { 12 | class Wire3D 13 | { 14 | 15 | protected Shader shader; 16 | 17 | int vertexBufferObject = -1; 18 | int vertexArrayObject = -1; 19 | int elementBufferObject = -1; 20 | int nLines = 0; 21 | bool useIndices = false; 22 | public Matrix4 objPos; 23 | public float lineThickness; 24 | 25 | const int sizeofVertex = 5 * sizeof(float); 26 | public struct WireVertex 27 | { 28 | public float x, y, z; 29 | public float index, color; // Fixme: using floats as I cant find a way to pass ints 30 | public WireVertex(float _x, float _y, float _z, int ind, int col) 31 | { 32 | x = _x; 33 | y = _y; 34 | z = _z; 35 | index = ind; 36 | color = col; 37 | } 38 | } 39 | 40 | 41 | public void Init(WireVertex [] verts, uint[] indices = null) 42 | { 43 | CleanObject(); 44 | shader = Shader.GetShader(Shader.ShadingType.Wire3D); 45 | //shader.SetUint("changeIndex", 0); 46 | SetChangeIndex(0); 47 | objPos = Matrix4.Identity; 48 | lineThickness = 2; 49 | nLines = useIndices ? indices.Length : verts.Length; 50 | vertexBufferObject = GL.GenBuffer(); 51 | 52 | // VAO 53 | vertexArrayObject = GL.GenVertexArray(); 54 | GL.BindVertexArray(vertexArrayObject); 55 | 56 | // VBO 57 | GL.BindBuffer(BufferTarget.ArrayBuffer, vertexBufferObject); 58 | GL.BufferData(BufferTarget.ArrayBuffer, verts.Length * sizeofVertex, verts, BufferUsageHint.StaticDraw); 59 | //GL.BufferData(BufferTarget.ArrayBuffer, fverts.Length * sizeof(float), fverts, BufferUsageHint.StaticDraw); 60 | // set data strides 61 | GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, sizeofVertex, 0); 62 | GL.EnableVertexAttribArray(0); 63 | GL.VertexAttribPointer(1, 2, VertexAttribPointerType.Float, false, sizeofVertex, 3 * sizeof(float)); 64 | GL.EnableVertexAttribArray(1); 65 | 66 | // EBO 67 | if (indices != null) 68 | { 69 | useIndices = true; 70 | elementBufferObject = GL.GenBuffer(); 71 | GL.BindBuffer(BufferTarget.ElementArrayBuffer, elementBufferObject); 72 | GL.BufferData(BufferTarget.ElementArrayBuffer, indices.Length * sizeof(uint), indices, BufferUsageHint.StaticDraw); 73 | } 74 | } 75 | 76 | public void SetChangeIndex(int changeIndex) 77 | { 78 | changeIndex &= 0xFFFFFF; 79 | shader.SetFloat("changeIndex", (float)changeIndex); 80 | } 81 | 82 | public void SetHighlightIndex(int idx) 83 | { 84 | idx &= 0xFFFFFF; 85 | shader.SetFloat("hltIndex", (float)idx); 86 | } 87 | 88 | public void Render() 89 | { 90 | shader.Use(); 91 | shader.SetMatrix4("model", objPos); 92 | GL.LineWidth(lineThickness); 93 | GL.BindVertexArray(vertexArrayObject); 94 | if (useIndices) 95 | GL.DrawElements(PrimitiveType.Lines, nLines, DrawElementsType.UnsignedInt, 0); 96 | else 97 | GL.DrawArrays(PrimitiveType.LineStrip, 0, nLines); 98 | } 99 | 100 | void CleanObject() 101 | { 102 | useIndices = false; 103 | if (vertexBufferObject >= 0) 104 | { 105 | GL.BindBuffer(BufferTarget.ArrayBuffer, 0); 106 | GL.DeleteBuffer(vertexBufferObject); 107 | vertexBufferObject = -1; 108 | } 109 | if (vertexArrayObject >= 0) 110 | { 111 | GL.BindVertexArray(0); 112 | GL.DeleteVertexArray(vertexArrayObject); 113 | vertexArrayObject = -1; 114 | } 115 | if (elementBufferObject >= 0) 116 | { 117 | GL.BindBuffer(BufferTarget.ElementArrayBuffer, 0); 118 | GL.DeleteBuffer(elementBufferObject); 119 | elementBufferObject = -1; 120 | } 121 | } 122 | 123 | public void Dispose() 124 | { 125 | CleanObject(); 126 | } 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /Software/GrblCNC/GrblCNC.csproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ShowAllFiles 5 | 6 | -------------------------------------------------------------------------------- /Software/GrblCNC/GrblCommDevice.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace GrblCNC 8 | { 9 | public abstract class GrblCommDevice 10 | { 11 | public delegate void LineReceivedDelegate(GrblCommDevice sender, string line); 12 | public event LineReceivedDelegate LineReceived; 13 | 14 | public abstract bool Open(string portname); 15 | public abstract void Close(); 16 | public abstract string[] GetPortNames(); 17 | public abstract void WriteLine(string line); 18 | public abstract void WriteByte(byte b); 19 | 20 | public abstract string CommType { get; } 21 | public abstract string CommName { get; } 22 | 23 | public void onLineReceived(string line) 24 | { 25 | LineReceived?.Invoke(this, line); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Software/GrblCNC/GrblCommSerial.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO.Ports; 7 | 8 | namespace GrblCNC 9 | { 10 | public class GrblCommSerial : GrblCommDevice 11 | { 12 | SerialPort port; 13 | public bool portOpened = false; 14 | StringBuilder readLine; 15 | string portName; 16 | bool portClosing = false; 17 | 18 | public GrblCommSerial() 19 | { 20 | port = new SerialPort(); 21 | port.DataReceived += Port_DataReceived; 22 | readLine = new StringBuilder(); 23 | } 24 | 25 | public override string CommType { get { return "Serial"; } } 26 | 27 | private void Port_DataReceived(object sender, SerialDataReceivedEventArgs e) 28 | { 29 | while (!portClosing && port.BytesToRead != 0) 30 | { 31 | char ch = (char)port.ReadChar(); 32 | if (ch == '\r') 33 | continue; 34 | if (ch == '\n') 35 | { 36 | onLineReceived(readLine.ToString()); 37 | readLine.Clear(); 38 | continue; 39 | } 40 | readLine.Append(ch); 41 | } 42 | } 43 | 44 | public override string CommName 45 | { 46 | get { return portName; } 47 | } 48 | 49 | public override bool Open(string portname) 50 | { 51 | if (portOpened) 52 | Close(); 53 | portName = portname; 54 | try 55 | { 56 | port.PortName = portname; 57 | //serPort.BaudRate = 57600; 58 | port.BaudRate = 115200; 59 | port.Parity = Parity.None; 60 | port.DataBits = 8; 61 | port.StopBits = StopBits.One; 62 | port.Handshake = Handshake.None; 63 | port.WriteTimeout = 500; 64 | port.Open(); 65 | portClosing = false; 66 | portOpened = true; 67 | } 68 | catch 69 | { 70 | return false; 71 | } 72 | return true; 73 | } 74 | 75 | public override void Close() 76 | { 77 | if (!portOpened) 78 | return; 79 | try { 80 | portClosing = true; 81 | System.Threading.Thread.Sleep(100); 82 | port.Close(); 83 | } 84 | catch { } // sometimes when the usb disconnects, closing the port causes error 85 | portOpened = false; 86 | } 87 | 88 | public override string[] GetPortNames() 89 | { 90 | return SerialPort.GetPortNames(); 91 | } 92 | 93 | public override void WriteLine(string line) 94 | { 95 | line += "\n"; 96 | if (!portClosing) 97 | port.Write(line); 98 | } 99 | 100 | public override void WriteByte(byte b) 101 | { 102 | byte[] msg = new byte[1]; 103 | msg[0] = b; 104 | if (!portClosing) 105 | port.Write(msg, 0, 1); 106 | } 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /Software/GrblCNC/GrblProbber.cs: -------------------------------------------------------------------------------- 1 | using GrblCNC.Glutils; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace GrblCNC 9 | { 10 | internal class GrblProbber 11 | { 12 | enum ProbeType 13 | { 14 | None, 15 | SingleAxis, 16 | Hole 17 | } 18 | 19 | ProbeType probeType; 20 | int probeStage; 21 | GrblComm grblComm; 22 | int probeAxis; 23 | float probeAxisPos; 24 | int probeCoord; 25 | float probeOffset; 26 | float probeDir; 27 | 28 | public GrblProbber(GrblComm gComm) 29 | { 30 | grblComm = gComm; 31 | probeType = ProbeType.None; 32 | grblComm.ProbeCompleted += GrblComm_ProbeCompleted; 33 | } 34 | 35 | public void ProbeSingle(int axis, int coordSystemIx, float offset, float dir) 36 | { 37 | if (coordSystemIx < -1 || coordSystemIx > 8) 38 | return; 39 | probeType = ProbeType.SingleAxis; 40 | probeAxisPos = grblComm.GetAxisPosition(axis); 41 | probeAxis = axis; 42 | probeDir = dir; 43 | probeCoord = coordSystemIx; 44 | probeOffset = offset; 45 | grblComm.ProbeAxis(axis, dir * 10); 46 | } 47 | 48 | void ProbeSingleComplete(float[] prbVals) 49 | { 50 | probeType = ProbeType.None; 51 | float retractDist = probeAxisPos - prbVals[probeAxis]; 52 | if (retractDist < -5) 53 | retractDist = -5; 54 | if (retractDist > 5) 55 | retractDist = 5; 56 | grblComm.CoordTouchAxis(probeAxis, probeCoord, probeOffset, retractDist); 57 | } 58 | 59 | public void ProbeHoleCenter() 60 | { 61 | probeType = ProbeType.Hole; 62 | probeAxis = GrblComm.X_AXIS; 63 | probeDir = -1; 64 | probeAxisPos = grblComm.GetAxisPosition(probeAxis); 65 | grblComm.ProbeAxis(probeAxis, probeDir * 50); 66 | } 67 | 68 | public void ProbeHoleProcess(float[] prbVals) 69 | { 70 | float retractDist; 71 | if (probeDir < 0) 72 | { 73 | retractDist = probeAxisPos - prbVals[probeAxis]; 74 | grblComm.MoveRelative(probeAxis, retractDist); 75 | probeDir = 1; 76 | probeAxisPos = prbVals[probeAxis]; 77 | grblComm.ProbeAxis(probeAxis, probeDir * 50); 78 | } 79 | else 80 | { 81 | retractDist = (probeAxisPos - prbVals[probeAxis]) / 2; 82 | grblComm.MoveRelative(probeAxis, retractDist); 83 | if (probeAxis == GrblComm.X_AXIS) 84 | { 85 | probeAxis = GrblComm.Y_AXIS; 86 | probeDir = -1; 87 | probeAxisPos = prbVals[probeAxis]; 88 | grblComm.ProbeAxis(probeAxis, probeDir * 50); 89 | } 90 | else 91 | probeType = ProbeType.None; 92 | } 93 | } 94 | 95 | private void GrblComm_ProbeCompleted(object sender, float[] prbVals) 96 | { 97 | switch (probeType) 98 | { 99 | case ProbeType.None: 100 | return; 101 | 102 | case ProbeType.SingleAxis: 103 | ProbeSingleComplete(prbVals); 104 | break; 105 | 106 | case ProbeType.Hole: 107 | ProbeHoleProcess(prbVals); 108 | break; 109 | } 110 | } 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /Software/GrblCNC/GrblUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace GrblCNC 8 | { 9 | public class GrblUtils 10 | { 11 | static string[] axisLetter = new string[] { "X", "Y", "Z", "A", "B", "C" }; 12 | static string[] coordSystems = new string[] { "G54", "G55", "G56", "G57", "G58", "G59", "G59.1", "G59.2", "G59.3" }; 13 | public static int numCoordSystems = coordSystems.Length; 14 | 15 | private static int lastNumCoordSystems = -1; 16 | private static string[] range; 17 | 18 | public static string GetAxisLetter(int axis) 19 | { 20 | if (axis < 0 || axis >= axisLetter.Length) 21 | return null; 22 | return axisLetter[axis]; 23 | } 24 | 25 | public static string GetCoordSystem(int coordSystemIx) 26 | { 27 | if (coordSystemIx < 0 || coordSystemIx >= coordSystems.Length) 28 | return ""; 29 | return coordSystems[coordSystemIx]; 30 | } 31 | 32 | public static string[] GetCoordSystemRange() 33 | { 34 | if (numCoordSystems == lastNumCoordSystems) 35 | return range; 36 | 37 | lastNumCoordSystems = numCoordSystems; 38 | range = new string[numCoordSystems]; 39 | for (int i = 0; i < numCoordSystems; i++) 40 | { 41 | range[i] = string.Format("P{0} ({1})", i + 1, coordSystems[i]); 42 | } 43 | return range; 44 | } 45 | 46 | public static string GetGcodeLocation(int axisMask, double[] pos) 47 | { 48 | StringBuilder sb = new StringBuilder(); 49 | int axis = 1; 50 | for (int i = 0; i < Global.NumAxes; i++) 51 | { 52 | if ((axisMask & axis) != 0) 53 | sb.Append(string.Format("{0}{1:0.0}", axisLetter[i], pos[i])); 54 | axis <<= 1; 55 | } 56 | return sb.ToString(); 57 | } 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /Software/GrblCNC/MillHead3D.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using GrblCNC.Glutils; 7 | using OpenTK; 8 | 9 | namespace GrblCNC 10 | { 11 | class MillHead3D : Object3D 12 | { 13 | const int resolution = 24; 14 | const float height = 10; 15 | const float radiust = 2; 16 | const float radiusb = 0.1f; 17 | 18 | Vector3 lightColor; 19 | Vector3 objectColor; 20 | Vector3 ambientColor; 21 | Vector3 lightPos = new Vector3(-500, -300, 300); 22 | 23 | 24 | public MillHead3D() 25 | { 26 | GenerateHead(); 27 | SetColors("FFFFFF", "b54fef", "600000"); 28 | } 29 | 30 | public void SetColors(string lampcol, string objcol, string ambcolor) 31 | { 32 | if (lampcol != null) 33 | lightColor = Utils.ColorToVector3(lampcol); 34 | if (objcol != null) 35 | objectColor = Utils.ColorToVector3(objcol); 36 | if (ambcolor != null) 37 | ambientColor = Utils.ColorToVector3(ambcolor); 38 | } 39 | 40 | void GenerateHead() 41 | { 42 | // the head is a simple cone. but we use n points in the tip, so normal vector will be correct 43 | float[] verts = new float[(3 * resolution + 1) * 6]; 44 | double angstep = 2 * Math.PI / resolution; 45 | double ang = 0; 46 | float raddiff = radiust - radiusb; 47 | float sidelen = (float)Math.Sqrt(height * height + raddiff * raddiff); 48 | // side triangles 49 | int p = 0; 50 | for (int i = 0; i < resolution; i++) 51 | { 52 | float cosAng = (float)Math.Cos(ang); 53 | float sinAng = (float)Math.Sin(ang); 54 | // top vertex coord 55 | verts[p++] = radiust * cosAng; 56 | verts[p++] = radiust * sinAng; 57 | verts[p++] = height; 58 | // top vertex normal 59 | float lxy = height / sidelen; 60 | int vPos = p; // save normal location 61 | verts[p++] = lxy * sinAng; 62 | verts[p++] = lxy * cosAng; 63 | verts[p++] = -raddiff / sidelen; 64 | 65 | // bottom vertex 66 | verts[p++] = radiusb * cosAng; 67 | verts[p++] = radiusb * sinAng; 68 | verts[p++] = 0; 69 | // bottom normal same as top normal 70 | verts[p++] = verts[vPos++]; 71 | verts[p++] = verts[vPos++]; 72 | verts[p++] = verts[vPos++]; 73 | 74 | ang += angstep; 75 | } 76 | 77 | // top triangles. 78 | ang = 0; 79 | for (int i = 0; i < resolution; i++) 80 | { 81 | // circ vertex 82 | verts[p++] = (float)(radiust * Math.Cos(ang)); 83 | verts[p++] = (float)(radiust * Math.Sin(ang)); 84 | verts[p++] = height; 85 | // circ vertex normal (simple top) 86 | verts[p++] = 0; 87 | verts[p++] = 0; 88 | verts[p++] = 1; 89 | ang += angstep; 90 | } 91 | 92 | // and the top center vetrex 93 | verts[p++] = 0; 94 | verts[p++] = 0; 95 | verts[p++] = height; 96 | // circ vertex normal (simple top) 97 | verts[p++] = 0; 98 | verts[p++] = 0; 99 | verts[p++] = 1; 100 | 101 | // generate indices, there are resolution * 3 triangles 102 | uint[] indices = new uint[resolution * 3 * 3]; 103 | // side triangles 104 | p = 0; 105 | for (uint i = 0; i < resolution; i++) 106 | { 107 | indices[p++] = i * 2; 108 | indices[p++] = i * 2 + 1; 109 | indices[p++] = i * 2 + 2; 110 | indices[p++] = i * 2 + 2; 111 | indices[p++] = i * 2 + 1; 112 | indices[p++] = i * 2 + 3; 113 | } 114 | // fix the last indices (its back to the first vertex) 115 | indices[p - 4] = 0; 116 | indices[p - 3] = 0; 117 | indices[p - 1] = 1; 118 | 119 | // top triangles 120 | uint firstind = resolution * 2; 121 | uint centvert = resolution * 3; 122 | for (uint i = 0; i < resolution; i++) 123 | { 124 | indices[p++] = centvert; 125 | indices[p++] = i + firstind; 126 | indices[p++] = i + firstind + 1; 127 | } 128 | // fix last index 129 | indices[p - 1] = firstind; 130 | 131 | Init(Shader.ShadingType.FlatNorm3D, verts, indices); 132 | } 133 | 134 | public override void Render() 135 | { 136 | shader.SetVector3("lightPos", lightPos); 137 | shader.SetVector3("lightColor", lightColor); 138 | shader.SetVector3("objectColor", objectColor); 139 | shader.SetVector3("ambient", ambientColor); 140 | base.Render(); 141 | } 142 | 143 | public void SetHeadPosition(Vector3 headpos) 144 | { 145 | objPos = Matrix4.CreateTranslation(headpos); 146 | } 147 | 148 | } 149 | } 150 | -------------------------------------------------------------------------------- /Software/GrblCNC/Obj3DFloor.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using GrblCNC.Glutils; 7 | using OpenTK; 8 | using OpenTK.Graphics.OpenGL4; 9 | 10 | namespace GrblCNC 11 | { 12 | class Obj3DFloor 13 | { 14 | Object3D FCenter; 15 | Object3D FRuler; 16 | Object3D FRest; 17 | float scale = 10; 18 | 19 | public Obj3DFloor(int nUnits) 20 | { 21 | // center tile 22 | FCenter = new Object3D(); 23 | float[] verts = { 24 | -1, 1, 0, 0, 0, 25 | 1, 1, 0, 1, 0, 26 | -1, -1, 0, 0, 1, 27 | 1, -1, 0, 1, 1, 28 | }; 29 | ScaleVerts(verts); 30 | 31 | uint[] inds = { 0, 2, 1, 2, 3, 1 }; 32 | FCenter.Init(Shader.ShadingType.Textured3D, verts, inds, "GridCenter"); 33 | 34 | 35 | // ruler tiles 36 | FRuler = new Object3D(); 37 | float[] vertsr = { 38 | 1, 1, 0, 0, 0, 39 | 1 + 2 * nUnits, 1, 0, nUnits, 0, 40 | 1, -1, 0, 0, 1, 41 | 1 + 2 * nUnits, -1, 0, nUnits, 1, 42 | -1, 1 + 2 * nUnits, 0, nUnits, 1, 43 | 1, 1 + 2 * nUnits, 0, nUnits, 0, 44 | -1, 1, 0, 0, 1, 45 | -1 - 2 * nUnits, 1, 0, nUnits, 1, 46 | -1 - 2 * nUnits, -1, 0, nUnits, 0, 47 | -1, -1, 0, 0, 0, 48 | -1, -1 - 2 * nUnits, 0, nUnits, 0, 49 | 1, -1 - 2 * nUnits, 0, nUnits, 1, 50 | }; 51 | ScaleVerts(vertsr); 52 | 53 | uint[] indsr = { 0, 2, 1, 2, 3, 1, 6, 5, 4, 6, 0, 5, 8, 6, 7, 8, 9, 6, 10, 2, 9, 10, 11, 2 }; 54 | FRuler.Init(Shader.ShadingType.Textured3D, vertsr, indsr, "GridRuler"); 55 | 56 | // empty tiles 57 | FRest = new Object3D(); 58 | float[] vertse = { 59 | 1, 1, 0, 0, nUnits, 60 | 1 + 2 * nUnits, 1, 0, nUnits, nUnits, 61 | 1, -1, 0, 0, 0, 62 | 1 + 2 * nUnits, -1, 0, nUnits, 0, 63 | -1, 1 + 2 * nUnits, 0, nUnits, 0, 64 | 1, 1 + 2 * nUnits, 0, 0, 0, 65 | -1, 1, 0, nUnits, nUnits, 66 | -1 - 2 * nUnits, 1, 0, 0, nUnits, 67 | -1 - 2 * nUnits, -1, 0, 0, 0, 68 | -1, -1, 0, nUnits, 0, 69 | -1, -1 - 2 * nUnits, 0, nUnits, nUnits, 70 | 1, -1 - 2 * nUnits, 0, 0, nUnits, 71 | 1 + 2 * nUnits, 1 + 2 * nUnits, 0, nUnits, 0, 72 | -1 - 2 * nUnits, 1 + 2 * nUnits, 0, 0, 0, 73 | -1 - 2 * nUnits, -1 - 2 * nUnits, 0, 0, nUnits, 74 | 1 + 2 * nUnits, -1 - 2 * nUnits, 0, nUnits, nUnits, 75 | }; 76 | ScaleVerts(vertse); 77 | uint[] indse = { 0, 1, 2, 0, 12, 5, 0, 1, 12, 7, 4, 13, 7, 6, 4, 14, 9, 8, 14, 10, 9, 11, 3, 2, 11, 15, 3 }; 78 | FRest.Init(Shader.ShadingType.Textured3D, vertse, indse, "GridEmpty"); 79 | } 80 | 81 | void ScaleVerts(float [] verts) 82 | { 83 | for (int i = 0; i < verts.Length; i += 5) 84 | { 85 | verts[i] *= scale; 86 | verts[i + 1] *= scale; 87 | } 88 | } 89 | 90 | public void Render() 91 | { 92 | FCenter.Render(); 93 | FRuler.Render(); 94 | FRest.Render(); 95 | } 96 | 97 | public void SetFloorZ(float zHeight) 98 | { 99 | Matrix4 flevel = Matrix4.CreateTranslation(0, 0, zHeight); 100 | FCenter.objPos = flevel; 101 | FRuler.objPos = flevel; 102 | FRest.objPos = flevel; 103 | } 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Software/GrblCNC/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | using System.Windows.Forms; 6 | 7 | namespace GrblCNC 8 | { 9 | static class Program 10 | { 11 | /// 12 | /// The main entry point for the application. 13 | /// 14 | [STAThread] 15 | static void Main() 16 | { 17 | Application.EnableVisualStyles(); 18 | Application.SetCompatibleTextRenderingDefault(false); 19 | Application.Run(new MainForm()); 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Software/GrblCNC/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("GrblCNC")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("GrblCNC")] 13 | [assembly: AssemblyCopyright("Copyright © 2020")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("bfa77880-ef92-4610-a439-89d4c3dbe529")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /Software/GrblCNC/Properties/Settings.Designer.cs: -------------------------------------------------------------------------------- 1 | //------------------------------------------------------------------------------ 2 | // 3 | // This code was generated by a tool. 4 | // Runtime Version:4.0.30319.42000 5 | // 6 | // Changes to this file may cause incorrect behavior and will be lost if 7 | // the code is regenerated. 8 | // 9 | //------------------------------------------------------------------------------ 10 | 11 | namespace GrblCNC.Properties { 12 | 13 | 14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] 15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "12.0.0.0")] 16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { 17 | 18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); 19 | 20 | public static Settings Default { 21 | get { 22 | return defaultInstance; 23 | } 24 | } 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /Software/GrblCNC/Properties/Settings.settings: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/AboutPicSmall.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/AboutPicSmall.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/AlarmErrorIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/AlarmErrorIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/AlarmIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/AlarmIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/ConfGrblButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/ConfGrblButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/ConfSenderButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/ConfSenderButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/ErrorIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/ErrorIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/FragShaderColor.txt: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | in vec3 vertColor; 4 | 5 | void main() 6 | { 7 | FragColor = vec4(vertColor, 1.0); 8 | } 9 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/FragShaderFlat.txt: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | out vec4 FragColor; 4 | uniform vec4 flatColor; // we set this variable in the OpenGL code. 5 | 6 | void main() 7 | { 8 | FragColor = flatColor; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/FragShaderLine.txt: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | flat in float vColor; 4 | 5 | void main() 6 | { 7 | uint wc = uint(vColor + 0.1); 8 | float b = 0.0039215 * float(wc & 0xFFu); 9 | float g = 0.0039215 * float((wc >> 8) & 0xFFu); 10 | float r = 0.0039215 * float((wc >> 16) & 0xFFu); 11 | float a = 1.0; 12 | FragColor = vec4(r, g, b, a); 13 | } 14 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/FragShaderNorm.txt: -------------------------------------------------------------------------------- 1 | // Normals Color shader 2 | #version 330 3 | 4 | out vec4 FragColor; 5 | 6 | in vec3 Normal; 7 | in vec3 FragPos; 8 | 9 | uniform vec3 lightPos; 10 | uniform vec3 lightColor; 11 | uniform vec3 objectColor; 12 | uniform vec3 ambient; 13 | 14 | void main() 15 | { 16 | vec3 norm = normalize(Normal); 17 | vec3 lightDir = normalize(lightPos - FragPos); 18 | float diff = max(dot(norm, lightDir), 0.0); 19 | vec3 diffuse = diff * lightColor; 20 | vec3 result = (ambient + diffuse) * objectColor; 21 | FragColor = vec4(result, 1.0); 22 | } 23 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/FragShaderText.txt: -------------------------------------------------------------------------------- 1 | // Texture Color shader 2 | #version 330 3 | #extension GL_ARB_texture_query_lod : enable 4 | 5 | out vec4 outputColor; 6 | in vec2 texCoord; 7 | uniform sampler2D texture0; 8 | uniform vec4 tintColor; 9 | 10 | void main() 11 | { 12 | //float mipmapLevel = textureQueryLod(texture0, texCoord).x; 13 | #ifdef GL_ARB_texture_query_lod 14 | float mipmapLevel = textureQueryLOD(texture0, texCoord).x; // NOTE CAPITALIZATION 15 | outputColor = tintColor * textureLod(texture0, texCoord, mipmapLevel * 0.7); 16 | #else 17 | outputColor = tintColor * texture(texture0, texCoord); 18 | #endif 19 | } -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/FragShaderWire.txt: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | out vec4 FragColor; 3 | flat in vec2 texCoord; // using the texture coord to pass color info 4 | 5 | uniform float changeIndex; // before this index add transparency 6 | uniform float hltIndex; // highligt this segment 7 | 8 | void main() 9 | { 10 | uint wc = uint(texCoord[1] + 0.1); 11 | float b = 0.0039215 * float(wc & 0xFFu); 12 | float g = 0.0039215 * float((wc >> 8) & 0xFFu); 13 | float r = 0.0039215 * float((wc >> 16) & 0xFFu); 14 | float a = 1.0; 15 | if (hltIndex == texCoord[0]) // && hltIndex <= (texCoord[0] + 1.0)) 16 | FragColor = vec4(0.0, 0.0, 1.0, 1.0); 17 | else 18 | { 19 | if (changeIndex > texCoord[0]) 20 | a = 0.25; 21 | FragColor = vec4(r, g, b, a); 22 | } 23 | //FragColor = vec4(1.0, 0.0, 0.0, 1.0); 24 | } 25 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/GotoIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/GotoIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/GrblAlarmCodes.txt: -------------------------------------------------------------------------------- 1 | 1:Hard limit triggered. Machine position is likely lost due to sudden and immediate halt. Re-homing is highly recommended. 2 | 2:G-code motion target exceeds machine travel. Machine position safely retained. Alarm may be unlocked. 3 | 3:Reset while in motion. Grbl cannot guarantee position. Lost steps are likely. Re-homing is highly recommended. 4 | 4:Probe fail. The probe is not in the expected initial state before starting probe cycle, where G38.2 and G38.3 is not triggered and G38.4 and G38.5 is triggered. 5 | 5:Probe fail. Probe did not contact the workpiece within the programmed travel for G38.2 and G38.4. 6 | 6:Homing fail. Reset during active homing cycle. 7 | 7:Homing fail. Safety door was opened during active homing cycle. 8 | 8:Homing fail. Cycle failed to clear limit switch when pulling off. Try increasing pull-off setting or check wiring. 9 | 9:Homing fail. Could not find limit switch within search distance. Defined as 1.5 * max_travel on search and 5 * pulloff on locate phases. -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/GrblErrorCodes.txt: -------------------------------------------------------------------------------- 1 | 1:G-code words consist of a letter and a value. Letter was not found. 2 | 2:Numeric value format is not valid or missing an expected value. 3 | 3:Grbl '$' system command was not recognized or supported. 4 | 4:Negative value received for an expected positive value. 5 | 5:Homing cycle is not enabled via settings. 6 | 6:Minimum step pulse time must be greater than 3usec 7 | 7:EEPROM read failed. Reset and restored to default values. 8 | 8:Grbl '$' command cannot be used unless Grbl is IDLE. Ensures smooth operation during a job. 9 | 9:G-code locked out during alarm or jog state. Press red knob button to release alarm. 10 | 10:Soft limits cannot be enabled without homing also enabled. 11 | 11:Max characters per line exceeded. Line was not processed and executed. 12 | 12:(Compile Option) Grbl '$' setting value exceeds the maximum step rate supported. 13 | 13:Safety door detected as opened and door state initiated. 14 | 14:(Grbl-Mega Only) Build info or startup line exceeded EEPROM line length limit. 15 | 15:Jog target exceeds machine travel. Command ignored. 16 | 16:Jog command with no '=' or contains prohibited g-code. 17 | 17:Laser mode requires PWM output. 18 | 20:Unsupported or invalid g-code command found in block. 19 | 21:More than one g-code command from same modal group found in block. 20 | 22:Feed rate has not yet been set or is undefined. 21 | 23:G-code command in block requires an integer value. 22 | 24:Two G-code commands that both require the use of the XYZ axis words were detected in the block. 23 | 25:A G-code word was repeated in the block. 24 | 26:A G-code command implicitly or explicitly requires XYZ axis words in the block, but none were detected. 25 | 27:N line number value is not within the valid range of 1 - 9,999,999. 26 | 28:A G-code command was sent, but is missing some required P or L value words in the line. 27 | 29:Grbl supports six work coordinate systems G54-G59. G59.1, G59.2, and G59.3 are not supported. 28 | 30:The G53 G-code command requires either a G0 seek or G1 feed motion mode to be active. A different motion was active. 29 | 31:There are unused axis words in the block and G80 motion mode cancel is active. 30 | 32:A G2 or G3 arc was commanded but there are no XYZ axis words in the selected plane to trace the arc. 31 | 33:The motion command has an invalid target. G2, G3, and G38.2 generates this error, if the arc is impossible to generate or if the probe target is the current position. 32 | 34:A G2 or G3 arc, traced with the radius definition, had a mathematical error when computing the arc geometry. Try either breaking up the arc into semi-circles or quadrants, or redefine them with the arc offset definition. 33 | 35:A G2 or G3 arc, traced with the offset definition, is missing the IJK offset word in the selected plane to trace the arc. 34 | 36:There are unused, leftover G-code words that aren't used by any command in the block. 35 | 37:The G43.1 dynamic tool length offset command cannot apply an offset to an axis other than its configured axis. The Grbl default axis is the Z-axis. 36 | 38:Tool number greater than max supported value. 37 | 39:GCode value out of range. 38 | 40:Tool change pending. 39 | 41:Spindle not running. 40 | 42:Illegal plane used in GCode. 41 | 43:Maximum feed rate exceeded. 42 | 44:RPM out of range. 43 | 45:Limits engaged. 44 | 46:Homing required. 45 | 47:Tool error. 46 | 48:Value conflict. 47 | 50:Emergency Stop. 48 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/GrblParamDescription.txt: -------------------------------------------------------------------------------- 1 | # Code | Description | Units | Type | Group | Extra 2 | 0|Step pulse time|us|Float|Hardware Timings 3 | 1|Step idle delay|ms|Int|Hardware Timings 4 | 2|Step pulse invert|mask|Mask|Polarity/Direction inverts|X,Y,Z,A,B,C 5 | 3|Step direction invert|mask|Mask|Polarity/Direction inverts|X,Y,Z,A,B,C 6 | 4|Invert step enable pin|bool|Bool|Polarity/Direction inverts 7 | 5|Invert limit pins|mask|Mask|Polarity/Direction inverts|X,Y,Z,A,B,C 8 | 6|Invert probe pin|bool|Bool|Polarity/Direction inverts 9 | 10|Status report options|mask|Mask|General Settings|Absolute position,Buffer status,Line numbers,Feed rate and spindle RPM,Input pins state,Working coordinate offset,Overrides,Probe coordinates,,Alarm sub-state,GCode parser status 10 | 11|Junction deviation|mm|Float|General Settings 11 | 12|Arc tolerance|mm|Float|General Settings 12 | 13|Report in inches|bool|Bool|General Settings 13 | 14|*Control invert|mask|Mask|Polarity/Direction inverts|reset,feed hold,cycle start,safety door,block delete,stop disable 14 | 15|*Coolant invert|mask|Mask|Polarity/Direction inverts|flood,mist 15 | 16|*Spindle invert|mask|Mask|Polarity/Direction inverts|spindle on,spindle ccw,PWM invert 16 | 17|*Control PullUp disable|mask|Mask|Polarity/Direction inverts|reset,feed hold,cycle start,safety door,block delete,stop disable 17 | 18|*Limit PullUp disable|mask|Mask|Polarity/Direction inverts|X,Y,Z,A,B,C 18 | 19|*Probe PullUp disable|bool|Bool|Polarity/Direction inverts 19 | 20|Soft limits enable|bool|Bool|General Settings 20 | 21|Hard limits enable|bool|Bool|General Settings 21 | 22|Homing cycle|mask|Mask|Homing|Enable automatic homing,Single axis homing,Initial lock,Set origin to 0,Dual limit switches,Manual homing 22 | 23|Homing direction invert|mask|Mask|Polarity/Direction inverts,Homing|X,Y,Z,A,B,C 23 | 24|Homing locate feed rate|mm/min|Float|Homing 24 | 25|Homing search seek rate|mm/min|Float|Homing 25 | 26|Homing switch debounce delay|ms|Int|Hardware Timings,Homing 26 | 27|Homing switch pull-off dist|mm|Float|Homing 27 | 28|*G73 Retract|mm|Float|GCode Settings 28 | 29|*Pulse delay|us|Float|Hardware Timings 29 | 30|Max spindle speed|RPM|Float|Spindle Settings 30 | 31|Min spindle speed|RPM|Float|Spindle Settings 31 | 32|Machine mode|int|Selection|Spindle Settings,General Settings|normal,Laser,Lathe 32 | 33|*PWM Frequency|Hz|Float|Spindle Settings 33 | 34|*PWM Off value|percent|Float|Spindle Settings 34 | 35|*PWM Min value|percent|Float|Spindle Settings 35 | 36|*PWM Max Value|percent|Float|Spindle Settings 36 | 37|*Stepper deenergize|mask|Mask|General Settings|X,Y,Z,A,B,C 37 | 38|*Spindle PPR|int|Int|Spindle Settings 38 | 39|*Enable legacy RT commands|bool|Bool|General Settings 39 | 40|*Jog soft limited|bool|Bool|Jog Settings 40 | 41|*Parking enable|bool|Bool|Homing 41 | 42|*Parking axis|int|Int|Homing 42 | 43|*Homing locate cycles|int|Int|Homing 43 | 44|*Homing Cycle 1|mask|Mask|Homing|X,Y,Z,A,B,C 44 | 45|*Homing Cycle 2|mask|Mask|Homing|X,Y,Z,A,B,C 45 | 46|*Homing Cycle 3|mask|Mask|Homing|X,Y,Z,A,B,C 46 | 47|*Homing Cycle 4|mask|Mask|Homing|X,Y,Z,A,B,C 47 | 48|*Homing Cycle 5|mask|Mask|Homing|X,Y,Z,A,B,C 48 | 49|*Homing Cycle 6|mask|Mask|Homing|X,Y,Z,A,B,C 49 | 50|*Jog step speed|mm/min|Float|Jog Settings 50 | 51|*Jog slow speed|mm/min|Float|Jog Settings 51 | 52|*Jog fast speed|mm/min|Float|Jog Settings 52 | 53|*Jog step distance|mm|Float|Jog Settings 53 | 54|*Jog slow distance|mm|Float|Jog Settings 54 | 55|*Jog fast distance|mm|Float|Jog Settings 55 | 56|*Parking pullout increment|mm|Float|Homing 56 | 57|*Parking pullout rate|mm/min|Float|Homing 57 | 58|*Parking target|mm|Float|Homing 58 | 59|*Parking fast rate|mm/min|Float|Homing 59 | 60|*Restore overrides|bool|Bool|General Settings 60 | 61|*Ignore door when idle|bool|Bool|General Settings 61 | 62|*Sleep enable|bool|Bool|General Settings 62 | 63|*Hold actions|mask|Mask|General Settings|Disable laser during hold,Restart laser after hold 63 | 64|*Force initial alarm|bool|Bool|General Settings 64 | 65|*Probing feed override|bool|Bool|General Settings 65 | 70|*Network services|mask|Mask|Network|Telnet,,,,,mDNS 66 | 73|*WiFi mode|int|Selection|Network|Off,WiFi station 67 | 74|*WiFi SSID|string|String|Network 68 | 75|*WiFi password|string|String|Network 69 | 100|X-axis|steps/mm|Float|X-Axis Settings 70 | 101|Y-axis|steps/mm|Float|Y-Axis Settings 71 | 102|Z-axis|steps/mm|Float|Z-Axis Settings 72 | 103|A-axis|steps/deg|Float|A-Axis Settings 73 | 104|B-axis|steps/deg|Float|B-Axis Settings 74 | 105|C-axis|steps/deg|Float|C-Axis Settings 75 | 110|X-axis max rate|mm/min|Float|X-Axis Settings 76 | 111|Y-axis max rate|mm/min|Float|Y-Axis Settings 77 | 112|Z-axis max rate|mm/min|Float|Z-Axis Settings 78 | 113|A-axis max rate|deg/min|Float|A-Axis Settings 79 | 114|B-axis max rate|deg/min|Float|B-Axis Settings 80 | 115|C-axis max rate|deg/min|Float|C-Axis Settings 81 | 120|X-axis acceleration|mm/sec^2|Float|X-Axis Settings 82 | 121|Y-axis acceleration|mm/sec^2|Float|Y-Axis Settings 83 | 122|Z-axis acceleration|mm/sec^2|Float|Z-Axis Settings 84 | 123|A-axis acceleration|deg/sec^2|Float|A-Axis Settings 85 | 124|B-axis acceleration|deg/sec^2|Float|B-Axis Settings 86 | 125|C-axis acceleration|deg/sec^2|Float|C-Axis Settings 87 | 130|X-axis max travel|mm|Float|X-Axis Settings 88 | 131|Y-axis max travel|mm|Float|Y-Axis Settings 89 | 132|Z-axis max travel|mm|Float|Z-Axis Settings 90 | 133|A-axis max travel|deg|Float|A-Axis Settings 91 | 134|B-axis max travel|deg|Float|B-Axis Settings 92 | 135|C-axis max travel|deg|Float|C-Axis Settings 93 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/GridCenter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/GridCenter.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/GridEmpty.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/GridEmpty.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/GridRuler.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/GridRuler.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/HomeIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/HomeIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/HomeIconFull.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/HomeIconFull.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/HomedIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/HomedIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/JetBrainsMono-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/JetBrainsMono-Medium.ttf -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/JogButtHover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/JogButtHover.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/JogButtNorm.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/JogButtNorm.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/JogButtPress.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/JogButtPress.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/MacroAddButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/MacroAddButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/MacroF1Buttt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/MacroF1Buttt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/MacroF2Buttt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/MacroF2Buttt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/MacroF3Buttt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/MacroF3Buttt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/MacroF4Buttt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/MacroF4Buttt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/MacroF5Buttt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/MacroF5Buttt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/MacroF6Buttt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/MacroF6Buttt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/MacroF7Buttt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/MacroF7Buttt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/MacroF8Buttt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/MacroF8Buttt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/MacroF9Buttt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/MacroF9Buttt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/OpenButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/OpenButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/ProbeHoleIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/ProbeHoleIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/ProbeIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/ProbeIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/ReloaButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/ReloaButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/SliderThumb.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/SliderThumb.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/SpinLeftIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/SpinLeftIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/SpinRightIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/SpinRightIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/StepButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/StepButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/StopIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/StopIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/ToolTableButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/ToolTableButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/TouchGIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/TouchGIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/TouchTIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/TouchTIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/VertShader2DColor.txt: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout (location = 0) in vec3 aPos; // the position variable has attribute position 0 3 | layout (location = 1) in vec3 aColor; // the color variable has attribute position 1 4 | 5 | out vec3 vertColor; // output a color to the fragment shader 6 | 7 | void main() 8 | { 9 | gl_Position = vec4(aPos, 1.0); 10 | vertColor = aColor; // set textColor to the input color we got from the vertex data 11 | } 12 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/VertShader2DFlat.txt: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | layout(location = 0) in vec3 aPosition; 3 | void main(void) 4 | { 5 | gl_Position = vec4(aPosition, 1.0); 6 | } -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/VertShader2DText.txt: -------------------------------------------------------------------------------- 1 | // this is a 2D textured shader 2 | #version 330 core 3 | layout(location = 0) in vec3 aPosition; 4 | layout(location = 1) in vec2 aTexCoord; 5 | 6 | out vec2 texCoord; 7 | 8 | void main(void) 9 | { 10 | texCoord = aTexCoord; 11 | gl_Position = vec4(aPosition, 1.0); 12 | } 13 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/VertShader3DFlat.txt: -------------------------------------------------------------------------------- 1 | // this is a 3D textured shader 2 | #version 330 core 3 | 4 | layout(location = 0) in vec3 aPosition; 5 | 6 | uniform mat4 model; 7 | uniform mat4 view; 8 | uniform mat4 projection; 9 | 10 | void main(void) 11 | { 12 | gl_Position = vec4(aPosition, 1.0) * model * view * projection; 13 | } 14 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/VertShader3DLine.txt: -------------------------------------------------------------------------------- 1 | // this is a 3D line shader: 3 float vert, 1 float color 2 | #version 330 core 3 | 4 | layout(location = 0) in vec3 aPosition; 5 | layout(location = 1) in float aVertColor; 6 | 7 | flat out float vColor; 8 | 9 | uniform mat4 model; 10 | uniform mat4 view; 11 | uniform mat4 projection; 12 | 13 | void main(void) 14 | { 15 | vColor = aVertColor; 16 | gl_Position = vec4(aPosition, 1.0) * model * view * projection; 17 | } 18 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/VertShader3DNorm.txt: -------------------------------------------------------------------------------- 1 | // this is a 3D textured shader 2 | #version 330 core 3 | 4 | layout(location = 0) in vec3 aPosition; 5 | layout(location = 1) in vec3 aNormal; 6 | 7 | out vec3 Normal; 8 | out vec3 FragPos; 9 | 10 | uniform mat4 model; 11 | uniform mat4 view; 12 | uniform mat4 projection; 13 | 14 | void main(void) 15 | { 16 | gl_Position = vec4(aPosition, 1.0) * model * view * projection; 17 | FragPos = vec3(model * vec4(aPosition, 1.0)); 18 | Normal = aNormal; 19 | } -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/VertShader3DText.txt: -------------------------------------------------------------------------------- 1 | // this is a 3D textured shader 2 | #version 330 core 3 | 4 | layout(location = 0) in vec3 aPosition; 5 | 6 | layout(location = 1) in vec2 aTexCoord; 7 | 8 | out vec2 texCoord; 9 | 10 | uniform mat4 model; 11 | uniform mat4 view; 12 | uniform mat4 projection; 13 | 14 | void main(void) 15 | { 16 | texCoord = aTexCoord; 17 | 18 | gl_Position = vec4(aPosition, 1.0) * model * view * projection; 19 | } 20 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/VertShader3DWire.txt: -------------------------------------------------------------------------------- 1 | // this is a 3D textured shader 2 | #version 330 core 3 | 4 | layout(location = 0) in vec3 aPosition; 5 | 6 | layout(location = 1) in vec2 aTexCoord; 7 | 8 | flat out vec2 texCoord; 9 | 10 | uniform mat4 model; 11 | uniform mat4 view; 12 | uniform mat4 projection; 13 | 14 | void main(void) 15 | { 16 | texCoord = aTexCoord; 17 | 18 | gl_Position = vec4(aPosition, 1.0) * model * view * projection; 19 | } 20 | -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/WifiButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/WifiButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/aboutButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/aboutButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/checkedButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/checkedButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/estop.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/estop.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/grblIcon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/grblIcon.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/pauseButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/pauseButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/playButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/playButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/powerButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/powerButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/Resources/stopButt.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/Resources/stopButt.png -------------------------------------------------------------------------------- /Software/GrblCNC/ToolButton.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.Windows.Forms; 7 | using System.Drawing; 8 | using GrblCNC.Properties; 9 | 10 | namespace GrblCNC 11 | { 12 | class ToolButton : ToolStripProfessionalRenderer 13 | { 14 | public Color checkedColor = Color.FromArgb(130,200,250); 15 | 16 | protected override void OnRenderButtonBackground(ToolStripItemRenderEventArgs e) 17 | { 18 | var btn = e.Item as ToolStripButton; 19 | if (btn != null && btn.Checked) 20 | { 21 | int offsx = (btn.Width - Resources.checkedButt.Width) / 2; 22 | int offsy = (btn.Height - Resources.checkedButt.Height) / 2; 23 | Rectangle bounds = new Rectangle(Point.Empty, e.Item.Size); 24 | e.Graphics.DrawImageUnscaled(Resources.checkedButt, offsx, offsy); 25 | } 26 | else base.OnRenderButtonBackground(e); 27 | } 28 | 29 | 30 | 31 | /* protected override void OnPaint(PaintEventArgs e) 32 | { 33 | if (Checked) 34 | { 35 | Rectangle r = new Rectangle(0, 0, Width, Height); 36 | if (r.Contains(Control.MousePosition)) 37 | e.Graphics.DrawRectangle(Pens.DarkBlue, 0, 0, Height - 1, Width - 1); 38 | int offsx = (Width - Image.Width) / 2; 39 | int offsy = (Height - Image.Height) / 2; 40 | //e.Graphics.Clear(checkedColor); 41 | e.Graphics.DrawImageUnscaled(Resources.checkedButt, offsx, offsy); 42 | e.Graphics.DrawImageUnscaled(Image, offsx, offsy); 43 | return; 44 | } 45 | base.OnPaint(e); 46 | } 47 | 48 | protected override void OnMouseEnter(EventArgs e) 49 | { 50 | isHovered = true; 51 | base.OnMouseEnter(e); 52 | Invalidate(); 53 | } 54 | 55 | protected override void OnMouseLeave(EventArgs e) 56 | { 57 | isHovered = false; 58 | base.OnMouseLeave(e); 59 | }*/ 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /Software/GrblCNC/ToolTable.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using System.IO; 7 | 8 | namespace GrblCNC 9 | { 10 | public class ToolTable 11 | { 12 | List tools; 13 | 14 | public ToolTable() 15 | { 16 | tools = new List(); 17 | } 18 | 19 | public List Tools 20 | { 21 | get { return tools; } 22 | } 23 | 24 | public CncTool GetTool(int toolNum) 25 | { 26 | foreach (CncTool tool in tools) 27 | if (toolNum == tool.toolNum) 28 | return tool; 29 | return null; 30 | } 31 | 32 | public void AddUpdateTool(CncTool updatetool) 33 | { 34 | CncTool tool = GetTool(updatetool.toolNum); 35 | if (tool == null) 36 | { 37 | tool = new CncTool(updatetool.toolNum); 38 | tools.Add(tool); 39 | tools.Sort(); 40 | } 41 | tool.CopyFrom(updatetool); 42 | } 43 | 44 | public void RemoveTool(int toolnum) 45 | { 46 | CncTool tool = GetTool(toolnum); 47 | if (tool != null) 48 | tools.Remove(tool); 49 | } 50 | 51 | public void Clear() 52 | { 53 | tools.Clear(); 54 | } 55 | 56 | public void UpdateFrom(ToolTable otherTable) 57 | { 58 | foreach (CncTool tool in otherTable.tools) 59 | AddUpdateTool(tool); 60 | } 61 | 62 | public string Save(string filepath) 63 | { 64 | try 65 | { 66 | StreamWriter sw = new StreamWriter(filepath); 67 | sw.WriteLine("# GrbleCNC Tool Table [1.0]"); 68 | foreach (CncTool tool in tools) 69 | { 70 | sw.WriteLine(tool.ToString()); 71 | } 72 | sw.Close(); 73 | } 74 | catch (Exception ex) 75 | { 76 | return ex.Message; 77 | } 78 | 79 | return "OK"; 80 | } 81 | 82 | 83 | public string Load(string filepath) 84 | { 85 | try 86 | { 87 | StreamReader sr = new StreamReader(filepath); 88 | string line = sr.ReadLine().Trim(); 89 | if (!line.StartsWith("# GrbleCNC Tool Table")) 90 | return "Not a GrblCNC Tool Table file"; 91 | tools.Clear(); 92 | while (!sr.EndOfStream) 93 | { 94 | line = sr.ReadLine().Trim(); 95 | if (line.Length == 0 || line[0] == '#') 96 | continue; 97 | CncTool tool = new CncTool(0); 98 | if (tool.TryParse(line).Count == 0) 99 | { 100 | tool.Parse(line); 101 | tools.Add(tool); 102 | } 103 | } 104 | sr.Close(); 105 | if (tools.Count > 0) 106 | tools.Sort(); 107 | } 108 | catch (Exception ex) 109 | { 110 | return ex.Message; 111 | } 112 | 113 | return "OK"; 114 | } 115 | } 116 | } 117 | -------------------------------------------------------------------------------- /Software/GrblCNC/VisualizerOverlay.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | using GrblCNC.Glutils; 7 | using System.Drawing; 8 | using System.Drawing.Text; 9 | 10 | namespace GrblCNC 11 | { 12 | class VisualizerOverlay 13 | { 14 | VisualizerWin viswin; 15 | int cury, curx; 16 | string lastCoordCode = ""; 17 | int lastTool = -2; 18 | float[] lastCoords = new float[GrblStatus.NUM_AXIS]; 19 | Font font; 20 | public VisualizerOverlay(VisualizerWin viswin) 21 | { 22 | this.viswin = viswin; 23 | font = new Font("Courier New", 12, FontStyle.Bold); 24 | } 25 | 26 | bool CopyCoords(float [] newCoords) 27 | { 28 | bool isChange = false; 29 | for (int i=0; i 6 | /// Required designer variable. 7 | /// 8 | private System.ComponentModel.IContainer components = null; 9 | 10 | /// 11 | /// Clean up any resources being used. 12 | /// 13 | /// true if managed resources should be disposed; otherwise, false. 14 | protected override void Dispose(bool disposing) 15 | { 16 | if (disposing && (components != null)) 17 | { 18 | components.Dispose(); 19 | } 20 | base.Dispose(disposing); 21 | } 22 | 23 | #region Component Designer generated code 24 | 25 | /// 26 | /// Required method for Designer support - do not modify 27 | /// the contents of this method with the code editor. 28 | /// 29 | private void InitializeComponent() 30 | { 31 | components = new System.ComponentModel.Container(); 32 | this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 33 | } 34 | 35 | #endregion 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /Software/GrblCNC/lib/OpenTK.GLControl.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/lib/OpenTK.GLControl.dll -------------------------------------------------------------------------------- /Software/GrblCNC/lib/OpenTK.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/shaise/GrblCNC/0bce1363a70e0e875228e2cf178f1a4239cdfdf5/Software/GrblCNC/lib/OpenTK.dll -------------------------------------------------------------------------------- /Software/GrblCNC/lib/OpenTK.dll.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /Software/GrblCNC/mDns/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014, Karl Redgate 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are met: 6 | 7 | * Redistributions of source code must retain the above copyright notice, this 8 | list of conditions and the following disclaimer. 9 | 10 | * Redistributions in binary form must reproduce the above copyright notice, 11 | this list of conditions and the following disclaimer in the documentation 12 | and/or other materials provided with the distribution. 13 | 14 | * Neither the name of mDNS-sharp nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this software without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 22 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 24 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 25 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 26 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | 29 | -------------------------------------------------------------------------------- /TODO.md: -------------------------------------------------------------------------------- 1 | ##TO DO list 2 | 3 | * Add copy/paste features 4 | * Translate decimal values to invarient culture when copy/paste-ing 5 | * support Inch system 6 | * use the $c system to check for gcode errors 7 | 8 | ## future To Do 9 | * Make the gui GMOCCAPY like --------------------------------------------------------------------------------