-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathManualModeForm.cs
More file actions
76 lines (61 loc) · 2.14 KB
/
Copy pathManualModeForm.cs
File metadata and controls
76 lines (61 loc) · 2.14 KB
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace gcodeparser
{
public partial class ManualModeForm : Form
{
public ManualModeForm()
{
InitializeComponent();
}
private MainForm mCommander = null;
public void SetCommander(MainForm command)
{
mCommander = command;
}
private void ManualModeForm_KeyDown(object sender, KeyEventArgs e)
{
string command = "D10{0}{1}\r\n";
int steps = e.Shift ? 16 : 160;
char axis = ' ';
switch (e.KeyCode)
{
case Keys.Up: axis = 'X'; steps = -steps; break;
case Keys.Down: axis = 'X'; break;
case Keys.Left: axis = 'Y'; steps = -steps; break;
case Keys.Right: axis = 'Y'; break;
case Keys.PageDown: axis = 'Z'; steps = -steps; break;
case Keys.PageUp: axis = 'Z'; break;
default: return;
}
string finalCommand = string.Format(command, axis, steps);
if (mCommander.IsDeviceIdle())
{
mCommander.EnqueueLine(finalCommand, -1);
mCommander.SendQueuedLineToDevice();
}
}
private void SetZeroLabel_Click(object sender, EventArgs e)
{
mCommander.EnqueueLine("D1", -1);
mCommander.SendQueuedLineToDevice();
MessageBox.Show("Machine current location reset to 0, 0, 0");
}
private void SetFeedRate_Click(object sender, EventArgs e)
{
string result = InputBox.Show("New feed rate (1-230)", "Set feed rate");
if (result == null) return;
int feedRate;
if (!Int32.TryParse(result, out feedRate)) return;
mCommander.EnqueueLine("F" + feedRate, -1);
mCommander.SendQueuedLineToDevice();
SetFeedRate.Text = string.Format("Feed rate set to {0}mm/min", feedRate);
}
}
}